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

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

Issue 2441653003: Enable fetching of admin policies for login screen apps (Closed)
Patch Set: Rebase Created 4 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 (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 <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 21 matching lines...) Expand all
32 #include "extensions/browser/value_store/value_store_change.h" 32 #include "extensions/browser/value_store/value_store_change.h"
33 #include "extensions/browser/value_store/value_store_factory.h" 33 #include "extensions/browser/value_store/value_store_factory.h"
34 #include "extensions/common/api/storage.h" 34 #include "extensions/common/api/storage.h"
35 #include "extensions/common/constants.h" 35 #include "extensions/common/constants.h"
36 #include "extensions/common/extension.h" 36 #include "extensions/common/extension.h"
37 #include "extensions/common/extension_set.h" 37 #include "extensions/common/extension_set.h"
38 #include "extensions/common/manifest.h" 38 #include "extensions/common/manifest.h"
39 #include "extensions/common/manifest_constants.h" 39 #include "extensions/common/manifest_constants.h"
40 #include "extensions/common/one_shot_event.h" 40 #include "extensions/common/one_shot_event.h"
41 41
42 #if defined(OS_CHROMEOS)
43 #include "chrome/browser/chromeos/profiles/profile_helper.h"
44 #endif
45
42 using content::BrowserContext; 46 using content::BrowserContext;
43 using content::BrowserThread; 47 using content::BrowserThread;
44 48
45 namespace extensions { 49 namespace extensions {
46 class ExtensionRegistry; 50 class ExtensionRegistry;
47 51
48 namespace storage = api::storage; 52 namespace storage = api::storage;
49 53
50 namespace { 54 namespace {
51 55
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
231 // profile, regardless of its type, therefore all extensions policy domains 235 // profile, regardless of its type, therefore all extensions policy domains
232 // are marked as ready here. 236 // are marked as ready here.
233 schema_registry_->SetExtensionsDomainsReady(); 237 schema_registry_->SetExtensionsDomainsReady();
234 } 238 }
235 239
236 ManagedValueStoreCache::ManagedValueStoreCache( 240 ManagedValueStoreCache::ManagedValueStoreCache(
237 BrowserContext* context, 241 BrowserContext* context,
238 const scoped_refptr<ValueStoreFactory>& factory, 242 const scoped_refptr<ValueStoreFactory>& factory,
239 const scoped_refptr<SettingsObserverList>& observers) 243 const scoped_refptr<SettingsObserverList>& observers)
240 : profile_(Profile::FromBrowserContext(context)), 244 : profile_(Profile::FromBrowserContext(context)),
241 policy_domain_(policy::POLICY_DOMAIN_EXTENSIONS), 245 policy_domain_(GetPolicyDomain(profile_)),
242 policy_service_( 246 policy_service_(
243 policy::ProfilePolicyConnectorFactory::GetForBrowserContext(context) 247 policy::ProfilePolicyConnectorFactory::GetForBrowserContext(context)
244 ->policy_service()), 248 ->policy_service()),
245 storage_factory_(factory), 249 storage_factory_(factory),
246 observers_(observers) { 250 observers_(observers) {
247 DCHECK_CURRENTLY_ON(BrowserThread::UI); 251 DCHECK_CURRENTLY_ON(BrowserThread::UI);
248 252
249 policy_service_->AddObserver(policy_domain_, this); 253 policy_service_->AddObserver(policy_domain_, this);
250 254
251 extension_tracker_.reset(new ExtensionTracker(profile_, policy_domain_)); 255 extension_tracker_.reset(new ExtensionTracker(profile_, policy_domain_));
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
324 } 328 }
325 329
326 BrowserThread::PostTask( 330 BrowserThread::PostTask(
327 BrowserThread::FILE, FROM_HERE, 331 BrowserThread::FILE, FROM_HERE,
328 base::Bind(&ManagedValueStoreCache::UpdatePolicyOnFILE, 332 base::Bind(&ManagedValueStoreCache::UpdatePolicyOnFILE,
329 base::Unretained(this), 333 base::Unretained(this),
330 ns.component_id, 334 ns.component_id,
331 base::Passed(current.DeepCopy()))); 335 base::Passed(current.DeepCopy())));
332 } 336 }
333 337
338 // static
339 policy::PolicyDomain ManagedValueStoreCache::GetPolicyDomain(Profile* profile) {
340 #if defined(OS_CHROMEOS)
341 return chromeos::ProfileHelper::IsSigninProfile(profile)
342 ? policy::POLICY_DOMAIN_SIGNIN_EXTENSIONS
343 : policy::POLICY_DOMAIN_EXTENSIONS;
344 #else
345 return policy::POLICY_DOMAIN_EXTENSIONS;
346 #endif
347 }
348
334 void ManagedValueStoreCache::UpdatePolicyOnFILE( 349 void ManagedValueStoreCache::UpdatePolicyOnFILE(
335 const std::string& extension_id, 350 const std::string& extension_id,
336 std::unique_ptr<policy::PolicyMap> current_policy) { 351 std::unique_ptr<policy::PolicyMap> current_policy) {
337 DCHECK_CURRENTLY_ON(BrowserThread::FILE); 352 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
338 353
339 if (!HasStore(extension_id) && current_policy->empty()) { 354 if (!HasStore(extension_id) && current_policy->empty()) {
340 // Don't create the store now if there are no policies configured for this 355 // Don't create the store now if there are no policies configured for this
341 // extension. If the extension uses the storage.managed API then the store 356 // extension. If the extension uses the storage.managed API then the store
342 // will be created at RunWithValueStoreForExtension(). 357 // will be created at RunWithValueStoreForExtension().
343 return; 358 return;
(...skipping 22 matching lines...) Expand all
366 return raw_store; 381 return raw_store;
367 } 382 }
368 383
369 bool ManagedValueStoreCache::HasStore(const std::string& extension_id) const { 384 bool ManagedValueStoreCache::HasStore(const std::string& extension_id) const {
370 // Note: Currently only manage extensions (not apps). 385 // Note: Currently only manage extensions (not apps).
371 return storage_factory_->HasSettings(settings_namespace::MANAGED, 386 return storage_factory_->HasSettings(settings_namespace::MANAGED,
372 kManagedModelType, extension_id); 387 kManagedModelType, extension_id);
373 } 388 }
374 389
375 } // namespace extensions 390 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698