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

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

Issue 1491043004: Fixes document type detection on iOS 9. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@2564
Patch Set: Created 5 years 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
« no previous file with comments | « ios/web/web_state/ui/crw_web_controller+protected.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/containers/mru_cache.h" 9 #include "base/containers/mru_cache.h"
10 #include "base/ios/ios_util.h" 10 #include "base/ios/ios_util.h"
(...skipping 518 matching lines...) Expand 10 before | Expand all | Expand 10 after
529 // to |WEB_VIEW_DOCUMENT| because it does not support iframe creation used 529 // to |WEB_VIEW_DOCUMENT| because it does not support iframe creation used
530 // by core.js to communicate back. That functionality is only supported 530 // by core.js to communicate back. That functionality is only supported
531 // by |WEB_VIEW_HTML_DOCUMENT|. |WEB_VIEW_DOCUMENT| is used when displaying 531 // by |WEB_VIEW_HTML_DOCUMENT|. |WEB_VIEW_DOCUMENT| is used when displaying
532 // non-HTML contents (e.g. PDF documents). 532 // non-HTML contents (e.g. PDF documents).
533 - (web::WebViewDocumentType)webViewDocumentType { 533 - (web::WebViewDocumentType)webViewDocumentType {
534 // This happens during tests. 534 // This happens during tests.
535 if (!_wkWebView) { 535 if (!_wkWebView) {
536 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; 536 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC;
537 } 537 }
538 538
539 std::string mimeType = self.webState->GetContentsMimeType(); 539 std::string MIMEType = self.webState->GetContentsMimeType();
540 if (mimeType.empty()) { 540 return [self documentTypeFromMIMEType:base::SysUTF8ToNSString(MIMEType)];
541 return web::WEB_VIEW_DOCUMENT_TYPE_UNKNOWN;
542 }
543
544 if (mimeType == "text/html" || mimeType == "application/xhtml+xml" ||
545 mimeType == "application/xml") {
546 return web::WEB_VIEW_DOCUMENT_TYPE_HTML;
547 }
548
549 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC;
550 } 541 }
551 542
552 - (void)loadRequest:(NSMutableURLRequest*)request { 543 - (void)loadRequest:(NSMutableURLRequest*)request {
553 [_wkWebView loadRequest:request]; 544 [_wkWebView loadRequest:request];
554 } 545 }
555 546
556 - (void)loadWebHTMLString:(NSString*)html forURL:(const GURL&)URL { 547 - (void)loadWebHTMLString:(NSString*)html forURL:(const GURL&)URL {
557 [_wkWebView loadHTMLString:html baseURL:net::NSURLWithGURL(URL)]; 548 [_wkWebView loadHTMLString:html baseURL:net::NSURLWithGURL(URL)];
558 } 549 }
559 550
(...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after
1924 runJavaScriptTextInputPanelWithPrompt:prompt 1915 runJavaScriptTextInputPanelWithPrompt:prompt
1925 defaultText:defaultText 1916 defaultText:defaultText
1926 requestURL:requestURL 1917 requestURL:requestURL
1927 completionHandler:completionHandler]; 1918 completionHandler:completionHandler];
1928 } else if (completionHandler) { 1919 } else if (completionHandler) {
1929 completionHandler(nil); 1920 completionHandler(nil);
1930 } 1921 }
1931 } 1922 }
1932 1923
1933 @end 1924 @end
OLDNEW
« no previous file with comments | « ios/web/web_state/ui/crw_web_controller+protected.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698