| 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 |
| (...skipping 16 matching lines...) Expand all Loading... |
| 27 #include "ios/web/web_state/ui/crw_web_controller.h" | 27 #include "ios/web/web_state/ui/crw_web_controller.h" |
| 28 #include "ios/web/web_state/web_state_impl.h" | 28 #include "ios/web/web_state/web_state_impl.h" |
| 29 #include "ui/base/page_transition_types.h" | 29 #include "ui/base/page_transition_types.h" |
| 30 | 30 |
| 31 NSString* const kWebShellBackButtonAccessibilityLabel = @"Back"; | 31 NSString* const kWebShellBackButtonAccessibilityLabel = @"Back"; |
| 32 NSString* const kWebShellForwardButtonAccessibilityLabel = @"Forward"; | 32 NSString* const kWebShellForwardButtonAccessibilityLabel = @"Forward"; |
| 33 NSString* const kWebShellAddressFieldAccessibilityLabel = @"Address field"; | 33 NSString* const kWebShellAddressFieldAccessibilityLabel = @"Address field"; |
| 34 | 34 |
| 35 using web::NavigationManager; | 35 using web::NavigationManager; |
| 36 | 36 |
| 37 @interface ViewController ()<CRWWebStateObserver, CRWWebUserInterfaceDelegate> { | 37 @interface ViewController ()<CRWWebStateObserver> { |
| 38 web::BrowserState* _browserState; | 38 web::BrowserState* _browserState; |
| 39 base::scoped_nsobject<CRWWebController> _webController; | 39 base::scoped_nsobject<CRWWebController> _webController; |
| 40 scoped_ptr<web::RequestTrackerFactoryImpl> _requestTrackerFactory; | 40 scoped_ptr<web::RequestTrackerFactoryImpl> _requestTrackerFactory; |
| 41 scoped_ptr<web::WebHTTPProtocolHandlerDelegate> _httpProtocolDelegate; | 41 scoped_ptr<web::WebHTTPProtocolHandlerDelegate> _httpProtocolDelegate; |
| 42 scoped_ptr<web::WebStateObserverBridge> _webStateObserver; | 42 scoped_ptr<web::WebStateObserverBridge> _webStateObserver; |
| 43 | 43 |
| 44 base::mac::ObjCPropertyReleaser _propertyReleaser_ViewController; | 44 base::mac::ObjCPropertyReleaser _propertyReleaser_ViewController; |
| 45 } | 45 } |
| 46 @property(nonatomic, assign, readonly) web::WebState* webState; | 46 @property(nonatomic, assign, readonly) web::WebState* webState; |
| 47 @property(nonatomic, readwrite, retain) UITextField* field; | 47 @property(nonatomic, readwrite, retain) UITextField* field; |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 112 [_toolbarView addSubview:forward]; | 112 [_toolbarView addSubview:forward]; |
| 113 [_toolbarView addSubview:field]; | 113 [_toolbarView addSubview:field]; |
| 114 | 114 |
| 115 // Set up the network stack before creating the WebState. | 115 // Set up the network stack before creating the WebState. |
| 116 [self setUpNetworkStack]; | 116 [self setUpNetworkStack]; |
| 117 | 117 |
| 118 scoped_ptr<web::WebStateImpl> webState(new web::WebStateImpl(_browserState)); | 118 scoped_ptr<web::WebStateImpl> webState(new web::WebStateImpl(_browserState)); |
| 119 webState->GetNavigationManagerImpl().InitializeSession(nil, nil, NO, 0); | 119 webState->GetNavigationManagerImpl().InitializeSession(nil, nil, NO, 0); |
| 120 _webController.reset(web::CreateWebController(std::move(webState))); | 120 _webController.reset(web::CreateWebController(std::move(webState))); |
| 121 [_webController setDelegate:self]; | 121 [_webController setDelegate:self]; |
| 122 [_webController setUIDelegate:self]; | |
| 123 [_webController setWebUsageEnabled:YES]; | 122 [_webController setWebUsageEnabled:YES]; |
| 124 | 123 |
| 125 _webStateObserver.reset(new web::WebStateObserverBridge(self.webState, self)); | 124 _webStateObserver.reset(new web::WebStateObserverBridge(self.webState, self)); |
| 126 | 125 |
| 127 UIView* view = self.webState->GetView(); | 126 UIView* view = self.webState->GetView(); |
| 128 [view setFrame:[_containerView bounds]]; | 127 [view setFrame:[_containerView bounds]]; |
| 129 [_containerView addSubview:view]; | 128 [_containerView addSubview:view]; |
| 130 | 129 |
| 131 NavigationManager::WebLoadParams params(GURL("https://dev.chromium.org/")); | 130 NavigationManager::WebLoadParams params(GURL("https://dev.chromium.org/")); |
| 132 params.transition_type = ui::PAGE_TRANSITION_TYPED; | 131 params.transition_type = ui::PAGE_TRANSITION_TYPED; |
| (...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 365 } | 364 } |
| 366 - (void)webWillFinishHistoryNavigationFromEntry:(CRWSessionEntry*)fromEntry { | 365 - (void)webWillFinishHistoryNavigationFromEntry:(CRWSessionEntry*)fromEntry { |
| 367 } | 366 } |
| 368 - (int)downloadImageAtUrl:(const GURL&)url | 367 - (int)downloadImageAtUrl:(const GURL&)url |
| 369 maxBitmapSize:(uint32_t)maxBitmapSize | 368 maxBitmapSize:(uint32_t)maxBitmapSize |
| 370 callback: | 369 callback: |
| 371 (const web::WebState::ImageDownloadCallback&)callback { | 370 (const web::WebState::ImageDownloadCallback&)callback { |
| 372 return -1; | 371 return -1; |
| 373 } | 372 } |
| 374 | 373 |
| 375 // ----------------------------------------------------------------------- | |
| 376 // CRWWebUserInterfaceDelegate implementation. | |
| 377 | |
| 378 - (void)webController:(CRWWebController*)webController | |
| 379 runAuthDialogForProtectionSpace:(NSURLProtectionSpace*)protectionSpace | |
| 380 proposedCredential:(NSURLCredential*)credential | |
| 381 completionHandler: | |
| 382 (void (^)(NSString* user, NSString* password))handler { | |
| 383 // Calling |handler| with nil objects is the same as not implemeting it. This | |
| 384 // method is implemented to make testing easier. | |
| 385 handler(nil, nil); | |
| 386 } | |
| 387 | |
| 388 @end | 374 @end |
| OLD | NEW |