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

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: Rebased. Ready to reland after revert due to conflicting concurrent commit. 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 =
358 chromeos::UserManager::Get()->GetUserByProfile(profile);
359 if (user && policy::IsDeviceLocalAccountUser(user->email(), NULL)) {
360 policy::DeviceLocalAccountPolicyBroker* broker =
361 g_browser_process->browser_policy_connector()->
362 GetDeviceLocalAccountPolicyService()->
363 GetBrokerForUser(user->email());
364 if (broker) {
365 external_loader = broker->extension_loader();
366 crx_location = Manifest::EXTERNAL_POLICY;
367 } else {
368 NOTREACHED();
369 }
370 } else {
371 external_loader = new ExternalPolicyLoader(profile);
372 }
373 #else
374 external_loader = new ExternalPolicyLoader(profile);
375 #endif
376
349 // Policies are mandatory so they can't be skipped with command line flag. 377 // Policies are mandatory so they can't be skipped with command line flag.
350 provider_list->push_back( 378 if (external_loader) {
351 linked_ptr<ExternalProviderInterface>( 379 provider_list->push_back(
352 new ExternalProviderImpl( 380 linked_ptr<ExternalProviderInterface>(
353 service, 381 new ExternalProviderImpl(
354 new ExternalPolicyLoader(profile), 382 service,
355 profile, 383 external_loader,
356 Manifest::INVALID_LOCATION, 384 profile,
357 Manifest::EXTERNAL_POLICY_DOWNLOAD, 385 crx_location,
358 Extension::NO_FLAGS))); 386 Manifest::EXTERNAL_POLICY_DOWNLOAD,
387 Extension::NO_FLAGS)));
388 }
359 389
360 // In tests don't install extensions from default external sources. 390 // In tests don't install extensions from default external sources.
361 // It would only slowdown tests and make them flaky. 391 // It would only slowdown tests and make them flaky.
362 if (CommandLine::ForCurrentProcess()->HasSwitch( 392 if (CommandLine::ForCurrentProcess()->HasSwitch(
363 switches::kDisableDefaultApps)) 393 switches::kDisableDefaultApps))
364 return; 394 return;
365 395
366 // No external app install in app mode. 396 // No external app install in app mode.
367 if (chrome::IsRunningInForcedAppMode()) 397 if (chrome::IsRunningInForcedAppMode())
368 return; 398 return;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
498 service, 528 service,
499 new ExternalComponentLoader(), 529 new ExternalComponentLoader(),
500 profile, 530 profile,
501 Manifest::INVALID_LOCATION, 531 Manifest::INVALID_LOCATION,
502 Manifest::EXTERNAL_COMPONENT, 532 Manifest::EXTERNAL_COMPONENT,
503 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT))); 533 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT)));
504 } 534 }
505 } 535 }
506 536
507 } // namespace extensions 537 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/external_provider_impl.h ('k') | chrome/browser/policy/browser_policy_connector.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698