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

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

Issue 290293002: clenaup: Removed deprecated GetInstalledExtension function from c/b/e/api (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 6 years, 7 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
« no previous file with comments | « no previous file | chrome/browser/extensions/api/declarative_content/content_action.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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_service.h" 9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/extensions/extension_util.h" 10 #include "chrome/browser/extensions/extension_util.h"
11 #include "chrome/browser/extensions/state_store.h" 11 #include "chrome/browser/extensions/state_store.h"
12 #include "chrome/browser/profiles/profile.h" 12 #include "chrome/browser/profiles/profile.h"
13 #include "content/public/browser/notification_details.h" 13 #include "content/public/browser/notification_details.h"
14 #include "content/public/browser/notification_source.h" 14 #include "content/public/browser/notification_source.h"
15 #include "extensions/browser/extension_registry.h"
15 #include "extensions/browser/extension_system.h" 16 #include "extensions/browser/extension_system.h"
16 #include "extensions/browser/info_map.h" 17 #include "extensions/browser/info_map.h"
17 18
18 namespace { 19 namespace {
19 20
20 // Returns the key to use for storing declarative rules in the state store. 21 // Returns the key to use for storing declarative rules in the state store.
21 std::string GetDeclarativeRuleStorageKey(const std::string& event_name, 22 std::string GetDeclarativeRuleStorageKey(const std::string& event_name,
22 bool incognito) { 23 bool incognito) {
23 if (incognito) 24 if (incognito)
24 return "declarative_rules.incognito." + event_name; 25 return "declarative_rules.incognito." + event_name;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
68 69
69 profile_ = registry->profile(); 70 profile_ = registry->profile();
70 storage_key_ = 71 storage_key_ =
71 GetDeclarativeRuleStorageKey(registry->event_name(), 72 GetDeclarativeRuleStorageKey(registry->event_name(),
72 profile_->IsOffTheRecord()); 73 profile_->IsOffTheRecord());
73 rules_stored_key_ = GetRulesStoredKey(registry->event_name(), 74 rules_stored_key_ = GetRulesStoredKey(registry->event_name(),
74 profile_->IsOffTheRecord()); 75 profile_->IsOffTheRecord());
75 rules_registry_thread_ = registry->owner_thread(); 76 rules_registry_thread_ = registry->owner_thread();
76 77
77 ExtensionSystem& system = *ExtensionSystem::Get(profile_); 78 ExtensionSystem& system = *ExtensionSystem::Get(profile_);
78 extensions::StateStore* store = system.rules_store(); 79 StateStore* store = system.rules_store();
79 if (store) 80 if (store)
80 store->RegisterKey(storage_key_); 81 store->RegisterKey(storage_key_);
81 82
82 if (profile_->IsOffTheRecord()) 83 if (profile_->IsOffTheRecord())
83 log_storage_init_delay_ = false; 84 log_storage_init_delay_ = false;
84 85
85 system.ready().Post( 86 system.ready().Post(
86 FROM_HERE, 87 FROM_HERE,
87 base::Bind(&RulesCacheDelegate::ReadRulesForInstalledExtensions, 88 base::Bind(&RulesCacheDelegate::ReadRulesForInstalledExtensions,
88 weak_ptr_factory_.GetWeakPtr())); 89 weak_ptr_factory_.GetWeakPtr()));
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
155 if (log_storage_init_delay_ && storage_init_time_.is_null()) 156 if (log_storage_init_delay_ && storage_init_time_.is_null())
156 storage_init_time_ = base::Time::Now(); 157 storage_init_time_ = base::Time::Now();
157 158
158 if (!GetDeclarativeRulesStored(extension_id)) { 159 if (!GetDeclarativeRulesStored(extension_id)) {
159 ExtensionSystem::Get(profile_)->ready().Post( 160 ExtensionSystem::Get(profile_)->ready().Post(
160 FROM_HERE, base::Bind(&RulesCacheDelegate::CheckIfReady, 161 FROM_HERE, base::Bind(&RulesCacheDelegate::CheckIfReady,
161 weak_ptr_factory_.GetWeakPtr())); 162 weak_ptr_factory_.GetWeakPtr()));
162 return; 163 return;
163 } 164 }
164 165
165 extensions::StateStore* store = ExtensionSystem::Get(profile_)->rules_store(); 166 StateStore* store = ExtensionSystem::Get(profile_)->rules_store();
166 if (!store) 167 if (!store)
167 return; 168 return;
168 waiting_for_extensions_.insert(extension_id); 169 waiting_for_extensions_.insert(extension_id);
169 store->GetExtensionValue( 170 store->GetExtensionValue(
170 extension_id, 171 extension_id,
171 storage_key_, 172 storage_key_,
172 base::Bind(&RulesCacheDelegate::ReadFromStorageCallback, 173 base::Bind(&RulesCacheDelegate::ReadFromStorageCallback,
173 weak_ptr_factory_.GetWeakPtr(), 174 weak_ptr_factory_.GetWeakPtr(),
174 extension_id)); 175 extension_id));
175 } 176 }
(...skipping 30 matching lines...) Expand all
206 207
207 // Safe default -- if we don't know that the rules are not stored, we force 208 // Safe default -- if we don't know that the rules are not stored, we force
208 // a read by returning true. 209 // a read by returning true.
209 return true; 210 return true;
210 } 211 }
211 212
212 void RulesCacheDelegate::SetDeclarativeRulesStored( 213 void RulesCacheDelegate::SetDeclarativeRulesStored(
213 const std::string& extension_id, 214 const std::string& extension_id,
214 bool rules_stored) { 215 bool rules_stored) {
215 CHECK(profile_); 216 CHECK(profile_);
216 ExtensionSystem& system = *ExtensionSystem::Get(profile_); 217 DCHECK(ExtensionRegistry::Get(profile_)
217 ExtensionService* extension_service = system.extension_service(); 218 ->GetExtensionById(extension_id, ExtensionRegistry::EVERYTHING));
218 DCHECK(extension_service); 219
219 DCHECK(extension_service->GetInstalledExtension(extension_id));
220 ExtensionScopedPrefs* extension_prefs = ExtensionPrefs::Get(profile_); 220 ExtensionScopedPrefs* extension_prefs = ExtensionPrefs::Get(profile_);
221 extension_prefs->UpdateExtensionPref( 221 extension_prefs->UpdateExtensionPref(
222 extension_id, 222 extension_id,
223 rules_stored_key_, 223 rules_stored_key_,
224 new base::FundamentalValue(rules_stored)); 224 new base::FundamentalValue(rules_stored));
225 } 225 }
226 226
227 } // namespace extensions 227 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/api/declarative_content/content_action.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698