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

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

Issue 15061007: Added a PolicyDomainDescriptor. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 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 | Annotate | Revision Log
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 <set>
8
9 #include "base/bind.h" 7 #include "base/bind.h"
10 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
11 #include "base/callback.h" 9 #include "base/callback.h"
12 #include "base/file_util.h" 10 #include "base/file_util.h"
13 #include "base/logging.h" 11 #include "base/logging.h"
14 #include "base/memory/ref_counted.h" 12 #include "base/memory/ref_counted.h"
15 #include "base/message_loop/message_loop_proxy.h" 13 #include "base/message_loop/message_loop_proxy.h"
16 #include "chrome/browser/extensions/api/storage/policy_value_store.h" 14 #include "chrome/browser/extensions/api/storage/policy_value_store.h"
17 #include "chrome/browser/extensions/api/storage/settings_storage_factory.h" 15 #include "chrome/browser/extensions/api/storage/settings_storage_factory.h"
18 #include "chrome/browser/extensions/event_names.h" 16 #include "chrome/browser/extensions/event_names.h"
19 #include "chrome/browser/extensions/extension_prefs.h" 17 #include "chrome/browser/extensions/extension_prefs.h"
20 #include "chrome/browser/extensions/extension_service.h" 18 #include "chrome/browser/extensions/extension_service.h"
21 #include "chrome/browser/extensions/extension_system.h" 19 #include "chrome/browser/extensions/extension_system.h"
20 #include "chrome/browser/policy/policy_domain_descriptor.h"
21 #include "chrome/browser/policy/policy_schema.h"
22 #include "chrome/browser/policy/profile_policy_connector.h" 22 #include "chrome/browser/policy/profile_policy_connector.h"
23 #include "chrome/browser/policy/profile_policy_connector_factory.h" 23 #include "chrome/browser/policy/profile_policy_connector_factory.h"
24 #include "chrome/browser/profiles/profile.h" 24 #include "chrome/browser/profiles/profile.h"
25 #include "chrome/browser/value_store/value_store_change.h" 25 #include "chrome/browser/value_store/value_store_change.h"
26 #include "chrome/common/extensions/extension.h" 26 #include "chrome/common/extensions/extension.h"
27 #include "chrome/common/extensions/extension_set.h" 27 #include "chrome/common/extensions/extension_set.h"
28 #include "chrome/common/extensions/permissions/api_permission.h" 28 #include "chrome/common/extensions/permissions/api_permission.h"
29 #include "content/public/browser/browser_thread.h" 29 #include "content/public/browser/browser_thread.h"
30 #include "content/public/browser/notification_observer.h" 30 #include "content/public/browser/notification_observer.h"
31 #include "content/public/browser/notification_registrar.h" 31 #include "content/public/browser/notification_registrar.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 int type, 71 int type,
72 const content::NotificationSource& source, 72 const content::NotificationSource& source,
73 const content::NotificationDetails& details) { 73 const content::NotificationDetails& details) {
74 if (!ExtensionSystem::Get(profile_)->ready().is_signaled()) 74 if (!ExtensionSystem::Get(profile_)->ready().is_signaled())
75 return; 75 return;
76 76
77 // TODO(joaodasilva): this currently only registers extensions that use 77 // TODO(joaodasilva): this currently only registers extensions that use
78 // the storage API, but that still includes a lot of extensions that don't 78 // the storage API, but that still includes a lot of extensions that don't
79 // use the storage.managed namespace. Use the presence of a schema for the 79 // use the storage.managed namespace. Use the presence of a schema for the
80 // managed namespace in the manifest as a better signal, once available. 80 // managed namespace in the manifest as a better signal, once available.
81 81 scoped_refptr<policy::PolicyDomainDescriptor> descriptor(
82 new policy::PolicyDomainDescriptor(policy::POLICY_DOMAIN_EXTENSIONS));
82 const ExtensionSet* set = 83 const ExtensionSet* set =
83 ExtensionSystem::Get(profile_)->extension_service()->extensions(); 84 ExtensionSystem::Get(profile_)->extension_service()->extensions();
84 std::set<std::string> use_storage_set; 85 for (ExtensionSet::const_iterator it = set->begin(); it != set->end(); ++it) {
85 for (ExtensionSet::const_iterator it = set->begin(); 86 // TODO(joaodasilva): pass the parsed schema here, once available.
86 it != set->end(); ++it) { 87 if ((*it)->HasAPIPermission(APIPermission::kStorage)) {
87 if ((*it)->HasAPIPermission(APIPermission::kStorage)) 88 descriptor->RegisterComponent((*it)->id(),
88 use_storage_set.insert((*it)->id()); 89 scoped_ptr<policy::PolicySchema>());
90 }
89 } 91 }
90 92
91 policy::ProfilePolicyConnector* connector = 93 policy::ProfilePolicyConnector* connector =
92 policy::ProfilePolicyConnectorFactory::GetForProfile(profile_); 94 policy::ProfilePolicyConnectorFactory::GetForProfile(profile_);
93 connector->policy_service()->RegisterPolicyDomain( 95 connector->policy_service()->RegisterPolicyDomain(descriptor);
94 policy::POLICY_DOMAIN_EXTENSIONS,
95 use_storage_set);
96 } 96 }
97 97
98 ManagedValueStoreCache::ManagedValueStoreCache( 98 ManagedValueStoreCache::ManagedValueStoreCache(
99 Profile* profile, 99 Profile* profile,
100 const scoped_refptr<SettingsStorageFactory>& factory, 100 const scoped_refptr<SettingsStorageFactory>& factory,
101 const scoped_refptr<SettingsObserverList>& observers) 101 const scoped_refptr<SettingsObserverList>& observers)
102 : weak_factory_(this), 102 : weak_factory_(this),
103 weak_this_on_ui_(weak_factory_.GetWeakPtr()), 103 weak_this_on_ui_(weak_factory_.GetWeakPtr()),
104 profile_(profile), 104 profile_(profile),
105 event_router_(ExtensionSystem::Get(profile)->event_router()), 105 event_router_(ExtensionSystem::Get(profile)->event_router()),
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 continuation.Run(); 331 continuation.Run();
332 } 332 }
333 333
334 policy::PolicyService* ManagedValueStoreCache::GetPolicyService() { 334 policy::PolicyService* ManagedValueStoreCache::GetPolicyService() {
335 policy::ProfilePolicyConnector* connector = 335 policy::ProfilePolicyConnector* connector =
336 policy::ProfilePolicyConnectorFactory::GetForProfile(profile_); 336 policy::ProfilePolicyConnectorFactory::GetForProfile(profile_);
337 return connector->policy_service(); 337 return connector->policy_service();
338 } 338 }
339 339
340 } // namespace extensions 340 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698