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

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

Issue 314113010: Remove deprecated permissions functions from Extension (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 6 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 | Annotate | Revision Log
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_prefs.h" 15 #include "extensions/browser/extension_prefs.h"
16 #include "extensions/browser/extension_registry.h" 16 #include "extensions/browser/extension_registry.h"
17 #include "extensions/browser/extension_system.h" 17 #include "extensions/browser/extension_system.h"
18 #include "extensions/browser/info_map.h" 18 #include "extensions/browser/info_map.h"
19 #include "extensions/common/permissions/permissions_data.h"
19 20
20 namespace { 21 namespace {
21 22
22 // Returns the key to use for storing declarative rules in the state store. 23 // Returns the key to use for storing declarative rules in the state store.
23 std::string GetDeclarativeRuleStorageKey(const std::string& event_name, 24 std::string GetDeclarativeRuleStorageKey(const std::string& event_name,
24 bool incognito) { 25 bool incognito) {
25 if (incognito) 26 if (incognito)
26 return "declarative_rules.incognito." + event_name; 27 return "declarative_rules.incognito." + event_name;
27 else 28 else
28 return "declarative_rules." + event_name; 29 return "declarative_rules." + event_name;
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after
131 DCHECK(extension_service); 132 DCHECK(extension_service);
132 // In an OTR profile, we start on top of a normal profile already, so the 133 // In an OTR profile, we start on top of a normal profile already, so the
133 // extension service should be ready. 134 // extension service should be ready.
134 DCHECK(!profile_->IsOffTheRecord() || extension_service->is_ready()); 135 DCHECK(!profile_->IsOffTheRecord() || extension_service->is_ready());
135 if (extension_service->is_ready()) { 136 if (extension_service->is_ready()) {
136 const ExtensionSet* extensions = extension_service->extensions(); 137 const ExtensionSet* extensions = extension_service->extensions();
137 for (ExtensionSet::const_iterator i = extensions->begin(); 138 for (ExtensionSet::const_iterator i = extensions->begin();
138 i != extensions->end(); 139 i != extensions->end();
139 ++i) { 140 ++i) {
140 bool needs_apis_storing_rules = 141 bool needs_apis_storing_rules =
141 (*i)->HasAPIPermission(APIPermission::kDeclarativeContent) || 142 (*i)->permissions_data()->HasAPIPermission(
142 (*i)->HasAPIPermission(APIPermission::kDeclarativeWebRequest); 143 APIPermission::kDeclarativeContent) ||
144 (*i)->permissions_data()->HasAPIPermission(
145 APIPermission::kDeclarativeWebRequest);
143 bool respects_off_the_record = 146 bool respects_off_the_record =
144 !(profile_->IsOffTheRecord()) || 147 !(profile_->IsOffTheRecord()) ||
145 util::IsIncognitoEnabled((*i)->id(), profile_); 148 util::IsIncognitoEnabled((*i)->id(), profile_);
146 if (needs_apis_storing_rules && respects_off_the_record) 149 if (needs_apis_storing_rules && respects_off_the_record)
147 ReadFromStorage((*i)->id()); 150 ReadFromStorage((*i)->id());
148 } 151 }
149 } 152 }
150 } 153 }
151 154
152 void RulesCacheDelegate::ReadFromStorage(const std::string& extension_id) { 155 void RulesCacheDelegate::ReadFromStorage(const std::string& extension_id) {
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after
219 ->GetExtensionById(extension_id, ExtensionRegistry::EVERYTHING)); 222 ->GetExtensionById(extension_id, ExtensionRegistry::EVERYTHING));
220 223
221 ExtensionScopedPrefs* extension_prefs = ExtensionPrefs::Get(profile_); 224 ExtensionScopedPrefs* extension_prefs = ExtensionPrefs::Get(profile_);
222 extension_prefs->UpdateExtensionPref( 225 extension_prefs->UpdateExtensionPref(
223 extension_id, 226 extension_id,
224 rules_stored_key_, 227 rules_stored_key_,
225 new base::FundamentalValue(rules_stored)); 228 new base::FundamentalValue(rules_stored));
226 } 229 }
227 230
228 } // namespace extensions 231 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698