Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(261)

Side by Side Diff: ios/web_view/internal/web_view_web_client.mm

Issue 2791403005: Remove CWV class and move setting User Agent to CWVWebViewConfiguration. (Closed)
Patch Set: Move Browser State and Web Client ownership to CWVWebViewConfiguration. Each CWVWebViewConfiguratio… Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 {
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 { 27 std::string WebViewWebClient::GetProduct() const {
37 return user_agent_product_; 28 return user_agent_product_;
38 } 29 }
39 30
40 std::string WebViewWebClient::GetUserAgent(web::UserAgentType type) const { 31 std::string WebViewWebClient::GetUserAgent(web::UserAgentType type) const {
41 return web::BuildUserAgentFromProduct(GetProduct()); 32 return web::BuildUserAgentFromProduct(GetProduct());
42 } 33 }
43 34
44 NSString* WebViewWebClient::GetEarlyPageScript( 35 NSString* WebViewWebClient::GetEarlyPageScript(
45 web::BrowserState* browser_state) const { 36 web::BrowserState* browser_state) const {
46 return WebViewEarlyPageScriptProvider::FromBrowserState(browser_state) 37 return WebViewEarlyPageScriptProvider::FromBrowserState(browser_state)
47 .GetScript(); 38 .GetScript();
48 } 39 }
49 40
41 void WebViewWebClient::SetProduct(const std::string& user_agent_product) {
42 user_agent_product_ = user_agent_product;
43 }
44
50 } // namespace ios_web_view 45 } // namespace ios_web_view
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698