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

Side by Side Diff: chrome/browser/extensions/api/storage/managed_value_store_cache.cc

Issue 298883006: Rename NOTIFICATION_EXTENSION_INSTALLED to (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add comment 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
OLDNEW
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/storage/managed_value_store_cache.h" 5 #include "chrome/browser/extensions/api/storage/managed_value_store_cache.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/file_util.h" 10 #include "base/file_util.h"
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
99 99
100 DISALLOW_COPY_AND_ASSIGN(ExtensionTracker); 100 DISALLOW_COPY_AND_ASSIGN(ExtensionTracker);
101 }; 101 };
102 102
103 ManagedValueStoreCache::ExtensionTracker::ExtensionTracker(Profile* profile) 103 ManagedValueStoreCache::ExtensionTracker::ExtensionTracker(Profile* profile)
104 : profile_(profile), 104 : profile_(profile),
105 schema_registry_( 105 schema_registry_(
106 policy::SchemaRegistryServiceFactory::GetForContext(profile)), 106 policy::SchemaRegistryServiceFactory::GetForContext(profile)),
107 weak_factory_(this) { 107 weak_factory_(this) {
108 registrar_.Add(this, 108 registrar_.Add(this,
109 chrome::NOTIFICATION_EXTENSION_INSTALLED, 109 chrome::NOTIFICATION_EXTENSION_INSTALLED_DEPRECATED,
110 content::Source<Profile>(profile_)); 110 content::Source<Profile>(profile_));
111 registrar_.Add(this, 111 registrar_.Add(this,
112 chrome::NOTIFICATION_EXTENSION_UNINSTALLED, 112 chrome::NOTIFICATION_EXTENSION_UNINSTALLED,
113 content::Source<Profile>(profile_)); 113 content::Source<Profile>(profile_));
114 114
115 // Load schemas when the extension system is ready. It might be ready now. 115 // Load schemas when the extension system is ready. It might be ready now.
116 ExtensionSystem::Get(profile_)->ready().Post( 116 ExtensionSystem::Get(profile_)->ready().Post(
117 FROM_HERE, 117 FROM_HERE,
118 base::Bind(&ExtensionTracker::OnExtensionsReady, 118 base::Bind(&ExtensionTracker::OnExtensionsReady,
119 weak_factory_.GetWeakPtr())); 119 weak_factory_.GetWeakPtr()));
120 } 120 }
121 121
122 void ManagedValueStoreCache::ExtensionTracker::Observe( 122 void ManagedValueStoreCache::ExtensionTracker::Observe(
123 int type, 123 int type,
124 const content::NotificationSource& source, 124 const content::NotificationSource& source,
125 const content::NotificationDetails& details) { 125 const content::NotificationDetails& details) {
126 // Some extensions are installed on the first run before the ExtensionSystem 126 // Some extensions are installed on the first run before the ExtensionSystem
127 // becomes ready. Wait until all of them are ready before registering the 127 // becomes ready. Wait until all of them are ready before registering the
128 // schemas of managed extensions, so that the policy loaders are reloaded at 128 // schemas of managed extensions, so that the policy loaders are reloaded at
129 // most once. 129 // most once.
130 if (!ExtensionSystem::Get(profile_)->ready().is_signaled()) 130 if (!ExtensionSystem::Get(profile_)->ready().is_signaled())
131 return; 131 return;
132 132
133 switch (type) { 133 switch (type) {
134 case chrome::NOTIFICATION_EXTENSION_INSTALLED: { 134 case chrome::NOTIFICATION_EXTENSION_INSTALLED_DEPRECATED: {
135 scoped_ptr<ExtensionSet> added(new ExtensionSet); 135 scoped_ptr<ExtensionSet> added(new ExtensionSet);
136 added->Insert( 136 added->Insert(
137 content::Details<InstalledExtensionInfo>(details)->extension); 137 content::Details<InstalledExtensionInfo>(details)->extension);
138 LoadSchemas(added.Pass()); 138 LoadSchemas(added.Pass());
139 break; 139 break;
140 } 140 }
141 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: { 141 case chrome::NOTIFICATION_EXTENSION_UNINSTALLED: {
142 const Extension* removed = 142 const Extension* removed =
143 content::Details<const Extension>(details).ptr(); 143 content::Details<const Extension>(details).ptr();
144 if (removed && UsesManagedStorage(removed)) { 144 if (removed && UsesManagedStorage(removed)) {
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after
369 369
370 return store; 370 return store;
371 } 371 }
372 372
373 bool ManagedValueStoreCache::HasStore(const std::string& extension_id) const { 373 bool ManagedValueStoreCache::HasStore(const std::string& extension_id) const {
374 // TODO(joaodasilva): move this check to a ValueStore method. 374 // TODO(joaodasilva): move this check to a ValueStore method.
375 return base::DirectoryExists(base_path_.AppendASCII(extension_id)); 375 return base::DirectoryExists(base_path_.AppendASCII(extension_id));
376 } 376 }
377 377
378 } // namespace extensions 378 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698