Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(179)

Side by Side Diff: chrome/renderer/chrome_content_renderer_client.cc

Issue 1293673002: Create thread-safe RendererExtensionRegistry from ExtensionSet (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/field_trial.h" 10 #include "base/metrics/field_trial.h"
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
119 #include "extensions/common/extension_set.h" 119 #include "extensions/common/extension_set.h"
120 #include "extensions/common/extension_urls.h" 120 #include "extensions/common/extension_urls.h"
121 #include "extensions/common/switches.h" 121 #include "extensions/common/switches.h"
122 #include "extensions/renderer/dispatcher.h" 122 #include "extensions/renderer/dispatcher.h"
123 #include "extensions/renderer/extension_frame_helper.h" 123 #include "extensions/renderer/extension_frame_helper.h"
124 #include "extensions/renderer/extension_helper.h" 124 #include "extensions/renderer/extension_helper.h"
125 #include "extensions/renderer/extensions_render_frame_observer.h" 125 #include "extensions/renderer/extensions_render_frame_observer.h"
126 #include "extensions/renderer/guest_view/extensions_guest_view_container.h" 126 #include "extensions/renderer/guest_view/extensions_guest_view_container.h"
127 #include "extensions/renderer/guest_view/extensions_guest_view_container_dispatc her.h" 127 #include "extensions/renderer/guest_view/extensions_guest_view_container_dispatc her.h"
128 #include "extensions/renderer/guest_view/mime_handler_view/mime_handler_view_con tainer.h" 128 #include "extensions/renderer/guest_view/mime_handler_view/mime_handler_view_con tainer.h"
129 #include "extensions/renderer/renderer_extension_registry.h"
129 #include "extensions/renderer/script_context.h" 130 #include "extensions/renderer/script_context.h"
130 #endif 131 #endif
131 132
132 #if defined(ENABLE_IPC_FUZZER) 133 #if defined(ENABLE_IPC_FUZZER)
133 #include "chrome/common/external_ipc_dumper.h" 134 #include "chrome/common/external_ipc_dumper.h"
134 #endif 135 #endif
135 136
136 #if defined(ENABLE_PLUGINS) 137 #if defined(ENABLE_PLUGINS)
137 #include "chrome/renderer/plugins/chrome_plugin_placeholder.h" 138 #include "chrome/renderer/plugins/chrome_plugin_placeholder.h"
138 #endif 139 #endif
(...skipping 470 matching lines...) Expand 10 before | Expand all | Expand 10 after
609 } 610 }
610 611
611 #if defined(ENABLE_EXTENSIONS) 612 #if defined(ENABLE_EXTENSIONS)
612 const Extension* ChromeContentRendererClient::GetExtensionByOrigin( 613 const Extension* ChromeContentRendererClient::GetExtensionByOrigin(
613 const WebSecurityOrigin& origin) const { 614 const WebSecurityOrigin& origin) const {
614 if (!base::EqualsASCII(base::StringPiece16(origin.protocol()), 615 if (!base::EqualsASCII(base::StringPiece16(origin.protocol()),
615 extensions::kExtensionScheme)) 616 extensions::kExtensionScheme))
616 return NULL; 617 return NULL;
617 618
618 const std::string extension_id = origin.host().utf8().data(); 619 const std::string extension_id = origin.host().utf8().data();
619 return extension_dispatcher_->extensions()->GetByID(extension_id); 620 return extensions::RendererExtensionRegistry::GetRegistry()->GetByID(
621 extension_id);
620 } 622 }
621 #endif 623 #endif
622 624
623 scoped_ptr<blink::WebPluginPlaceholder> 625 scoped_ptr<blink::WebPluginPlaceholder>
624 ChromeContentRendererClient::CreatePluginPlaceholder( 626 ChromeContentRendererClient::CreatePluginPlaceholder(
625 content::RenderFrame* render_frame, 627 content::RenderFrame* render_frame,
626 blink::WebLocalFrame* frame, 628 blink::WebLocalFrame* frame,
627 const blink::WebPluginParams& orig_params) { 629 const blink::WebPluginParams& orig_params) {
628 return CreateShadowDOMPlaceholderForPluginInfo( 630 return CreateShadowDOMPlaceholderForPluginInfo(
629 render_frame, frame, orig_params); 631 render_frame, frame, orig_params);
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
804 // Normal NaCl/PNaCl embed. The app URL is the page URL. 806 // Normal NaCl/PNaCl embed. The app URL is the page URL.
805 manifest_url = url; 807 manifest_url = url;
806 app_url = frame->top()->document().url(); 808 app_url = frame->top()->document().url();
807 } else { 809 } else {
808 // NaCl is being invoked as a content handler. Look up the NaCl 810 // NaCl is being invoked as a content handler. Look up the NaCl
809 // module using the MIME type. The app URL is the manifest URL. 811 // module using the MIME type. The app URL is the manifest URL.
810 manifest_url = GetNaClContentHandlerURL(actual_mime_type, info); 812 manifest_url = GetNaClContentHandlerURL(actual_mime_type, info);
811 app_url = manifest_url; 813 app_url = manifest_url;
812 } 814 }
813 const Extension* extension = 815 const Extension* extension =
814 g_current_client->extension_dispatcher_->extensions()-> 816 extensions::RendererExtensionRegistry::GetRegistry()
815 GetExtensionOrAppByURL(manifest_url); 817 ->GetExtensionOrAppByURL(manifest_url);
816 if (!IsNaClAllowed(manifest_url, 818 if (!IsNaClAllowed(manifest_url,
817 app_url, 819 app_url,
818 is_nacl_unrestricted, 820 is_nacl_unrestricted,
819 extension, 821 extension,
820 &params)) { 822 &params)) {
821 WebString error_message; 823 WebString error_message;
822 if (is_nacl_mime_type) { 824 if (is_nacl_mime_type) {
823 error_message = 825 error_message =
824 "Only unpacked extensions and apps installed from the Chrome " 826 "Only unpacked extensions and apps installed from the Chrome "
825 "Web Store can load NaCl modules without enabling Native " 827 "Web Store can load NaCl modules without enabling Native "
(...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after
1228 // page no longer exists by the time the OpenURL IPC is handled, a normal 1230 // page no longer exists by the time the OpenURL IPC is handled, a normal
1229 // navigation is attempted. 1231 // navigation is attempted.
1230 if (prerender_dispatcher_.get() && 1232 if (prerender_dispatcher_.get() &&
1231 prerender_dispatcher_->IsPrerenderURL(url)) { 1233 prerender_dispatcher_->IsPrerenderURL(url)) {
1232 *send_referrer = true; 1234 *send_referrer = true;
1233 return true; 1235 return true;
1234 } 1236 }
1235 1237
1236 #if defined(ENABLE_EXTENSIONS) 1238 #if defined(ENABLE_EXTENSIONS)
1237 const extensions::ExtensionSet* extensions = 1239 const extensions::ExtensionSet* extensions =
1238 extension_dispatcher_->extensions(); 1240 extensions::RendererExtensionRegistry::GetRegistry()
1241 ->GetMainThreadExtensionSet();
1239 1242
1240 // Determine if the new URL is an extension (excluding bookmark apps). 1243 // Determine if the new URL is an extension (excluding bookmark apps).
1241 const Extension* new_url_extension = extensions::GetNonBookmarkAppExtension( 1244 const Extension* new_url_extension = extensions::GetNonBookmarkAppExtension(
1242 *extensions, url); 1245 *extensions, url);
1243 bool is_extension_url = !!new_url_extension; 1246 bool is_extension_url = !!new_url_extension;
1244 1247
1245 // If the navigation would cross an app extent boundary, we also need 1248 // If the navigation would cross an app extent boundary, we also need
1246 // to defer to the browser to ensure process isolation. This is not necessary 1249 // to defer to the browser to ensure process isolation. This is not necessary
1247 // for server redirects, which will be transferred to a new process by the 1250 // for server redirects, which will be transferred to a new process by the
1248 // browser process when they are ready to commit. It is necessary for client 1251 // browser process when they are ready to commit. It is necessary for client
1249 // redirects, which won't be transferred in the same way. 1252 // redirects, which won't be transferred in the same way.
1250 if (!is_server_redirect && 1253 if (!is_server_redirect &&
1251 CrossesExtensionExtents(frame, url, *extensions, is_extension_url, 1254 CrossesExtensionExtents(frame, url, *extensions, is_extension_url,
1252 is_initial_navigation)) { 1255 is_initial_navigation)) {
1253 // Include the referrer in this case since we're going from a hosted web 1256 // Include the referrer in this case since we're going from a hosted web
1254 // page. (the packaged case is handled previously by the extension 1257 // page. (the packaged case is handled previously by the extension
1255 // navigation test) 1258 // navigation test)
1256 *send_referrer = true; 1259 *send_referrer = true;
1257 1260
1258 const Extension* extension = 1261 const Extension* extension =
1259 extension_dispatcher_->extensions()->GetExtensionOrAppByURL(url); 1262 extensions::RendererExtensionRegistry::GetRegistry()
1263 ->GetExtensionOrAppByURL(url);
1260 if (extension && extension->is_app()) { 1264 if (extension && extension->is_app()) {
1261 extensions::RecordAppLaunchType( 1265 extensions::RecordAppLaunchType(
1262 extension_misc::APP_LAUNCH_CONTENT_NAVIGATION, extension->GetType()); 1266 extension_misc::APP_LAUNCH_CONTENT_NAVIGATION, extension->GetType());
1263 } 1267 }
1264 return true; 1268 return true;
1265 } 1269 }
1266 1270
1267 // If this is a reload, check whether it has the wrong process type. We 1271 // If this is a reload, check whether it has the wrong process type. We
1268 // should send it to the browser if it's an extension URL (e.g., hosted app) 1272 // should send it to the browser if it's an extension URL (e.g., hosted app)
1269 // in a normal process, or if it's a process for an extension that has been 1273 // in a normal process, or if it's a process for an extension that has been
(...skipping 14 matching lines...) Expand all
1284 blink::WebFrame* frame, 1288 blink::WebFrame* frame,
1285 ui::PageTransition transition_type, 1289 ui::PageTransition transition_type,
1286 const GURL& url, 1290 const GURL& url,
1287 const GURL& first_party_for_cookies, 1291 const GURL& first_party_for_cookies,
1288 GURL* new_url) { 1292 GURL* new_url) {
1289 // Check whether the request should be allowed. If not allowed, we reset the 1293 // Check whether the request should be allowed. If not allowed, we reset the
1290 // URL to something invalid to prevent the request and cause an error. 1294 // URL to something invalid to prevent the request and cause an error.
1291 #if defined(ENABLE_EXTENSIONS) 1295 #if defined(ENABLE_EXTENSIONS)
1292 if (url.SchemeIs(extensions::kExtensionScheme) && 1296 if (url.SchemeIs(extensions::kExtensionScheme) &&
1293 !extensions::ResourceRequestPolicy::CanRequestResource( 1297 !extensions::ResourceRequestPolicy::CanRequestResource(
1294 url, 1298 url, frame, transition_type,
1295 frame, 1299 extensions::RendererExtensionRegistry::GetRegistry()
1296 transition_type, 1300 ->GetMainThreadExtensionSet())) {
1297 extension_dispatcher_->extensions())) {
1298 *new_url = GURL(chrome::kExtensionInvalidRequestURL); 1301 *new_url = GURL(chrome::kExtensionInvalidRequestURL);
1299 return true; 1302 return true;
1300 } 1303 }
1301 1304
1302 if (url.SchemeIs(extensions::kExtensionResourceScheme) && 1305 if (url.SchemeIs(extensions::kExtensionResourceScheme) &&
1303 !extensions::ResourceRequestPolicy::CanRequestExtensionResourceScheme( 1306 !extensions::ResourceRequestPolicy::CanRequestExtensionResourceScheme(
1304 url, 1307 url,
1305 frame)) { 1308 frame)) {
1306 *new_url = GURL(chrome::kExtensionResourceInvalidRequestURL); 1309 *new_url = GURL(chrome::kExtensionResourceInvalidRequestURL);
1307 return true; 1310 return true;
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1457 // TODO(bbudge) remove this when the trusted NaCl plugin has been removed. 1460 // TODO(bbudge) remove this when the trusted NaCl plugin has been removed.
1458 // We must defer certain plugin events for NaCl instances since we switch 1461 // We must defer certain plugin events for NaCl instances since we switch
1459 // from the in-process to the out-of-process proxy after instantiating them. 1462 // from the in-process to the out-of-process proxy after instantiating them.
1460 return module_name == "Native Client"; 1463 return module_name == "Native Client";
1461 } 1464 }
1462 1465
1463 #if defined(ENABLE_PLUGINS) && defined(ENABLE_EXTENSIONS) 1466 #if defined(ENABLE_PLUGINS) && defined(ENABLE_EXTENSIONS)
1464 bool ChromeContentRendererClient::IsExtensionOrSharedModuleWhitelisted( 1467 bool ChromeContentRendererClient::IsExtensionOrSharedModuleWhitelisted(
1465 const GURL& url, const std::set<std::string>& whitelist) { 1468 const GURL& url, const std::set<std::string>& whitelist) {
1466 const extensions::ExtensionSet* extension_set = 1469 const extensions::ExtensionSet* extension_set =
1467 g_current_client->extension_dispatcher_->extensions(); 1470 extensions::RendererExtensionRegistry::GetRegistry()
1471 ->GetMainThreadExtensionSet();
1468 return chrome::IsExtensionOrSharedModuleWhitelisted(url, extension_set, 1472 return chrome::IsExtensionOrSharedModuleWhitelisted(url, extension_set,
1469 whitelist); 1473 whitelist);
1470 } 1474 }
1471 #endif 1475 #endif
1472 1476
1473 blink::WebSpeechSynthesizer* 1477 blink::WebSpeechSynthesizer*
1474 ChromeContentRendererClient::OverrideSpeechSynthesizer( 1478 ChromeContentRendererClient::OverrideSpeechSynthesizer(
1475 blink::WebSpeechSynthesizerClient* client) { 1479 blink::WebSpeechSynthesizerClient* client) {
1476 return new TtsDispatcher(client); 1480 return new TtsDispatcher(client);
1477 } 1481 }
(...skipping 149 matching lines...) Expand 10 before | Expand all | Expand 10 after
1627 WebString header_key(ASCIIToUTF16( 1631 WebString header_key(ASCIIToUTF16(
1628 data_reduction_proxy::chrome_proxy_header())); 1632 data_reduction_proxy::chrome_proxy_header()));
1629 if (!response.httpHeaderField(header_key).isNull() && 1633 if (!response.httpHeaderField(header_key).isNull() &&
1630 response.httpHeaderField(header_key).utf8().find( 1634 response.httpHeaderField(header_key).utf8().find(
1631 data_reduction_proxy::chrome_proxy_lo_fi_directive()) != 1635 data_reduction_proxy::chrome_proxy_lo_fi_directive()) !=
1632 std::string::npos) { 1636 std::string::npos) {
1633 (*properties)[data_reduction_proxy::chrome_proxy_header()] = 1637 (*properties)[data_reduction_proxy::chrome_proxy_header()] =
1634 data_reduction_proxy::chrome_proxy_lo_fi_directive(); 1638 data_reduction_proxy::chrome_proxy_lo_fi_directive();
1635 } 1639 }
1636 } 1640 }
OLDNEW
« no previous file with comments | « no previous file | chrome/renderer/content_settings_observer.cc » ('j') | extensions/renderer/dispatcher.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698