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_with_cache.h" | 5 #include "chrome/browser/extensions/api/declarative/rules_registry_with_cache.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/logging.h" | 8 #include "base/logging.h" |
9 #include "base/message_loop.h" | 9 #include "base/message_loop.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 314 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
325 base::Bind(&RuleStorageOnUI::CheckIfReady, GetWeakPtr())); | 325 base::Bind(&RuleStorageOnUI::CheckIfReady, GetWeakPtr())); |
326 } | 326 } |
327 | 327 |
328 void RulesRegistryWithCache::RuleStorageOnUI::WriteToStorage( | 328 void RulesRegistryWithCache::RuleStorageOnUI::WriteToStorage( |
329 const std::string& extension_id, | 329 const std::string& extension_id, |
330 scoped_ptr<base::Value> value) { | 330 scoped_ptr<base::Value> value) { |
331 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 331 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
332 if (!profile_) | 332 if (!profile_) |
333 return; | 333 return; |
334 | 334 |
335 const ListValue* rules = NULL; | 335 const base::ListValue* rules = NULL; |
336 CHECK(value->GetAsList(&rules)); | 336 CHECK(value->GetAsList(&rules)); |
337 bool rules_stored_previously = GetDeclarativeRulesStored(extension_id); | 337 bool rules_stored_previously = GetDeclarativeRulesStored(extension_id); |
338 bool store_rules = !rules->empty(); | 338 bool store_rules = !rules->empty(); |
339 SetDeclarativeRulesStored(extension_id, store_rules); | 339 SetDeclarativeRulesStored(extension_id, store_rules); |
340 if (!rules_stored_previously && !store_rules) | 340 if (!rules_stored_previously && !store_rules) |
341 return; | 341 return; |
342 | 342 |
343 StateStore* store = ExtensionSystem::Get(profile_)->rules_store(); | 343 StateStore* store = ExtensionSystem::Get(profile_)->rules_store(); |
344 if (store) | 344 if (store) |
345 store->SetExtensionValue(extension_id, storage_key_, value.Pass()); | 345 store->SetExtensionValue(extension_id, storage_key_, value.Pass()); |
(...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
445 void RulesRegistryWithCache::RuleStorageOnUI::SetDeclarativeRulesStored( | 445 void RulesRegistryWithCache::RuleStorageOnUI::SetDeclarativeRulesStored( |
446 const std::string& extension_id, | 446 const std::string& extension_id, |
447 bool rules_stored) { | 447 bool rules_stored) { |
448 CHECK(profile_); | 448 CHECK(profile_); |
449 ExtensionScopedPrefs* extension_prefs = ExtensionPrefs::Get(profile_); | 449 ExtensionScopedPrefs* extension_prefs = ExtensionPrefs::Get(profile_); |
450 extension_prefs->UpdateExtensionPref( | 450 extension_prefs->UpdateExtensionPref( |
451 extension_id, kRulesStoredKey, new base::FundamentalValue(rules_stored)); | 451 extension_id, kRulesStoredKey, new base::FundamentalValue(rules_stored)); |
452 } | 452 } |
453 | 453 |
454 } // namespace extensions | 454 } // namespace extensions |
OLD | NEW |