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/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 <utility> | 9 #include <utility> |
| 10 | 10 |
| 11 #include "base/mac/objc_property_releaser.h" | 11 #include "base/mac/objc_property_releaser.h" |
| 12 #import "base/mac/scoped_nsobject.h" | 12 #import "base/mac/scoped_nsobject.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.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> { |
|
Eugene But (OOO till 7-30)
2016/04/06 21:35:17
This is unused now, but works as example and a bas
| |
| 34 web::BrowserState* _browserState; | 35 web::BrowserState* _browserState; |
| 35 base::scoped_nsobject<CRWWebController> _webController; | 36 base::scoped_nsobject<CRWWebController> _webController; |
| 36 scoped_ptr<web::WebStateObserverBridge> _webStateObserver; | 37 scoped_ptr<web::WebStateObserverBridge> _webStateObserver; |
| 38 scoped_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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 110 // Set up the network stack before creating the WebState. | 112 // Set up the network stack before creating the WebState. |
| 111 [self setUpNetworkStack]; | 113 [self setUpNetworkStack]; |
| 112 | 114 |
| 113 scoped_ptr<web::WebStateImpl> webState(new web::WebStateImpl(_browserState)); | 115 scoped_ptr<web::WebStateImpl> webState(new web::WebStateImpl(_browserState)); |
| 114 webState->GetNavigationManagerImpl().InitializeSession(nil, nil, NO, 0); | 116 webState->GetNavigationManagerImpl().InitializeSession(nil, nil, NO, 0); |
| 115 _webController.reset(web::CreateWebController(std::move(webState))); | 117 _webController.reset(web::CreateWebController(std::move(webState))); |
| 116 [_webController setDelegate:self]; | 118 [_webController setDelegate:self]; |
| 117 [_webController setWebUsageEnabled:YES]; | 119 [_webController setWebUsageEnabled:YES]; |
| 118 | 120 |
| 119 _webStateObserver.reset(new web::WebStateObserverBridge(self.webState, self)); | 121 _webStateObserver.reset(new web::WebStateObserverBridge(self.webState, self)); |
| 122 _webStateDelegate.reset(new web::WebStateDelegateBridge(self)); | |
| 123 self.webState->SetDelegate(_webStateDelegate.get()); | |
| 120 | 124 |
| 121 UIView* view = self.webState->GetView(); | 125 UIView* view = self.webState->GetView(); |
| 122 [view setFrame:[_containerView bounds]]; | 126 [view setFrame:[_containerView bounds]]; |
| 123 [_containerView addSubview:view]; | 127 [_containerView addSubview:view]; |
| 124 | 128 |
| 125 NavigationManager::WebLoadParams params(GURL("https://dev.chromium.org/")); | 129 NavigationManager::WebLoadParams params(GURL("https://dev.chromium.org/")); |
| 126 params.transition_type = ui::PAGE_TRANSITION_TYPED; | 130 params.transition_type = ui::PAGE_TRANSITION_TYPED; |
| 127 self.navigationManager->LoadURLWithParams(params); | 131 self.navigationManager->LoadURLWithParams(params); |
| 128 } | 132 } |
| 129 | 133 |
| (...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 347 - (void)webWillFinishHistoryNavigationFromEntry:(CRWSessionEntry*)fromEntry { | 351 - (void)webWillFinishHistoryNavigationFromEntry:(CRWSessionEntry*)fromEntry { |
| 348 } | 352 } |
| 349 - (int)downloadImageAtUrl:(const GURL&)url | 353 - (int)downloadImageAtUrl:(const GURL&)url |
| 350 maxBitmapSize:(uint32_t)maxBitmapSize | 354 maxBitmapSize:(uint32_t)maxBitmapSize |
| 351 callback: | 355 callback: |
| 352 (const web::WebState::ImageDownloadCallback&)callback { | 356 (const web::WebState::ImageDownloadCallback&)callback { |
| 353 return -1; | 357 return -1; |
| 354 } | 358 } |
| 355 | 359 |
| 356 @end | 360 @end |
| OLD | NEW |