OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include "chrome/renderer/chrome_content_renderer_client.h" | 5 #include "chrome/renderer/chrome_content_renderer_client.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/crash_logging.h" | 10 #include "base/debug/crash_logging.h" |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 #include "content/public/renderer/render_frame.h" | 84 #include "content/public/renderer/render_frame.h" |
85 #include "content/public/renderer/render_thread.h" | 85 #include "content/public/renderer/render_thread.h" |
86 #include "content/public/renderer/render_view.h" | 86 #include "content/public/renderer/render_view.h" |
87 #include "content/public/renderer/render_view_visitor.h" | 87 #include "content/public/renderer/render_view_visitor.h" |
88 #include "extensions/common/constants.h" | 88 #include "extensions/common/constants.h" |
89 #include "ipc/ipc_sync_channel.h" | 89 #include "ipc/ipc_sync_channel.h" |
90 #include "net/base/net_errors.h" | 90 #include "net/base/net_errors.h" |
91 #include "ppapi/c/private/ppb_pdf.h" | 91 #include "ppapi/c/private/ppb_pdf.h" |
92 #include "ppapi/shared_impl/ppapi_switches.h" | 92 #include "ppapi/shared_impl/ppapi_switches.h" |
93 #include "third_party/WebKit/public/platform/URLConversion.h" | 93 #include "third_party/WebKit/public/platform/URLConversion.h" |
| 94 #include "third_party/WebKit/public/platform/WebCachePolicy.h" |
94 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" | 95 #include "third_party/WebKit/public/platform/WebSecurityOrigin.h" |
95 #include "third_party/WebKit/public/platform/WebURL.h" | 96 #include "third_party/WebKit/public/platform/WebURL.h" |
96 #include "third_party/WebKit/public/platform/WebURLError.h" | 97 #include "third_party/WebKit/public/platform/WebURLError.h" |
97 #include "third_party/WebKit/public/platform/WebURLRequest.h" | 98 #include "third_party/WebKit/public/platform/WebURLRequest.h" |
98 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 99 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
99 #include "third_party/WebKit/public/web/WebCache.h" | 100 #include "third_party/WebKit/public/web/WebCache.h" |
100 #include "third_party/WebKit/public/web/WebDataSource.h" | 101 #include "third_party/WebKit/public/web/WebDataSource.h" |
101 #include "third_party/WebKit/public/web/WebDocument.h" | 102 #include "third_party/WebKit/public/web/WebDocument.h" |
102 #include "third_party/WebKit/public/web/WebElement.h" | 103 #include "third_party/WebKit/public/web/WebElement.h" |
103 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 104 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 #if defined(ENABLE_WEBRTC) | 153 #if defined(ENABLE_WEBRTC) |
153 #include "chrome/renderer/media/webrtc_logging_message_filter.h" | 154 #include "chrome/renderer/media/webrtc_logging_message_filter.h" |
154 #endif | 155 #endif |
155 | 156 |
156 using autofill::AutofillAgent; | 157 using autofill::AutofillAgent; |
157 using autofill::PasswordAutofillAgent; | 158 using autofill::PasswordAutofillAgent; |
158 using autofill::PasswordGenerationAgent; | 159 using autofill::PasswordGenerationAgent; |
159 using base::ASCIIToUTF16; | 160 using base::ASCIIToUTF16; |
160 using base::UserMetricsAction; | 161 using base::UserMetricsAction; |
161 using blink::WebCache; | 162 using blink::WebCache; |
| 163 using blink::WebCachePolicy; |
162 using blink::WebConsoleMessage; | 164 using blink::WebConsoleMessage; |
163 using blink::WebDataSource; | 165 using blink::WebDataSource; |
164 using blink::WebDocument; | 166 using blink::WebDocument; |
| 167 using blink::WebFrame; |
165 using blink::WebLocalFrame; | 168 using blink::WebLocalFrame; |
166 using blink::WebPlugin; | 169 using blink::WebPlugin; |
167 using blink::WebPluginParams; | 170 using blink::WebPluginParams; |
168 using blink::WebSecurityOrigin; | 171 using blink::WebSecurityOrigin; |
169 using blink::WebSecurityPolicy; | 172 using blink::WebSecurityPolicy; |
170 using blink::WebString; | 173 using blink::WebString; |
171 using blink::WebURL; | 174 using blink::WebURL; |
172 using blink::WebURLError; | 175 using blink::WebURLError; |
173 using blink::WebURLRequest; | 176 using blink::WebURLRequest; |
174 using blink::WebURLResponse; | 177 using blink::WebURLResponse; |
(...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
544 GetImageNamed(IDR_SAD_PLUGIN).ToSkBitmap()); | 547 GetImageNamed(IDR_SAD_PLUGIN).ToSkBitmap()); |
545 } | 548 } |
546 | 549 |
547 SkBitmap* ChromeContentRendererClient::GetSadWebViewBitmap() { | 550 SkBitmap* ChromeContentRendererClient::GetSadWebViewBitmap() { |
548 return const_cast<SkBitmap*>(ResourceBundle::GetSharedInstance(). | 551 return const_cast<SkBitmap*>(ResourceBundle::GetSharedInstance(). |
549 GetImageNamed(IDR_SAD_WEBVIEW).ToSkBitmap()); | 552 GetImageNamed(IDR_SAD_WEBVIEW).ToSkBitmap()); |
550 } | 553 } |
551 | 554 |
552 bool ChromeContentRendererClient::OverrideCreatePlugin( | 555 bool ChromeContentRendererClient::OverrideCreatePlugin( |
553 content::RenderFrame* render_frame, | 556 content::RenderFrame* render_frame, |
554 blink::WebLocalFrame* frame, | 557 WebLocalFrame* frame, |
555 const WebPluginParams& params, | 558 const WebPluginParams& params, |
556 WebPlugin** plugin) { | 559 WebPlugin** plugin) { |
557 std::string orig_mime_type = params.mimeType.utf8(); | 560 std::string orig_mime_type = params.mimeType.utf8(); |
558 #if defined(ENABLE_EXTENSIONS) | 561 #if defined(ENABLE_EXTENSIONS) |
559 if (!ChromeExtensionsRendererClient::GetInstance()->OverrideCreatePlugin( | 562 if (!ChromeExtensionsRendererClient::GetInstance()->OverrideCreatePlugin( |
560 render_frame, params)) { | 563 render_frame, params)) { |
561 return false; | 564 return false; |
562 } | 565 } |
563 #endif | 566 #endif |
564 | 567 |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
617 new MediaLoadDeferrer(render_frame, closure); | 620 new MediaLoadDeferrer(render_frame, closure); |
618 return; | 621 return; |
619 } | 622 } |
620 | 623 |
621 closure.Run(); | 624 closure.Run(); |
622 } | 625 } |
623 | 626 |
624 #if defined(ENABLE_PLUGINS) | 627 #if defined(ENABLE_PLUGINS) |
625 WebPlugin* ChromeContentRendererClient::CreatePlugin( | 628 WebPlugin* ChromeContentRendererClient::CreatePlugin( |
626 content::RenderFrame* render_frame, | 629 content::RenderFrame* render_frame, |
627 blink::WebLocalFrame* frame, | 630 WebLocalFrame* frame, |
628 const WebPluginParams& original_params, | 631 const WebPluginParams& original_params, |
629 const ChromeViewHostMsg_GetPluginInfo_Output& output) { | 632 const ChromeViewHostMsg_GetPluginInfo_Output& output) { |
630 const WebPluginInfo& info = output.plugin; | 633 const WebPluginInfo& info = output.plugin; |
631 const std::string& actual_mime_type = output.actual_mime_type; | 634 const std::string& actual_mime_type = output.actual_mime_type; |
632 const base::string16& group_name = output.group_name; | 635 const base::string16& group_name = output.group_name; |
633 const std::string& identifier = output.group_identifier; | 636 const std::string& identifier = output.group_identifier; |
634 ChromeViewHostMsg_GetPluginInfo_Status status = output.status; | 637 ChromeViewHostMsg_GetPluginInfo_Status status = output.status; |
635 GURL url(original_params.url); | 638 GURL url(original_params.url); |
636 std::string orig_mime_type = original_params.mimeType.utf8(); | 639 std::string orig_mime_type = original_params.mimeType.utf8(); |
637 ChromePluginPlaceholder* placeholder = NULL; | 640 ChromePluginPlaceholder* placeholder = NULL; |
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1014 if (render_frame && | 1017 if (render_frame && |
1015 NetErrorHelper::Get(render_frame)->ShouldSuppressErrorPage(url)) { | 1018 NetErrorHelper::Get(render_frame)->ShouldSuppressErrorPage(url)) { |
1016 return true; | 1019 return true; |
1017 } | 1020 } |
1018 // Do not flash an error page if the Instant new tab page fails to load. | 1021 // Do not flash an error page if the Instant new tab page fails to load. |
1019 return SearchBouncer::GetInstance()->IsNewTabPage(url); | 1022 return SearchBouncer::GetInstance()->IsNewTabPage(url); |
1020 } | 1023 } |
1021 | 1024 |
1022 void ChromeContentRendererClient::GetNavigationErrorStrings( | 1025 void ChromeContentRendererClient::GetNavigationErrorStrings( |
1023 content::RenderFrame* render_frame, | 1026 content::RenderFrame* render_frame, |
1024 const blink::WebURLRequest& failed_request, | 1027 const WebURLRequest& failed_request, |
1025 const blink::WebURLError& error, | 1028 const WebURLError& error, |
1026 std::string* error_html, | 1029 std::string* error_html, |
1027 base::string16* error_description) { | 1030 base::string16* error_description) { |
1028 const GURL failed_url = error.unreachableURL; | 1031 const GURL failed_url = error.unreachableURL; |
1029 | 1032 |
1030 bool is_post = base::EqualsASCII( | 1033 bool is_post = base::EqualsASCII( |
1031 base::StringPiece16(failed_request.httpMethod()), "POST"); | 1034 base::StringPiece16(failed_request.httpMethod()), "POST"); |
1032 bool is_ignoring_cache = | 1035 bool is_ignoring_cache = |
1033 failed_request.getCachePolicy() == blink::WebURLRequest::BypassingCache; | 1036 failed_request.getCachePolicy() == WebCachePolicy::BypassingCache; |
1034 if (error_html) { | 1037 if (error_html) { |
1035 NetErrorHelper::Get(render_frame) | 1038 NetErrorHelper::Get(render_frame) |
1036 ->GetErrorHTML(error, is_post, is_ignoring_cache, error_html); | 1039 ->GetErrorHTML(error, is_post, is_ignoring_cache, error_html); |
1037 } | 1040 } |
1038 | 1041 |
1039 if (error_description) { | 1042 if (error_description) { |
1040 *error_description = error_page::LocalizedError::GetErrorDetails( | 1043 *error_description = error_page::LocalizedError::GetErrorDetails( |
1041 error.domain.utf8(), error.reason, is_post); | 1044 error.domain.utf8(), error.reason, is_post); |
1042 } | 1045 } |
1043 } | 1046 } |
(...skipping 16 matching lines...) Expand all Loading... |
1060 } | 1063 } |
1061 | 1064 |
1062 bool ChromeContentRendererClient::AllowPopup() { | 1065 bool ChromeContentRendererClient::AllowPopup() { |
1063 #if defined(ENABLE_EXTENSIONS) | 1066 #if defined(ENABLE_EXTENSIONS) |
1064 return ChromeExtensionsRendererClient::GetInstance()->AllowPopup(); | 1067 return ChromeExtensionsRendererClient::GetInstance()->AllowPopup(); |
1065 #else | 1068 #else |
1066 return false; | 1069 return false; |
1067 #endif | 1070 #endif |
1068 } | 1071 } |
1069 | 1072 |
1070 bool ChromeContentRendererClient::ShouldFork(blink::WebLocalFrame* frame, | 1073 bool ChromeContentRendererClient::ShouldFork(WebLocalFrame* frame, |
1071 const GURL& url, | 1074 const GURL& url, |
1072 const std::string& http_method, | 1075 const std::string& http_method, |
1073 bool is_initial_navigation, | 1076 bool is_initial_navigation, |
1074 bool is_server_redirect, | 1077 bool is_server_redirect, |
1075 bool* send_referrer) { | 1078 bool* send_referrer) { |
1076 DCHECK(!frame->parent()); | 1079 DCHECK(!frame->parent()); |
1077 | 1080 |
1078 // If this is the Instant process, fork all navigations originating from the | 1081 // If this is the Instant process, fork all navigations originating from the |
1079 // renderer. The destination page will then be bucketed back to this Instant | 1082 // renderer. The destination page will then be bucketed back to this Instant |
1080 // process if it is an Instant url, or to another process if not. Conversely, | 1083 // process if it is an Instant url, or to another process if not. Conversely, |
(...skipping 27 matching lines...) Expand all Loading... |
1108 bool should_fork = ChromeExtensionsRendererClient::ShouldFork( | 1111 bool should_fork = ChromeExtensionsRendererClient::ShouldFork( |
1109 frame, url, is_initial_navigation, is_server_redirect, send_referrer); | 1112 frame, url, is_initial_navigation, is_server_redirect, send_referrer); |
1110 if (should_fork) | 1113 if (should_fork) |
1111 return true; | 1114 return true; |
1112 #endif // defined(ENABLE_EXTENSIONS) | 1115 #endif // defined(ENABLE_EXTENSIONS) |
1113 | 1116 |
1114 return false; | 1117 return false; |
1115 } | 1118 } |
1116 | 1119 |
1117 bool ChromeContentRendererClient::WillSendRequest( | 1120 bool ChromeContentRendererClient::WillSendRequest( |
1118 blink::WebFrame* frame, | 1121 WebFrame* frame, |
1119 ui::PageTransition transition_type, | 1122 ui::PageTransition transition_type, |
1120 const GURL& url, | 1123 const GURL& url, |
1121 const GURL& first_party_for_cookies, | 1124 const GURL& first_party_for_cookies, |
1122 GURL* new_url) { | 1125 GURL* new_url) { |
1123 // Check whether the request should be allowed. If not allowed, we reset the | 1126 // Check whether the request should be allowed. If not allowed, we reset the |
1124 // URL to something invalid to prevent the request and cause an error. | 1127 // URL to something invalid to prevent the request and cause an error. |
1125 #if defined(ENABLE_EXTENSIONS) | 1128 #if defined(ENABLE_EXTENSIONS) |
1126 if (ChromeExtensionsRendererClient::GetInstance()->WillSendRequest( | 1129 if (ChromeExtensionsRendererClient::GetInstance()->WillSendRequest( |
1127 frame, transition_type, url, new_url)) { | 1130 frame, transition_type, url, new_url)) { |
1128 return true; | 1131 return true; |
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1262 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 1265 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
1263 return !command_line->HasSwitch(extensions::switches::kExtensionProcess); | 1266 return !command_line->HasSwitch(extensions::switches::kExtensionProcess); |
1264 #else | 1267 #else |
1265 return true; | 1268 return true; |
1266 #endif | 1269 #endif |
1267 } | 1270 } |
1268 | 1271 |
1269 blink::WebWorkerContentSettingsClientProxy* | 1272 blink::WebWorkerContentSettingsClientProxy* |
1270 ChromeContentRendererClient::CreateWorkerContentSettingsClientProxy( | 1273 ChromeContentRendererClient::CreateWorkerContentSettingsClientProxy( |
1271 content::RenderFrame* render_frame, | 1274 content::RenderFrame* render_frame, |
1272 blink::WebFrame* frame) { | 1275 WebFrame* frame) { |
1273 return new WorkerContentSettingsClientProxy(render_frame, frame); | 1276 return new WorkerContentSettingsClientProxy(render_frame, frame); |
1274 } | 1277 } |
1275 | 1278 |
1276 bool ChromeContentRendererClient::IsPluginAllowedToUseDevChannelAPIs() { | 1279 bool ChromeContentRendererClient::IsPluginAllowedToUseDevChannelAPIs() { |
1277 #if defined(ENABLE_PLUGINS) | 1280 #if defined(ENABLE_PLUGINS) |
1278 // Allow access for tests. | 1281 // Allow access for tests. |
1279 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1282 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
1280 switches::kEnablePepperTesting)) { | 1283 switches::kEnablePepperTesting)) { |
1281 return true; | 1284 return true; |
1282 } | 1285 } |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1345 } | 1348 } |
1346 | 1349 |
1347 scoped_ptr<blink::WebAppBannerClient> | 1350 scoped_ptr<blink::WebAppBannerClient> |
1348 ChromeContentRendererClient::CreateAppBannerClient( | 1351 ChromeContentRendererClient::CreateAppBannerClient( |
1349 content::RenderFrame* render_frame) { | 1352 content::RenderFrame* render_frame) { |
1350 return scoped_ptr<blink::WebAppBannerClient>( | 1353 return scoped_ptr<blink::WebAppBannerClient>( |
1351 new AppBannerClient(render_frame)); | 1354 new AppBannerClient(render_frame)); |
1352 } | 1355 } |
1353 | 1356 |
1354 void ChromeContentRendererClient::AddImageContextMenuProperties( | 1357 void ChromeContentRendererClient::AddImageContextMenuProperties( |
1355 const blink::WebURLResponse& response, | 1358 const WebURLResponse& response, |
1356 std::map<std::string, std::string>* properties) { | 1359 std::map<std::string, std::string>* properties) { |
1357 DCHECK(properties); | 1360 DCHECK(properties); |
1358 WebString header_key(ASCIIToUTF16( | 1361 WebString header_key(ASCIIToUTF16( |
1359 data_reduction_proxy::chrome_proxy_header())); | 1362 data_reduction_proxy::chrome_proxy_header())); |
1360 if (!response.httpHeaderField(header_key).isNull() && | 1363 if (!response.httpHeaderField(header_key).isNull() && |
1361 response.httpHeaderField(header_key).utf8().find( | 1364 response.httpHeaderField(header_key).utf8().find( |
1362 data_reduction_proxy::chrome_proxy_lo_fi_directive()) != | 1365 data_reduction_proxy::chrome_proxy_lo_fi_directive()) != |
1363 std::string::npos) { | 1366 std::string::npos) { |
1364 (*properties)[data_reduction_proxy::chrome_proxy_header()] = | 1367 (*properties)[data_reduction_proxy::chrome_proxy_header()] = |
1365 data_reduction_proxy::chrome_proxy_lo_fi_directive(); | 1368 data_reduction_proxy::chrome_proxy_lo_fi_directive(); |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1407 // chrome.system.network.getNetworkInterfaces provides the same | 1410 // chrome.system.network.getNetworkInterfaces provides the same |
1408 // information. Also, the enforcement of sending and binding UDP is already done | 1411 // information. Also, the enforcement of sending and binding UDP is already done |
1409 // by chrome extension permission model. | 1412 // by chrome extension permission model. |
1410 bool ChromeContentRendererClient::ShouldEnforceWebRTCRoutingPreferences() { | 1413 bool ChromeContentRendererClient::ShouldEnforceWebRTCRoutingPreferences() { |
1411 #if defined(ENABLE_EXTENSIONS) | 1414 #if defined(ENABLE_EXTENSIONS) |
1412 return !IsStandaloneExtensionProcess(); | 1415 return !IsStandaloneExtensionProcess(); |
1413 #else | 1416 #else |
1414 return true; | 1417 return true; |
1415 #endif | 1418 #endif |
1416 } | 1419 } |
OLD | NEW |