| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #import "ios/web_view/internal/web_view_web_client.h" | 5 #import "ios/web_view/internal/web_view_web_client.h" |
| 6 | 6 |
| 7 #include "base/command_line.h" |
| 7 #include "base/strings/sys_string_conversions.h" | 8 #include "base/strings/sys_string_conversions.h" |
| 8 #include "ios/web/public/user_agent.h" | 9 #include "ios/web/public/user_agent.h" |
| 9 #include "ios/web_view/internal/web_view_browser_state.h" | 10 #include "ios/web_view/internal/web_view_browser_state.h" |
| 10 #import "ios/web_view/internal/web_view_early_page_script_provider.h" | 11 #import "ios/web_view/internal/web_view_early_page_script_provider.h" |
| 11 #import "ios/web_view/internal/web_view_web_main_parts.h" | 12 #import "ios/web_view/internal/web_view_web_main_parts.h" |
| 12 #include "ios/web_view/public/cwv_web_view.h" | 13 #include "ios/web_view/public/cwv_web_view.h" |
| 13 | 14 |
| 14 #if !defined(__has_feature) || !__has_feature(objc_arc) | 15 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 15 #error "This file requires ARC support." | 16 #error "This file requires ARC support." |
| 16 #endif | 17 #endif |
| 17 | 18 |
| 18 namespace ios_web_view { | 19 namespace ios_web_view { |
| 19 | 20 |
| 20 WebViewWebClient::WebViewWebClient() : web_main_parts_(nullptr) {} | 21 WebViewWebClient::WebViewWebClient() : web_main_parts_(nullptr) {} |
| 21 | 22 |
| 22 WebViewWebClient::~WebViewWebClient() = default; | 23 WebViewWebClient::~WebViewWebClient() = default; |
| 23 | 24 |
| 24 web::WebMainParts* WebViewWebClient::CreateWebMainParts() { | 25 web::WebMainParts* WebViewWebClient::CreateWebMainParts() { |
| 25 web_main_parts_ = new WebViewWebMainParts(); | 26 web_main_parts_ = |
| 27 new WebViewWebMainParts(*base::CommandLine::ForCurrentProcess()); |
| 26 return web_main_parts_; | 28 return web_main_parts_; |
| 27 } | 29 } |
| 28 | 30 |
| 29 std::string WebViewWebClient::GetProduct() const { | 31 std::string WebViewWebClient::GetProduct() const { |
| 30 return base::SysNSStringToUTF8([CWVWebView userAgentProduct]); | 32 return base::SysNSStringToUTF8([CWVWebView userAgentProduct]); |
| 31 } | 33 } |
| 32 | 34 |
| 33 std::string WebViewWebClient::GetUserAgent(web::UserAgentType type) const { | 35 std::string WebViewWebClient::GetUserAgent(web::UserAgentType type) const { |
| 34 return web::BuildUserAgentFromProduct(GetProduct()); | 36 return web::BuildUserAgentFromProduct(GetProduct()); |
| 35 } | 37 } |
| 36 | 38 |
| 37 NSString* WebViewWebClient::GetEarlyPageScript( | 39 NSString* WebViewWebClient::GetEarlyPageScript( |
| 38 web::BrowserState* browser_state) const { | 40 web::BrowserState* browser_state) const { |
| 39 return WebViewEarlyPageScriptProvider::FromBrowserState(browser_state) | 41 return WebViewEarlyPageScriptProvider::FromBrowserState(browser_state) |
| 40 .GetScript(); | 42 .GetScript(); |
| 41 } | 43 } |
| 42 | 44 |
| 43 } // namespace ios_web_view | 45 } // namespace ios_web_view |
| OLD | NEW |