| 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 <memory> |
| 9 #include <utility> | 10 #include <utility> |
| 10 | 11 |
| 11 #include "base/mac/objc_property_releaser.h" | 12 #include "base/mac/objc_property_releaser.h" |
| 12 #import "base/mac/scoped_nsobject.h" | 13 #import "base/mac/scoped_nsobject.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_observer_bridge.h" | 21 #import "ios/web/public/web_state/web_state_observer_bridge.h" |
| 22 #include "ios/web/shell/shell_browser_state.h" | 22 #include "ios/web/shell/shell_browser_state.h" |
| 23 #include "ios/web/web_state/ui/crw_web_controller.h" | 23 #include "ios/web/web_state/ui/crw_web_controller.h" |
| 24 #include "ios/web/web_state/web_state_impl.h" | 24 #include "ios/web/web_state/web_state_impl.h" |
| 25 #include "ui/base/page_transition_types.h" | 25 #include "ui/base/page_transition_types.h" |
| 26 | 26 |
| 27 NSString* const kWebShellBackButtonAccessibilityLabel = @"Back"; | 27 NSString* const kWebShellBackButtonAccessibilityLabel = @"Back"; |
| 28 NSString* const kWebShellForwardButtonAccessibilityLabel = @"Forward"; | 28 NSString* const kWebShellForwardButtonAccessibilityLabel = @"Forward"; |
| 29 NSString* const kWebShellAddressFieldAccessibilityLabel = @"Address field"; | 29 NSString* const kWebShellAddressFieldAccessibilityLabel = @"Address field"; |
| 30 | 30 |
| 31 using web::NavigationManager; | 31 using web::NavigationManager; |
| 32 | 32 |
| 33 @interface ViewController ()<CRWWebStateObserver> { | 33 @interface ViewController ()<CRWWebStateObserver> { |
| 34 web::BrowserState* _browserState; | 34 web::BrowserState* _browserState; |
| 35 base::scoped_nsobject<CRWWebController> _webController; | 35 base::scoped_nsobject<CRWWebController> _webController; |
| 36 scoped_ptr<web::WebStateObserverBridge> _webStateObserver; | 36 std::unique_ptr<web::WebStateObserverBridge> _webStateObserver; |
| 37 | 37 |
| 38 base::mac::ObjCPropertyReleaser _propertyReleaser_ViewController; | 38 base::mac::ObjCPropertyReleaser _propertyReleaser_ViewController; |
| 39 } | 39 } |
| 40 @property(nonatomic, assign, readonly) web::WebState* webState; | 40 @property(nonatomic, assign, readonly) web::WebState* webState; |
| 41 @property(nonatomic, assign, readonly) NavigationManager* navigationManager; | 41 @property(nonatomic, assign, readonly) NavigationManager* navigationManager; |
| 42 @property(nonatomic, readwrite, retain) UITextField* field; | 42 @property(nonatomic, readwrite, retain) UITextField* field; |
| 43 @end | 43 @end |
| 44 | 44 |
| 45 @implementation ViewController | 45 @implementation ViewController |
| 46 | 46 |
| (...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 103 [field setClearButtonMode:UITextFieldViewModeWhileEditing]; | 103 [field setClearButtonMode:UITextFieldViewModeWhileEditing]; |
| 104 self.field = field; | 104 self.field = field; |
| 105 | 105 |
| 106 [_toolbarView addSubview:back]; | 106 [_toolbarView addSubview:back]; |
| 107 [_toolbarView addSubview:forward]; | 107 [_toolbarView addSubview:forward]; |
| 108 [_toolbarView addSubview:field]; | 108 [_toolbarView addSubview:field]; |
| 109 | 109 |
| 110 // Set up the network stack before creating the WebState. | 110 // Set up the network stack before creating the WebState. |
| 111 [self setUpNetworkStack]; | 111 [self setUpNetworkStack]; |
| 112 | 112 |
| 113 scoped_ptr<web::WebStateImpl> webState(new web::WebStateImpl(_browserState)); | 113 std::unique_ptr<web::WebStateImpl> webState( |
| 114 new web::WebStateImpl(_browserState)); |
| 114 webState->GetNavigationManagerImpl().InitializeSession(nil, nil, NO, 0); | 115 webState->GetNavigationManagerImpl().InitializeSession(nil, nil, NO, 0); |
| 115 _webController.reset(web::CreateWebController(std::move(webState))); | 116 _webController.reset(web::CreateWebController(std::move(webState))); |
| 116 [_webController setDelegate:self]; | 117 [_webController setDelegate:self]; |
| 117 [_webController setWebUsageEnabled:YES]; | 118 [_webController setWebUsageEnabled:YES]; |
| 118 | 119 |
| 119 _webStateObserver.reset(new web::WebStateObserverBridge(self.webState, self)); | 120 _webStateObserver.reset(new web::WebStateObserverBridge(self.webState, self)); |
| 120 | 121 |
| 121 UIView* view = self.webState->GetView(); | 122 UIView* view = self.webState->GetView(); |
| 122 [view setFrame:[_containerView bounds]]; | 123 [view setFrame:[_containerView bounds]]; |
| 123 [_containerView addSubview:view]; | 124 [_containerView addSubview:view]; |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 347 - (void)webWillFinishHistoryNavigationFromEntry:(CRWSessionEntry*)fromEntry { | 348 - (void)webWillFinishHistoryNavigationFromEntry:(CRWSessionEntry*)fromEntry { |
| 348 } | 349 } |
| 349 - (int)downloadImageAtUrl:(const GURL&)url | 350 - (int)downloadImageAtUrl:(const GURL&)url |
| 350 maxBitmapSize:(uint32_t)maxBitmapSize | 351 maxBitmapSize:(uint32_t)maxBitmapSize |
| 351 callback: | 352 callback: |
| 352 (const web::WebState::ImageDownloadCallback&)callback { | 353 (const web::WebState::ImageDownloadCallback&)callback { |
| 353 return -1; | 354 return -1; |
| 354 } | 355 } |
| 355 | 356 |
| 356 @end | 357 @end |
| OLD | NEW |