Chromium Code Reviews| 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/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" |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 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_state_policy_decider.h" | 28 #import "ios/web_view/internal/web_view_web_state_policy_decider.h" |
| 29 #import "ios/web_view/public/cwv_navigation_delegate.h" | 29 #import "ios/web_view/public/cwv_navigation_delegate.h" |
| 30 #import "ios/web_view/public/cwv_ui_delegate.h" | 30 #import "ios/web_view/public/cwv_ui_delegate.h" |
| 31 #import "ios/web_view/public/cwv_web_view_configuration.h" | 31 #import "ios/web_view/public/cwv_web_view_configuration.h" |
| 32 #import "net/base/mac/url_conversions.h" | 32 #import "net/base/mac/url_conversions.h" |
| 33 #include "ui/base/page_transition_types.h" | 33 #include "ui/base/page_transition_types.h" |
| 34 #include "url/gurl.h" | 34 #include "url/gurl.h" |
| 35 | 35 |
| 36 @interface CWVWebView ()<CRWWebStateDelegate, CRWWebStateObserver> { | 36 @interface CWVWebView ()<CRWWebStateDelegate, CRWWebStateObserver> { |
| 37 CWVWebViewConfiguration* _configuration; | |
| 38 std::unique_ptr<web::WebState> _webState; | 37 std::unique_ptr<web::WebState> _webState; |
| 39 std::unique_ptr<web::WebStateDelegateBridge> _webStateDelegate; | 38 std::unique_ptr<web::WebStateDelegateBridge> _webStateDelegate; |
| 40 std::unique_ptr<web::WebStateObserverBridge> _webStateObserver; | 39 std::unique_ptr<web::WebStateObserverBridge> _webStateObserver; |
| 41 std::unique_ptr<ios_web_view::WebViewWebStatePolicyDecider> | 40 std::unique_ptr<ios_web_view::WebViewWebStatePolicyDecider> |
| 42 _webStatePolicyDecider; | 41 _webStatePolicyDecider; |
| 43 double _estimatedProgress; | 42 double _estimatedProgress; |
| 44 // Handles presentation of JavaScript dialogs. | 43 // Handles presentation of JavaScript dialogs. |
| 45 std::unique_ptr<ios_web_view::WebViewJavaScriptDialogPresenter> | 44 std::unique_ptr<ios_web_view::WebViewJavaScriptDialogPresenter> |
| 46 _javaScriptDialogPresenter; | 45 _javaScriptDialogPresenter; |
| 47 } | 46 } |
| 48 | 47 |
| 48 // Redefine the property as readwrite. | |
| 49 @property(nonatomic, copy) CWVWebViewConfiguration* configuration; | |
| 49 // Redefine the property as readwrite to define -setEstimatedProgress:, which | 50 // Redefine the property as readwrite to define -setEstimatedProgress:, which |
| 50 // can be used to send KVO notification. | 51 // can be used to send KVO notification. |
| 51 @property(nonatomic, readwrite) double estimatedProgress; | 52 @property(nonatomic, readwrite) double estimatedProgress; |
| 52 | 53 |
| 53 @end | 54 @end |
| 54 | 55 |
| 56 static NSString* gUserAgentProduct = nil; | |
| 57 | |
| 55 @implementation CWVWebView | 58 @implementation CWVWebView |
| 56 | 59 |
| 57 @synthesize configuration = _configuration; | 60 @synthesize configuration = _configuration; |
| 58 @synthesize navigationDelegate = _navigationDelegate; | 61 @synthesize navigationDelegate = _navigationDelegate; |
| 59 @synthesize translationDelegate = _translationDelegate; | 62 @synthesize translationDelegate = _translationDelegate; |
| 60 @synthesize estimatedProgress = _estimatedProgress; | 63 @synthesize estimatedProgress = _estimatedProgress; |
| 61 @synthesize UIDelegate = _UIDelegate; | 64 @synthesize UIDelegate = _UIDelegate; |
| 62 | 65 |
| 66 + (NSString*)userAgentProduct { | |
| 67 return gUserAgentProduct; | |
| 68 } | |
| 69 | |
| 70 + (void)setUserAgentProduct:(NSString*)product { | |
| 71 gUserAgentProduct = product; | |
|
Eugene But (OOO till 7-30)
2017/04/12 00:46:17
gUserAgentProduct = [product copy];
michaeldo
2017/04/12 17:16:48
Done.
| |
| 72 } | |
| 73 | |
| 63 - (instancetype)initWithFrame:(CGRect)frame | 74 - (instancetype)initWithFrame:(CGRect)frame |
| 64 configuration:(CWVWebViewConfiguration*)configuration { | 75 configuration:(CWVWebViewConfiguration*)configuration { |
| 65 self = [super initWithFrame:frame]; | 76 self = [super initWithFrame:frame]; |
| 66 if (self) { | 77 if (self) { |
| 67 _configuration = [configuration copy]; | 78 _configuration = [configuration copy]; |
| 68 | 79 |
| 69 web::WebState::CreateParams webStateCreateParams( | 80 web::WebState::CreateParams webStateCreateParams( |
| 70 configuration.browserState); | 81 _configuration.browserState); |
| 71 _webState = web::WebState::Create(webStateCreateParams); | 82 _webState = web::WebState::Create(webStateCreateParams); |
| 72 _webState->SetWebUsageEnabled(true); | 83 _webState->SetWebUsageEnabled(true); |
| 73 | 84 |
| 74 _webStateObserver = | 85 _webStateObserver = |
| 75 base::MakeUnique<web::WebStateObserverBridge>(_webState.get(), self); | 86 base::MakeUnique<web::WebStateObserverBridge>(_webState.get(), self); |
| 76 _webStateDelegate = base::MakeUnique<web::WebStateDelegateBridge>(self); | 87 _webStateDelegate = base::MakeUnique<web::WebStateDelegateBridge>(self); |
| 77 _webState->SetDelegate(_webStateDelegate.get()); | 88 _webState->SetDelegate(_webStateDelegate.get()); |
| 78 | 89 |
| 79 _webStatePolicyDecider = | 90 _webStatePolicyDecider = |
| 80 base::MakeUnique<ios_web_view::WebViewWebStatePolicyDecider>( | 91 base::MakeUnique<ios_web_view::WebViewWebStatePolicyDecider>( |
| (...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 263 [_UIDelegate webViewDidClose:self]; | 274 [_UIDelegate webViewDidClose:self]; |
| 264 } | 275 } |
| 265 } | 276 } |
| 266 | 277 |
| 267 - (web::JavaScriptDialogPresenter*)javaScriptDialogPresenterForWebState: | 278 - (web::JavaScriptDialogPresenter*)javaScriptDialogPresenterForWebState: |
| 268 (web::WebState*)webState { | 279 (web::WebState*)webState { |
| 269 return _javaScriptDialogPresenter.get(); | 280 return _javaScriptDialogPresenter.get(); |
| 270 } | 281 } |
| 271 | 282 |
| 272 @end | 283 @end |
| OLD | NEW |