Chromium Code Reviews| 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 401 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1039 if (render_frame && | 1042 if (render_frame && |
| 1040 NetErrorHelper::Get(render_frame)->ShouldSuppressErrorPage(url)) { | 1043 NetErrorHelper::Get(render_frame)->ShouldSuppressErrorPage(url)) { |
| 1041 return true; | 1044 return true; |
| 1042 } | 1045 } |
| 1043 // Do not flash an error page if the Instant new tab page fails to load. | 1046 // Do not flash an error page if the Instant new tab page fails to load. |
| 1044 return SearchBouncer::GetInstance()->IsNewTabPage(url); | 1047 return SearchBouncer::GetInstance()->IsNewTabPage(url); |
| 1045 } | 1048 } |
| 1046 | 1049 |
| 1047 void ChromeContentRendererClient::GetNavigationErrorStrings( | 1050 void ChromeContentRendererClient::GetNavigationErrorStrings( |
| 1048 content::RenderFrame* render_frame, | 1051 content::RenderFrame* render_frame, |
| 1049 const blink::WebURLRequest& failed_request, | 1052 const WebURLRequest& failed_request, |
| 1050 const blink::WebURLError& error, | 1053 const WebURLError& error, |
| 1051 std::string* error_html, | 1054 std::string* error_html, |
| 1052 base::string16* error_description) { | 1055 base::string16* error_description) { |
| 1053 const GURL failed_url = error.unreachableURL; | 1056 const GURL failed_url = error.unreachableURL; |
| 1054 | 1057 |
| 1055 bool is_post = base::EqualsASCII( | 1058 bool is_post = base::EqualsASCII( |
| 1056 base::StringPiece16(failed_request.httpMethod()), "POST"); | 1059 base::StringPiece16(failed_request.httpMethod()), "POST"); |
| 1057 bool is_ignoring_cache = | 1060 bool is_ignoring_cache = |
| 1058 failed_request.getCachePolicy() == blink::WebURLRequest::BypassingCache; | 1061 failed_request.getCachePolicy() == WebCachePolicy::BypassingCache; |
| 1059 if (error_html) { | 1062 if (error_html) { |
| 1060 NetErrorHelper::Get(render_frame) | 1063 NetErrorHelper::Get(render_frame) |
| 1061 ->GetErrorHTML(error, is_post, is_ignoring_cache, error_html); | 1064 ->GetErrorHTML(error, is_post, is_ignoring_cache, error_html); |
| 1062 } | 1065 } |
| 1063 | 1066 |
| 1064 if (error_description) { | 1067 if (error_description) { |
| 1065 *error_description = error_page::LocalizedError::GetErrorDetails( | 1068 *error_description = error_page::LocalizedError::GetErrorDetails( |
| 1066 error.domain.utf8(), error.reason, is_post); | 1069 error.domain.utf8(), error.reason, is_post); |
| 1067 } | 1070 } |
| 1068 } | 1071 } |
| (...skipping 16 matching lines...) Expand all Loading... | |
| 1085 } | 1088 } |
| 1086 | 1089 |
| 1087 bool ChromeContentRendererClient::AllowPopup() { | 1090 bool ChromeContentRendererClient::AllowPopup() { |
| 1088 #if defined(ENABLE_EXTENSIONS) | 1091 #if defined(ENABLE_EXTENSIONS) |
| 1089 return ChromeExtensionsRendererClient::GetInstance()->AllowPopup(); | 1092 return ChromeExtensionsRendererClient::GetInstance()->AllowPopup(); |
| 1090 #else | 1093 #else |
| 1091 return false; | 1094 return false; |
| 1092 #endif | 1095 #endif |
| 1093 } | 1096 } |
| 1094 | 1097 |
| 1095 bool ChromeContentRendererClient::ShouldFork(blink::WebLocalFrame* frame, | 1098 bool ChromeContentRendererClient::ShouldFork(WebLocalFrame* frame, |
| 1096 const GURL& url, | 1099 const GURL& url, |
| 1097 const std::string& http_method, | 1100 const std::string& http_method, |
| 1098 bool is_initial_navigation, | 1101 bool is_initial_navigation, |
| 1099 bool is_server_redirect, | 1102 bool is_server_redirect, |
| 1100 bool* send_referrer) { | 1103 bool* send_referrer) { |
| 1101 DCHECK(!frame->parent()); | 1104 DCHECK(!frame->parent()); |
| 1102 | 1105 |
| 1103 // If this is the Instant process, fork all navigations originating from the | 1106 // If this is the Instant process, fork all navigations originating from the |
| 1104 // renderer. The destination page will then be bucketed back to this Instant | 1107 // renderer. The destination page will then be bucketed back to this Instant |
| 1105 // process if it is an Instant url, or to another process if not. Conversely, | 1108 // process if it is an Instant url, or to another process if not. Conversely, |
| (...skipping 27 matching lines...) Expand all Loading... | |
| 1133 bool should_fork = ChromeExtensionsRendererClient::ShouldFork( | 1136 bool should_fork = ChromeExtensionsRendererClient::ShouldFork( |
| 1134 frame, url, is_initial_navigation, is_server_redirect, send_referrer); | 1137 frame, url, is_initial_navigation, is_server_redirect, send_referrer); |
| 1135 if (should_fork) | 1138 if (should_fork) |
| 1136 return true; | 1139 return true; |
| 1137 #endif // defined(ENABLE_EXTENSIONS) | 1140 #endif // defined(ENABLE_EXTENSIONS) |
| 1138 | 1141 |
| 1139 return false; | 1142 return false; |
| 1140 } | 1143 } |
| 1141 | 1144 |
| 1142 bool ChromeContentRendererClient::WillSendRequest( | 1145 bool ChromeContentRendererClient::WillSendRequest( |
| 1143 blink::WebFrame* frame, | 1146 WebFrame* frame, |
| 1144 ui::PageTransition transition_type, | 1147 ui::PageTransition transition_type, |
| 1145 const GURL& url, | 1148 const GURL& url, |
| 1146 const GURL& first_party_for_cookies, | 1149 const GURL& first_party_for_cookies, |
| 1147 GURL* new_url) { | 1150 GURL* new_url) { |
| 1148 // Check whether the request should be allowed. If not allowed, we reset the | 1151 // Check whether the request should be allowed. If not allowed, we reset the |
|
hiroshige
2016/04/07 06:30:32
nit: spaces here shouldn't be removed?
Takashi Toyoshima
2016/04/08 04:41:48
Oh, thanks!
It seems "git cl format" was confused.
| |
| 1149 // URL to something invalid to prevent the request and cause an error. | 1152 // URL to something invalid to prevent the request and cause an error. |
| 1150 #if defined(ENABLE_EXTENSIONS) | 1153 #if defined(ENABLE_EXTENSIONS) |
| 1151 if (ChromeExtensionsRendererClient::GetInstance()->WillSendRequest( | 1154 if (ChromeExtensionsRendererClient::GetInstance()->WillSendRequest( |
| 1152 frame, transition_type, url, new_url)) { | 1155 frame, transition_type, url, new_url)) { |
| 1153 return true; | 1156 return true; |
| 1154 } | 1157 } |
| 1155 #endif | 1158 #endif |
| 1156 | 1159 |
| 1157 const content::RenderView* render_view = | 1160 const content::RenderView* render_view = |
| 1158 content::RenderView::FromWebView(frame->view()); | 1161 content::RenderView::FromWebView(frame->view()); |
| 1159 SearchBox* search_box = SearchBox::Get(render_view); | 1162 SearchBox* search_box = SearchBox::Get(render_view); |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1287 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); | 1290 base::CommandLine* command_line = base::CommandLine::ForCurrentProcess(); |
| 1288 return !command_line->HasSwitch(extensions::switches::kExtensionProcess); | 1291 return !command_line->HasSwitch(extensions::switches::kExtensionProcess); |
| 1289 #else | 1292 #else |
| 1290 return true; | 1293 return true; |
| 1291 #endif | 1294 #endif |
| 1292 } | 1295 } |
| 1293 | 1296 |
| 1294 blink::WebWorkerContentSettingsClientProxy* | 1297 blink::WebWorkerContentSettingsClientProxy* |
| 1295 ChromeContentRendererClient::CreateWorkerContentSettingsClientProxy( | 1298 ChromeContentRendererClient::CreateWorkerContentSettingsClientProxy( |
| 1296 content::RenderFrame* render_frame, | 1299 content::RenderFrame* render_frame, |
| 1297 blink::WebFrame* frame) { | 1300 WebFrame* frame) { |
| 1298 return new WorkerContentSettingsClientProxy(render_frame, frame); | 1301 return new WorkerContentSettingsClientProxy(render_frame, frame); |
| 1299 } | 1302 } |
| 1300 | 1303 |
| 1301 bool ChromeContentRendererClient::IsPluginAllowedToUseDevChannelAPIs() { | 1304 bool ChromeContentRendererClient::IsPluginAllowedToUseDevChannelAPIs() { |
| 1302 #if defined(ENABLE_PLUGINS) | 1305 #if defined(ENABLE_PLUGINS) |
| 1303 // Allow access for tests. | 1306 // Allow access for tests. |
| 1304 if (base::CommandLine::ForCurrentProcess()->HasSwitch( | 1307 if (base::CommandLine::ForCurrentProcess()->HasSwitch( |
| 1305 switches::kEnablePepperTesting)) { | 1308 switches::kEnablePepperTesting)) { |
| 1306 return true; | 1309 return true; |
| 1307 } | 1310 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1370 } | 1373 } |
| 1371 | 1374 |
| 1372 scoped_ptr<blink::WebAppBannerClient> | 1375 scoped_ptr<blink::WebAppBannerClient> |
| 1373 ChromeContentRendererClient::CreateAppBannerClient( | 1376 ChromeContentRendererClient::CreateAppBannerClient( |
| 1374 content::RenderFrame* render_frame) { | 1377 content::RenderFrame* render_frame) { |
| 1375 return scoped_ptr<blink::WebAppBannerClient>( | 1378 return scoped_ptr<blink::WebAppBannerClient>( |
| 1376 new AppBannerClient(render_frame)); | 1379 new AppBannerClient(render_frame)); |
| 1377 } | 1380 } |
| 1378 | 1381 |
| 1379 void ChromeContentRendererClient::AddImageContextMenuProperties( | 1382 void ChromeContentRendererClient::AddImageContextMenuProperties( |
| 1380 const blink::WebURLResponse& response, | 1383 const WebURLResponse& response, |
| 1381 std::map<std::string, std::string>* properties) { | 1384 std::map<std::string, std::string>* properties) { |
| 1382 DCHECK(properties); | 1385 DCHECK(properties); |
| 1383 WebString header_key(ASCIIToUTF16( | 1386 WebString header_key(ASCIIToUTF16( |
| 1384 data_reduction_proxy::chrome_proxy_header())); | 1387 data_reduction_proxy::chrome_proxy_header())); |
| 1385 if (!response.httpHeaderField(header_key).isNull() && | 1388 if (!response.httpHeaderField(header_key).isNull() && |
| 1386 response.httpHeaderField(header_key).utf8().find( | 1389 response.httpHeaderField(header_key).utf8().find( |
| 1387 data_reduction_proxy::chrome_proxy_lo_fi_directive()) != | 1390 data_reduction_proxy::chrome_proxy_lo_fi_directive()) != |
| 1388 std::string::npos) { | 1391 std::string::npos) { |
| 1389 (*properties)[data_reduction_proxy::chrome_proxy_header()] = | 1392 (*properties)[data_reduction_proxy::chrome_proxy_header()] = |
| 1390 data_reduction_proxy::chrome_proxy_lo_fi_directive(); | 1393 data_reduction_proxy::chrome_proxy_lo_fi_directive(); |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1432 // chrome.system.network.getNetworkInterfaces provides the same | 1435 // chrome.system.network.getNetworkInterfaces provides the same |
| 1433 // information. Also, the enforcement of sending and binding UDP is already done | 1436 // information. Also, the enforcement of sending and binding UDP is already done |
| 1434 // by chrome extension permission model. | 1437 // by chrome extension permission model. |
| 1435 bool ChromeContentRendererClient::ShouldEnforceWebRTCRoutingPreferences() { | 1438 bool ChromeContentRendererClient::ShouldEnforceWebRTCRoutingPreferences() { |
| 1436 #if defined(ENABLE_EXTENSIONS) | 1439 #if defined(ENABLE_EXTENSIONS) |
| 1437 return !IsStandaloneExtensionProcess(); | 1440 return !IsStandaloneExtensionProcess(); |
| 1438 #else | 1441 #else |
| 1439 return true; | 1442 return true; |
| 1440 #endif | 1443 #endif |
| 1441 } | 1444 } |
| OLD | NEW |