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

Unified Diff: chrome/browser/extensions/api/declarative/rules_registry_storage_delegate.cc

Issue 10831008: Refactor and fix declarative webRequest API permissions (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed license headers Created 8 years, 5 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 side-by-side diff with in-line comments
Download patch
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();

Powered by Google App Engine
This is Rietveld 408576698