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_ui_web_view_web_controller.h" | 5 #import "ios/web/web_state/ui/crw_ui_web_view_web_controller.h" |
6 | 6 |
7 #import "base/ios/ns_error_util.h" | 7 #import "base/ios/ns_error_util.h" |
8 #import "base/ios/weak_nsobject.h" | 8 #import "base/ios/weak_nsobject.h" |
9 #include "base/json/json_reader.h" | 9 #include "base/json/json_reader.h" |
10 #include "base/json/string_escape.h" | 10 #include "base/json/string_escape.h" |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
543 // The core.js cannot pass messages back to obj-c if it is injected | 543 // The core.js cannot pass messages back to obj-c if it is injected |
544 // to |WEB_VIEW_DOCUMENT| because it does not support iframe creation used | 544 // to |WEB_VIEW_DOCUMENT| because it does not support iframe creation used |
545 // by core.js to communicate back. That functionality is only supported | 545 // by core.js to communicate back. That functionality is only supported |
546 // by |WEB_VIEW_HTML_DOCUMENT|. |WEB_VIEW_DOCUMENT| is used when displaying | 546 // by |WEB_VIEW_HTML_DOCUMENT|. |WEB_VIEW_DOCUMENT| is used when displaying |
547 // non-HTML contents (e.g. PDF documents). | 547 // non-HTML contents (e.g. PDF documents). |
548 - (web::WebViewDocumentType)webViewDocumentType { | 548 - (web::WebViewDocumentType)webViewDocumentType { |
549 // This happens during tests. | 549 // This happens during tests. |
550 if (!_uiWebView) { | 550 if (!_uiWebView) { |
551 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; | 551 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; |
552 } | 552 } |
553 NSString* documentType = | 553 |
554 [_uiWebView stringByEvaluatingJavaScriptFromString: | 554 if (base::ios::IsRunningOnIOS9OrLater()) { |
Eugene But (OOO till 7-30)
2015/11/18 16:30:57
Please explain in the comments why iOS9 implementa
stkhapugin
2015/11/19 16:16:35
Done.
| |
555 @"'' + document"]; | 555 NSString* documentType = [_uiWebView |
556 if ([documentType isEqualToString:@"[object HTMLDocument]"]) | 556 stringByEvaluatingJavaScriptFromString:@"document.contentType"]; |
557 return web::WEB_VIEW_DOCUMENT_TYPE_HTML; | 557 if ([documentType isEqualToString:@"text/html"]) |
Eugene But (OOO till 7-30)
2015/11/18 16:30:57
I think you also want to check for "application/xh
stkhapugin
2015/11/19 16:16:35
Done.
| |
558 else if ([documentType isEqualToString:@"[object Document]"]) | 558 return web::WEB_VIEW_DOCUMENT_TYPE_HTML; |
559 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; | 559 else if ([documentType isEqualToString:@"application/pdf"]) |
560 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; | |
561 } else { | |
562 NSString* documentType = | |
563 [_uiWebView stringByEvaluatingJavaScriptFromString:@"'' + document"]; | |
564 if ([documentType isEqualToString:@"[object HTMLDocument]"]) | |
565 return web::WEB_VIEW_DOCUMENT_TYPE_HTML; | |
566 else if ([documentType isEqualToString:@"[object Document]"]) | |
567 return web::WEB_VIEW_DOCUMENT_TYPE_GENERIC; | |
568 } | |
569 | |
560 return web::WEB_VIEW_DOCUMENT_TYPE_UNKNOWN; | 570 return web::WEB_VIEW_DOCUMENT_TYPE_UNKNOWN; |
561 } | 571 } |
562 | 572 |
563 - (void)loadRequest:(NSMutableURLRequest*)request { | 573 - (void)loadRequest:(NSMutableURLRequest*)request { |
564 DCHECK(web::GetWebClient()); | 574 DCHECK(web::GetWebClient()); |
565 GURL requestURL = net::GURLWithNSURL(request.URL); | 575 GURL requestURL = net::GURLWithNSURL(request.URL); |
566 // If the request is for WebUI, add information to let the network stack | 576 // If the request is for WebUI, add information to let the network stack |
567 // access the requestGroupID. | 577 // access the requestGroupID. |
568 if (web::GetWebClient()->IsAppSpecificURL(requestURL)) { | 578 if (web::GetWebClient()->IsAppSpecificURL(requestURL)) { |
569 // Sub requests of a chrome:// page will not contain the user agent. | 579 // Sub requests of a chrome:// page will not contain the user agent. |
(...skipping 984 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1554 } | 1564 } |
1555 | 1565 |
1556 #pragma mark - | 1566 #pragma mark - |
1557 #pragma mark Testing methods | 1567 #pragma mark Testing methods |
1558 | 1568 |
1559 -(id<CRWRecurringTaskDelegate>)recurringTaskDelegate { | 1569 -(id<CRWRecurringTaskDelegate>)recurringTaskDelegate { |
1560 return _recurringTaskDelegate; | 1570 return _recurringTaskDelegate; |
1561 } | 1571 } |
1562 | 1572 |
1563 @end | 1573 @end |
OLD | NEW |