Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[wip] use CWVWebView embedder in iOS #24657

Draft
wants to merge 60 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
60 commits
Select commit Hold shift + click to select a range
7e13af2
use CWVWebView embedder in iOS
kylehickinson Jul 5, 2024
454f2c6
fix mixed content ssl check
kylehickinson Jul 15, 2024
ab747e8
fix webui/javascript injection
kylehickinson Jul 15, 2024
d5610bc
hookup rest of delegate methods, attach usual tab helpers
kylehickinson Jul 17, 2024
d02171d
chromium session restoration
kylehickinson Jul 18, 2024
5a9be52
fix back/forward usage & list display
kylehickinson Jul 18, 2024
ed0650b
shift snapshot + pdf creation to webstate calls
kylehickinson Jul 18, 2024
5c58374
fix reload
kylehickinson Jul 19, 2024
b1fe418
restore certain configuration options
kylehickinson Jul 19, 2024
65c846d
remove more direct WKWebView usages
kylehickinson Jul 22, 2024
880a413
Fix loading internal scheme pages such as reader mode
kylehickinson Jul 22, 2024
571c762
fix url bar ssl status for internal pages
kylehickinson Jul 22, 2024
d4f73bd
formatting
kylehickinson Jul 22, 2024
2614639
minimize changes in copied files
kylehickinson Jul 22, 2024
4823816
override factories with chrome factories, re-enable autofill/translate
kylehickinson Jul 23, 2024
f3bbe58
remove unneeded chromium_src override on web controller
kylehickinson Jul 23, 2024
3e5ceec
replace copied files with temporary patches
kylehickinson Jul 23, 2024
8da0e45
chromium user agent handling
kylehickinson Jul 25, 2024
4426949
restore open tab sync & favicon driver
kylehickinson Jul 25, 2024
1b21132
fix web downloads (passkit, mobileconfig, ical, regular)
kylehickinson Jul 25, 2024
f0d030f
add autofill sync type
kylehickinson Jul 26, 2024
008a75a
fix tab titles on NTP
kylehickinson Jul 29, 2024
5f2dc16
fix links that open new tabs & shift js execution to WebState
kylehickinson Jul 29, 2024
36e64f1
use `//ios/web_view` dep directly now, initial gn check/presubmit cle…
kylehickinson Jul 31, 2024
55f6fc3
expose SecCertificate from CWVX509Certificate
kylehickinson Jul 31, 2024
4515fd9
restore user scripts check in navigation action handler
kylehickinson Aug 1, 2024
1098c47
restore universal link block feature
kylehickinson Aug 2, 2024
9b4fcd7
use chromium error pages
kylehickinson Aug 7, 2024
f937b87
fix website redirects feature
kylehickinson Aug 7, 2024
21aa213
replace web view factories setup with chrome counterparts
kylehickinson Aug 8, 2024
26ceeaf
remove patch on `CWVWebViewConfiguration.reuseCheckService`
kylehickinson Aug 8, 2024
e3612ac
restore always request desktop site feature
kylehickinson Aug 8, 2024
e4e6998
restore basic auth handling
kylehickinson Aug 8, 2024
558a397
use correct ssl status error messages in certificate viewer
kylehickinson Aug 9, 2024
fc4c348
[wip]: restore certificate pinning
kylehickinson Aug 9, 2024
bf66f0a
remove mixed content upgrade content blocker
kylehickinson Aug 12, 2024
07ce550
restore playlist web loader delegates
kylehickinson Aug 13, 2024
e848a1f
better handling and display for webui schemes
kylehickinson Aug 13, 2024
cc02182
restore link preview feature
kylehickinson Aug 19, 2024
2355e69
restore block scripts shield functionality
kylehickinson Aug 19, 2024
aa60f50
fix alternative app store installs
kylehickinson Aug 21, 2024
eabed5b
fix loading redirected request that may error after said redirected load
kylehickinson Aug 21, 2024
bf8b940
replace https upgrade logic with chromium tab helper & prefs
kylehickinson Aug 26, 2024
989890f
add restore data validation to ignore old WebKit restore data
kylehickinson Aug 26, 2024
89bb4c4
expose HttpsUpgradeService to allow clearing allowlist
kylehickinson Aug 28, 2024
d293596
restore KVO for sampled page top color
kylehickinson Aug 29, 2024
d361580
replace CWVWebViewConfiguration patches and vend from BraveCoreMain
kylehickinson Sep 5, 2024
cf80c3c
remove factory typedefs and disable usages of factories
kylehickinson Sep 6, 2024
52475e0
remove ApplicationContext wrapper and unused public headers
kylehickinson Sep 6, 2024
8ef6a68
fix WebBrowserState layering violation
kylehickinson Sep 9, 2024
41a8ade
fix AttachTabHelper layering violation
kylehickinson Sep 10, 2024
b300351
add proper shutdown for webview configurations
kylehickinson Sep 10, 2024
310544c
presubmit fixes
kylehickinson Sep 10, 2024
b4e6991
fix crash when tapping a link that would trigger a download in a new tab
kylehickinson Sep 16, 2024
0f7b403
fix js message handling to support popup tabs correctly
kylehickinson Sep 18, 2024
4fbf54b
add cleanup to top page color observer
kylehickinson Sep 18, 2024
7c65a64
Cr130 fixes
kylehickinson Oct 3, 2024
f08de32
Fix Javascript crashes. Fix SSL-Pinning page not displaying correctly…
Brandon-T Oct 7, 2024
20f0b52
Add new download alert
Brandon-T Oct 8, 2024
8dd4654
ensure the OTR browser is recreated when OTR browser state is destroyed
kylehickinson Oct 8, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions chromium_src/ios/CPPLINT.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
# Common linting false posititives from Obj-C syntax in headers
filter=-readability/casting,-whitespace/parens,-whitespace/operators
4 changes: 4 additions & 0 deletions chromium_src/ios/chrome/browser/https_upgrades/model/DEPS
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
include_rules = [
"+brave/components/https_upgrade_exceptions/browser",
"+brave/ios/browser/application_context",
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
// Copyright (c) 2024 The Brave Authors. All rights reserved.
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.

#include "brave/components/https_upgrade_exceptions/browser/https_upgrade_exceptions_service.h"
#include "brave/ios/browser/application_context/brave_application_context_impl.h"
#import "ios/chrome/browser/shared/model/prefs/pref_names.h"
#import "ios/components/security_interstitials/https_only_mode/feature.h"
#import "ios/components/security_interstitials/https_only_mode/https_upgrade_service.h"
#include "net/base/features.h"
#include "net/base/url_util.h"

namespace {
bool CanUpgradeToHTTPS(const GURL& url) {
// FIXME: Move this impl out of the chromium_src override
BraveApplicationContextImpl* braveContext =
static_cast<BraveApplicationContextImpl*>(GetApplicationContext());
return braveContext->https_upgrade_exceptions_service()->CanUpgradeToHTTPS(
url);
}
} // namespace

// Add checks for Brave-by-default feature flag, standard HTTPS upgrades pref
// and the brave https upgrade exception list when determining if the navigation
// should be upgraded
#define kHttpsUpgrades kHttpsUpgrades) && \
!base::FeatureList::IsEnabled(net::features::kBraveHttpsByDefault) && \
!(prefs_ && prefs_->GetBoolean(prefs::kHttpsUpgradesEnabled)
#define IsLocalhost IsLocalhost(url) || !CanUpgradeToHTTPS
#include "src/ios/chrome/browser/https_upgrades/model/https_only_mode_upgrade_tab_helper.mm"
#undef IsLocalhost
#undef kHttpsUpgrades
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,16 @@
#include "ios/chrome/browser/profile/model/keyed_service_factories.h"

#include "brave/ios/browser/profile/model/brave_keyed_service_factories.h"
#include "ios/chrome/browser/affiliations/model/ios_chrome_affiliation_service_factory.h"
#include "ios/chrome/browser/autocomplete/model/autocomplete_classifier_factory.h"
#include "ios/chrome/browser/autocomplete/model/zero_suggest_cache_service_factory.h"
#include "ios/chrome/browser/autofill/model/autofill_log_router_factory.h"
#include "ios/chrome/browser/autofill/model/personal_data_manager_factory.h"
#include "ios/chrome/browser/bookmarks/model/account_bookmark_sync_service_factory.h"
#include "ios/chrome/browser/bookmarks/model/bookmark_model_factory.h"
#include "ios/chrome/browser/bookmarks/model/bookmark_undo_service_factory.h"
#include "ios/chrome/browser/bookmarks/model/local_or_syncable_bookmark_sync_service_factory.h"
#include "ios/chrome/browser/browsing_data/model/browsing_data_remover_factory.h"
#include "ios/chrome/browser/consent_auditor/model/consent_auditor_factory.h"
#include "ios/chrome/browser/content_settings/model/host_content_settings_map_factory.h"
#include "ios/chrome/browser/credential_provider/model/credential_provider_buildflags.h"
Expand All @@ -22,25 +25,33 @@
#include "ios/chrome/browser/favicon/model/ios_chrome_favicon_loader_factory.h"
#include "ios/chrome/browser/favicon/model/ios_chrome_large_icon_cache_factory.h"
#include "ios/chrome/browser/favicon/model/ios_chrome_large_icon_service_factory.h"
#include "ios/chrome/browser/gcm/model/ios_chrome_gcm_profile_service_factory.h"
#include "ios/chrome/browser/history/model/history_service_factory.h"
#include "ios/chrome/browser/history/model/top_sites_factory.h"
#include "ios/chrome/browser/history/model/web_history_service_factory.h"
#include "ios/chrome/browser/https_upgrades/model/https_upgrade_service_factory.h"
#include "ios/chrome/browser/invalidation/model/ios_chrome_profile_invalidation_provider_factory.h"
#include "ios/chrome/browser/language/model/accept_languages_service_factory.h"
#include "ios/chrome/browser/language/model/language_model_manager_factory.h"
#include "ios/chrome/browser/language/model/url_language_histogram_factory.h"
#include "ios/chrome/browser/metrics/model/google_groups_manager_factory.h"
#include "ios/chrome/browser/optimization_guide/model/optimization_guide_service_factory.h"
#include "ios/chrome/browser/page_info/about_this_site_service_factory.h"
#include "ios/chrome/browser/passwords/model/ios_chrome_account_password_store_factory.h"
#include "ios/chrome/browser/passwords/model/ios_chrome_bulk_leak_check_service_factory.h"
#include "ios/chrome/browser/passwords/model/ios_chrome_password_receiver_service_factory.h"
#include "ios/chrome/browser/passwords/model/ios_chrome_password_reuse_manager_factory.h"
#include "ios/chrome/browser/passwords/model/ios_chrome_password_sender_service_factory.h"
#include "ios/chrome/browser/passwords/model/ios_chrome_profile_password_store_factory.h"
#include "ios/chrome/browser/passwords/model/ios_password_manager_settings_service_factory.h"
#include "ios/chrome/browser/passwords/model/ios_password_requirements_service_factory.h"
#include "ios/chrome/browser/passwords/model/password_manager_log_router_factory.h"
#include "ios/chrome/browser/plus_addresses/model/plus_address_service_factory.h"
#include "ios/chrome/browser/plus_addresses/model/plus_address_setting_service_factory.h"
#include "ios/chrome/browser/power_bookmarks/model/power_bookmark_service_factory.h"
#include "ios/chrome/browser/push_notification/model/push_notification_profile_service_factory.h"
#include "ios/chrome/browser/reading_list/model/reading_list_model_factory.h"
#include "ios/chrome/browser/safe_browsing/model/safe_browsing_client_factory.h"
#include "ios/chrome/browser/safe_browsing/model/safe_browsing_metrics_collector_factory.h"
#include "ios/chrome/browser/saved_tab_groups/model/tab_group_sync_service_factory.h"
#include "ios/chrome/browser/search_engines/model/template_url_service_factory.h"
Expand All @@ -50,6 +61,7 @@
#include "ios/chrome/browser/signin/model/account_consistency_service_factory.h"
#include "ios/chrome/browser/signin/model/account_reconcilor_factory.h"
#include "ios/chrome/browser/signin/model/identity_manager_factory.h"
#include "ios/chrome/browser/signin/model/signin_client_factory.h"
#include "ios/chrome/browser/supervised_user/model/child_account_service_factory.h"
#include "ios/chrome/browser/supervised_user/model/list_family_members_service_factory.h"
#include "ios/chrome/browser/supervised_user/model/supervised_user_service_factory.h"
Expand All @@ -70,47 +82,56 @@
#endif

void EnsureProfileKeyedServiceFactoriesBuilt() {
autofill::AutofillLogRouterFactory::GetInstance();
autofill::PersonalDataManagerFactory::GetInstance();
data_sharing::DataSharingServiceFactory::GetInstance();
ios::AccountBookmarkSyncServiceFactory::GetInstance();
ios::AccountConsistencyServiceFactory::GetInstance();
ios::AccountReconcilorFactory::GetInstance();
ios::AutocompleteClassifierFactory::GetInstance();
ios::BookmarkModelFactory::GetInstance();
ios::BookmarkUndoServiceFactory::GetInstance();
ios::FaviconServiceFactory::GetInstance();
ios::HistoryServiceFactory::GetInstance();
ios::LocalOrSyncableBookmarkSyncServiceFactory::GetInstance();
ios::TopSitesFactory::GetInstance();
ios::AutocompleteClassifierFactory::GetInstance();
ios::HostContentSettingsMapFactory::GetInstance();
ios::LocalOrSyncableBookmarkSyncServiceFactory::GetInstance();
ios::PasswordManagerLogRouterFactory::GetInstance();
ios::TemplateURLServiceFactory::GetInstance();
ios::TopSitesFactory::GetInstance();
ios::WebDataServiceFactory::GetInstance();
ios::WebHistoryServiceFactory::GetInstance();
ios::ZeroSuggestCacheServiceFactory::GetInstance();
segmentation_platform::SegmentationPlatformServiceFactory::GetInstance();
tab_groups::TabGroupSyncServiceFactory::GetInstance();
translate::TranslateRankerFactory::GetInstance();
AboutThisSiteServiceFactory::GetInstance();
AcceptLanguagesServiceFactory::GetInstance();
BackgroundDownloadServiceFactory::GetInstance();
BrowserListFactory::GetInstance();
BrowsingDataRemoverFactory::GetInstance();
ChildAccountServiceFactory::GetInstance();
ConsentAuditorFactory::GetInstance();
DeviceInfoSyncServiceFactory::GetInstance();
GoogleGroupsManagerFactory::GetInstance();
HttpsUpgradeServiceFactory::GetInstance();
IdentityManagerFactory::GetInstance();
IOSChromeAccountPasswordStoreFactory::GetInstance();
IOSChromeAffiliationServiceFactory::GetInstance();
IOSChromeBulkLeakCheckServiceFactory::GetInstance();
IOSChromeFaviconLoaderFactory::GetInstance();
IOSChromeGCMProfileServiceFactory::GetInstance();
IOSChromeLargeIconCacheFactory::GetInstance();
IOSChromeLargeIconServiceFactory::GetInstance();
IOSChromePasswordReceiverServiceFactory::GetInstance();
IOSChromePasswordReuseManagerFactory::GetInstance();
IOSChromePasswordSenderServiceFactory::GetInstance();
IOSChromeProfilePasswordStoreFactory::GetInstance();
IOSChromeProfileInvalidationProviderFactory::GetInstance();
IOSChromeProfilePasswordStoreFactory::GetInstance();
IOSPasskeyModelFactory::GetInstance();
IOSPasswordManagerSettingsServiceFactory::GetInstance();
IOSPasswordRequirementsServiceFactory::GetInstance();
IOSUserEventServiceFactory::GetInstance();
HttpsUpgradeServiceFactory::GetInstance();
LanguageModelManagerFactory::GetInstance();
ListFamilyMembersServiceFactory::GetInstance();
OptimizationGuideServiceFactory::GetInstance();
DataTypeStoreServiceFactory::GetInstance();
Expand All @@ -122,11 +143,17 @@ void EnsureProfileKeyedServiceFactoriesBuilt() {
SyncServiceFactory::GetInstance();
UnifiedConsentServiceFactory::GetInstance();
ReadingListModelFactory::GetInstance();
SafeBrowsingClientFactory::GetInstance();
SafeBrowsingMetricsCollectorFactory::GetInstance();
SendTabToSelfSyncServiceFactory::GetInstance();
SessionRestorationServiceFactory::GetInstance();
SessionSyncServiceFactory::GetInstance();
SigninClientFactory::GetInstance();
SupervisedUserServiceFactory::GetInstance();
SupervisedUserSettingsServiceFactory::GetInstance();
SyncServiceFactory::GetInstance();
UnifiedConsentServiceFactory::GetInstance();
UrlLanguageHistogramFactory::GetInstance();

#if BUILDFLAG(IOS_CREDENTIAL_PROVIDER_ENABLED)
CredentialProviderServiceFactory::GetInstance();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
#include "brave/components/skus/browser/skus_utils.h"
#include "brave/ios/browser/brave_stats/brave_stats_prefs.h"
#include "components/pref_registry/pref_registry_syncable.h"
#include "ios/chrome/browser/shared/model/prefs/pref_names.h"

void BraveRegisterBrowserStatePrefs(
user_prefs::PrefRegistrySyncable* registry) {
Expand All @@ -42,6 +43,8 @@ void BraveRegisterBrowserStatePrefs(
ai_chat::ModelService::RegisterProfilePrefs(registry);
omnibox::RegisterBraveProfilePrefs(registry);
brave_news::prefs::RegisterProfilePrefs(registry);

registry->RegisterBooleanPref(prefs::kHttpsUpgradesEnabled, true);
}

void BraveRegisterLocalStatePrefs(PrefRegistrySimple* registry) {
Expand Down
16 changes: 16 additions & 0 deletions chromium_src/ios/chrome/browser/shared/model/prefs/pref_names.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// Copyright (c) 2024 The Brave Authors. All rights reserved.
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.

#ifndef BRAVE_CHROMIUM_SRC_IOS_CHROME_BROWSER_SHARED_MODEL_PREFS_PREF_NAMES_H_
#define BRAVE_CHROMIUM_SRC_IOS_CHROME_BROWSER_SHARED_MODEL_PREFS_PREF_NAMES_H_

#include "src/ios/chrome/browser/shared/model/prefs/pref_names.h" // IWYU pragma: export

namespace prefs {
// A boolean specifying whether HTTPS Upgrades are enabled.
inline constexpr char kHttpsUpgradesEnabled[] = "ios.https_upgrades_enabled";
} // namespace prefs

#endif // BRAVE_CHROMIUM_SRC_IOS_CHROME_BROWSER_SHARED_MODEL_PREFS_PREF_NAMES_H_
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
// Copyright (c) 2024 The Brave Authors. All rights reserved.
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.

#ifndef BRAVE_CHROMIUM_SRC_IOS_CHROME_BROWSER_SHARED_MODEL_PROFILE_PROFILE_IOS_H_
#define BRAVE_CHROMIUM_SRC_IOS_CHROME_BROWSER_SHARED_MODEL_PROFILE_PROFILE_IOS_H_

#include "ios/web/public/browser_state.h"

#define GetPrefs() \
GetPrefs_Unused(); \
PrefService* GetPrefs() override
#include "src/ios/chrome/browser/shared/model/profile/profile_ios.h" // IWYU pragma: export
#undef GetPrefs

#endif // BRAVE_CHROMIUM_SRC_IOS_CHROME_BROWSER_SHARED_MODEL_PROFILE_PROFILE_IOS_H_
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// Copyright (c) 2024 The Brave Authors. All rights reserved.
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
// You can obtain one at https://mozilla.org/MPL/2.0/.

#include "src/ios/chrome/browser/shared/model/profile/profile_ios.mm"

PrefService* ChromeBrowserState::GetPrefs_Unused() {
return nullptr;
}
34 changes: 33 additions & 1 deletion chromium_src/ios/chrome/browser/tabs/model/tab_helper_util.mm
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,46 @@

#import "ios/chrome/browser/tabs/model/tab_helper_util.h"

#import "components/omnibox/common/omnibox_features.h"
#include "ios/chrome/browser/complex_tasks/model/ios_task_tab_helper.h"
#import "ios/chrome/browser/https_upgrades/model/https_only_mode_upgrade_tab_helper.h"
#import "ios/chrome/browser/https_upgrades/model/https_upgrade_service_factory.h"
#import "ios/chrome/browser/https_upgrades/model/typed_navigation_upgrade_tab_helper.h"
#import "ios/chrome/browser/prerender/model/prerender_service_factory.h"
#include "ios/chrome/browser/sessions/model/ios_chrome_session_tab_helper.h"
#import "ios/chrome/browser/sessions/model/web_session_state_tab_helper.h"
#include "ios/chrome/browser/sessions/model/web_session_state_tab_helper.h"
#import "ios/chrome/browser/shared/model/profile/profile_ios.h"
#include "ios/chrome/browser/tabs/model/ios_chrome_synced_tab_delegate.h"
#import "ios/components/security_interstitials/https_only_mode/feature.h"
#import "ios/components/security_interstitials/https_only_mode/https_only_mode_container.h"
#import "ios/components/security_interstitials/ios_blocking_page_tab_helper.h"

void AttachTabHelpers(web::WebState* web_state, TabHelperFilter filter_flags) {
ChromeBrowserState* const browser_state =
ChromeBrowserState::FromBrowserState(web_state->GetBrowserState());

IOSChromeSessionTabHelper::CreateForWebState(web_state);
IOSChromeSyncedTabDelegate::CreateForWebState(web_state);
WebSessionStateTabHelper::CreateForWebState(web_state);
IOSTaskTabHelper::CreateForWebState(web_state);

security_interstitials::IOSBlockingPageTabHelper::CreateForWebState(
web_state);

if (base::FeatureList::IsEnabled(
security_interstitials::features::kHttpsOnlyMode) ||
base::FeatureList::IsEnabled(
security_interstitials::features::kHttpsUpgrades)) {
HttpsOnlyModeUpgradeTabHelper::CreateForWebState(
web_state, browser_state->GetPrefs(),
PrerenderServiceFactory::GetForBrowserState(browser_state),
HttpsUpgradeServiceFactory::GetForBrowserState(browser_state));
HttpsOnlyModeContainer::CreateForWebState(web_state);
}

if (base::FeatureList::IsEnabled(omnibox::kDefaultTypedNavigationsToHttps)) {
TypedNavigationUpgradeTabHelper::CreateForWebState(
web_state, PrerenderServiceFactory::GetForBrowserState(browser_state),
HttpsUpgradeServiceFactory::GetForBrowserState(browser_state));
}
}
Loading
Loading