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/internal/criwv_web_view_internal.h" | 5 #import "ios/web_view/internal/criwv_web_view_internal.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 #import "ios/web/public/web_state/ui/crw_web_delegate.h" | 15 #import "ios/web/public/web_state/ui/crw_web_delegate.h" |
| 16 #import "ios/web/public/web_state/web_state.h" | 16 #import "ios/web/public/web_state/web_state.h" |
| 17 #import "ios/web/public/web_state/web_state_delegate_bridge.h" | 17 #import "ios/web/public/web_state/web_state_delegate_bridge.h" |
| 18 #import "ios/web/public/web_state/web_state_observer_bridge.h" | 18 #import "ios/web/public/web_state/web_state_observer_bridge.h" |
| 19 #include "ios/web_view/internal/criwv_browser_state.h" | 19 #include "ios/web_view/internal/criwv_browser_state.h" |
| 20 #import "ios/web_view/internal/criwv_website_data_store_internal.h" | |
|
Eugene But (OOO till 7-30)
2017/02/06 23:31:56
nit: Import "ios/web_view/internal/criwv_website_d
michaeldo
2017/02/06 23:53:49
Done.
| |
| 20 #import "ios/web_view/internal/translate/criwv_translate_client.h" | 21 #import "ios/web_view/internal/translate/criwv_translate_client.h" |
| 22 #import "ios/web_view/public/criwv_web_view_configuration.h" | |
| 21 #import "ios/web_view/public/criwv_web_view_delegate.h" | 23 #import "ios/web_view/public/criwv_web_view_delegate.h" |
| 22 #import "net/base/mac/url_conversions.h" | 24 #import "net/base/mac/url_conversions.h" |
| 23 #include "ui/base/page_transition_types.h" | 25 #include "ui/base/page_transition_types.h" |
| 24 #include "url/gurl.h" | 26 #include "url/gurl.h" |
| 25 | 27 |
| 26 @interface CRIWVWebView ()<CRWWebStateDelegate, CRWWebStateObserver> { | 28 @interface CRIWVWebView ()<CRWWebStateDelegate, CRWWebStateObserver> { |
| 27 id<CRIWVWebViewDelegate> _delegate; | 29 id<CRIWVWebViewDelegate> _delegate; |
| 28 ios_web_view::CRIWVBrowserState* _browserState; | 30 CRIWVWebViewConfiguration* _configuration; |
| 29 std::unique_ptr<web::WebState> _webState; | 31 std::unique_ptr<web::WebState> _webState; |
| 30 std::unique_ptr<web::WebStateDelegateBridge> _webStateDelegate; | 32 std::unique_ptr<web::WebStateDelegateBridge> _webStateDelegate; |
| 31 std::unique_ptr<web::WebStateObserverBridge> _webStateObserver; | 33 std::unique_ptr<web::WebStateObserverBridge> _webStateObserver; |
| 32 CGFloat _loadProgress; | 34 CGFloat _loadProgress; |
| 33 } | 35 } |
| 34 | 36 |
| 35 @end | 37 @end |
| 36 | 38 |
| 37 @implementation CRIWVWebView | 39 @implementation CRIWVWebView |
| 38 | 40 |
| 39 @synthesize delegate = _delegate; | 41 @synthesize delegate = _delegate; |
| 40 @synthesize loadProgress = _loadProgress; | 42 @synthesize loadProgress = _loadProgress; |
| 41 | 43 |
| 42 - (instancetype)initWithFrame:(CGRect)frame | 44 - (instancetype)initWithFrame:(CGRect)frame |
| 43 browserState:(ios_web_view::CRIWVBrowserState*)browserState { | 45 configuration:(CRIWVWebViewConfiguration*)configuration { |
| 44 self = [super initWithFrame:frame]; | 46 self = [super initWithFrame:frame]; |
| 45 if (self) { | 47 if (self) { |
| 46 _browserState = browserState; | 48 _configuration = configuration; |
|
Eugene But (OOO till 7-30)
2017/02/06 23:31:56
[configuration copy]
It's ok to make the change i
michaeldo
2017/02/06 23:53:49
Done. Needed to upload new patch anyway.
| |
| 47 | 49 |
| 48 web::WebState::CreateParams webStateCreateParams(_browserState); | 50 web::WebState::CreateParams webStateCreateParams( |
| 51 [configuration.websiteDataStore browserState]); | |
| 49 _webState = web::WebState::Create(webStateCreateParams); | 52 _webState = web::WebState::Create(webStateCreateParams); |
| 50 _webState->SetWebUsageEnabled(true); | 53 _webState->SetWebUsageEnabled(true); |
| 51 | 54 |
| 52 _webStateObserver = | 55 _webStateObserver = |
| 53 base::MakeUnique<web::WebStateObserverBridge>(_webState.get(), self); | 56 base::MakeUnique<web::WebStateObserverBridge>(_webState.get(), self); |
| 54 _webStateDelegate = base::MakeUnique<web::WebStateDelegateBridge>(self); | 57 _webStateDelegate = base::MakeUnique<web::WebStateDelegateBridge>(self); |
| 55 _webState->SetDelegate(_webStateDelegate.get()); | 58 _webState->SetDelegate(_webStateDelegate.get()); |
| 56 | 59 |
| 57 // Initialize Translate. | 60 // Initialize Translate. |
| 58 ios_web_view::CRIWVTranslateClient::CreateForWebState(_webState.get()); | 61 ios_web_view::CRIWVTranslateClient::CreateForWebState(_webState.get()); |
| (...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 166 loadSuccess:success]; | 169 loadSuccess:success]; |
| 167 } | 170 } |
| 168 } | 171 } |
| 169 | 172 |
| 170 - (void)webState:(web::WebState*)webState | 173 - (void)webState:(web::WebState*)webState |
| 171 didChangeLoadingProgress:(double)progress { | 174 didChangeLoadingProgress:(double)progress { |
| 172 [self notifyDidUpdateWithChanges:CRIWVWebViewUpdateTypeProgress]; | 175 [self notifyDidUpdateWithChanges:CRIWVWebViewUpdateTypeProgress]; |
| 173 } | 176 } |
| 174 | 177 |
| 175 @end | 178 @end |
| OLD | NEW |