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

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

Issue 2791403005: Remove CWV class and move setting User Agent to CWVWebViewConfiguration. (Closed)
Patch Set: Remove cwv.h import from Framework header. 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/public/cwv_web_view.h" 5 #import "ios/web_view/public/cwv_web_view.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #import "base/ios/weak_nsobject.h" 10 #import "base/ios/weak_nsobject.h"
11 #include "base/memory/ptr_util.h" 11 #include "base/memory/ptr_util.h"
12 #include "base/strings/sys_string_conversions.h" 12 #include "base/strings/sys_string_conversions.h"
13 #import "ios/web/public/navigation_manager.h" 13 #import "ios/web/public/navigation_manager.h"
14 #include "ios/web/public/referrer.h" 14 #include "ios/web/public/referrer.h"
15 #include "ios/web/public/reload_type.h" 15 #include "ios/web/public/reload_type.h"
16 #import "ios/web/public/web_state/context_menu_params.h" 16 #import "ios/web/public/web_state/context_menu_params.h"
17 #import "ios/web/public/web_state/js/crw_js_injection_receiver.h" 17 #import "ios/web/public/web_state/js/crw_js_injection_receiver.h"
18 #import "ios/web/public/web_state/ui/crw_web_delegate.h" 18 #import "ios/web/public/web_state/ui/crw_web_delegate.h"
19 #import "ios/web/public/web_state/web_state.h" 19 #import "ios/web/public/web_state/web_state.h"
20 #import "ios/web/public/web_state/web_state_delegate_bridge.h" 20 #import "ios/web/public/web_state/web_state_delegate_bridge.h"
21 #import "ios/web/public/web_state/web_state_observer_bridge.h" 21 #import "ios/web/public/web_state/web_state_observer_bridge.h"
22 #import "ios/web_view/internal/cwv_html_element_internal.h" 22 #import "ios/web_view/internal/cwv_html_element_internal.h"
23 #import "ios/web_view/internal/cwv_navigation_action_internal.h" 23 #import "ios/web_view/internal/cwv_navigation_action_internal.h"
24 #import "ios/web_view/internal/cwv_web_view_configuration_internal.h" 24 #import "ios/web_view/internal/cwv_web_view_configuration_internal.h"
25 #import "ios/web_view/internal/translate/web_view_translate_client.h" 25 #import "ios/web_view/internal/translate/web_view_translate_client.h"
26 #include "ios/web_view/internal/web_view_browser_state.h" 26 #include "ios/web_view/internal/web_view_browser_state.h"
27 #import "ios/web_view/internal/web_view_java_script_dialog_presenter.h" 27 #import "ios/web_view/internal/web_view_java_script_dialog_presenter.h"
28 #import "ios/web_view/internal/web_view_web_client.h"
28 #import "ios/web_view/internal/web_view_web_state_policy_decider.h" 29 #import "ios/web_view/internal/web_view_web_state_policy_decider.h"
29 #import "ios/web_view/public/cwv_navigation_delegate.h" 30 #import "ios/web_view/public/cwv_navigation_delegate.h"
30 #import "ios/web_view/public/cwv_ui_delegate.h" 31 #import "ios/web_view/public/cwv_ui_delegate.h"
31 #import "ios/web_view/public/cwv_web_view_configuration.h" 32 #import "ios/web_view/public/cwv_web_view_configuration.h"
32 #import "net/base/mac/url_conversions.h" 33 #import "net/base/mac/url_conversions.h"
33 #include "ui/base/page_transition_types.h" 34 #include "ui/base/page_transition_types.h"
34 #include "url/gurl.h" 35 #include "url/gurl.h"
35 36
36 @interface CWVWebView ()<CRWWebStateDelegate, CRWWebStateObserver> { 37 @interface CWVWebView ()<CRWWebStateDelegate, CRWWebStateObserver> {
37 CWVWebViewConfiguration* _configuration; 38 CWVWebViewConfiguration* _configuration;
(...skipping 15 matching lines...) Expand all
53 @end 54 @end
54 55
55 @implementation CWVWebView 56 @implementation CWVWebView
56 57
57 @synthesize configuration = _configuration; 58 @synthesize configuration = _configuration;
58 @synthesize navigationDelegate = _navigationDelegate; 59 @synthesize navigationDelegate = _navigationDelegate;
59 @synthesize translationDelegate = _translationDelegate; 60 @synthesize translationDelegate = _translationDelegate;
60 @synthesize estimatedProgress = _estimatedProgress; 61 @synthesize estimatedProgress = _estimatedProgress;
61 @synthesize UIDelegate = _UIDelegate; 62 @synthesize UIDelegate = _UIDelegate;
62 63
64 + (void)setUserAgentProduct:(NSString*)product {
65 ios_web_view::WebViewWebClient* client = [CWVWebViewConfiguration webClient];
66 client->SetProduct(base::SysNSStringToUTF8(product));
67 }
68
63 - (instancetype)initWithFrame:(CGRect)frame 69 - (instancetype)initWithFrame:(CGRect)frame
64 configuration:(CWVWebViewConfiguration*)configuration { 70 configuration:(CWVWebViewConfiguration*)configuration {
65 self = [super initWithFrame:frame]; 71 self = [super initWithFrame:frame];
66 if (self) { 72 if (self) {
67 _configuration = [configuration copy]; 73 _configuration = [configuration copy];
68 74
69 web::WebState::CreateParams webStateCreateParams( 75 web::WebState::CreateParams webStateCreateParams(
70 configuration.browserState); 76 configuration.browserState);
71 _webState = web::WebState::Create(webStateCreateParams); 77 _webState = web::WebState::Create(webStateCreateParams);
72 _webState->SetWebUsageEnabled(true); 78 _webState->SetWebUsageEnabled(true);
(...skipping 190 matching lines...) Expand 10 before | Expand all | Expand 10 after
263 [_UIDelegate webViewDidClose:self]; 269 [_UIDelegate webViewDidClose:self];
264 } 270 }
265 } 271 }
266 272
267 - (web::JavaScriptDialogPresenter*)javaScriptDialogPresenterForWebState: 273 - (web::JavaScriptDialogPresenter*)javaScriptDialogPresenterForWebState:
268 (web::WebState*)webState { 274 (web::WebState*)webState {
269 return _javaScriptDialogPresenter.get(); 275 return _javaScriptDialogPresenter.get();
270 } 276 }
271 277
272 @end 278 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698