Index: ios/web/web_state/ui/wk_web_view_configuration_provider.mm |
diff --git a/ios/web/web_state/ui/wk_web_view_configuration_provider.mm b/ios/web/web_state/ui/wk_web_view_configuration_provider.mm |
index 3370fad17f786507df5c1874479dcdeb2c71ad2b..94485350ccee8423799cc8c6c0647dae9391371e 100644 |
--- a/ios/web/web_state/ui/wk_web_view_configuration_provider.mm |
+++ b/ios/web/web_state/ui/wk_web_view_configuration_provider.mm |
@@ -21,9 +21,9 @@ const char kWKWebViewConfigProviderKeyName[] = "wk_web_view_config_provider"; |
// Returns an autoreleased instance of WKUserScript to be added to |
// configuration's userContentController. |
-WKUserScript* InternalGetEarlyPageScript() { |
+WKUserScript* InternalGetEarlyPageScript(BrowserState* browser_state) { |
return [[[WKUserScript alloc] |
- initWithSource:GetEarlyPageScript() |
+ initWithSource:GetEarlyPageScript(browser_state) |
injectionTime:WKUserScriptInjectionTimeAtDocumentStart |
forMainFrameOnly:YES] autorelease]; |
} |
@@ -39,15 +39,16 @@ WKWebViewConfigurationProvider::FromBrowserState(BrowserState* browser_state) { |
bool is_off_the_record = browser_state->IsOffTheRecord(); |
browser_state->SetUserData( |
kWKWebViewConfigProviderKeyName, |
- new WKWebViewConfigurationProvider(is_off_the_record)); |
+ new WKWebViewConfigurationProvider(is_off_the_record, browser_state)); |
} |
return *(static_cast<WKWebViewConfigurationProvider*>( |
browser_state->GetUserData(kWKWebViewConfigProviderKeyName))); |
} |
WKWebViewConfigurationProvider::WKWebViewConfigurationProvider( |
- bool is_off_the_record) |
- : is_off_the_record_(is_off_the_record) {} |
+ bool is_off_the_record, |
+ BrowserState* browser_state) |
+ : is_off_the_record_(is_off_the_record), browser_state_(browser_state) {} |
WKWebViewConfigurationProvider::~WKWebViewConfigurationProvider() { |
} |
@@ -67,7 +68,7 @@ WKWebViewConfigurationProvider::GetWebViewConfiguration() { |
// setJavaScriptCanOpenWindowsAutomatically is required to support popups. |
[[configuration_ preferences] setJavaScriptCanOpenWindowsAutomatically:YES]; |
[[configuration_ userContentController] |
- addUserScript:InternalGetEarlyPageScript()]; |
+ addUserScript:InternalGetEarlyPageScript(browser_state_)]; |
} |
// Prevent callers from changing the internals of configuration. |
return [[configuration_ copy] autorelease]; |