Commit 1a05021f authored by John Z Wu's avatar John Z Wu Committed by Commit Bot

Refactor //ios/web_view to use one flag per feature.

This allows us to control the final binary size by optionally including features.

We only want clients to import one umbrella header:
  #import <ChromeWebView/ChromeWebView.h>
To accomplish this, we generate the umbrella header based on the feature flags.

Binary size for Release-iphoneos with Cronet included:
+signin and +autofill: 20MB
-signin and -autofill: 15.5MB
+signin and -autofill: 16.7MB
-signin and +autofill: 19.6MB

Cq-Include-Trybots: master.tryserver.chromium.mac:ios-simulator-cronet;master.tryserver.chromium.mac:ios-simulator-full-configs
Change-Id: I2981b06812495d9b24b1d9630f010247a7ab1331
Reviewed-on: https://chromium-review.googlesource.com/980737
Commit-Queue: John Wu <jzw@chromium.org>
Reviewed-by: default avatarHiroshi Ichikawa <ichikawa@chromium.org>
Reviewed-by: default avatarSylvain Defresne <sdefresne@chromium.org>
Reviewed-by: default avatarEugene But <eugenebut@chromium.org>
Cr-Commit-Position: refs/heads/master@{#549276}
parent 321a3dda
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be # Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file. # found in the LICENSE file.
import("//build/buildflag_header.gni")
import("//build/config/ios/ios_sdk.gni") import("//build/config/ios/ios_sdk.gni")
import("//build/config/ios/rules.gni") import("//build/config/ios/rules.gni")
import("//components/cronet/native/include/headers.gni") import("//components/cronet/native/include/headers.gni")
...@@ -12,6 +13,15 @@ import("//ios/web_view/features.gni") ...@@ -12,6 +13,15 @@ import("//ios/web_view/features.gni")
import("//testing/test.gni") import("//testing/test.gni")
import("//tools/grit/repack.gni") import("//tools/grit/repack.gni")
buildflag_header("web_view_features") {
header = "cwv_web_view_features.h"
flags = [
"IOS_WEB_VIEW_ENABLE_SIGNIN=$ios_web_view_enable_signin",
"IOS_WEB_VIEW_ENABLE_AUTOFILL=$ios_web_view_enable_autofill",
]
}
group("all_tests") { group("all_tests") {
testonly = true testonly = true
deps = [ deps = [
...@@ -30,12 +40,8 @@ config("config") { ...@@ -30,12 +40,8 @@ config("config") {
] ]
} }
# These variables are used to share framework sources with both ChromeWebView # These are defined as vars so they can be shared with different targets below.
# and CronetChromeWebView frameworks.
ios_web_view_public_headers = [ ios_web_view_public_headers = [
"public/cwv_autofill_controller.h",
"public/cwv_autofill_controller_delegate.h",
"public/cwv_autofill_suggestion.h",
"public/cwv_export.h", "public/cwv_export.h",
"public/cwv_html_element.h", "public/cwv_html_element.h",
"public/cwv_navigation_action.h", "public/cwv_navigation_action.h",
...@@ -55,13 +61,21 @@ ios_web_view_public_headers = [ ...@@ -55,13 +61,21 @@ ios_web_view_public_headers = [
"public/cwv_web_view.h", "public/cwv_web_view.h",
"public/cwv_web_view_configuration.h", "public/cwv_web_view_configuration.h",
] ]
if (ios_web_view_enable_sync) { if (ios_web_view_enable_signin) {
ios_web_view_public_headers += [ ios_web_view_public_headers += [
"public/ChromeSync.h",
"public/cwv_authentication_controller.h", "public/cwv_authentication_controller.h",
"public/cwv_authentication_controller_delegate.h", "public/cwv_authentication_controller_delegate.h",
"public/cwv_identity.h", "public/cwv_identity.h",
"public/cwv_web_view_configuration+sync.h", "public/cwv_web_view_configuration_signin.h",
]
}
if (ios_web_view_enable_autofill) {
ios_web_view_public_headers += [
"public/cwv_autofill_controller.h",
"public/cwv_autofill_controller_delegate.h",
"public/cwv_autofill_suggestion.h",
"public/cwv_preferences_autofill.h",
"public/cwv_web_view_autofill.h",
] ]
} }
...@@ -70,10 +84,6 @@ ios_web_view_sources = [ ...@@ -70,10 +84,6 @@ ios_web_view_sources = [
"internal/app/application_context.h", "internal/app/application_context.h",
"internal/app/web_view_io_thread.h", "internal/app/web_view_io_thread.h",
"internal/app/web_view_io_thread.mm", "internal/app/web_view_io_thread.mm",
"internal/autofill/cwv_autofill_controller.mm",
"internal/autofill/cwv_autofill_controller_internal.h",
"internal/autofill/cwv_autofill_suggestion.mm",
"internal/autofill/cwv_autofill_suggestion_internal.h",
"internal/autofill/web_view_autofill_client_ios.h", "internal/autofill/web_view_autofill_client_ios.h",
"internal/autofill/web_view_autofill_client_ios.mm", "internal/autofill/web_view_autofill_client_ios.mm",
"internal/autofill/web_view_personal_data_manager_factory.cc", "internal/autofill/web_view_personal_data_manager_factory.cc",
...@@ -165,17 +175,25 @@ ios_web_view_sources = [ ...@@ -165,17 +175,25 @@ ios_web_view_sources = [
"internal/webdata_services/web_view_web_data_service_wrapper_factory.h", "internal/webdata_services/web_view_web_data_service_wrapper_factory.h",
] ]
ios_web_view_sources += ios_web_view_public_headers ios_web_view_sources += ios_web_view_public_headers
if (ios_web_view_enable_sync) { if (ios_web_view_enable_signin) {
ios_web_view_sources += [ ios_web_view_sources += [
"internal/cwv_web_view_configuration+sync.mm",
"internal/signin/cwv_authentication_controller.mm", "internal/signin/cwv_authentication_controller.mm",
"internal/signin/cwv_authentication_controller_internal.h", "internal/signin/cwv_authentication_controller_internal.h",
"internal/signin/cwv_identity.mm", "internal/signin/cwv_identity.mm",
] ]
} }
if (ios_web_view_enable_autofill) {
ios_web_view_sources += [
"internal/autofill/cwv_autofill_controller.mm",
"internal/autofill/cwv_autofill_controller_internal.h",
"internal/autofill/cwv_autofill_suggestion.mm",
"internal/autofill/cwv_autofill_suggestion_internal.h",
]
}
ios_web_view_deps = [ ios_web_view_deps = [
":web_view_bundle", ":web_view_bundle",
":web_view_features",
":packed_resources", ":packed_resources",
"//base", "//base",
"//components/autofill/core/browser", "//components/autofill/core/browser",
...@@ -216,6 +234,12 @@ ios_web_view_deps = [ ...@@ -216,6 +234,12 @@ ios_web_view_deps = [
"//url", "//url",
] ]
# Generate the umbrella header to exclude headers for disabled features.
# This is preferable to guarding header imports using flags defined in
# :web_view_features because:
# 1. Confusing to see headers for unsupported features in umbrella header.
# 2. A need to include cwv_web_view_features.h as part of public headers and
# any headers it itself includes, despite not being part of the public API.
action("web_view_umbrella_header") { action("web_view_umbrella_header") {
script = "//build/config/ios/generate_umbrella_header.py" script = "//build/config/ios/generate_umbrella_header.py"
......
...@@ -6,8 +6,11 @@ declare_args() { ...@@ -6,8 +6,11 @@ declare_args() {
# Controls if cronet is included. # Controls if cronet is included.
ios_web_view_include_cronet = true ios_web_view_include_cronet = true
# Controls if sign and sync APIs are exposed. # Controls if signin APIs are exposed.
ios_web_view_enable_sync = true ios_web_view_enable_signin = true
# Controls if autofill APIs are exposed.
ios_web_view_enable_autofill = true
# Controls the output name of the built framework. # Controls the output name of the built framework.
ios_web_view_output_name = "ChromeWebView" ios_web_view_output_name = "ChromeWebView"
......
...@@ -18,6 +18,7 @@ ...@@ -18,6 +18,7 @@
#include "components/ssl_config/ssl_config_service_manager.h" #include "components/ssl_config/ssl_config_service_manager.h"
#include "components/translate/core/browser/translate_download_manager.h" #include "components/translate/core/browser/translate_download_manager.h"
#include "ios/web/public/web_thread.h" #include "ios/web/public/web_thread.h"
#include "ios/web_view/cwv_web_view_features.h"
#include "ios/web_view/internal/app/web_view_io_thread.h" #include "ios/web_view/internal/app/web_view_io_thread.h"
#include "net/socket/client_socket_pool_manager.h" #include "net/socket/client_socket_pool_manager.h"
#include "ui/base/l10n/l10n_util_mac.h" #include "ui/base/l10n/l10n_util_mac.h"
...@@ -70,7 +71,10 @@ PrefService* ApplicationContext::GetLocalState() { ...@@ -70,7 +71,10 @@ PrefService* ApplicationContext::GetLocalState() {
flags_ui::PrefServiceFlagsStorage::RegisterPrefs(pref_registry.get()); flags_ui::PrefServiceFlagsStorage::RegisterPrefs(pref_registry.get());
PrefProxyConfigTrackerImpl::RegisterPrefs(pref_registry.get()); PrefProxyConfigTrackerImpl::RegisterPrefs(pref_registry.get());
ssl_config::SSLConfigServiceManager::RegisterPrefs(pref_registry.get()); ssl_config::SSLConfigServiceManager::RegisterPrefs(pref_registry.get());
#if BUILDFLAG(IOS_WEB_VIEW_ENABLE_SIGNIN)
SigninManagerBase::RegisterPrefs(pref_registry.get()); SigninManagerBase::RegisterPrefs(pref_registry.get());
#endif // BUILDFLAG(IOS_WEB_VIEW_ENABLE_SIGNIN)
base::FilePath local_state_path; base::FilePath local_state_path;
PathService::Get(base::DIR_APP_DATA, &local_state_path); PathService::Get(base::DIR_APP_DATA, &local_state_path);
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/translate/core/browser/translate_pref_names.h" #include "components/translate/core/browser/translate_pref_names.h"
#include "components/translate/core/browser/translate_prefs.h" #include "components/translate/core/browser/translate_prefs.h"
#include "ios/web_view/cwv_web_view_features.h"
#include "ios/web_view/internal/pref_names.h" #include "ios/web_view/internal/pref_names.h"
#if !defined(__has_feature) || !__has_feature(objc_arc) #if !defined(__has_feature) || !__has_feature(objc_arc)
...@@ -43,6 +44,9 @@ ...@@ -43,6 +44,9 @@
translatePrefs.ResetToDefaults(); translatePrefs.ResetToDefaults();
} }
#if BUILDFLAG(IOS_WEB_VIEW_ENABLE_AUTOFILL)
#pragma mark - Autofill
- (void)setAutofillEnabled:(BOOL)enabled { - (void)setAutofillEnabled:(BOOL)enabled {
_prefService->SetBoolean(autofill::prefs::kAutofillEnabled, enabled); _prefService->SetBoolean(autofill::prefs::kAutofillEnabled, enabled);
} }
...@@ -50,5 +54,6 @@ ...@@ -50,5 +54,6 @@
- (BOOL)isAutofillEnabled { - (BOOL)isAutofillEnabled {
return _prefService->GetBoolean(autofill::prefs::kAutofillEnabled); return _prefService->GetBoolean(autofill::prefs::kAutofillEnabled);
} }
#endif // BUILDFLAG(IOS_WEB_VIEW_ENABLE_AUTOFILL)
@end @end
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include "components/prefs/pref_service.h" #include "components/prefs/pref_service.h"
#include "components/prefs/pref_service_factory.h" #include "components/prefs/pref_service_factory.h"
#include "components/translate/core/browser/translate_pref_names.h" #include "components/translate/core/browser/translate_pref_names.h"
#import "ios/web_view/public/cwv_preferences_autofill.h"
#include "testing/gtest/include/gtest/gtest.h" #include "testing/gtest/include/gtest/gtest.h"
#import "testing/gtest_mac.h" #import "testing/gtest_mac.h"
#include "testing/platform_test.h" #include "testing/platform_test.h"
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#import "ios/web/public/web_state/web_state.h" #import "ios/web/public/web_state/web_state.h"
#import "ios/web/public/web_state/web_state_delegate_bridge.h" #import "ios/web/public/web_state/web_state_delegate_bridge.h"
#import "ios/web/public/web_state/web_state_observer_bridge.h" #import "ios/web/public/web_state/web_state_observer_bridge.h"
#include "ios/web_view/cwv_web_view_features.h"
#import "ios/web_view/internal/autofill/cwv_autofill_controller_internal.h" #import "ios/web_view/internal/autofill/cwv_autofill_controller_internal.h"
#import "ios/web_view/internal/cwv_html_element_internal.h" #import "ios/web_view/internal/cwv_html_element_internal.h"
#import "ios/web_view/internal/cwv_navigation_action_internal.h" #import "ios/web_view/internal/cwv_navigation_action_internal.h"
...@@ -76,6 +77,9 @@ NSString* const kSessionStorageKey = @"sessionStorage"; ...@@ -76,6 +77,9 @@ NSString* const kSessionStorageKey = @"sessionStorage";
@property(nonatomic, readwrite) BOOL loading; @property(nonatomic, readwrite) BOOL loading;
@property(nonatomic, readwrite, copy) NSString* title; @property(nonatomic, readwrite, copy) NSString* title;
@property(nonatomic, readwrite) NSURL* visibleURL; @property(nonatomic, readwrite) NSURL* visibleURL;
#if BUILDFLAG(IOS_WEB_VIEW_ENABLE_AUTOFILL)
@property(nonatomic, readonly) CWVAutofillController* autofillController;
#endif // BUILDFLAG(IOS_WEB_VIEW_ENABLE_AUTOFILL)
// Updates the availability of the back/forward navigation properties exposed // Updates the availability of the back/forward navigation properties exposed
// through |canGoBack| and |canGoForward|. // through |canGoBack| and |canGoForward|.
...@@ -84,8 +88,10 @@ NSString* const kSessionStorageKey = @"sessionStorage"; ...@@ -84,8 +88,10 @@ NSString* const kSessionStorageKey = @"sessionStorage";
- (void)updateCurrentURLs; - (void)updateCurrentURLs;
// Updates |title| property. // Updates |title| property.
- (void)updateTitle; - (void)updateTitle;
#if BUILDFLAG(IOS_WEB_VIEW_ENABLE_AUTOFILL)
// Returns a new CWVAutofillController created from |_webState|. // Returns a new CWVAutofillController created from |_webState|.
- (CWVAutofillController*)newAutofillController; - (CWVAutofillController*)newAutofillController;
#endif // BUILDFLAG(IOS_WEB_VIEW_ENABLE_AUTOFILL)
// Returns a new CWVTranslationController created from |_webState|. // Returns a new CWVTranslationController created from |_webState|.
- (CWVTranslationController*)newTranslationController; - (CWVTranslationController*)newTranslationController;
// Updates |_webState| visiblity. // Updates |_webState| visiblity.
...@@ -97,7 +103,9 @@ static NSString* gUserAgentProduct = nil; ...@@ -97,7 +103,9 @@ static NSString* gUserAgentProduct = nil;
@implementation CWVWebView @implementation CWVWebView
#if BUILDFLAG(IOS_WEB_VIEW_ENABLE_AUTOFILL)
@synthesize autofillController = _autofillController; @synthesize autofillController = _autofillController;
#endif // BUILDFLAG(IOS_WEB_VIEW_ENABLE_AUTOFILL)
@synthesize canGoBack = _canGoBack; @synthesize canGoBack = _canGoBack;
@synthesize canGoForward = _canGoForward; @synthesize canGoForward = _canGoForward;
@synthesize configuration = _configuration; @synthesize configuration = _configuration;
...@@ -403,6 +411,7 @@ static NSString* gUserAgentProduct = nil; ...@@ -403,6 +411,7 @@ static NSString* gUserAgentProduct = nil;
initWithTranslateClient:translateClient]; initWithTranslateClient:translateClient];
} }
#if BUILDFLAG(IOS_WEB_VIEW_ENABLE_AUTOFILL)
#pragma mark - Autofill #pragma mark - Autofill
- (CWVAutofillController*)autofillController { - (CWVAutofillController*)autofillController {
...@@ -429,6 +438,7 @@ static NSString* gUserAgentProduct = nil; ...@@ -429,6 +438,7 @@ static NSString* gUserAgentProduct = nil;
JSAutofillManager:JSAutofillManager JSAutofillManager:JSAutofillManager
JSSuggestionManager:JSSuggestionManager]; JSSuggestionManager:JSSuggestionManager];
} }
#endif // BUILDFLAG(IOS_WEB_VIEW_ENABLE_AUTOFILL)
#pragma mark - Preserving and Restoring State #pragma mark - Preserving and Restoring State
...@@ -506,12 +516,14 @@ static NSString* gUserAgentProduct = nil; ...@@ -506,12 +516,14 @@ static NSString* gUserAgentProduct = nil;
_translationController.delegate = delegate; _translationController.delegate = delegate;
} }
#if BUILDFLAG(IOS_WEB_VIEW_ENABLE_AUTOFILL)
// Recreate and restore the delegate only if previously lazily loaded. // Recreate and restore the delegate only if previously lazily loaded.
if (_autofillController) { if (_autofillController) {
id<CWVAutofillControllerDelegate> delegate = _autofillController.delegate; id<CWVAutofillControllerDelegate> delegate = _autofillController.delegate;
_autofillController = [self newAutofillController]; _autofillController = [self newAutofillController];
_autofillController.delegate = delegate; _autofillController.delegate = delegate;
} }
#endif // BUILDFLAG(IOS_WEB_VIEW_ENABLE_AUTOFILL)
[self addInternalWebViewAsSubview]; [self addInternalWebViewAsSubview];
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "ios/web_view/internal/cwv_web_view_configuration_internal.h"
#import <objc/runtime.h>
#import "ios/web_view/internal/signin/cwv_authentication_controller_internal.h"
#include "ios/web_view/internal/web_view_browser_state.h"
#if !defined(__has_feature) || !__has_feature(objc_arc)
#error "This file requires ARC support."
#endif
@implementation CWVWebViewConfiguration (Sync)
- (CWVAuthenticationController*)authenticationController {
CWVAuthenticationController* authenticationController =
objc_getAssociatedObject(self, @selector(authenticationController));
ios_web_view::WebViewBrowserState* browserState = self.browserState;
if (!authenticationController && !browserState->IsOffTheRecord()) {
authenticationController =
[[CWVAuthenticationController alloc] initWithBrowserState:browserState];
objc_setAssociatedObject(self, @selector(authenticationController),
authenticationController,
OBJC_ASSOCIATION_RETAIN_NONATOMIC);
}
return authenticationController;
}
@end
...@@ -8,10 +8,12 @@ ...@@ -8,10 +8,12 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/threading/thread_restrictions.h" #include "base/threading/thread_restrictions.h"
#include "ios/web_view/cwv_web_view_features.h"
#include "ios/web_view/internal/app/application_context.h" #include "ios/web_view/internal/app/application_context.h"
#import "ios/web_view/internal/cwv_preferences_internal.h" #import "ios/web_view/internal/cwv_preferences_internal.h"
#import "ios/web_view/internal/cwv_user_content_controller_internal.h" #import "ios/web_view/internal/cwv_user_content_controller_internal.h"
#import "ios/web_view/internal/cwv_web_view_internal.h" #import "ios/web_view/internal/cwv_web_view_internal.h"
#import "ios/web_view/internal/signin/cwv_authentication_controller_internal.h"
#include "ios/web_view/internal/web_view_browser_state.h" #include "ios/web_view/internal/web_view_browser_state.h"
#include "ios/web_view/internal/web_view_global_state_util.h" #include "ios/web_view/internal/web_view_global_state_util.h"
...@@ -30,13 +32,24 @@ ...@@ -30,13 +32,24 @@
BOOL _wasShutDown; BOOL _wasShutDown;
} }
#if BUILDFLAG(IOS_WEB_VIEW_ENABLE_SIGNIN)
// This web view configuration's authentication controller.
// Nil if CWVWebViewConfiguration is created with +incognitoConfiguration.
@property(nonatomic, readonly, nullable)
CWVAuthenticationController* authenticationController;
#endif // BUILDFLAG(IOS_WEB_VIEW_ENABLE_SIGNIN)
// Initializes configuration with the specified browser state mode. // Initializes configuration with the specified browser state mode.
- (instancetype)initWithBrowserState: - (instancetype)initWithBrowserState:
(std::unique_ptr<ios_web_view::WebViewBrowserState>)browserState; (std::unique_ptr<ios_web_view::WebViewBrowserState>)browserState;
@end @end
@implementation CWVWebViewConfiguration @implementation CWVWebViewConfiguration
#if BUILDFLAG(IOS_WEB_VIEW_ENABLE_SIGNIN)
@synthesize authenticationController = _authenticationController;
#endif // BUILDFLAG(IOS_WEB_VIEW_ENABLE_SIGNIN)
@synthesize preferences = _preferences; @synthesize preferences = _preferences;
@synthesize userContentController = _userContentController; @synthesize userContentController = _userContentController;
...@@ -102,6 +115,18 @@ CWVWebViewConfiguration* gIncognitoConfiguration = nil; ...@@ -102,6 +115,18 @@ CWVWebViewConfiguration* gIncognitoConfiguration = nil;
DCHECK(_wasShutDown); DCHECK(_wasShutDown);
} }
#if BUILDFLAG(IOS_WEB_VIEW_ENABLE_SIGNIN)
#pragma mark - Signin
- (CWVAuthenticationController*)authenticationController {
if (!_authenticationController && self.persistent) {
_authenticationController = [[CWVAuthenticationController alloc]
initWithBrowserState:self.browserState];
}
return _authenticationController;
}
#endif // BUILDFLAG(IOS_WEB_VIEW_ENABLE_SIGNIN)
#pragma mark - Public Methods #pragma mark - Public Methods
- (BOOL)isPersistent { - (BOOL)isPersistent {
......
...@@ -23,6 +23,7 @@ ...@@ -23,6 +23,7 @@
#include "components/translate/core/browser/translate_pref_names.h" #include "components/translate/core/browser/translate_pref_names.h"
#include "components/translate/core/browser/translate_prefs.h" #include "components/translate/core/browser/translate_prefs.h"
#include "ios/web/public/web_thread.h" #include "ios/web/public/web_thread.h"
#include "ios/web_view/cwv_web_view_features.h"
#include "ios/web_view/internal/autofill/web_view_personal_data_manager_factory.h" #include "ios/web_view/internal/autofill/web_view_personal_data_manager_factory.h"
#include "ios/web_view/internal/content_settings/web_view_cookie_settings_factory.h" #include "ios/web_view/internal/content_settings/web_view_cookie_settings_factory.h"
#include "ios/web_view/internal/content_settings/web_view_host_content_settings_map_factory.h" #include "ios/web_view/internal/content_settings/web_view_host_content_settings_map_factory.h"
...@@ -96,7 +97,9 @@ WebViewBrowserState::WebViewBrowserState( ...@@ -96,7 +97,9 @@ WebViewBrowserState::WebViewBrowserState(
base::ThreadRestrictions::SetIOAllowed(wasIOAllowed); base::ThreadRestrictions::SetIOAllowed(wasIOAllowed);
#if BUILDFLAG(IOS_WEB_VIEW_ENABLE_SIGNIN)
ActiveStateManager::FromBrowserState(this)->SetActive(true); ActiveStateManager::FromBrowserState(this)->SetActive(true);
#endif // BUILDFLAG(IOS_WEB_VIEW_ENABLE_SIGNIN)
BrowserStateDependencyManager::GetInstance()->CreateBrowserStateServices( BrowserStateDependencyManager::GetInstance()->CreateBrowserStateServices(
this); this);
...@@ -106,7 +109,9 @@ WebViewBrowserState::~WebViewBrowserState() { ...@@ -106,7 +109,9 @@ WebViewBrowserState::~WebViewBrowserState() {
BrowserStateDependencyManager::GetInstance()->DestroyBrowserStateServices( BrowserStateDependencyManager::GetInstance()->DestroyBrowserStateServices(
this); this);
#if BUILDFLAG(IOS_WEB_VIEW_ENABLE_SIGNIN)
ActiveStateManager::FromBrowserState(this)->SetActive(false); ActiveStateManager::FromBrowserState(this)->SetActive(false);
#endif // BUILDFLAG(IOS_WEB_VIEW_ENABLE_SIGNIN)
} }
PrefService* WebViewBrowserState::GetPrefs() { PrefService* WebViewBrowserState::GetPrefs() {
...@@ -151,25 +156,34 @@ void WebViewBrowserState::RegisterPrefs( ...@@ -151,25 +156,34 @@ void WebViewBrowserState::RegisterPrefs(
l10n_util::GetLocaleOverride()); l10n_util::GetLocaleOverride());
pref_registry->RegisterBooleanPref(prefs::kOfferTranslateEnabled, true); pref_registry->RegisterBooleanPref(prefs::kOfferTranslateEnabled, true);
translate::TranslatePrefs::RegisterProfilePrefs(pref_registry); translate::TranslatePrefs::RegisterProfilePrefs(pref_registry);
#if BUILDFLAG(IOS_WEB_VIEW_ENABLE_AUTOFILL)
autofill::AutofillManager::RegisterProfilePrefs(pref_registry); autofill::AutofillManager::RegisterProfilePrefs(pref_registry);
#endif // BUILDFLAG(IOS_WEB_VIEW_ENABLE_AUTOFILL)
// Instantiate all factories to setup dependency graph for pref registration. // Instantiate all factories to setup dependency graph for pref registration.
WebViewLanguageModelFactory::GetInstance();
WebViewTranslateRankerFactory::GetInstance();
WebViewUrlLanguageHistogramFactory::GetInstance();
WebViewTranslateAcceptLanguagesFactory::GetInstance();
#if BUILDFLAG(IOS_WEB_VIEW_ENABLE_AUTOFILL)
WebViewPersonalDataManagerFactory::GetInstance();
WebViewWebDataServiceWrapperFactory::GetInstance();
#endif // BUILDFLAG(IOS_WEB_VIEW_ENABLE_AUTOFILL)
#if BUILDFLAG(IOS_WEB_VIEW_ENABLE_SIGNIN)
WebViewCookieSettingsFactory::GetInstance(); WebViewCookieSettingsFactory::GetInstance();
WebViewHostContentSettingsMapFactory::GetInstance(); WebViewHostContentSettingsMapFactory::GetInstance();
WebViewAccountFetcherServiceFactory::GetInstance(); WebViewAccountFetcherServiceFactory::GetInstance();
WebViewAccountTrackerServiceFactory::GetInstance(); WebViewAccountTrackerServiceFactory::GetInstance();
WebViewGaiaCookieManagerServiceFactory::GetInstance(); WebViewGaiaCookieManagerServiceFactory::GetInstance();
WebViewLanguageModelFactory::GetInstance();
WebViewOAuth2TokenServiceFactory::GetInstance(); WebViewOAuth2TokenServiceFactory::GetInstance();
WebViewSigninClientFactory::GetInstance(); WebViewSigninClientFactory::GetInstance();
WebViewSigninErrorControllerFactory::GetInstance(); WebViewSigninErrorControllerFactory::GetInstance();
WebViewSigninManagerFactory::GetInstance(); WebViewSigninManagerFactory::GetInstance();
WebViewTranslateRankerFactory::GetInstance();
WebViewUrlLanguageHistogramFactory::GetInstance();
WebViewPersonalDataManagerFactory::GetInstance();
WebViewIdentityManagerFactory::GetInstance(); WebViewIdentityManagerFactory::GetInstance();
WebViewTranslateAcceptLanguagesFactory::GetInstance(); #endif // BUILDFLAG(IOS_WEB_VIEW_ENABLE_SIGNIN)
WebViewWebDataServiceWrapperFactory::GetInstance();
BrowserStateDependencyManager::GetInstance() BrowserStateDependencyManager::GetInstance()
->RegisterBrowserStatePrefsForServices(this, pref_registry); ->RegisterBrowserStatePrefsForServices(this, pref_registry);
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "base/base_paths.h" #include "base/base_paths.h"
#include "base/path_service.h" #include "base/path_service.h"
#include "components/content_settings/core/common/content_settings_pattern.h" #include "components/content_settings/core/common/content_settings_pattern.h"
#include "ios/web_view/cwv_web_view_features.h"
#include "ios/web_view/internal/app/application_context.h" #include "ios/web_view/internal/app/application_context.h"
#import "ios/web_view/internal/cwv_web_view_configuration_internal.h" #import "ios/web_view/internal/cwv_web_view_configuration_internal.h"
#include "ios/web_view/internal/translate/web_view_translate_service.h" #include "ios/web_view/internal/translate/web_view_translate_service.h"
...@@ -46,8 +47,10 @@ void WebViewWebMainParts::PreCreateThreads() { ...@@ -46,8 +47,10 @@ void WebViewWebMainParts::PreCreateThreads() {
void WebViewWebMainParts::PreMainMessageLoopRun() { void WebViewWebMainParts::PreMainMessageLoopRun() {
WebViewTranslateService::GetInstance()->Initialize(); WebViewTranslateService::GetInstance()->Initialize();
#if BUILDFLAG(IOS_WEB_VIEW_ENABLE_SIGNIN)
ContentSettingsPattern::SetNonWildcardDomainNonPortSchemes( ContentSettingsPattern::SetNonWildcardDomainNonPortSchemes(
/*schemes=*/nullptr, 0); /*schemes=*/nullptr, 0);
#endif // BUILDFLAG(IOS_WEB_VIEW_ENABLE_SIGNIN)
} }
void WebViewWebMainParts::PostMainMessageLoopRun() { void WebViewWebMainParts::PostMainMessageLoopRun() {
......
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_WEB_VIEW_PUBLIC_CHROMESYNC_H_
#define IOS_WEB_VIEW_PUBLIC_CHROMESYNC_H_
// NOTE: Relative imports are used throughout the implementation of
// ChromeWebView. Framework style imports can't be used because multiple
// frameworks are built from ios/web_view with different output names.
#import "cwv_authentication_controller.h"
#import "cwv_authentication_controller_delegate.h"
#import "cwv_identity.h"
#import "cwv_web_view_configuration+sync.h"
#endif // IOS_WEB_VIEW_PUBLIC_CHROMESYNC_H_
...@@ -19,11 +19,6 @@ CWV_EXPORT ...@@ -19,11 +19,6 @@ CWV_EXPORT
@property(nonatomic, assign, getter=isTranslationEnabled) @property(nonatomic, assign, getter=isTranslationEnabled)
BOOL translationEnabled; BOOL translationEnabled;
// Whether or not autofill as a feature is turned on. Defaults to |YES|.
// If enabled, contents of submitted forms may be saved and offered as a
// suggestion in either the same or similar forms.
@property(nonatomic, assign, getter=isAutofillEnabled) BOOL autofillEnabled;
- (instancetype)init NS_UNAVAILABLE; - (instancetype)init NS_UNAVAILABLE;
// Resets all translation settings back to default. In particular, this will // Resets all translation settings back to default. In particular, this will
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_WEB_VIEW_PUBLIC_CWV_PREFERENCES_AUTOFILL_H_
#define IOS_WEB_VIEW_PUBLIC_CWV_PREFERENCES_AUTOFILL_H_
#import <Foundation/Foundation.h>
#import "cwv_preferences.h"
@interface CWVPreferences (Autofill)
// Whether or not autofill as a feature is turned on. Defaults to |YES|.
// If enabled, contents of submitted forms may be saved and offered as a
// suggestion in either the same or similar forms.
@property(nonatomic, assign, getter=isAutofillEnabled) BOOL autofillEnabled;
@end
#endif // IOS_WEB_VIEW_PUBLIC_CWV_PREFERENCES_AUTOFILL_H_
...@@ -37,9 +37,6 @@ CWV_EXPORT ...@@ -37,9 +37,6 @@ CWV_EXPORT
// This web view's translation controller. // This web view's translation controller.
@property(nonatomic, readonly) CWVTranslationController* translationController; @property(nonatomic, readonly) CWVTranslationController* translationController;
// This web view's autofill controller.
@property(nonatomic, readonly) CWVAutofillController* autofillController;
// This web view's UI delegate // This web view's UI delegate
@property(nonatomic, weak, nullable) id<CWVUIDelegate> UIDelegate; @property(nonatomic, weak, nullable) id<CWVUIDelegate> UIDelegate;
......
// Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef IOS_WEB_VIEW_PUBLIC_CWV_WEB_VIEW_AUTOFILL_H_
#define IOS_WEB_VIEW_PUBLIC_CWV_WEB_VIEW_AUTOFILL_H_
#import "cwv_web_view.h"
@interface CWVWebView (Autofill)
// The web view's autofill controller.
@property(nonatomic, readonly) CWVAutofillController* autofillController;
@end
#endif // IOS_WEB_VIEW_PUBLIC_CWV_WEB_VIEW_AUTOFILL_H_
// Copyright 2017 The Chromium Authors. All rights reserved. // Copyright 2018 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef IOS_WEB_VIEW_PUBLIC_CWV_WEB_VIEW_CONFIGURATION_SYNC_H_ #ifndef IOS_WEB_VIEW_PUBLIC_CWV_WEB_VIEW_CONFIGURATION_SIGNIN_H_
#define IOS_WEB_VIEW_PUBLIC_CWV_WEB_VIEW_CONFIGURATION_SYNC_H_ #define IOS_WEB_VIEW_PUBLIC_CWV_WEB_VIEW_CONFIGURATION_SIGNIN_H_
#import "ios/web_view/public/cwv_web_view_configuration.h" #import <Foundation/Foundation.h>
#import "cwv_web_view_configuration.h"
NS_ASSUME_NONNULL_BEGIN NS_ASSUME_NONNULL_BEGIN
@class CWVAuthenticationController; @class CWVAuthenticationController;
@interface CWVWebViewConfiguration (Sync) @interface CWVWebViewConfiguration (Signin)
// This web view configuration's authentication controller. // This web view configuration's authentication controller.
// Nil if CWVWebViewConfiguration is created with +incognitoConfiguration. // nil if CWVWebViewConfiguration is created with +incognitoConfiguration.
@property(nonatomic, readonly, nullable) @property(nonatomic, readonly, nullable)
CWVAuthenticationController* authenticationController; CWVAuthenticationController* authenticationController;
...@@ -22,4 +24,4 @@ NS_ASSUME_NONNULL_BEGIN ...@@ -22,4 +24,4 @@ NS_ASSUME_NONNULL_BEGIN
NS_ASSUME_NONNULL_END NS_ASSUME_NONNULL_END
#endif // IOS_WEB_VIEW_PUBLIC_CWV_WEB_VIEW_CONFIGURATION_SYNC_H_ #endif // IOS_WEB_VIEW_PUBLIC_CWV_WEB_VIEW_CONFIGURATION_SIGNIN_H_
...@@ -189,8 +189,10 @@ def main(): ...@@ -189,8 +189,10 @@ def main():
help='Additional gn args to pass through to ninja.') help='Additional gn args to pass through to ninja.')
parser.add_argument('--include_cronet', action='store_true', parser.add_argument('--include_cronet', action='store_true',
help='Combines Cronet and ChromeWebView as 1 framework.') help='Combines Cronet and ChromeWebView as 1 framework.')
parser.add_argument('--enable_sync', action='store_true', parser.add_argument('--enable_signin', action='store_true',
help='Enables public API for ChromeSync.') help='Enables public API for signin.')
parser.add_argument('--enable_autofill', action='store_true',
help='Enables public API for autofill.')
build_configs = ['Debug', 'Release'] build_configs = ['Debug', 'Release']
target_devices = ['iphonesimulator', 'iphoneos'] target_devices = ['iphonesimulator', 'iphoneos']
parser.add_argument('--build_configs', nargs='+', default=build_configs, parser.add_argument('--build_configs', nargs='+', default=build_configs,
...@@ -222,10 +224,14 @@ def main(): ...@@ -222,10 +224,14 @@ def main():
output_name = 'CronetChromeWebView' output_name = 'CronetChromeWebView'
else: else:
extra_gn_options += 'ios_web_view_include_cronet=false ' extra_gn_options += 'ios_web_view_include_cronet=false '
if options.enable_sync: if options.enable_signin:
extra_gn_options += 'ios_web_view_enable_sync=true ' extra_gn_options += 'ios_web_view_enable_signin=true '
else: else:
extra_gn_options += 'ios_web_view_enable_sync=false ' extra_gn_options += 'ios_web_view_enable_signin=false '
if options.enable_autofill:
extra_gn_options += 'ios_web_view_enable_autofill=true '
else:
extra_gn_options += 'ios_web_view_enable_autofill=false '
extra_gn_options += 'ios_web_view_output_name="%s" ' % output_name extra_gn_options += 'ios_web_view_output_name="%s" ' % output_name
return package_all_frameworks(out_dir, output_name, extra_gn_options, return package_all_frameworks(out_dir, output_name, extra_gn_options,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment