OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 2012 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/net/crw_url_verifying_protocol_handler.h" | 5 #import "ios/web/net/crw_url_verifying_protocol_handler.h" |
6 | 6 |
7 #include "base/ios/ios_util.h" | 7 #include "base/ios/ios_util.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/mac/scoped_nsobject.h" | 9 #include "base/mac/scoped_nsobject.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
242 | 242 |
243 // Injection of JavaScript into any UIWebView pre-initializes the entire | 243 // Injection of JavaScript into any UIWebView pre-initializes the entire |
244 // system which will save run time when user types into Omnibox and triggers | 244 // system which will save run time when user types into Omnibox and triggers |
245 // JavaScript injection again. | 245 // JavaScript injection again. |
246 + (BOOL)preInitialize { | 246 + (BOOL)preInitialize { |
247 if ([[CRWURLVerifyingProtocolHandlerData sharedInstance] preInitialized]) | 247 if ([[CRWURLVerifyingProtocolHandlerData sharedInstance] preInitialized]) |
248 return YES; | 248 return YES; |
249 web::URLVerificationTrustLevel trustLevel; | 249 web::URLVerificationTrustLevel trustLevel; |
250 web::WebClient* web_client = web::GetWebClient(); | 250 web::WebClient* web_client = web::GetWebClient(); |
251 DCHECK(web_client); | 251 DCHECK(web_client); |
252 base::scoped_nsobject<UIWebView> dummyWebView(web::CreateStaticFileWebView()); | 252 base::scoped_nsobject<UIWebView> dummyWebView(web::CreateWebView(CGRectZero)); |
253 [CRWURLVerifyingProtocolHandler currentURLForWebView:dummyWebView | 253 [CRWURLVerifyingProtocolHandler currentURLForWebView:dummyWebView |
254 trustLevel:&trustLevel]; | 254 trustLevel:&trustLevel]; |
255 return [[CRWURLVerifyingProtocolHandlerData sharedInstance] preInitialized]; | 255 return [[CRWURLVerifyingProtocolHandlerData sharedInstance] preInitialized]; |
256 } | 256 } |
257 | 257 |
258 #pragma mark NSURLProtocol methods | 258 #pragma mark NSURLProtocol methods |
259 | 259 |
260 + (BOOL)canInitWithRequest:(NSURLRequest*)request { | 260 + (BOOL)canInitWithRequest:(NSURLRequest*)request { |
261 GURL requestURL = net::GURLWithNSURL(request.URL); | 261 GURL requestURL = net::GURLWithNSURL(request.URL); |
262 if (requestURL != GURL(web::kURLForVerification) && | 262 if (requestURL != GURL(web::kURLForVerification) && |
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
306 cacheStoragePolicy:NSURLCacheStorageNotAllowed]; | 306 cacheStoragePolicy:NSURLCacheStorageNotAllowed]; |
307 [self.client URLProtocol:self didLoadData:[NSData data]]; | 307 [self.client URLProtocol:self didLoadData:[NSData data]]; |
308 [self.client URLProtocolDidFinishLoading:self]; | 308 [self.client URLProtocolDidFinishLoading:self]; |
309 } | 309 } |
310 | 310 |
311 - (void)stopLoading { | 311 - (void)stopLoading { |
312 // Nothing to do. | 312 // Nothing to do. |
313 } | 313 } |
314 | 314 |
315 @end | 315 @end |
OLD | NEW |