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

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

Issue 550403003: Move declarative api files to extensions/browser/api/declarative. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix browser tests. Created 6 years, 3 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
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 "extensions/browser/api/declarative/rules_cache_delegate.h"
6 6
7 #include "chrome/browser/chrome_notification_types.h"
8 #include "chrome/browser/extensions/api/declarative/rules_registry.h"
9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/extensions/extension_util.h"
11 #include "content/public/browser/browser_context.h" 7 #include "content/public/browser/browser_context.h"
12 #include "content/public/browser/notification_details.h" 8 #include "content/public/browser/notification_details.h"
13 #include "content/public/browser/notification_source.h" 9 #include "content/public/browser/notification_source.h"
10 #include "extensions/browser/api/declarative/rules_registry.h"
14 #include "extensions/browser/extension_prefs.h" 11 #include "extensions/browser/extension_prefs.h"
15 #include "extensions/browser/extension_registry.h" 12 #include "extensions/browser/extension_registry.h"
16 #include "extensions/browser/extension_system.h" 13 #include "extensions/browser/extension_system.h"
17 #include "extensions/browser/info_map.h" 14 #include "extensions/browser/info_map.h"
18 #include "extensions/browser/state_store.h" 15 #include "extensions/browser/state_store.h"
19 #include "extensions/common/permissions/permissions_data.h" 16 #include "extensions/common/permissions/permissions_data.h"
20 17
21 namespace { 18 namespace {
22 19
23 // 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.
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after
120 117
121 content::BrowserThread::PostTask( 118 content::BrowserThread::PostTask(
122 rules_registry_thread_, 119 rules_registry_thread_,
123 FROM_HERE, 120 FROM_HERE,
124 base::Bind( 121 base::Bind(
125 &RulesRegistry::MarkReady, registry_, storage_init_time_)); 122 &RulesRegistry::MarkReady, registry_, storage_init_time_));
126 notified_registry_ = true; 123 notified_registry_ = true;
127 } 124 }
128 125
129 void RulesCacheDelegate::ReadRulesForInstalledExtensions() { 126 void RulesCacheDelegate::ReadRulesForInstalledExtensions() {
130 ExtensionSystem& system = *ExtensionSystem::Get(browser_context_); 127 bool is_ready = ExtensionSystem::Get(browser_context_)->ready().is_signaled();
131 ExtensionService* extension_service = system.extension_service();
132 DCHECK(extension_service);
133 // In an OTR context, we start on top of a normal context already, so the 128 // In an OTR context, we start on top of a normal context already, so the
134 // extension service should be ready. 129 // extension service should be ready.
135 DCHECK(!browser_context_->IsOffTheRecord() || extension_service->is_ready()); 130 DCHECK(!browser_context_->IsOffTheRecord() || is_ready);
136 if (extension_service->is_ready()) { 131 if (is_ready) {
137 const ExtensionSet* extensions = extension_service->extensions(); 132 const ExtensionSet& extensions =
138 for (ExtensionSet::const_iterator i = extensions->begin(); 133 ExtensionRegistry::Get(browser_context_)->enabled_extensions();
139 i != extensions->end(); 134 const ExtensionPrefs* extension_prefs =
135 ExtensionPrefs::Get(browser_context_);
136 for (ExtensionSet::const_iterator i = extensions.begin();
137 i != extensions.end();
140 ++i) { 138 ++i) {
141 bool needs_apis_storing_rules = 139 bool needs_apis_storing_rules =
142 (*i)->permissions_data()->HasAPIPermission( 140 (*i)->permissions_data()->HasAPIPermission(
143 APIPermission::kDeclarativeContent) || 141 APIPermission::kDeclarativeContent) ||
144 (*i)->permissions_data()->HasAPIPermission( 142 (*i)->permissions_data()->HasAPIPermission(
145 APIPermission::kDeclarativeWebRequest); 143 APIPermission::kDeclarativeWebRequest);
146 bool respects_off_the_record = 144 bool respects_off_the_record =
147 !(browser_context_->IsOffTheRecord()) || 145 !(browser_context_->IsOffTheRecord()) ||
148 util::IsIncognitoEnabled((*i)->id(), browser_context_); 146 extension_prefs->IsIncognitoEnabled((*i)->id());
149 if (needs_apis_storing_rules && respects_off_the_record) 147 if (needs_apis_storing_rules && respects_off_the_record)
150 ReadFromStorage((*i)->id()); 148 ReadFromStorage((*i)->id());
151 } 149 }
152 } 150 }
153 } 151 }
154 152
155 void RulesCacheDelegate::ReadFromStorage(const std::string& extension_id) { 153 void RulesCacheDelegate::ReadFromStorage(const std::string& extension_id) {
156 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 154 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
157 if (!browser_context_) 155 if (!browser_context_)
158 return; 156 return;
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after
223 ->GetExtensionById(extension_id, ExtensionRegistry::EVERYTHING)); 221 ->GetExtensionById(extension_id, ExtensionRegistry::EVERYTHING));
224 222
225 ExtensionScopedPrefs* extension_prefs = ExtensionPrefs::Get(browser_context_); 223 ExtensionScopedPrefs* extension_prefs = ExtensionPrefs::Get(browser_context_);
226 extension_prefs->UpdateExtensionPref( 224 extension_prefs->UpdateExtensionPref(
227 extension_id, 225 extension_id,
228 rules_stored_key_, 226 rules_stored_key_,
229 new base::FundamentalValue(rules_stored)); 227 new base::FundamentalValue(rules_stored));
230 } 228 }
231 229
232 } // namespace extensions 230 } // namespace extensions
OLDNEW
« no previous file with comments | « extensions/browser/api/declarative/rules_cache_delegate.h ('k') | extensions/browser/api/declarative/rules_registry.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698