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

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: Created 4 years, 2 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 <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 176 matching lines...) Expand 10 before | Expand all | Expand 10 after
228 // Subsequent calls to SetReady() are ignored. 232 // Subsequent calls to SetReady() are ignored.
229 schema_registry_->SetReady(policy::POLICY_DOMAIN_EXTENSIONS); 233 schema_registry_->SetReady(policy::POLICY_DOMAIN_EXTENSIONS);
230 schema_registry_->SetReady(policy::POLICY_DOMAIN_SIGNIN_EXTENSIONS); 234 schema_registry_->SetReady(policy::POLICY_DOMAIN_SIGNIN_EXTENSIONS);
231 } 235 }
232 236
233 ManagedValueStoreCache::ManagedValueStoreCache( 237 ManagedValueStoreCache::ManagedValueStoreCache(
234 BrowserContext* context, 238 BrowserContext* context,
235 const scoped_refptr<ValueStoreFactory>& factory, 239 const scoped_refptr<ValueStoreFactory>& factory,
236 const scoped_refptr<SettingsObserverList>& observers) 240 const scoped_refptr<SettingsObserverList>& observers)
237 : profile_(Profile::FromBrowserContext(context)), 241 : profile_(Profile::FromBrowserContext(context)),
238 policy_domain_(policy::POLICY_DOMAIN_EXTENSIONS), 242 policy_domain_(GetPolicyDomain(profile_)),
239 policy_service_( 243 policy_service_(
240 policy::ProfilePolicyConnectorFactory::GetForBrowserContext(context) 244 policy::ProfilePolicyConnectorFactory::GetForBrowserContext(context)
241 ->policy_service()), 245 ->policy_service()),
242 storage_factory_(factory), 246 storage_factory_(factory),
243 observers_(observers) { 247 observers_(observers) {
244 DCHECK_CURRENTLY_ON(BrowserThread::UI); 248 DCHECK_CURRENTLY_ON(BrowserThread::UI);
245 249
246 policy_service_->AddObserver(policy_domain_, this); 250 policy_service_->AddObserver(policy_domain_, this);
247 251
248 extension_tracker_.reset(new ExtensionTracker(profile_, policy_domain_)); 252 extension_tracker_.reset(new ExtensionTracker(profile_, policy_domain_));
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
321 } 325 }
322 326
323 BrowserThread::PostTask( 327 BrowserThread::PostTask(
324 BrowserThread::FILE, FROM_HERE, 328 BrowserThread::FILE, FROM_HERE,
325 base::Bind(&ManagedValueStoreCache::UpdatePolicyOnFILE, 329 base::Bind(&ManagedValueStoreCache::UpdatePolicyOnFILE,
326 base::Unretained(this), 330 base::Unretained(this),
327 ns.component_id, 331 ns.component_id,
328 base::Passed(current.DeepCopy()))); 332 base::Passed(current.DeepCopy())));
329 } 333 }
330 334
335 // static
336 policy::PolicyDomain ManagedValueStoreCache::GetPolicyDomain(Profile* profile) {
337 #if defined(OS_CHROMEOS)
338 return chromeos::ProfileHelper::IsSigninProfile(profile)
339 ? policy::POLICY_DOMAIN_SIGNIN_EXTENSIONS
340 : policy::POLICY_DOMAIN_EXTENSIONS;
341 #else
342 return policy::POLICY_DOMAIN_EXTENSIONS;
343 #endif
344 }
345
331 void ManagedValueStoreCache::UpdatePolicyOnFILE( 346 void ManagedValueStoreCache::UpdatePolicyOnFILE(
332 const std::string& extension_id, 347 const std::string& extension_id,
333 std::unique_ptr<policy::PolicyMap> current_policy) { 348 std::unique_ptr<policy::PolicyMap> current_policy) {
334 DCHECK_CURRENTLY_ON(BrowserThread::FILE); 349 DCHECK_CURRENTLY_ON(BrowserThread::FILE);
335 350
336 if (!HasStore(extension_id) && current_policy->empty()) { 351 if (!HasStore(extension_id) && current_policy->empty()) {
337 // Don't create the store now if there are no policies configured for this 352 // Don't create the store now if there are no policies configured for this
338 // extension. If the extension uses the storage.managed API then the store 353 // extension. If the extension uses the storage.managed API then the store
339 // will be created at RunWithValueStoreForExtension(). 354 // will be created at RunWithValueStoreForExtension().
340 return; 355 return;
(...skipping 21 matching lines...) Expand all
362 return store; 377 return store;
363 } 378 }
364 379
365 bool ManagedValueStoreCache::HasStore(const std::string& extension_id) const { 380 bool ManagedValueStoreCache::HasStore(const std::string& extension_id) const {
366 // Note: Currently only manage extensions (not apps). 381 // Note: Currently only manage extensions (not apps).
367 return storage_factory_->HasSettings(settings_namespace::MANAGED, 382 return storage_factory_->HasSettings(settings_namespace::MANAGED,
368 kManagedModelType, extension_id); 383 kManagedModelType, extension_id);
369 } 384 }
370 385
371 } // namespace extensions 386 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698