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

Side by Side Diff: chrome/browser/extensions/external_provider_impl.cc

Issue 27548004: Cache force-installed apps/extensions in device-local accounts (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 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 | 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/external_provider_impl.h" 5 #include "chrome/browser/extensions/external_provider_impl.h"
6 6
7 #include <set> 7 #include <set>
8 #include <vector> 8 #include <vector>
9 9
10 #include "base/command_line.h" 10 #include "base/command_line.h"
(...skipping 16 matching lines...) Expand all
27 #include "chrome/browser/profiles/profile.h" 27 #include "chrome/browser/profiles/profile.h"
28 #include "chrome/common/chrome_paths.h" 28 #include "chrome/common/chrome_paths.h"
29 #include "chrome/common/chrome_switches.h" 29 #include "chrome/common/chrome_switches.h"
30 #include "chrome/common/extensions/extension.h" 30 #include "chrome/common/extensions/extension.h"
31 #include "chrome/common/pref_names.h" 31 #include "chrome/common/pref_names.h"
32 #include "content/public/browser/browser_thread.h" 32 #include "content/public/browser/browser_thread.h"
33 #include "extensions/common/manifest.h" 33 #include "extensions/common/manifest.h"
34 #include "ui/base/l10n/l10n_util.h" 34 #include "ui/base/l10n/l10n_util.h"
35 35
36 #if defined(OS_CHROMEOS) 36 #if defined(OS_CHROMEOS)
37 #include "chrome/browser/chromeos/extensions/device_local_account_external_polic y_loader.h"
37 #include "chrome/browser/chromeos/extensions/external_pref_cache_loader.h" 38 #include "chrome/browser/chromeos/extensions/external_pref_cache_loader.h"
39 #include "chrome/browser/chromeos/login/user.h"
38 #include "chrome/browser/chromeos/login/user_manager.h" 40 #include "chrome/browser/chromeos/login/user_manager.h"
39 #include "chrome/browser/chromeos/policy/app_pack_updater.h" 41 #include "chrome/browser/chromeos/policy/app_pack_updater.h"
42 #include "chrome/browser/chromeos/policy/device_local_account.h"
43 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h"
40 #include "chrome/browser/policy/browser_policy_connector.h" 44 #include "chrome/browser/policy/browser_policy_connector.h"
41 #else 45 #else
42 #include "chrome/browser/extensions/default_apps.h" 46 #include "chrome/browser/extensions/default_apps.h"
43 #endif 47 #endif
44 48
45 #if defined(OS_WIN) 49 #if defined(OS_WIN)
46 #include "chrome/browser/extensions/external_registry_loader_win.h" 50 #include "chrome/browser/extensions/external_registry_loader_win.h"
47 #endif 51 #endif
48 52
49 using content::BrowserThread; 53 using content::BrowserThread;
50 54
51 namespace extensions { 55 namespace extensions {
52 56
53 // Constants for keeping track of extension preferences in a dictionary. 57 // Constants for keeping track of extension preferences in a dictionary.
54 const char ExternalProviderImpl::kExternalCrx[] = "external_crx"; 58 const char ExternalProviderImpl::kExternalCrx[] = "external_crx";
55 const char ExternalProviderImpl::kExternalVersion[] = "external_version"; 59 const char ExternalProviderImpl::kExternalVersion[] = "external_version";
56 const char ExternalProviderImpl::kExternalUpdateUrl[] = "external_update_url"; 60 const char ExternalProviderImpl::kExternalUpdateUrl[] = "external_update_url";
57 const char ExternalProviderImpl::kSupportedLocales[] = "supported_locales"; 61 const char ExternalProviderImpl::kSupportedLocales[] = "supported_locales";
58 const char ExternalProviderImpl::kIsBookmarkApp[] = "is_bookmark_app"; 62 const char ExternalProviderImpl::kIsBookmarkApp[] = "is_bookmark_app";
59 const char ExternalProviderImpl::kIsFromWebstore[] = "is_from_webstore"; 63 const char ExternalProviderImpl::kIsFromWebstore[] = "is_from_webstore";
60 const char ExternalProviderImpl::kKeepIfPresent[] = "keep_if_present"; 64 const char ExternalProviderImpl::kKeepIfPresent[] = "keep_if_present";
61 const char ExternalProviderImpl::kRequirePermissionsConsent[] = 65 const char ExternalProviderImpl::kRequirePermissionsConsent[] =
62 "require_permissions_consent"; 66 "require_permissions_consent";
63 67
64 ExternalProviderImpl::ExternalProviderImpl(VisitorInterface* service, 68 ExternalProviderImpl::ExternalProviderImpl(
65 ExternalLoader* loader, 69 VisitorInterface* service,
66 Profile* profile, 70 const scoped_refptr<ExternalLoader>& loader,
67 Manifest::Location crx_location, 71 Profile* profile,
68 Manifest::Location download_location, 72 Manifest::Location crx_location,
69 int creation_flags) 73 Manifest::Location download_location,
74 int creation_flags)
70 : crx_location_(crx_location), 75 : crx_location_(crx_location),
71 download_location_(download_location), 76 download_location_(download_location),
72 service_(service), 77 service_(service),
73 ready_(false), 78 ready_(false),
74 loader_(loader), 79 loader_(loader),
75 profile_(profile), 80 profile_(profile),
76 creation_flags_(creation_flags), 81 creation_flags_(creation_flags),
77 auto_acknowledge_(false) { 82 auto_acknowledge_(false) {
78 loader_->Init(this); 83 loader_->Init(this);
79 } 84 }
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
339 *location = loc; 344 *location = loc;
340 345
341 return true; 346 return true;
342 } 347 }
343 348
344 // static 349 // static
345 void ExternalProviderImpl::CreateExternalProviders( 350 void ExternalProviderImpl::CreateExternalProviders(
346 VisitorInterface* service, 351 VisitorInterface* service,
347 Profile* profile, 352 Profile* profile,
348 ProviderCollection* provider_list) { 353 ProviderCollection* provider_list) {
354 scoped_refptr<ExternalLoader> external_loader;
355 extensions::Manifest::Location crx_location = Manifest::INVALID_LOCATION;
356 #if defined(OS_CHROMEOS)
357 const chromeos::User* user = chromeos::UserManager::Get()->GetActiveUser();
Joao da Silva 2013/10/17 14:57:54 Use GetUserByProfile() instead. When a new user i
bartfab (slow) 2013/10/18 12:58:39 Done.
358 if (user && policy::IsDeviceLocalAccountUser(user->email(), NULL)) {
Matt Perry 2013/10/16 21:19:29 I don't know what a device-local account is, but a
bartfab (slow) 2013/10/17 09:16:45 A device-local account is the mechanism shared by
359 policy::DeviceLocalAccountPolicyBroker* broker =
360 g_browser_process->browser_policy_connector()->
361 GetDeviceLocalAccountPolicyService()->
362 GetBrokerForUser(user->email());
363 if (broker) {
364 external_loader = broker->extension_loader();
365 crx_location = Manifest::EXTERNAL_POLICY;
366 } else {
367 NOTREACHED();
368 }
369 } else {
370 external_loader = new ExternalPolicyLoader(profile);
371 }
372 #else
373 external_loader = new ExternalPolicyLoader(profile);
374 #endif
375
349 // Policies are mandatory so they can't be skipped with command line flag. 376 // Policies are mandatory so they can't be skipped with command line flag.
350 provider_list->push_back( 377 if (external_loader) {
351 linked_ptr<ExternalProviderInterface>( 378 provider_list->push_back(
352 new ExternalProviderImpl( 379 linked_ptr<ExternalProviderInterface>(
353 service, 380 new ExternalProviderImpl(
354 new ExternalPolicyLoader(profile), 381 service,
355 profile, 382 external_loader,
356 Manifest::INVALID_LOCATION, 383 profile,
357 Manifest::EXTERNAL_POLICY_DOWNLOAD, 384 crx_location,
358 Extension::NO_FLAGS))); 385 Manifest::EXTERNAL_POLICY_DOWNLOAD,
386 Extension::NO_FLAGS)));
387 }
359 388
360 // In tests don't install extensions from default external sources. 389 // In tests don't install extensions from default external sources.
361 // It would only slowdown tests and make them flaky. 390 // It would only slowdown tests and make them flaky.
362 if (CommandLine::ForCurrentProcess()->HasSwitch( 391 if (CommandLine::ForCurrentProcess()->HasSwitch(
363 switches::kDisableDefaultApps)) 392 switches::kDisableDefaultApps))
364 return; 393 return;
365 394
366 // No external app install in app mode. 395 // No external app install in app mode.
367 if (chrome::IsRunningInForcedAppMode()) 396 if (chrome::IsRunningInForcedAppMode())
368 return; 397 return;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 service, 527 service,
499 new ExternalComponentLoader(), 528 new ExternalComponentLoader(),
500 profile, 529 profile,
501 Manifest::INVALID_LOCATION, 530 Manifest::INVALID_LOCATION,
502 Manifest::EXTERNAL_COMPONENT, 531 Manifest::EXTERNAL_COMPONENT,
503 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT))); 532 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT)));
504 } 533 }
505 } 534 }
506 535
507 } // namespace extensions 536 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698