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

Side by Side Diff: chrome/browser/extensions/api/declarative/rules_registry_storage_delegate.cc

Issue 11547033: Implement declarativeContent API. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync Created 7 years, 11 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/extensions/api/declarative/rules_registry_storage_deleg ate.h" 5 #include "chrome/browser/extensions/api/declarative/rules_registry_storage_deleg ate.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "chrome/browser/extensions/extension_info_map.h" 8 #include "chrome/browser/extensions/extension_info_map.h"
9 #include "chrome/browser/extensions/extension_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/extensions/extension_system.h" 10 #include "chrome/browser/extensions/extension_system.h"
(...skipping 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 RulesRegistryStorageDelegate::Inner::~Inner() { 187 RulesRegistryStorageDelegate::Inner::~Inner() {
188 DCHECK(!registrar_.get()); 188 DCHECK(!registrar_.get());
189 } 189 }
190 190
191 void RulesRegistryStorageDelegate::Inner::InitForOTRProfile() { 191 void RulesRegistryStorageDelegate::Inner::InitForOTRProfile() {
192 ExtensionService* extension_service = 192 ExtensionService* extension_service =
193 extensions::ExtensionSystem::Get(profile_)->extension_service(); 193 extensions::ExtensionSystem::Get(profile_)->extension_service();
194 const ExtensionSet* extensions = extension_service->extensions(); 194 const ExtensionSet* extensions = extension_service->extensions();
195 for (ExtensionSet::const_iterator i = extensions->begin(); 195 for (ExtensionSet::const_iterator i = extensions->begin();
196 i != extensions->end(); ++i) { 196 i != extensions->end(); ++i) {
197 if ((*i)->HasAPIPermission(APIPermission::kDeclarativeWebRequest) && 197 if (((*i)->HasAPIPermission(APIPermission::kDeclarativeContent) ||
198 (*i)->HasAPIPermission(APIPermission::kDeclarativeWebRequest)) &&
198 extension_service->IsIncognitoEnabled((*i)->id())) 199 extension_service->IsIncognitoEnabled((*i)->id()))
199 ReadFromStorage((*i)->id()); 200 ReadFromStorage((*i)->id());
200 } 201 }
201 ready_ = true; 202 ready_ = true;
202 } 203 }
203 204
204 void RulesRegistryStorageDelegate::Inner::Observe( 205 void RulesRegistryStorageDelegate::Inner::Observe(
205 int type, 206 int type,
206 const content::NotificationSource& source, 207 const content::NotificationSource& source,
207 const content::NotificationDetails& details) { 208 const content::NotificationDetails& details) {
208 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); 209 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI));
209 if (type == chrome::NOTIFICATION_EXTENSION_LOADED) { 210 if (type == chrome::NOTIFICATION_EXTENSION_LOADED) {
210 const extensions::Extension* extension = 211 const extensions::Extension* extension =
211 content::Details<const extensions::Extension>(details).ptr(); 212 content::Details<const extensions::Extension>(details).ptr();
212 // TODO(mpcomplete): This API check should generalize to any use of 213 // TODO(mpcomplete): This API check should generalize to any use of
213 // declarative rules, not just webRequest. 214 // declarative rules, not just webRequest.
214 if (extension->HasAPIPermission( 215 if (extension->HasAPIPermission(APIPermission::kDeclarativeContent) ||
215 APIPermission::kDeclarativeWebRequest)) { 216 extension->HasAPIPermission(APIPermission::kDeclarativeWebRequest)) {
216 ExtensionInfoMap* extension_info_map = 217 ExtensionInfoMap* extension_info_map =
217 ExtensionSystem::Get(profile_)->info_map(); 218 ExtensionSystem::Get(profile_)->info_map();
218 if (profile_->IsOffTheRecord() && 219 if (profile_->IsOffTheRecord() &&
219 !extension_info_map->IsIncognitoEnabled(extension->id())) { 220 !extension_info_map->IsIncognitoEnabled(extension->id())) {
220 // Ignore this extension. 221 // Ignore this extension.
221 } else { 222 } else {
222 ReadFromStorage(extension->id()); 223 ReadFromStorage(extension->id());
223 } 224 }
224 } 225 }
225 } else if (type == chrome::NOTIFICATION_EXTENSIONS_READY) { 226 } else if (type == chrome::NOTIFICATION_EXTENSIONS_READY) {
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
297 void RulesRegistryStorageDelegate::Inner::NotifyReadyOnRegistryThread() { 298 void RulesRegistryStorageDelegate::Inner::NotifyReadyOnRegistryThread() {
298 DCHECK(content::BrowserThread::CurrentlyOn(rules_registry_thread_)); 299 DCHECK(content::BrowserThread::CurrentlyOn(rules_registry_thread_));
299 if (ready_) 300 if (ready_)
300 return; // we've already notified our readiness 301 return; // we've already notified our readiness
301 302
302 ready_ = true; 303 ready_ = true;
303 rules_registry_->OnReady(); 304 rules_registry_->OnReady();
304 } 305 }
305 306
306 } // namespace extensions 307 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698