| OLD | NEW |
| 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 Loading... |
| 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 286 void RulesRegistryStorageDelegate::Inner::NotifyReadyOnRegistryThread() { | 287 void RulesRegistryStorageDelegate::Inner::NotifyReadyOnRegistryThread() { |
| 287 DCHECK(content::BrowserThread::CurrentlyOn(rules_registry_thread_)); | 288 DCHECK(content::BrowserThread::CurrentlyOn(rules_registry_thread_)); |
| 288 if (ready_) | 289 if (ready_) |
| 289 return; // we've already notified our readiness | 290 return; // we've already notified our readiness |
| 290 | 291 |
| 291 ready_ = true; | 292 ready_ = true; |
| 292 rules_registry_->OnReady(); | 293 rules_registry_->OnReady(); |
| 293 } | 294 } |
| 294 | 295 |
| 295 } // namespace extensions | 296 } // namespace extensions |
| OLD | NEW |