Index: chrome/browser/extensions/extension_system_impl.cc |
diff --git a/chrome/browser/extensions/extension_system_impl.cc b/chrome/browser/extensions/extension_system_impl.cc |
index fa7596f5ad8971e9170674d058eb884391aea2e6..6731e17e6b656ac9636fea7e6488f42f3b356244 100644 |
--- a/chrome/browser/extensions/extension_system_impl.cc |
+++ b/chrome/browser/extensions/extension_system_impl.cc |
@@ -38,6 +38,7 @@ |
#include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
#include "chrome/common/chrome_switches.h" |
#include "content/public/browser/browser_thread.h" |
+#include "content/public/browser/resource_dispatcher_host.h" |
#include "content/public/browser/url_data_source.h" |
#include "extensions/browser/content_verifier.h" |
#include "extensions/browser/extension_pref_store.h" |
@@ -54,6 +55,7 @@ |
#include "extensions/browser/value_store/value_store_factory_impl.h" |
#include "extensions/common/constants.h" |
#include "extensions/common/features/feature_channel.h" |
+#include "extensions/common/manifest_constants.h" |
#include "extensions/common/manifest_url_handlers.h" |
#if defined(ENABLE_NOTIFICATIONS) |
@@ -90,6 +92,46 @@ UninstallPingSender::FilterResult ShouldSendUninstallPing( |
return UninstallPingSender::DO_NOT_SEND_PING; |
} |
+// Helper functions to register and unregister extensions. These are invoked |
+// on the IO thread. |
+void RegisterExtensionHelper(InfoMap* info_map, |
+ const Extension* extension, |
+ base::Time install_time, |
+ bool incognito_enabled, |
+ bool notifications_disabled, |
+ const content::ResourceContext* context) { |
+ DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ |
+ info_map->AddExtension(extension, install_time, incognito_enabled, |
+ notifications_disabled); |
+ // Check for platform app origins. These can only be committed by the app |
+ // itself, or by one if its guests if there are accessible_resources. |
+ // If the origin is not a platform app, then we assume all processes can |
+ // commit to it as we don't have enough information to validate it. This |
+ // includes hosted apps and normal extensions. |
+ content::ResourceDispatcherHost::OriginAccessCheckMask access_check_mask = |
+ content::ResourceDispatcherHost::ALLOW_EVERYTHING; |
+ if (extension->is_platform_app() && !!extension->GetManifestData( |
+ manifest_keys::kWebviewAccessibleResources)) { |
+ access_check_mask = |
+ content::ResourceDispatcherHost::ALLOW_REGISTERED_ACCESS; |
+ } |
+ content::ResourceDispatcherHost::Get()->RegisterOriginForAccessChecks( |
+ context, Extension::GetBaseURLFromExtensionId(extension->id()).spec(), |
+ access_check_mask); |
+} |
+ |
+void UnregisterExtensionHelper(InfoMap* info_map, |
+ const std::string& extension_id, |
+ const UnloadedExtensionInfo::Reason reason, |
+ const content::ResourceContext* context) { |
+ DCHECK_CURRENTLY_ON(BrowserThread::IO); |
+ |
+ info_map->RemoveExtension(extension_id, reason); |
+ content::ResourceDispatcherHost::Get()->UnregisterOriginForAccessChecks( |
+ context, Extension::GetBaseURLFromExtensionId(extension_id).spec()); |
+} |
+ |
} // namespace |
// |
@@ -457,9 +499,9 @@ void ExtensionSystemImpl::RegisterExtensionWithRequestContexts( |
BrowserThread::PostTaskAndReply( |
BrowserThread::IO, FROM_HERE, |
- base::Bind(&InfoMap::AddExtension, info_map(), |
+ base::Bind(&RegisterExtensionHelper, base::RetainedRef(info_map()), |
base::RetainedRef(extension), install_time, incognito_enabled, |
- notifications_disabled), |
+ notifications_disabled, profile_->GetResourceContext()), |
callback); |
} |
@@ -469,7 +511,8 @@ void ExtensionSystemImpl::UnregisterExtensionWithRequestContexts( |
BrowserThread::PostTask( |
BrowserThread::IO, |
FROM_HERE, |
- base::Bind(&InfoMap::RemoveExtension, info_map(), extension_id, reason)); |
+ base::Bind(&UnregisterExtensionHelper, base::RetainedRef(info_map()), |
+ extension_id, reason, profile_->GetResourceContext())); |
} |
} // namespace extensions |