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

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: Self review 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 #import "ios/web/public/web_controller_factory.h" 19 #import "ios/web/public/web_controller_factory.h"
20 #include "ios/web/public/web_state/web_state.h" 20 #include "ios/web/public/web_state/web_state.h"
21 #import "ios/web/public/web_state/web_state_delegate_bridge.h"
21 #import "ios/web/public/web_state/web_state_observer_bridge.h" 22 #import "ios/web/public/web_state/web_state_observer_bridge.h"
22 #include "ios/web/shell/shell_browser_state.h" 23 #include "ios/web/shell/shell_browser_state.h"
23 #include "ios/web/web_state/ui/crw_web_controller.h" 24 #include "ios/web/web_state/ui/crw_web_controller.h"
24 #include "ios/web/web_state/web_state_impl.h" 25 #include "ios/web/web_state/web_state_impl.h"
25 #include "ui/base/page_transition_types.h" 26 #include "ui/base/page_transition_types.h"
26 27
27 NSString* const kWebShellBackButtonAccessibilityLabel = @"Back"; 28 NSString* const kWebShellBackButtonAccessibilityLabel = @"Back";
28 NSString* const kWebShellForwardButtonAccessibilityLabel = @"Forward"; 29 NSString* const kWebShellForwardButtonAccessibilityLabel = @"Forward";
29 NSString* const kWebShellAddressFieldAccessibilityLabel = @"Address field"; 30 NSString* const kWebShellAddressFieldAccessibilityLabel = @"Address field";
30 31
31 using web::NavigationManager; 32 using web::NavigationManager;
32 33
33 @interface ViewController ()<CRWWebStateObserver> { 34 @interface ViewController ()<CRWWebStateDelegate, CRWWebStateObserver> {
34 web::BrowserState* _browserState; 35 web::BrowserState* _browserState;
35 base::scoped_nsobject<CRWWebController> _webController; 36 base::scoped_nsobject<CRWWebController> _webController;
36 std::unique_ptr<web::WebStateObserverBridge> _webStateObserver; 37 std::unique_ptr<web::WebStateObserverBridge> _webStateObserver;
38 std::unique_ptr<web::WebStateDelegateBridge> _webStateDelegate;
37 39
38 base::mac::ObjCPropertyReleaser _propertyReleaser_ViewController; 40 base::mac::ObjCPropertyReleaser _propertyReleaser_ViewController;
39 } 41 }
40 @property(nonatomic, assign, readonly) web::WebState* webState; 42 @property(nonatomic, assign, readonly) web::WebState* webState;
41 @property(nonatomic, assign, readonly) NavigationManager* navigationManager; 43 @property(nonatomic, assign, readonly) NavigationManager* navigationManager;
42 @property(nonatomic, readwrite, retain) UITextField* field; 44 @property(nonatomic, readwrite, retain) UITextField* field;
43 @end 45 @end
44 46
45 @implementation ViewController 47 @implementation ViewController
46 48
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 [self setUpNetworkStack]; 113 [self setUpNetworkStack];
112 114
113 std::unique_ptr<web::WebStateImpl> webState( 115 std::unique_ptr<web::WebStateImpl> webState(
114 new web::WebStateImpl(_browserState)); 116 new web::WebStateImpl(_browserState));
115 webState->GetNavigationManagerImpl().InitializeSession(nil, nil, NO, 0); 117 webState->GetNavigationManagerImpl().InitializeSession(nil, nil, NO, 0);
116 _webController.reset(web::CreateWebController(std::move(webState))); 118 _webController.reset(web::CreateWebController(std::move(webState)));
117 [_webController setDelegate:self]; 119 [_webController setDelegate:self];
118 [_webController setWebUsageEnabled:YES]; 120 [_webController setWebUsageEnabled:YES];
119 121
120 _webStateObserver.reset(new web::WebStateObserverBridge(self.webState, self)); 122 _webStateObserver.reset(new web::WebStateObserverBridge(self.webState, self));
123 _webStateDelegate.reset(new web::WebStateDelegateBridge(self));
124 self.webState->SetDelegate(_webStateDelegate.get());
121 125
122 UIView* view = self.webState->GetView(); 126 UIView* view = self.webState->GetView();
123 [view setFrame:[_containerView bounds]]; 127 [view setFrame:[_containerView bounds]];
124 [_containerView addSubview:view]; 128 [_containerView addSubview:view];
125 129
126 NavigationManager::WebLoadParams params(GURL("https://dev.chromium.org/")); 130 NavigationManager::WebLoadParams params(GURL("https://dev.chromium.org/"));
127 params.transition_type = ui::PAGE_TRANSITION_TYPED; 131 params.transition_type = ui::PAGE_TRANSITION_TYPED;
128 self.navigationManager->LoadURLWithParams(params); 132 self.navigationManager->LoadURLWithParams(params);
129 } 133 }
130 134
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
348 - (void)webWillFinishHistoryNavigationFromEntry:(CRWSessionEntry*)fromEntry { 352 - (void)webWillFinishHistoryNavigationFromEntry:(CRWSessionEntry*)fromEntry {
349 } 353 }
350 - (int)downloadImageAtUrl:(const GURL&)url 354 - (int)downloadImageAtUrl:(const GURL&)url
351 maxBitmapSize:(uint32_t)maxBitmapSize 355 maxBitmapSize:(uint32_t)maxBitmapSize
352 callback: 356 callback:
353 (const web::WebState::ImageDownloadCallback&)callback { 357 (const web::WebState::ImageDownloadCallback&)callback {
354 return -1; 358 return -1;
355 } 359 }
356 360
357 @end 361 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698