| 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 "ios/web/public/user_agent.h" | 7 #include "ios/web/public/user_agent.h" |
| 8 #include "ios/web_view/internal/web_view_browser_state.h" | 8 #include "ios/web_view/internal/web_view_browser_state.h" |
| 9 #import "ios/web_view/internal/web_view_early_page_script_provider.h" | 9 #import "ios/web_view/internal/web_view_early_page_script_provider.h" |
| 10 #import "ios/web_view/internal/web_view_web_main_parts.h" | 10 #import "ios/web_view/internal/web_view_web_main_parts.h" |
| 11 | 11 |
| 12 #if !defined(__has_feature) || !__has_feature(objc_arc) | 12 #if !defined(__has_feature) || !__has_feature(objc_arc) |
| 13 #error "This file requires ARC support." | 13 #error "This file requires ARC support." |
| 14 #endif | 14 #endif |
| 15 | 15 |
| 16 namespace ios_web_view { | 16 namespace ios_web_view { |
| 17 | 17 |
| 18 WebViewWebClient::WebViewWebClient(const std::string& user_agent_product) | 18 WebViewWebClient::WebViewWebClient() : web_main_parts_(nullptr) {} |
| 19 : user_agent_product_(user_agent_product), web_main_parts_(nullptr) {} | |
| 20 | 19 |
| 21 WebViewWebClient::~WebViewWebClient() = default; | 20 WebViewWebClient::~WebViewWebClient() = default; |
| 22 | 21 |
| 23 web::WebMainParts* WebViewWebClient::CreateWebMainParts() { | 22 web::WebMainParts* WebViewWebClient::CreateWebMainParts() { |
| 24 web_main_parts_ = new WebViewWebMainParts(); | 23 web_main_parts_ = new WebViewWebMainParts(); |
| 25 return web_main_parts_; | 24 return web_main_parts_; |
| 26 } | 25 } |
| 27 | 26 |
| 28 WebViewBrowserState* WebViewWebClient::browser_state() const { | 27 WebViewBrowserState* WebViewWebClient::browser_state() const { |
| 29 return web_main_parts_->browser_state(); | 28 return web_main_parts_->browser_state(); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 40 std::string WebViewWebClient::GetUserAgent(web::UserAgentType type) const { | 39 std::string WebViewWebClient::GetUserAgent(web::UserAgentType type) const { |
| 41 return web::BuildUserAgentFromProduct(GetProduct()); | 40 return web::BuildUserAgentFromProduct(GetProduct()); |
| 42 } | 41 } |
| 43 | 42 |
| 44 NSString* WebViewWebClient::GetEarlyPageScript( | 43 NSString* WebViewWebClient::GetEarlyPageScript( |
| 45 web::BrowserState* browser_state) const { | 44 web::BrowserState* browser_state) const { |
| 46 return WebViewEarlyPageScriptProvider::FromBrowserState(browser_state) | 45 return WebViewEarlyPageScriptProvider::FromBrowserState(browser_state) |
| 47 .GetScript(); | 46 .GetScript(); |
| 48 } | 47 } |
| 49 | 48 |
| 49 void WebViewWebClient::SetProduct(const std::string& user_agent_product) { |
| 50 user_agent_product_ = user_agent_product; |
| 51 } |
| 52 |
| 50 } // namespace ios_web_view | 53 } // namespace ios_web_view |
| OLD | NEW |