| 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 "extensions/browser/api/declarative/rules_cache_delegate.h" | 5 #include "extensions/browser/api/declarative/rules_cache_delegate.h" |
| 6 | 6 |
| 7 #include <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "content/public/browser/browser_context.h" | 9 #include "content/public/browser/browser_context.h" |
| 10 #include "content/public/browser/notification_details.h" | 10 #include "content/public/browser/notification_details.h" |
| (...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 87 system.ready().Post( | 87 system.ready().Post( |
| 88 FROM_HERE, | 88 FROM_HERE, |
| 89 base::Bind(&RulesCacheDelegate::ReadRulesForInstalledExtensions, | 89 base::Bind(&RulesCacheDelegate::ReadRulesForInstalledExtensions, |
| 90 weak_ptr_factory_.GetWeakPtr())); | 90 weak_ptr_factory_.GetWeakPtr())); |
| 91 system.ready().Post(FROM_HERE, | 91 system.ready().Post(FROM_HERE, |
| 92 base::Bind(&RulesCacheDelegate::CheckIfReady, | 92 base::Bind(&RulesCacheDelegate::CheckIfReady, |
| 93 weak_ptr_factory_.GetWeakPtr())); | 93 weak_ptr_factory_.GetWeakPtr())); |
| 94 } | 94 } |
| 95 | 95 |
| 96 void RulesCacheDelegate::WriteToStorage(const std::string& extension_id, | 96 void RulesCacheDelegate::WriteToStorage(const std::string& extension_id, |
| 97 scoped_ptr<base::Value> value) { | 97 std::unique_ptr<base::Value> value) { |
| 98 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 98 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 99 if (!browser_context_) | 99 if (!browser_context_) |
| 100 return; | 100 return; |
| 101 | 101 |
| 102 const base::ListValue* rules = NULL; | 102 const base::ListValue* rules = NULL; |
| 103 CHECK(value->GetAsList(&rules)); | 103 CHECK(value->GetAsList(&rules)); |
| 104 bool rules_stored_previously = GetDeclarativeRulesStored(extension_id); | 104 bool rules_stored_previously = GetDeclarativeRulesStored(extension_id); |
| 105 bool store_rules = !rules->empty(); | 105 bool store_rules = !rules->empty(); |
| 106 SetDeclarativeRulesStored(extension_id, store_rules); | 106 SetDeclarativeRulesStored(extension_id, store_rules); |
| 107 if (!rules_stored_previously && !store_rules) | 107 if (!rules_stored_previously && !store_rules) |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 174 store->GetExtensionValue( | 174 store->GetExtensionValue( |
| 175 extension_id, | 175 extension_id, |
| 176 storage_key_, | 176 storage_key_, |
| 177 base::Bind(&RulesCacheDelegate::ReadFromStorageCallback, | 177 base::Bind(&RulesCacheDelegate::ReadFromStorageCallback, |
| 178 weak_ptr_factory_.GetWeakPtr(), | 178 weak_ptr_factory_.GetWeakPtr(), |
| 179 extension_id)); | 179 extension_id)); |
| 180 } | 180 } |
| 181 | 181 |
| 182 void RulesCacheDelegate::ReadFromStorageCallback( | 182 void RulesCacheDelegate::ReadFromStorageCallback( |
| 183 const std::string& extension_id, | 183 const std::string& extension_id, |
| 184 scoped_ptr<base::Value> value) { | 184 std::unique_ptr<base::Value> value) { |
| 185 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 185 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
| 186 content::BrowserThread::PostTask( | 186 content::BrowserThread::PostTask( |
| 187 rules_registry_thread_, | 187 rules_registry_thread_, |
| 188 FROM_HERE, | 188 FROM_HERE, |
| 189 base::Bind(&RulesRegistry::DeserializeAndAddRules, | 189 base::Bind(&RulesRegistry::DeserializeAndAddRules, |
| 190 registry_, | 190 registry_, |
| 191 extension_id, | 191 extension_id, |
| 192 base::Passed(&value))); | 192 base::Passed(&value))); |
| 193 | 193 |
| 194 waiting_for_extensions_.erase(extension_id); | 194 waiting_for_extensions_.erase(extension_id); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 223 ->GetExtensionById(extension_id, ExtensionRegistry::EVERYTHING)); | 223 ->GetExtensionById(extension_id, ExtensionRegistry::EVERYTHING)); |
| 224 | 224 |
| 225 ExtensionScopedPrefs* extension_prefs = ExtensionPrefs::Get(browser_context_); | 225 ExtensionScopedPrefs* extension_prefs = ExtensionPrefs::Get(browser_context_); |
| 226 extension_prefs->UpdateExtensionPref( | 226 extension_prefs->UpdateExtensionPref( |
| 227 extension_id, | 227 extension_id, |
| 228 rules_stored_key_, | 228 rules_stored_key_, |
| 229 new base::FundamentalValue(rules_stored)); | 229 new base::FundamentalValue(rules_stored)); |
| 230 } | 230 } |
| 231 | 231 |
| 232 } // namespace extensions | 232 } // namespace extensions |
| OLD | NEW |