| 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 #import "ios/web/navigation/crw_session_controller.h" | |
| 19 #import "ios/web/net/crw_url_verifying_protocol_handler.h" | |
| 20 #include "ios/web/net/request_tracker_factory_impl.h" | |
| 21 #import "ios/web/net/web_http_protocol_handler_delegate.h" | |
| 22 #include "ios/web/public/referrer.h" | 18 #include "ios/web/public/referrer.h" |
| 23 #import "ios/web/public/web_controller_factory.h" | 19 #import "ios/web/public/web_controller_factory.h" |
| 24 #include "ios/web/public/web_state/web_state.h" | 20 #include "ios/web/public/web_state/web_state.h" |
| 25 #import "ios/web/public/web_state/web_state_observer_bridge.h" | 21 #import "ios/web/public/web_state/web_state_observer_bridge.h" |
| 26 #include "ios/web/shell/shell_browser_state.h" | 22 #include "ios/web/shell/shell_browser_state.h" |
| 27 #include "ios/web/web_state/ui/crw_web_controller.h" | 23 #include "ios/web/web_state/ui/crw_web_controller.h" |
| 28 #include "ios/web/web_state/web_state_impl.h" | 24 #include "ios/web/web_state/web_state_impl.h" |
| 29 #include "ui/base/page_transition_types.h" | 25 #include "ui/base/page_transition_types.h" |
| 30 | 26 |
| 31 NSString* const kWebShellBackButtonAccessibilityLabel = @"Back"; | 27 NSString* const kWebShellBackButtonAccessibilityLabel = @"Back"; |
| 32 NSString* const kWebShellForwardButtonAccessibilityLabel = @"Forward"; | 28 NSString* const kWebShellForwardButtonAccessibilityLabel = @"Forward"; |
| 33 NSString* const kWebShellAddressFieldAccessibilityLabel = @"Address field"; | 29 NSString* const kWebShellAddressFieldAccessibilityLabel = @"Address field"; |
| 34 | 30 |
| 35 using web::NavigationManager; | 31 using web::NavigationManager; |
| 36 | 32 |
| 37 @interface ViewController ()<CRWWebStateObserver> { | 33 @interface ViewController ()<CRWWebStateObserver> { |
| 38 web::BrowserState* _browserState; | 34 web::BrowserState* _browserState; |
| 39 base::scoped_nsobject<CRWWebController> _webController; | 35 base::scoped_nsobject<CRWWebController> _webController; |
| 40 scoped_ptr<web::RequestTrackerFactoryImpl> _requestTrackerFactory; | |
| 41 scoped_ptr<web::WebHTTPProtocolHandlerDelegate> _httpProtocolDelegate; | |
| 42 scoped_ptr<web::WebStateObserverBridge> _webStateObserver; | 36 scoped_ptr<web::WebStateObserverBridge> _webStateObserver; |
| 43 | 37 |
| 44 base::mac::ObjCPropertyReleaser _propertyReleaser_ViewController; | 38 base::mac::ObjCPropertyReleaser _propertyReleaser_ViewController; |
| 45 } | 39 } |
| 46 @property(nonatomic, assign, readonly) web::WebState* webState; | 40 @property(nonatomic, assign, readonly) web::WebState* webState; |
| 47 @property(nonatomic, assign, readonly) NavigationManager* navigationManager; | 41 @property(nonatomic, assign, readonly) NavigationManager* navigationManager; |
| 48 @property(nonatomic, readwrite, retain) UITextField* field; | 42 @property(nonatomic, readwrite, retain) UITextField* field; |
| 49 @end | 43 @end |
| 50 | 44 |
| 51 @implementation ViewController | 45 @implementation ViewController |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 137 return [_webController webState]; | 131 return [_webController webState]; |
| 138 } | 132 } |
| 139 | 133 |
| 140 - (NavigationManager*)navigationManager { | 134 - (NavigationManager*)navigationManager { |
| 141 return self.webState->GetNavigationManager(); | 135 return self.webState->GetNavigationManager(); |
| 142 } | 136 } |
| 143 | 137 |
| 144 - (void)setUpNetworkStack { | 138 - (void)setUpNetworkStack { |
| 145 // Disable the default cache. | 139 // Disable the default cache. |
| 146 [NSURLCache setSharedURLCache:[EmptyNSURLCache emptyNSURLCache]]; | 140 [NSURLCache setSharedURLCache:[EmptyNSURLCache emptyNSURLCache]]; |
| 147 | |
| 148 _httpProtocolDelegate.reset(new web::WebHTTPProtocolHandlerDelegate( | |
| 149 _browserState->GetRequestContext())); | |
| 150 net::HTTPProtocolHandlerDelegate::SetInstance(_httpProtocolDelegate.get()); | |
| 151 BOOL success = [NSURLProtocol registerClass:[CRNHTTPProtocolHandler class]]; | |
| 152 DCHECK(success); | |
| 153 // The CRWURLVerifyingProtocolHandler is used to verify URL in the | |
| 154 // CRWWebController. It must be registered after the HttpProtocolHandler | |
| 155 // because handlers are called in the reverse order of declaration. | |
| 156 success = | |
| 157 [NSURLProtocol registerClass:[CRWURLVerifyingProtocolHandler class]]; | |
| 158 DCHECK(success); | |
| 159 _requestTrackerFactory.reset( | |
| 160 new web::RequestTrackerFactoryImpl(std::string())); | |
| 161 net::RequestTracker::SetRequestTrackerFactory(_requestTrackerFactory.get()); | |
| 162 net::CookieStoreIOS::SetCookiePolicy(net::CookieStoreIOS::ALLOW); | 141 net::CookieStoreIOS::SetCookiePolicy(net::CookieStoreIOS::ALLOW); |
| 163 } | 142 } |
| 164 | 143 |
| 165 - (void)didReceiveMemoryWarning { | 144 - (void)didReceiveMemoryWarning { |
| 166 [super didReceiveMemoryWarning]; | 145 [super didReceiveMemoryWarning]; |
| 167 } | 146 } |
| 168 | 147 |
| 169 - (UIBarPosition)positionForBar:(id<UIBarPositioning>)bar { | 148 - (UIBarPosition)positionForBar:(id<UIBarPositioning>)bar { |
| 170 if (bar == _toolbarView) { | 149 if (bar == _toolbarView) { |
| 171 return UIBarPositionTopAttached; | 150 return UIBarPositionTopAttached; |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 368 - (void)webWillFinishHistoryNavigationFromEntry:(CRWSessionEntry*)fromEntry { | 347 - (void)webWillFinishHistoryNavigationFromEntry:(CRWSessionEntry*)fromEntry { |
| 369 } | 348 } |
| 370 - (int)downloadImageAtUrl:(const GURL&)url | 349 - (int)downloadImageAtUrl:(const GURL&)url |
| 371 maxBitmapSize:(uint32_t)maxBitmapSize | 350 maxBitmapSize:(uint32_t)maxBitmapSize |
| 372 callback: | 351 callback: |
| 373 (const web::WebState::ImageDownloadCallback&)callback { | 352 (const web::WebState::ImageDownloadCallback&)callback { |
| 374 return -1; | 353 return -1; |
| 375 } | 354 } |
| 376 | 355 |
| 377 @end | 356 @end |
| OLD | NEW |