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..32d57893bc79650a77bd967a998e378f0b350343 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,10 @@ |
#include "chrome/browser/extensions/api/declarative/rules_registry_storage_delegate.h" |
#include "base/bind.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 +66,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 +170,34 @@ 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)); |
Matt Perry
2012/07/25 21:27:56
You need to register for the notification for prof
Yoyo Zhou
2012/07/25 21:44:45
You probably want profile->GetOriginalProfile() he
battre
2012/07/26 16:38:43
Done.
battre
2012/07/26 16:38:43
Done.
|
+ InitForOTRProfile(); |
Matt Perry
2012/07/25 21:27:56
You should also set ready_ = true.
battre
2012/07/26 16:38:43
I think the better approach is to call CheckIfRead
Matt Perry
2012/07/26 18:42:41
No, then it will be considered "not ready" for som
|
+ } |
} |
RulesRegistryStorageDelegate::Inner::~Inner() { |
DCHECK(!registrar_.get()); |
} |
+void RulesRegistryStorageDelegate::Inner::InitForOTRProfile() { |
Matt Perry
2012/07/25 21:27:56
May as well do this step for both types of profile
battre
2012/07/26 16:38:43
This is not quite clear to me. Note the check whet
Matt Perry
2012/07/26 18:42:41
OK, I take that back then.
|
+ 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()); |
+ } |
+} |
+ |
void RulesRegistryStorageDelegate::Inner::Observe( |
int type, |
const content::NotificationSource& source, |