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

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

Issue 2679003002: Initialize CRIWVWebView with Configuration object instead of browserState. (Closed)
Patch Set: Respond to comments. Created 3 years, 10 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/criwv_web_view_internal.h" 5 #import "ios/web_view/public/criwv_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 #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"
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"
24 #import "ios/web_view/public/criwv_website_data_store.h"
22 #import "net/base/mac/url_conversions.h" 25 #import "net/base/mac/url_conversions.h"
23 #include "ui/base/page_transition_types.h" 26 #include "ui/base/page_transition_types.h"
24 #include "url/gurl.h" 27 #include "url/gurl.h"
25 28
26 @interface CRIWVWebView ()<CRWWebStateDelegate, CRWWebStateObserver> { 29 @interface CRIWVWebView ()<CRWWebStateDelegate, CRWWebStateObserver> {
27 id<CRIWVWebViewDelegate> _delegate; 30 id<CRIWVWebViewDelegate> _delegate;
28 ios_web_view::CRIWVBrowserState* _browserState; 31 CRIWVWebViewConfiguration* _configuration;
29 std::unique_ptr<web::WebState> _webState; 32 std::unique_ptr<web::WebState> _webState;
30 std::unique_ptr<web::WebStateDelegateBridge> _webStateDelegate; 33 std::unique_ptr<web::WebStateDelegateBridge> _webStateDelegate;
31 std::unique_ptr<web::WebStateObserverBridge> _webStateObserver; 34 std::unique_ptr<web::WebStateObserverBridge> _webStateObserver;
32 CGFloat _loadProgress; 35 CGFloat _loadProgress;
33 } 36 }
34 37
35 @end 38 @end
36 39
37 @implementation CRIWVWebView 40 @implementation CRIWVWebView
38 41
39 @synthesize delegate = _delegate; 42 @synthesize delegate = _delegate;
40 @synthesize loadProgress = _loadProgress; 43 @synthesize loadProgress = _loadProgress;
41 44
42 - (instancetype)initWithFrame:(CGRect)frame 45 - (instancetype)initWithFrame:(CGRect)frame
43 browserState:(ios_web_view::CRIWVBrowserState*)browserState { 46 configuration:(CRIWVWebViewConfiguration*)configuration {
44 self = [super initWithFrame:frame]; 47 self = [super initWithFrame:frame];
45 if (self) { 48 if (self) {
46 _browserState = browserState; 49 _configuration = [configuration copy];
47 50
48 web::WebState::CreateParams webStateCreateParams(_browserState); 51 web::WebState::CreateParams webStateCreateParams(
52 [configuration.websiteDataStore browserState]);
49 _webState = web::WebState::Create(webStateCreateParams); 53 _webState = web::WebState::Create(webStateCreateParams);
50 _webState->SetWebUsageEnabled(true); 54 _webState->SetWebUsageEnabled(true);
51 55
52 _webStateObserver = 56 _webStateObserver =
53 base::MakeUnique<web::WebStateObserverBridge>(_webState.get(), self); 57 base::MakeUnique<web::WebStateObserverBridge>(_webState.get(), self);
54 _webStateDelegate = base::MakeUnique<web::WebStateDelegateBridge>(self); 58 _webStateDelegate = base::MakeUnique<web::WebStateDelegateBridge>(self);
55 _webState->SetDelegate(_webStateDelegate.get()); 59 _webState->SetDelegate(_webStateDelegate.get());
56 60
57 // Initialize Translate. 61 // Initialize Translate.
58 ios_web_view::CRIWVTranslateClient::CreateForWebState(_webState.get()); 62 ios_web_view::CRIWVTranslateClient::CreateForWebState(_webState.get());
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
166 loadSuccess:success]; 170 loadSuccess:success];
167 } 171 }
168 } 172 }
169 173
170 - (void)webState:(web::WebState*)webState 174 - (void)webState:(web::WebState*)webState
171 didChangeLoadingProgress:(double)progress { 175 didChangeLoadingProgress:(double)progress {
172 [self notifyDidUpdateWithChanges:CRIWVWebViewUpdateTypeProgress]; 176 [self notifyDidUpdateWithChanges:CRIWVWebViewUpdateTypeProgress];
173 } 177 }
174 178
175 @end 179 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698