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

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: addressed comments, rebase on new PolicySchema 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> 7 #include <set>
bartfab (slow) 2013/05/21 12:10:56 Nit: No longer used.
Joao da Silva 2013/05/21 17:50:14 Done.
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/file_util.h" 12 #include "base/file_util.h"
13 #include "base/logging.h" 13 #include "base/logging.h"
14 #include "base/memory/ref_counted.h" 14 #include "base/memory/ref_counted.h"
15 #include "base/message_loop/message_loop_proxy.h" 15 #include "base/message_loop/message_loop_proxy.h"
16 #include "chrome/browser/extensions/api/storage/policy_value_store.h" 16 #include "chrome/browser/extensions/api/storage/policy_value_store.h"
17 #include "chrome/browser/extensions/api/storage/settings_storage_factory.h" 17 #include "chrome/browser/extensions/api/storage/settings_storage_factory.h"
18 #include "chrome/browser/extensions/event_names.h" 18 #include "chrome/browser/extensions/event_names.h"
19 #include "chrome/browser/extensions/extension_prefs.h" 19 #include "chrome/browser/extensions/extension_prefs.h"
20 #include "chrome/browser/extensions/extension_service.h" 20 #include "chrome/browser/extensions/extension_service.h"
21 #include "chrome/browser/extensions/extension_system.h" 21 #include "chrome/browser/extensions/extension_system.h"
22 #include "chrome/browser/policy/policy_domain_descriptor.h"
23 #include "chrome/browser/policy/policy_schema.h"
22 #include "chrome/browser/policy/profile_policy_connector.h" 24 #include "chrome/browser/policy/profile_policy_connector.h"
23 #include "chrome/browser/policy/profile_policy_connector_factory.h" 25 #include "chrome/browser/policy/profile_policy_connector_factory.h"
24 #include "chrome/browser/profiles/profile.h" 26 #include "chrome/browser/profiles/profile.h"
25 #include "chrome/browser/value_store/value_store_change.h" 27 #include "chrome/browser/value_store/value_store_change.h"
26 #include "chrome/common/extensions/extension.h" 28 #include "chrome/common/extensions/extension.h"
27 #include "chrome/common/extensions/extension_set.h" 29 #include "chrome/common/extensions/extension_set.h"
28 #include "chrome/common/extensions/permissions/api_permission.h" 30 #include "chrome/common/extensions/permissions/api_permission.h"
29 #include "content/public/browser/browser_thread.h" 31 #include "content/public/browser/browser_thread.h"
30 #include "content/public/browser/notification_observer.h" 32 #include "content/public/browser/notification_observer.h"
31 #include "content/public/browser/notification_registrar.h" 33 #include "content/public/browser/notification_registrar.h"
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
79 if (type == chrome::NOTIFICATION_EXTENSIONS_READY) 81 if (type == chrome::NOTIFICATION_EXTENSIONS_READY)
80 is_ready_ = true; 82 is_ready_ = true;
81 83
82 if (!is_ready_) 84 if (!is_ready_)
83 return; 85 return;
84 86
85 // TODO(joaodasilva): this currently only registers extensions that use 87 // TODO(joaodasilva): this currently only registers extensions that use
86 // the storage API, but that still includes a lot of extensions that don't 88 // the storage API, but that still includes a lot of extensions that don't
87 // use the storage.managed namespace. Use the presence of a schema for the 89 // use the storage.managed namespace. Use the presence of a schema for the
88 // managed namespace in the manifest as a better signal, once available. 90 // managed namespace in the manifest as a better signal, once available.
89 91 scoped_refptr<policy::PolicyDomainDescriptor> descriptor(
92 new policy::PolicyDomainDescriptor(policy::POLICY_DOMAIN_EXTENSIONS));
90 const ExtensionSet* set = 93 const ExtensionSet* set =
91 ExtensionSystem::Get(profile_)->extension_service()->extensions(); 94 ExtensionSystem::Get(profile_)->extension_service()->extensions();
92 std::set<std::string> use_storage_set; 95 for (ExtensionSet::const_iterator it = set->begin(); it != set->end(); ++it) {
93 for (ExtensionSet::const_iterator it = set->begin(); 96 // TODO(joaodasilva): pass the parsed schema here, once available.
94 it != set->end(); ++it) {
95 if ((*it)->HasAPIPermission(APIPermission::kStorage)) 97 if ((*it)->HasAPIPermission(APIPermission::kStorage))
96 use_storage_set.insert((*it)->id()); 98 descriptor->SetComponent((*it)->id(), scoped_ptr<policy::PolicySchema>());
97 } 99 }
98 100
99 policy::ProfilePolicyConnector* connector = 101 policy::ProfilePolicyConnector* connector =
100 policy::ProfilePolicyConnectorFactory::GetForProfile(profile_); 102 policy::ProfilePolicyConnectorFactory::GetForProfile(profile_);
101 connector->policy_service()->RegisterPolicyDomain( 103 connector->policy_service()->RegisterPolicyDomain(descriptor);
102 policy::POLICY_DOMAIN_EXTENSIONS,
103 use_storage_set);
104 } 104 }
105 105
106 ManagedValueStoreCache::ManagedValueStoreCache( 106 ManagedValueStoreCache::ManagedValueStoreCache(
107 Profile* profile, 107 Profile* profile,
108 const scoped_refptr<SettingsStorageFactory>& factory, 108 const scoped_refptr<SettingsStorageFactory>& factory,
109 const scoped_refptr<SettingsObserverList>& observers) 109 const scoped_refptr<SettingsObserverList>& observers)
110 : weak_factory_(this), 110 : weak_factory_(this),
111 weak_this_on_ui_(weak_factory_.GetWeakPtr()), 111 weak_this_on_ui_(weak_factory_.GetWeakPtr()),
112 profile_(profile), 112 profile_(profile),
113 event_router_(ExtensionSystem::Get(profile)->event_router()), 113 event_router_(ExtensionSystem::Get(profile)->event_router()),
(...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 continuation.Run(); 339 continuation.Run();
340 } 340 }
341 341
342 policy::PolicyService* ManagedValueStoreCache::GetPolicyService() { 342 policy::PolicyService* ManagedValueStoreCache::GetPolicyService() {
343 policy::ProfilePolicyConnector* connector = 343 policy::ProfilePolicyConnector* connector =
344 policy::ProfilePolicyConnectorFactory::GetForProfile(profile_); 344 policy::ProfilePolicyConnectorFactory::GetForProfile(profile_);
345 return connector->policy_service(); 345 return connector->policy_service();
346 } 346 }
347 347
348 } // namespace extensions 348 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698