Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(96)

Side by Side Diff: ios/web/web_state/ui/crw_wk_web_view_web_controller.mm

Issue 1458703004: Fixes document type detection on iOS 9. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Addressed comments 1 Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/web_state/ui/crw_wk_web_view_web_controller.h" 5 #import "ios/web/web_state/ui/crw_wk_web_view_web_controller.h"
6 6
7 #import <WebKit/WebKit.h> 7 #import <WebKit/WebKit.h>
8 8
9 #include "base/ios/ios_util.h" 9 #include "base/ios/ios_util.h"
10 #include "base/ios/weak_nsobject.h" 10 #include "base/ios/weak_nsobject.h"
(...skipping 24 matching lines...) Expand all
35 #import "ios/web/web_state/js/page_script_util.h" 35 #import "ios/web/web_state/js/page_script_util.h"
36 #import "ios/web/web_state/ui/crw_web_controller+protected.h" 36 #import "ios/web/web_state/ui/crw_web_controller+protected.h"
37 #import "ios/web/web_state/ui/crw_wk_web_view_crash_detector.h" 37 #import "ios/web/web_state/ui/crw_wk_web_view_crash_detector.h"
38 #import "ios/web/web_state/ui/web_view_js_utils.h" 38 #import "ios/web/web_state/ui/web_view_js_utils.h"
39 #import "ios/web/web_state/ui/wk_back_forward_list_item_holder.h" 39 #import "ios/web/web_state/ui/wk_back_forward_list_item_holder.h"
40 #import "ios/web/web_state/ui/wk_web_view_configuration_provider.h" 40 #import "ios/web/web_state/ui/wk_web_view_configuration_provider.h"
41 #import "ios/web/web_state/web_state_impl.h" 41 #import "ios/web/web_state/web_state_impl.h"
42 #import "ios/web/web_state/web_view_internal_creation_util.h" 42 #import "ios/web/web_state/web_view_internal_creation_util.h"
43 #import "ios/web/web_state/wk_web_view_security_util.h" 43 #import "ios/web/web_state/wk_web_view_security_util.h"
44 #import "ios/web/webui/crw_web_ui_manager.h" 44 #import "ios/web/webui/crw_web_ui_manager.h"
45 #import "net/base/mac/url_conversions.h"
45 #include "net/cert/x509_certificate.h" 46 #include "net/cert/x509_certificate.h"
46 #import "net/base/mac/url_conversions.h"
47 #include "net/ssl/ssl_info.h" 47 #include "net/ssl/ssl_info.h"
48 #include "url/url_constants.h" 48 #include "url/url_constants.h"
49 49
50 namespace { 50 namespace {
51 // Extracts Referer value from WKNavigationAction request header. 51 // Extracts Referer value from WKNavigationAction request header.
52 NSString* GetRefererFromNavigationAction(WKNavigationAction* action) { 52 NSString* GetRefererFromNavigationAction(WKNavigationAction* action) {
53 return [action.request valueForHTTPHeaderField:@"Referer"]; 53 return [action.request valueForHTTPHeaderField:@"Referer"];
54 } 54 }
55 55
56 NSString* const kScriptMessageName = @"crwebinvoke"; 56 NSString* const kScriptMessageName = @"crwebinvoke";
(...skipping 367 matching lines...) Expand 10 before | Expand all | Expand 10 after
424 // to |WEB_VIEW_DOCUMENT| because it does not support iframe creation used 424 // to |WEB_VIEW_DOCUMENT| because it does not support iframe creation used
425 // by core.js to communicate back. That functionality is only supported 425 // by core.js to communicate back. That functionality is only supported
426 // by |WEB_VIEW_HTML_DOCUMENT|. |WEB_VIEW_DOCUMENT| is used when displaying 426 // by |WEB_VIEW_HTML_DOCUMENT|. |WEB_VIEW_DOCUMENT| is used when displaying
427 // non-HTML contents (e.g. PDF documents). 427 // non-HTML contents (e.g. PDF documents).
428 - (web::WebViewDocumentType)webViewDocumentType { 428 - (web::WebViewDocumentType)webViewDocumentType {
429 // This happens during tests. 429 // This happens during tests.
430 if (!_wkWebView) { 430 if (!_wkWebView) {
431 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; 431 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC;
432 } 432 }
433 433
434 if (!self.documentMIMEType) { 434 if (!self.documentMIMEType) {
Eugene But (OOO till 7-30) 2015/11/19 16:29:01 I would move this check inside documentTypeFromMIM
stkhapugin 2015/11/20 10:50:43 Done.
435 return web::WEB_VIEW_DOCUMENT_TYPE_UNKNOWN; 435 return web::WEB_VIEW_DOCUMENT_TYPE_UNKNOWN;
436 } 436 }
437 437
438 if ([self.documentMIMEType isEqualToString:@"text/html"] || 438 return [self documentTypeFromMIMEType:self.documentMIMEType];
439 [self.documentMIMEType isEqualToString:@"application/xhtml+xml"] ||
440 [self.documentMIMEType isEqualToString:@"application/xml"]) {
441 return web::WEB_VIEW_DOCUMENT_TYPE_HTML;
442 }
443
444 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC;
445 } 439 }
446 440
447 - (void)loadRequest:(NSMutableURLRequest*)request { 441 - (void)loadRequest:(NSMutableURLRequest*)request {
448 [_wkWebView loadRequest:request]; 442 [_wkWebView loadRequest:request];
449 } 443 }
450 444
451 - (void)loadWebHTMLString:(NSString*)html forURL:(const GURL&)URL { 445 - (void)loadWebHTMLString:(NSString*)html forURL:(const GURL&)URL {
452 [_wkWebView loadHTMLString:html baseURL:net::NSURLWithGURL(URL)]; 446 [_wkWebView loadHTMLString:html baseURL:net::NSURLWithGURL(URL)];
453 } 447 }
454 448
(...skipping 1031 matching lines...) Expand 10 before | Expand all | Expand 10 after
1486 placeholderText:defaultText 1480 placeholderText:defaultText
1487 requestURL: 1481 requestURL:
1488 net::GURLWithNSURL(frame.request.URL) 1482 net::GURLWithNSURL(frame.request.URL)
1489 completionHandler:completionHandler]; 1483 completionHandler:completionHandler];
1490 } else if (completionHandler) { 1484 } else if (completionHandler) {
1491 completionHandler(nil); 1485 completionHandler(nil);
1492 } 1486 }
1493 } 1487 }
1494 1488
1495 @end 1489 @end
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698