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