Index: chrome/browser/extensions/api/declarative/rules_registry_storage_delegate.cc |
diff --git a/chrome/browser/extensions/api/declarative/rules_registry_storage_delegate.cc b/chrome/browser/extensions/api/declarative/rules_registry_storage_delegate.cc |
index 010e1409dd08ff7d9f47ee6e9de845448f4ef352..41e51a191375ad319258cf57c5fe32b625d9982a 100644 |
--- a/chrome/browser/extensions/api/declarative/rules_registry_storage_delegate.cc |
+++ b/chrome/browser/extensions/api/declarative/rules_registry_storage_delegate.cc |
@@ -5,8 +5,11 @@ |
#include "chrome/browser/extensions/api/declarative/rules_registry_storage_delegate.h" |
#include "base/bind.h" |
+#include "chrome/browser/extensions/extension_info_map.h" |
+#include "chrome/browser/extensions/extension_service.h" |
#include "chrome/browser/extensions/extension_system.h" |
#include "chrome/browser/extensions/state_store.h" |
+#include "chrome/browser/profiles/profile.h" |
#include "chrome/common/chrome_notification_types.h" |
#include "chrome/common/extensions/extension.h" |
#include "content/public/browser/browser_thread.h" |
@@ -64,6 +67,10 @@ class RulesRegistryStorageDelegate::Inner |
~Inner(); |
+ // Initialization of the storage delegate if it is used in the context of |
+ // an incognito profile. |
+ void InitForOTRProfile(); |
+ |
// NotificationObserver |
virtual void Observe( |
int type, |
@@ -164,16 +171,35 @@ RulesRegistryStorageDelegate::Inner::Inner( |
rules_registry_thread_(rules_registry->GetOwnerThread()), |
rules_registry_(rules_registry), |
ready_(false) { |
- registrar_->Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
- content::Source<Profile>(profile)); |
- registrar_->Add(this, chrome::NOTIFICATION_EXTENSIONS_READY, |
- content::Source<Profile>(profile)); |
+ if (!profile_->IsOffTheRecord()) { |
+ registrar_->Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
+ content::Source<Profile>(profile)); |
+ registrar_->Add(this, chrome::NOTIFICATION_EXTENSIONS_READY, |
+ content::Source<Profile>(profile)); |
+ } else { |
+ registrar_->Add(this, chrome::NOTIFICATION_EXTENSION_LOADED, |
+ content::Source<Profile>(profile->GetOriginalProfile())); |
+ InitForOTRProfile(); |
+ } |
} |
RulesRegistryStorageDelegate::Inner::~Inner() { |
DCHECK(!registrar_.get()); |
} |
+void RulesRegistryStorageDelegate::Inner::InitForOTRProfile() { |
+ ExtensionService* extension_service = |
+ extensions::ExtensionSystem::Get(profile_)->extension_service(); |
+ const ExtensionSet* extensions = extension_service->extensions(); |
+ for (ExtensionSet::const_iterator i = extensions->begin(); |
+ i != extensions->end(); ++i) { |
+ if ((*i)->HasAPIPermission(APIPermission::kDeclarativeWebRequest) && |
+ extension_service->IsIncognitoEnabled((*i)->id())) |
+ ReadFromStorage((*i)->id()); |
+ } |
+ ready_ = true; |
+} |
+ |
void RulesRegistryStorageDelegate::Inner::Observe( |
int type, |
const content::NotificationSource& source, |
@@ -186,7 +212,14 @@ void RulesRegistryStorageDelegate::Inner::Observe( |
// declarative rules, not just webRequest. |
if (extension->HasAPIPermission( |
APIPermission::kDeclarativeWebRequest)) { |
- ReadFromStorage(extension->id()); |
+ ExtensionInfoMap* extension_info_map = |
+ ExtensionSystem::Get(profile_)->info_map(); |
+ if (profile_->IsOffTheRecord() && |
+ !extension_info_map->IsIncognitoEnabled(extension->id())) { |
+ // Ignore this extension. |
+ } else { |
+ ReadFromStorage(extension->id()); |
+ } |
} |
} else if (type == chrome::NOTIFICATION_EXTENSIONS_READY) { |
CheckIfReady(); |