| 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 491 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 502 // to |WEB_VIEW_DOCUMENT| because it does not support iframe creation used | 502 // to |WEB_VIEW_DOCUMENT| because it does not support iframe creation used |
| 503 // by core.js to communicate back. That functionality is only supported | 503 // by core.js to communicate back. That functionality is only supported |
| 504 // by |WEB_VIEW_HTML_DOCUMENT|. |WEB_VIEW_DOCUMENT| is used when displaying | 504 // by |WEB_VIEW_HTML_DOCUMENT|. |WEB_VIEW_DOCUMENT| is used when displaying |
| 505 // non-HTML contents (e.g. PDF documents). | 505 // non-HTML contents (e.g. PDF documents). |
| 506 - (web::WebViewDocumentType)webViewDocumentType { | 506 - (web::WebViewDocumentType)webViewDocumentType { |
| 507 // This happens during tests. | 507 // This happens during tests. |
| 508 if (!_wkWebView) { | 508 if (!_wkWebView) { |
| 509 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; | 509 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; |
| 510 } | 510 } |
| 511 | 511 |
| 512 std::string mimeType = self.webState->GetContentsMimeType(); | 512 std::string MIMEType = self.webState->GetContentsMimeType(); |
| 513 if (mimeType.empty()) { | 513 return [self documentTypeFromMIMEType:base::SysUTF8ToNSString(MIMEType)]; |
| 514 return web::WEB_VIEW_DOCUMENT_TYPE_UNKNOWN; | |
| 515 } | |
| 516 | |
| 517 if (mimeType == "text/html" || mimeType == "application/xhtml+xml" || | |
| 518 mimeType == "application/xml") { | |
| 519 return web::WEB_VIEW_DOCUMENT_TYPE_HTML; | |
| 520 } | |
| 521 | |
| 522 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; | |
| 523 } | 514 } |
| 524 | 515 |
| 525 - (void)loadRequest:(NSMutableURLRequest*)request { | 516 - (void)loadRequest:(NSMutableURLRequest*)request { |
| 526 [_wkWebView loadRequest:request]; | 517 [_wkWebView loadRequest:request]; |
| 527 } | 518 } |
| 528 | 519 |
| 529 - (void)loadWebHTMLString:(NSString*)html forURL:(const GURL&)URL { | 520 - (void)loadWebHTMLString:(NSString*)html forURL:(const GURL&)URL { |
| 530 [_wkWebView loadHTMLString:html baseURL:net::NSURLWithGURL(URL)]; | 521 [_wkWebView loadHTMLString:html baseURL:net::NSURLWithGURL(URL)]; |
| 531 } | 522 } |
| 532 | 523 |
| (...skipping 1262 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1795 runJavaScriptTextInputPanelWithPrompt:prompt | 1786 runJavaScriptTextInputPanelWithPrompt:prompt |
| 1796 defaultText:defaultText | 1787 defaultText:defaultText |
| 1797 requestURL:requestURL | 1788 requestURL:requestURL |
| 1798 completionHandler:completionHandler]; | 1789 completionHandler:completionHandler]; |
| 1799 } else if (completionHandler) { | 1790 } else if (completionHandler) { |
| 1800 completionHandler(nil); | 1791 completionHandler(nil); |
| 1801 } | 1792 } |
| 1802 } | 1793 } |
| 1803 | 1794 |
| 1804 @end | 1795 @end |
| OLD | NEW |