| OLD | NEW |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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_cache_delegate.h" | 5 #include "chrome/browser/extensions/api/declarative/rules_cache_delegate.h" |
| 6 | 6 |
| 7 #include "chrome/browser/chrome_notification_types.h" | 7 #include "chrome/browser/chrome_notification_types.h" |
| 8 #include "chrome/browser/extensions/api/declarative/rules_registry.h" | 8 #include "chrome/browser/extensions/api/declarative/rules_registry.h" |
| 9 #include "chrome/browser/extensions/extension_info_map.h" | |
| 10 #include "chrome/browser/extensions/extension_service.h" | 9 #include "chrome/browser/extensions/extension_service.h" |
| 11 #include "chrome/browser/extensions/extension_system.h" | 10 #include "chrome/browser/extensions/extension_system.h" |
| 12 #include "chrome/browser/extensions/extension_util.h" | 11 #include "chrome/browser/extensions/extension_util.h" |
| 13 #include "chrome/browser/extensions/state_store.h" | 12 #include "chrome/browser/extensions/state_store.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 15 #include "content/public/browser/notification_details.h" | 14 #include "content/public/browser/notification_details.h" |
| 16 #include "content/public/browser/notification_source.h" | 15 #include "content/public/browser/notification_source.h" |
| 16 #include "extensions/browser/info_map.h" |
| 17 | 17 |
| 18 namespace { | 18 namespace { |
| 19 | 19 |
| 20 // Returns the key to use for storing declarative rules in the state store. | 20 // Returns the key to use for storing declarative rules in the state store. |
| 21 std::string GetDeclarativeRuleStorageKey(const std::string& event_name, | 21 std::string GetDeclarativeRuleStorageKey(const std::string& event_name, |
| 22 bool incognito) { | 22 bool incognito) { |
| 23 if (incognito) | 23 if (incognito) |
| 24 return "declarative_rules.incognito." + event_name; | 24 return "declarative_rules.incognito." + event_name; |
| 25 else | 25 else |
| 26 return "declarative_rules." + event_name; | 26 return "declarative_rules." + event_name; |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 120 const content::NotificationDetails& details) { | 120 const content::NotificationDetails& details) { |
| 121 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 121 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
| 122 DCHECK(type == chrome::NOTIFICATION_EXTENSION_LOADED); | 122 DCHECK(type == chrome::NOTIFICATION_EXTENSION_LOADED); |
| 123 | 123 |
| 124 const extensions::Extension* extension = | 124 const extensions::Extension* extension = |
| 125 content::Details<const extensions::Extension>(details).ptr(); | 125 content::Details<const extensions::Extension>(details).ptr(); |
| 126 // TODO(mpcomplete): This API check should generalize to any use of | 126 // TODO(mpcomplete): This API check should generalize to any use of |
| 127 // declarative rules, not just webRequest. | 127 // declarative rules, not just webRequest. |
| 128 if (extension->HasAPIPermission(APIPermission::kDeclarativeContent) || | 128 if (extension->HasAPIPermission(APIPermission::kDeclarativeContent) || |
| 129 extension->HasAPIPermission(APIPermission::kDeclarativeWebRequest)) { | 129 extension->HasAPIPermission(APIPermission::kDeclarativeWebRequest)) { |
| 130 ExtensionInfoMap* extension_info_map = | 130 InfoMap* extension_info_map = ExtensionSystem::Get(profile_)->info_map(); |
| 131 ExtensionSystem::Get(profile_)->info_map(); | |
| 132 if (profile_->IsOffTheRecord() && | 131 if (profile_->IsOffTheRecord() && |
| 133 !extension_info_map->IsIncognitoEnabled(extension->id())) { | 132 !extension_info_map->IsIncognitoEnabled(extension->id())) { |
| 134 // Ignore this extension. | 133 // Ignore this extension. |
| 135 } else { | 134 } else { |
| 136 ReadFromStorage(extension->id()); | 135 ReadFromStorage(extension->id()); |
| 137 } | 136 } |
| 138 } | 137 } |
| 139 } | 138 } |
| 140 | 139 |
| 141 void RulesCacheDelegate::CheckIfReady() { | 140 void RulesCacheDelegate::CheckIfReady() { |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 242 bool rules_stored) { | 241 bool rules_stored) { |
| 243 CHECK(profile_); | 242 CHECK(profile_); |
| 244 ExtensionScopedPrefs* extension_prefs = ExtensionPrefs::Get(profile_); | 243 ExtensionScopedPrefs* extension_prefs = ExtensionPrefs::Get(profile_); |
| 245 extension_prefs->UpdateExtensionPref( | 244 extension_prefs->UpdateExtensionPref( |
| 246 extension_id, | 245 extension_id, |
| 247 rules_stored_key_, | 246 rules_stored_key_, |
| 248 new base::FundamentalValue(rules_stored)); | 247 new base::FundamentalValue(rules_stored)); |
| 249 } | 248 } |
| 250 | 249 |
| 251 } // namespace extensions | 250 } // namespace extensions |
| OLD | NEW |