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

Side by Side Diff: ios/web/shell/view_controller.mm

Issue 1851003003: [ios] Added web// public API to let embedder observe loading progress. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fixed compilation Created 4 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/shell/view_controller.h" 5 #import "ios/web/shell/view_controller.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <memory> 9 #include <memory>
10 #include <utility> 10 #include <utility>
11 11
12 #include "base/mac/objc_property_releaser.h" 12 #include "base/mac/objc_property_releaser.h"
13 #import "base/mac/scoped_nsobject.h" 13 #import "base/mac/scoped_nsobject.h"
14 #include "base/strings/sys_string_conversions.h" 14 #include "base/strings/sys_string_conversions.h"
15 #include "ios/net/cookies/cookie_store_ios.h" 15 #include "ios/net/cookies/cookie_store_ios.h"
16 #import "ios/net/crn_http_protocol_handler.h" 16 #import "ios/net/crn_http_protocol_handler.h"
17 #import "ios/net/empty_nsurlcache.h" 17 #import "ios/net/empty_nsurlcache.h"
18 #include "ios/web/public/referrer.h" 18 #include "ios/web/public/referrer.h"
19 #include "ios/web/public/web_state/web_state.h" 19 #include "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_observer_bridge.h" 21 #import "ios/web/public/web_state/web_state_observer_bridge.h"
21 #include "ios/web/shell/shell_browser_state.h" 22 #include "ios/web/shell/shell_browser_state.h"
22 #include "ios/web/web_state/ui/crw_web_controller.h" 23 #include "ios/web/web_state/ui/crw_web_controller.h"
23 #include "ios/web/web_state/web_state_impl.h" 24 #include "ios/web/web_state/web_state_impl.h"
24 #include "ui/base/page_transition_types.h" 25 #include "ui/base/page_transition_types.h"
25 26
26 NSString* const kWebShellBackButtonAccessibilityLabel = @"Back"; 27 NSString* const kWebShellBackButtonAccessibilityLabel = @"Back";
27 NSString* const kWebShellForwardButtonAccessibilityLabel = @"Forward"; 28 NSString* const kWebShellForwardButtonAccessibilityLabel = @"Forward";
28 NSString* const kWebShellAddressFieldAccessibilityLabel = @"Address field"; 29 NSString* const kWebShellAddressFieldAccessibilityLabel = @"Address field";
29 30
30 using web::NavigationManager; 31 using web::NavigationManager;
31 32
32 @interface ViewController ()<CRWWebStateObserver> { 33 @interface ViewController ()<CRWWebStateDelegate, CRWWebStateObserver> {
33 web::BrowserState* _browserState; 34 web::BrowserState* _browserState;
34 std::unique_ptr<web::WebStateImpl> _webState; 35 std::unique_ptr<web::WebStateImpl> _webState;
35 std::unique_ptr<web::WebStateObserverBridge> _webStateObserver; 36 std::unique_ptr<web::WebStateObserverBridge> _webStateObserver;
37 std::unique_ptr<web::WebStateDelegateBridge> _webStateDelegate;
36 38
37 base::mac::ObjCPropertyReleaser _propertyReleaser_ViewController; 39 base::mac::ObjCPropertyReleaser _propertyReleaser_ViewController;
38 } 40 }
39 @property(nonatomic, assign, readonly) NavigationManager* navigationManager; 41 @property(nonatomic, assign, readonly) NavigationManager* navigationManager;
40 @property(nonatomic, readwrite, retain) UITextField* field; 42 @property(nonatomic, readwrite, retain) UITextField* field;
41 @end 43 @end
42 44
43 @implementation ViewController 45 @implementation ViewController
44 46
45 @synthesize field = _field; 47 @synthesize field = _field;
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
108 // Set up the network stack before creating the WebState. 110 // Set up the network stack before creating the WebState.
109 [self setUpNetworkStack]; 111 [self setUpNetworkStack];
110 112
111 _webState.reset(new web::WebStateImpl(_browserState)); 113 _webState.reset(new web::WebStateImpl(_browserState));
112 _webState->GetNavigationManagerImpl().InitializeSession(nil, nil, NO, 0); 114 _webState->GetNavigationManagerImpl().InitializeSession(nil, nil, NO, 0);
113 [_webState->GetWebController() setDelegate:self]; 115 [_webState->GetWebController() setDelegate:self];
114 [_webState->GetWebController() setWebUsageEnabled:YES]; 116 [_webState->GetWebController() setWebUsageEnabled:YES];
115 117
116 _webStateObserver.reset( 118 _webStateObserver.reset(
117 new web::WebStateObserverBridge(_webState.get(), self)); 119 new web::WebStateObserverBridge(_webState.get(), self));
120 _webStateDelegate.reset(new web::WebStateDelegateBridge(self));
121 _webState->SetDelegate(_webStateDelegate.get());
118 122
119 UIView* view = _webState->GetView(); 123 UIView* view = _webState->GetView();
120 [view setFrame:[_containerView bounds]]; 124 [view setFrame:[_containerView bounds]];
121 [_containerView addSubview:view]; 125 [_containerView addSubview:view];
122 126
123 NavigationManager::WebLoadParams params(GURL("https://dev.chromium.org/")); 127 NavigationManager::WebLoadParams params(GURL("https://dev.chromium.org/"));
124 params.transition_type = ui::PAGE_TRANSITION_TYPED; 128 params.transition_type = ui::PAGE_TRANSITION_TYPED;
125 self.navigationManager->LoadURLWithParams(params); 129 self.navigationManager->LoadURLWithParams(params);
126 } 130 }
127 131
(...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after
341 - (void)webWillFinishHistoryNavigationFromEntry:(CRWSessionEntry*)fromEntry { 345 - (void)webWillFinishHistoryNavigationFromEntry:(CRWSessionEntry*)fromEntry {
342 } 346 }
343 - (int)downloadImageAtUrl:(const GURL&)url 347 - (int)downloadImageAtUrl:(const GURL&)url
344 maxBitmapSize:(uint32_t)maxBitmapSize 348 maxBitmapSize:(uint32_t)maxBitmapSize
345 callback: 349 callback:
346 (const web::WebState::ImageDownloadCallback&)callback { 350 (const web::WebState::ImageDownloadCallback&)callback {
347 return -1; 351 return -1;
348 } 352 }
349 353
350 @end 354 @end
OLDNEW
« no previous file with comments | « ios/web/public/web_state/web_state_delegate_bridge.h ('k') | ios/web/web_state/ui/crw_web_controller.mm » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698