| 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/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 Loading... |
| 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 return [self documentTypeFromMIMEType:base::SysUTF8ToNSString(MIMEType)]; | 540 if (mimeType.empty()) { |
| 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; |
| 541 } | 550 } |
| 542 | 551 |
| 543 - (void)loadRequest:(NSMutableURLRequest*)request { | 552 - (void)loadRequest:(NSMutableURLRequest*)request { |
| 544 [_wkWebView loadRequest:request]; | 553 [_wkWebView loadRequest:request]; |
| 545 } | 554 } |
| 546 | 555 |
| 547 - (void)loadWebHTMLString:(NSString*)html forURL:(const GURL&)URL { | 556 - (void)loadWebHTMLString:(NSString*)html forURL:(const GURL&)URL { |
| 548 [_wkWebView loadHTMLString:html baseURL:net::NSURLWithGURL(URL)]; | 557 [_wkWebView loadHTMLString:html baseURL:net::NSURLWithGURL(URL)]; |
| 549 } | 558 } |
| 550 | 559 |
| (...skipping 1364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1915 runJavaScriptTextInputPanelWithPrompt:prompt | 1924 runJavaScriptTextInputPanelWithPrompt:prompt |
| 1916 defaultText:defaultText | 1925 defaultText:defaultText |
| 1917 requestURL:requestURL | 1926 requestURL:requestURL |
| 1918 completionHandler:completionHandler]; | 1927 completionHandler:completionHandler]; |
| 1919 } else if (completionHandler) { | 1928 } else if (completionHandler) { |
| 1920 completionHandler(nil); | 1929 completionHandler(nil); |
| 1921 } | 1930 } |
| 1922 } | 1931 } |
| 1923 | 1932 |
| 1924 @end | 1933 @end |
| OLD | NEW |