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 "base/command_line.h" | 7 #include "base/command_line.h" |
8 #include "base/debug/crash_logging.h" | 8 #include "base/debug/crash_logging.h" |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 using blink::WebURLResponse; | 134 using blink::WebURLResponse; |
135 using blink::WebVector; | 135 using blink::WebVector; |
136 | 136 |
137 namespace { | 137 namespace { |
138 | 138 |
139 const char kWebViewTagName[] = "WEBVIEW"; | 139 const char kWebViewTagName[] = "WEBVIEW"; |
140 const char kAdViewTagName[] = "ADVIEW"; | 140 const char kAdViewTagName[] = "ADVIEW"; |
141 | 141 |
142 ChromeContentRendererClient* g_current_client; | 142 ChromeContentRendererClient* g_current_client; |
143 | 143 |
144 static void AppendParams(const std::vector<string16>& additional_names, | 144 static void AppendParams(const std::vector<base::string16>& additional_names, |
145 const std::vector<string16>& additional_values, | 145 const std::vector<base::string16>& additional_values, |
146 WebVector<WebString>* existing_names, | 146 WebVector<WebString>* existing_names, |
147 WebVector<WebString>* existing_values) { | 147 WebVector<WebString>* existing_values) { |
148 DCHECK(additional_names.size() == additional_values.size()); | 148 DCHECK(additional_names.size() == additional_values.size()); |
149 DCHECK(existing_names->size() == existing_values->size()); | 149 DCHECK(existing_names->size() == existing_values->size()); |
150 | 150 |
151 size_t existing_size = existing_names->size(); | 151 size_t existing_size = existing_names->size(); |
152 size_t total_size = existing_size + additional_names.size(); | 152 size_t total_size = existing_size + additional_names.size(); |
153 | 153 |
154 WebVector<WebString> names(total_size); | 154 WebVector<WebString> names(total_size); |
155 WebVector<WebString> values(total_size); | 155 WebVector<WebString> values(total_size); |
(...skipping 322 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
478 } | 478 } |
479 | 479 |
480 WebPlugin* ChromeContentRendererClient::CreatePlugin( | 480 WebPlugin* ChromeContentRendererClient::CreatePlugin( |
481 content::RenderView* render_view, | 481 content::RenderView* render_view, |
482 WebFrame* frame, | 482 WebFrame* frame, |
483 const WebPluginParams& original_params, | 483 const WebPluginParams& original_params, |
484 const ChromeViewHostMsg_GetPluginInfo_Output& output) { | 484 const ChromeViewHostMsg_GetPluginInfo_Output& output) { |
485 const ChromeViewHostMsg_GetPluginInfo_Status& status = output.status; | 485 const ChromeViewHostMsg_GetPluginInfo_Status& status = output.status; |
486 const WebPluginInfo& plugin = output.plugin; | 486 const WebPluginInfo& plugin = output.plugin; |
487 const std::string& actual_mime_type = output.actual_mime_type; | 487 const std::string& actual_mime_type = output.actual_mime_type; |
488 const string16& group_name = output.group_name; | 488 const base::string16& group_name = output.group_name; |
489 const std::string& identifier = output.group_identifier; | 489 const std::string& identifier = output.group_identifier; |
490 ChromeViewHostMsg_GetPluginInfo_Status::Value status_value = status.value; | 490 ChromeViewHostMsg_GetPluginInfo_Status::Value status_value = status.value; |
491 GURL url(original_params.url); | 491 GURL url(original_params.url); |
492 std::string orig_mime_type = original_params.mimeType.utf8(); | 492 std::string orig_mime_type = original_params.mimeType.utf8(); |
493 ChromePluginPlaceholder* placeholder = NULL; | 493 ChromePluginPlaceholder* placeholder = NULL; |
494 | 494 |
495 // If the browser plugin is to be enabled, this should be handled by the | 495 // If the browser plugin is to be enabled, this should be handled by the |
496 // renderer, so the code won't reach here due to the early exit in | 496 // renderer, so the code won't reach here due to the early exit in |
497 // OverrideCreatePlugin. | 497 // OverrideCreatePlugin. |
498 if (status_value == ChromeViewHostMsg_GetPluginInfo_Status::kNotFound || | 498 if (status_value == ChromeViewHostMsg_GetPluginInfo_Status::kNotFound || |
(...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
780 } | 780 } |
781 | 781 |
782 // For NaCl content handling plugins, the NaCl manifest is stored in an | 782 // For NaCl content handling plugins, the NaCl manifest is stored in an |
783 // additonal 'nacl' param associated with the MIME type. | 783 // additonal 'nacl' param associated with the MIME type. |
784 // static | 784 // static |
785 GURL ChromeContentRendererClient::GetNaClContentHandlerURL( | 785 GURL ChromeContentRendererClient::GetNaClContentHandlerURL( |
786 const std::string& actual_mime_type, | 786 const std::string& actual_mime_type, |
787 const content::WebPluginInfo& plugin) { | 787 const content::WebPluginInfo& plugin) { |
788 // Look for the manifest URL among the MIME type's additonal parameters. | 788 // Look for the manifest URL among the MIME type's additonal parameters. |
789 const char* kNaClPluginManifestAttribute = "nacl"; | 789 const char* kNaClPluginManifestAttribute = "nacl"; |
790 string16 nacl_attr = ASCIIToUTF16(kNaClPluginManifestAttribute); | 790 base::string16 nacl_attr = ASCIIToUTF16(kNaClPluginManifestAttribute); |
791 for (size_t i = 0; i < plugin.mime_types.size(); ++i) { | 791 for (size_t i = 0; i < plugin.mime_types.size(); ++i) { |
792 if (plugin.mime_types[i].mime_type == actual_mime_type) { | 792 if (plugin.mime_types[i].mime_type == actual_mime_type) { |
793 const content::WebPluginMimeType& content_type = plugin.mime_types[i]; | 793 const content::WebPluginMimeType& content_type = plugin.mime_types[i]; |
794 for (size_t i = 0; i < content_type.additional_param_names.size(); ++i) { | 794 for (size_t i = 0; i < content_type.additional_param_names.size(); ++i) { |
795 if (content_type.additional_param_names[i] == nacl_attr) | 795 if (content_type.additional_param_names[i] == nacl_attr) |
796 return GURL(content_type.additional_param_values[i]); | 796 return GURL(content_type.additional_param_values[i]); |
797 } | 797 } |
798 break; | 798 break; |
799 } | 799 } |
800 } | 800 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
862 (is_extension_from_webstore || | 862 (is_extension_from_webstore || |
863 is_extension_unrestricted)); | 863 is_extension_unrestricted)); |
864 if (is_nacl_allowed) { | 864 if (is_nacl_allowed) { |
865 bool app_can_use_dev_interfaces = is_nacl_pdf_viewer; | 865 bool app_can_use_dev_interfaces = is_nacl_pdf_viewer; |
866 // Make sure that PPAPI 'dev' interfaces aren't available for production | 866 // Make sure that PPAPI 'dev' interfaces aren't available for production |
867 // apps unless they're whitelisted. | 867 // apps unless they're whitelisted. |
868 WebString dev_attribute = WebString::fromUTF8("@dev"); | 868 WebString dev_attribute = WebString::fromUTF8("@dev"); |
869 if ((!is_whitelisted_app && !is_extension_from_webstore) || | 869 if ((!is_whitelisted_app && !is_extension_from_webstore) || |
870 app_can_use_dev_interfaces) { | 870 app_can_use_dev_interfaces) { |
871 // Add the special '@dev' attribute. | 871 // Add the special '@dev' attribute. |
872 std::vector<string16> param_names; | 872 std::vector<base::string16> param_names; |
873 std::vector<string16> param_values; | 873 std::vector<base::string16> param_values; |
874 param_names.push_back(dev_attribute); | 874 param_names.push_back(dev_attribute); |
875 param_values.push_back(WebString()); | 875 param_values.push_back(WebString()); |
876 AppendParams( | 876 AppendParams( |
877 param_names, | 877 param_names, |
878 param_values, | 878 param_values, |
879 ¶ms->attributeNames, | 879 ¶ms->attributeNames, |
880 ¶ms->attributeValues); | 880 ¶ms->attributeValues); |
881 } else { | 881 } else { |
882 // If the params somehow contain '@dev', remove it. | 882 // If the params somehow contain '@dev', remove it. |
883 size_t attribute_count = params->attributeNames.size(); | 883 size_t attribute_count = params->attributeNames.size(); |
(...skipping 22 matching lines...) Expand all Loading... |
906 // Do not flash an error page if the Instant new tab page fails to load. | 906 // Do not flash an error page if the Instant new tab page fails to load. |
907 return search_bouncer_.get() && search_bouncer_->IsNewTabPage(url); | 907 return search_bouncer_.get() && search_bouncer_->IsNewTabPage(url); |
908 } | 908 } |
909 | 909 |
910 void ChromeContentRendererClient::GetNavigationErrorStrings( | 910 void ChromeContentRendererClient::GetNavigationErrorStrings( |
911 blink::WebFrame* frame, | 911 blink::WebFrame* frame, |
912 const blink::WebURLRequest& failed_request, | 912 const blink::WebURLRequest& failed_request, |
913 const blink::WebURLError& error, | 913 const blink::WebURLError& error, |
914 const std::string& accept_languages, | 914 const std::string& accept_languages, |
915 std::string* error_html, | 915 std::string* error_html, |
916 string16* error_description) { | 916 base::string16* error_description) { |
917 const GURL failed_url = error.unreachableURL; | 917 const GURL failed_url = error.unreachableURL; |
918 const Extension* extension = NULL; | 918 const Extension* extension = NULL; |
919 | 919 |
920 if (failed_url.is_valid() && | 920 if (failed_url.is_valid() && |
921 !failed_url.SchemeIs(extensions::kExtensionScheme)) { | 921 !failed_url.SchemeIs(extensions::kExtensionScheme)) { |
922 extension = extension_dispatcher_->extensions()->GetExtensionOrAppByURL( | 922 extension = extension_dispatcher_->extensions()->GetExtensionOrAppByURL( |
923 failed_url); | 923 failed_url); |
924 } | 924 } |
925 | 925 |
926 bool is_post = EqualsASCII(failed_request.httpMethod(), "POST"); | 926 bool is_post = EqualsASCII(failed_request.httpMethod(), "POST"); |
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1367 CommandLine* command_line = CommandLine::ForCurrentProcess(); | 1367 CommandLine* command_line = CommandLine::ForCurrentProcess(); |
1368 return !command_line->HasSwitch(switches::kExtensionProcess); | 1368 return !command_line->HasSwitch(switches::kExtensionProcess); |
1369 } | 1369 } |
1370 | 1370 |
1371 blink::WebWorkerPermissionClientProxy* | 1371 blink::WebWorkerPermissionClientProxy* |
1372 ChromeContentRendererClient::CreateWorkerPermissionClientProxy( | 1372 ChromeContentRendererClient::CreateWorkerPermissionClientProxy( |
1373 content::RenderView* render_view, | 1373 content::RenderView* render_view, |
1374 blink::WebFrame* frame) { | 1374 blink::WebFrame* frame) { |
1375 return new WorkerPermissionClientProxy(render_view, frame); | 1375 return new WorkerPermissionClientProxy(render_view, frame); |
1376 } | 1376 } |
OLD | NEW |