| 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/strings/sys_string_conversions.h" |
| 7 #include "ios/web/public/user_agent.h" | 8 #include "ios/web/public/user_agent.h" |
| 8 #include "ios/web_view/internal/web_view_browser_state.h" | 9 #include "ios/web_view/internal/web_view_browser_state.h" |
| 9 #import "ios/web_view/internal/web_view_early_page_script_provider.h" | 10 #import "ios/web_view/internal/web_view_early_page_script_provider.h" |
| 10 #import "ios/web_view/internal/web_view_web_main_parts.h" | 11 #import "ios/web_view/internal/web_view_web_main_parts.h" |
| 12 #include "ios/web_view/public/cwv_web_view.h" |
| 11 | 13 |
| 12 #if !defined(__has_feature) || !__has_feature(objc_arc) | 14 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 13 #error "This file requires ARC support." | 15 #error "This file requires ARC support." |
| 14 #endif | 16 #endif |
| 15 | 17 |
| 16 namespace ios_web_view { | 18 namespace ios_web_view { |
| 17 | 19 |
| 18 WebViewWebClient::WebViewWebClient(const std::string& user_agent_product) | 20 WebViewWebClient::WebViewWebClient() : web_main_parts_(nullptr) {} |
| 19 : user_agent_product_(user_agent_product), web_main_parts_(nullptr) {} | |
| 20 | 21 |
| 21 WebViewWebClient::~WebViewWebClient() = default; | 22 WebViewWebClient::~WebViewWebClient() = default; |
| 22 | 23 |
| 23 web::WebMainParts* WebViewWebClient::CreateWebMainParts() { | 24 web::WebMainParts* WebViewWebClient::CreateWebMainParts() { |
| 24 web_main_parts_ = new WebViewWebMainParts(); | 25 web_main_parts_ = new WebViewWebMainParts(); |
| 25 return web_main_parts_; | 26 return web_main_parts_; |
| 26 } | 27 } |
| 27 | 28 |
| 28 WebViewBrowserState* WebViewWebClient::browser_state() const { | |
| 29 return web_main_parts_->browser_state(); | |
| 30 } | |
| 31 | |
| 32 WebViewBrowserState* WebViewWebClient::off_the_record_browser_state() const { | |
| 33 return web_main_parts_->off_the_record_browser_state(); | |
| 34 } | |
| 35 | |
| 36 std::string WebViewWebClient::GetProduct() const { | 29 std::string WebViewWebClient::GetProduct() const { |
| 37 return user_agent_product_; | 30 return base::SysNSStringToUTF8([CWVWebView userAgentProduct]); |
| 38 } | 31 } |
| 39 | 32 |
| 40 std::string WebViewWebClient::GetUserAgent(web::UserAgentType type) const { | 33 std::string WebViewWebClient::GetUserAgent(web::UserAgentType type) const { |
| 41 return web::BuildUserAgentFromProduct(GetProduct()); | 34 return web::BuildUserAgentFromProduct(GetProduct()); |
| 42 } | 35 } |
| 43 | 36 |
| 44 NSString* WebViewWebClient::GetEarlyPageScript( | 37 NSString* WebViewWebClient::GetEarlyPageScript( |
| 45 web::BrowserState* browser_state) const { | 38 web::BrowserState* browser_state) const { |
| 46 return WebViewEarlyPageScriptProvider::FromBrowserState(browser_state) | 39 return WebViewEarlyPageScriptProvider::FromBrowserState(browser_state) |
| 47 .GetScript(); | 40 .GetScript(); |
| 48 } | 41 } |
| 49 | 42 |
| 50 } // namespace ios_web_view | 43 } // namespace ios_web_view |
| OLD | NEW |