diff options
author | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-04 23:38:11 +0000 |
---|---|---|
committer | aa@chromium.org <aa@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-04-04 23:38:11 +0000 |
commit | 5bc248aa048b3ac131c2e0d50c41612f734d56c4 (patch) | |
tree | 8f206e1aa385f52e18fdd69f35150ac08db36b00 /chrome/browser/extensions | |
parent | 3adea20826da9eadd775858a4d207c29b32826ea (diff) | |
download | chromium_src-5bc248aa048b3ac131c2e0d50c41612f734d56c4.zip chromium_src-5bc248aa048b3ac131c2e0d50c41612f734d56c4.tar.gz chromium_src-5bc248aa048b3ac131c2e0d50c41612f734d56c4.tar.bz2 |
Revert "Revert 130697 - Reland r130462: Implement FeatureProvider for ExtensionAPI.""
This reverts commit b58edbf7df6f39ba3b3b1ad9dae415a79adf91a4.
BUG=120069
TBR=mpcomplete@chromium.org
Review URL: https://chromiumcodereview.appspot.com/9981014
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@130771 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
4 files changed, 27 insertions, 4 deletions
diff --git a/chrome/browser/extensions/extension_event_router.cc b/chrome/browser/extensions/extension_event_router.cc index 5787fb2..fae37af 100644 --- a/chrome/browser/extensions/extension_event_router.cc +++ b/chrome/browser/extensions/extension_event_router.cc @@ -317,7 +317,7 @@ void ExtensionEventRouter::DispatchEventToListener( listener_profile->GetExtensionService()->process_map(); // If the event is privileged, only send to extension processes. Otherwise, // it's OK to send to normal renderers (e.g., for content scripts). - if (ExtensionAPI::GetInstance()->IsPrivileged(event->event_name) && + if (ExtensionAPI::GetSharedInstance()->IsPrivileged(event->event_name) && !process_map->Contains(extension->id(), listener.process->GetID())) { return; } diff --git a/chrome/browser/extensions/extension_function_dispatcher.cc b/chrome/browser/extensions/extension_function_dispatcher.cc index 0a95858..588d088 100644 --- a/chrome/browser/extensions/extension_function_dispatcher.cc +++ b/chrome/browser/extensions/extension_function_dispatcher.cc @@ -7,6 +7,7 @@ #include <map> #include "base/json/json_string_value_serializer.h" +#include "base/lazy_instance.h" #include "base/memory/ref_counted.h" #include "base/process_util.h" #include "base/values.h" @@ -39,6 +40,8 @@ using extensions::ExtensionAPI; using content::RenderViewHost; using WebKit::WebSecurityOrigin; +namespace { + const char kAccessDenied[] = "access denied"; const char kQuotaExceeded[] = "quota exceeded"; @@ -80,6 +83,20 @@ void LogFailure(const Extension* extension, } } +// Separate copy of ExtensionAPI used for IO thread extension functions. We need +// this because ExtensionAPI has mutable data. It should be possible to remove +// this once all the extension APIs are updated to the feature system. +struct Static { + Static() + : api(extensions::ExtensionAPI::CreateWithDefaultConfiguration()) { + } + scoped_ptr<extensions::ExtensionAPI> api; +}; +base::LazyInstance<Static> g_global_io_data = LAZY_INSTANCE_INITIALIZER; + +} // namespace + + void ExtensionFunctionDispatcher::GetAllFunctionNames( std::vector<std::string>* names) { ExtensionFunctionRegistry::GetInstance()->GetAllNames(names); @@ -108,7 +125,9 @@ void ExtensionFunctionDispatcher::DispatchOnIOThread( scoped_refptr<ExtensionFunction> function( CreateExtensionFunction(params, extension, render_process_id, - extension_info_map->process_map(), profile, + extension_info_map->process_map(), + g_global_io_data.Get().api.get(), + profile, ipc_sender, routing_id)); if (!function) { LogFailure(extension, params.name, kAccessDenied); @@ -191,6 +210,7 @@ void ExtensionFunctionDispatcher::Dispatch( CreateExtensionFunction(params, extension, render_view_host->GetProcess()->GetID(), *(service->process_map()), + extensions::ExtensionAPI::GetSharedInstance(), profile(), render_view_host, render_view_host->GetRoutingID())); if (!function) { @@ -242,6 +262,7 @@ ExtensionFunction* ExtensionFunctionDispatcher::CreateExtensionFunction( const Extension* extension, int requesting_process_id, const extensions::ProcessMap& process_map, + extensions::ExtensionAPI* api, void* profile, IPC::Message::Sender* ipc_sender, int routing_id) { @@ -251,7 +272,7 @@ ExtensionFunction* ExtensionFunctionDispatcher::CreateExtensionFunction( return NULL; } - if (ExtensionAPI::GetInstance()->IsPrivileged(params.name) && + if (api->IsPrivileged(params.name) && !process_map.Contains(extension->id(), requesting_process_id)) { LOG(ERROR) << "Extension API called from incorrect process " << requesting_process_id diff --git a/chrome/browser/extensions/extension_function_dispatcher.h b/chrome/browser/extensions/extension_function_dispatcher.h index 13611ff..67c7656 100644 --- a/chrome/browser/extensions/extension_function_dispatcher.h +++ b/chrome/browser/extensions/extension_function_dispatcher.h @@ -28,6 +28,7 @@ class WebContents; } namespace extensions { +class ExtensionAPI; class ProcessMap; } @@ -126,6 +127,7 @@ class ExtensionFunctionDispatcher const Extension* extension, int requesting_process_id, const extensions::ProcessMap& process_map, + extensions::ExtensionAPI* api, void* profile, IPC::Message::Sender* ipc_sender, int routing_id); diff --git a/chrome/browser/extensions/settings/settings_frontend.cc b/chrome/browser/extensions/settings/settings_frontend.cc index a29fbc5..0c2c51d 100644 --- a/chrome/browser/extensions/settings/settings_frontend.cc +++ b/chrome/browser/extensions/settings/settings_frontend.cc @@ -106,7 +106,7 @@ size_t GetStringAsInteger( SettingsStorageQuotaEnforcer::Limits GetLimitsFromExtensionAPI( const std::string& storage_area_id) { const DictionaryValue* storage_schema = - ExtensionAPI::GetInstance()->GetSchema("storage"); + ExtensionAPI::GetSharedInstance()->GetSchema("storage"); CHECK(storage_schema); DictionaryValue* properties = NULL; |