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

Side by Side Diff: extensions/browser/extension_registry.cc

Issue 695133005: Temporarily disable extensions and sync while a profile is locked - Profiles Approach (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix unit test. Don't lock policy-forced extensions. Created 6 years, 1 month 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 "extensions/browser/extension_registry.h" 5 #include "extensions/browser/extension_registry.h"
6 6
7 #include "base/strings/string_util.h" 7 #include "base/strings/string_util.h"
8 #include "extensions/browser/extension_registry_factory.h" 8 #include "extensions/browser/extension_registry_factory.h"
9 #include "extensions/browser/extension_registry_observer.h" 9 #include "extensions/browser/extension_registry_observer.h"
10 10
11 namespace extensions { 11 namespace extensions {
12 12
13 ExtensionRegistry::ExtensionRegistry(content::BrowserContext* browser_context) 13 ExtensionRegistry::ExtensionRegistry(content::BrowserContext* browser_context)
14 : browser_context_(browser_context) {} 14 : browser_context_(browser_context) {}
15 ExtensionRegistry::~ExtensionRegistry() {} 15 ExtensionRegistry::~ExtensionRegistry() {}
16 16
17 // static 17 // static
18 ExtensionRegistry* ExtensionRegistry::Get(content::BrowserContext* context) { 18 ExtensionRegistry* ExtensionRegistry::Get(content::BrowserContext* context) {
19 return ExtensionRegistryFactory::GetForBrowserContext(context); 19 return ExtensionRegistryFactory::GetForBrowserContext(context);
20 } 20 }
21 21
22 scoped_ptr<ExtensionSet> ExtensionRegistry::GenerateInstalledExtensionsSet() 22 scoped_ptr<ExtensionSet> ExtensionRegistry::GenerateInstalledExtensionsSet()
23 const { 23 const {
24 scoped_ptr<ExtensionSet> installed_extensions(new ExtensionSet); 24 scoped_ptr<ExtensionSet> installed_extensions(new ExtensionSet);
25 installed_extensions->InsertAll(enabled_extensions_); 25 installed_extensions->InsertAll(enabled_extensions_);
26 installed_extensions->InsertAll(disabled_extensions_); 26 installed_extensions->InsertAll(disabled_extensions_);
27 installed_extensions->InsertAll(terminated_extensions_); 27 installed_extensions->InsertAll(terminated_extensions_);
28 installed_extensions->InsertAll(blacklisted_extensions_); 28 installed_extensions->InsertAll(blacklisted_extensions_);
29 installed_extensions->InsertAll(locked_extensions_);
29 return installed_extensions.Pass(); 30 return installed_extensions.Pass();
30 } 31 }
31 32
32 void ExtensionRegistry::AddObserver(ExtensionRegistryObserver* observer) { 33 void ExtensionRegistry::AddObserver(ExtensionRegistryObserver* observer) {
33 observers_.AddObserver(observer); 34 observers_.AddObserver(observer);
34 } 35 }
35 36
36 void ExtensionRegistry::RemoveObserver(ExtensionRegistryObserver* observer) { 37 void ExtensionRegistry::RemoveObserver(ExtensionRegistryObserver* observer) {
37 observers_.RemoveObserver(observer); 38 observers_.RemoveObserver(observer);
38 } 39 }
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
101 if (include_mask & TERMINATED) { 102 if (include_mask & TERMINATED) {
102 const Extension* extension = terminated_extensions_.GetByID(lowercase_id); 103 const Extension* extension = terminated_extensions_.GetByID(lowercase_id);
103 if (extension) 104 if (extension)
104 return extension; 105 return extension;
105 } 106 }
106 if (include_mask & BLACKLISTED) { 107 if (include_mask & BLACKLISTED) {
107 const Extension* extension = blacklisted_extensions_.GetByID(lowercase_id); 108 const Extension* extension = blacklisted_extensions_.GetByID(lowercase_id);
108 if (extension) 109 if (extension)
109 return extension; 110 return extension;
110 } 111 }
112 if (include_mask & LOCKED) {
113 const Extension* extension = locked_extensions_.GetByID(lowercase_id);
114 if (extension)
115 return extension;
116 }
111 return NULL; 117 return NULL;
112 } 118 }
113 119
114 bool ExtensionRegistry::AddEnabled( 120 bool ExtensionRegistry::AddEnabled(
115 const scoped_refptr<const Extension>& extension) { 121 const scoped_refptr<const Extension>& extension) {
116 return enabled_extensions_.Insert(extension); 122 return enabled_extensions_.Insert(extension);
117 } 123 }
118 124
119 bool ExtensionRegistry::RemoveEnabled(const std::string& id) { 125 bool ExtensionRegistry::RemoveEnabled(const std::string& id) {
120 return enabled_extensions_.Remove(id); 126 return enabled_extensions_.Remove(id);
(...skipping 19 matching lines...) Expand all
140 146
141 bool ExtensionRegistry::AddBlacklisted( 147 bool ExtensionRegistry::AddBlacklisted(
142 const scoped_refptr<const Extension>& extension) { 148 const scoped_refptr<const Extension>& extension) {
143 return blacklisted_extensions_.Insert(extension); 149 return blacklisted_extensions_.Insert(extension);
144 } 150 }
145 151
146 bool ExtensionRegistry::RemoveBlacklisted(const std::string& id) { 152 bool ExtensionRegistry::RemoveBlacklisted(const std::string& id) {
147 return blacklisted_extensions_.Remove(id); 153 return blacklisted_extensions_.Remove(id);
148 } 154 }
149 155
156 bool ExtensionRegistry::AddLocked(
157 const scoped_refptr<const Extension>& extension) {
158 return locked_extensions_.Insert(extension);
159 }
160
161 bool ExtensionRegistry::RemoveLocked(const std::string& id) {
162 return locked_extensions_.Remove(id);
163 }
164
150 void ExtensionRegistry::ClearAll() { 165 void ExtensionRegistry::ClearAll() {
151 enabled_extensions_.Clear(); 166 enabled_extensions_.Clear();
152 disabled_extensions_.Clear(); 167 disabled_extensions_.Clear();
153 terminated_extensions_.Clear(); 168 terminated_extensions_.Clear();
154 blacklisted_extensions_.Clear(); 169 blacklisted_extensions_.Clear();
170 locked_extensions_.Clear();
155 } 171 }
156 172
157 void ExtensionRegistry::SetDisabledModificationCallback( 173 void ExtensionRegistry::SetDisabledModificationCallback(
158 const ExtensionSet::ModificationCallback& callback) { 174 const ExtensionSet::ModificationCallback& callback) {
159 disabled_extensions_.set_modification_callback(callback); 175 disabled_extensions_.set_modification_callback(callback);
160 } 176 }
161 177
162 void ExtensionRegistry::Shutdown() { 178 void ExtensionRegistry::Shutdown() {
163 // Release references to all Extension objects in the sets. 179 // Release references to all Extension objects in the sets.
164 ClearAll(); 180 ClearAll();
165 FOR_EACH_OBSERVER(ExtensionRegistryObserver, observers_, OnShutdown(this)); 181 FOR_EACH_OBSERVER(ExtensionRegistryObserver, observers_, OnShutdown(this));
166 } 182 }
167 183
168 } // namespace extensions 184 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698