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

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

Issue 32513006: Revert 229896 "Cache force-installed apps/extensions in device-l..." (Closed) Base URL: svn://svn.chromium.org/chrome/
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"
38 #include "chrome/browser/chromeos/extensions/external_pref_cache_loader.h" 37 #include "chrome/browser/chromeos/extensions/external_pref_cache_loader.h"
39 #include "chrome/browser/chromeos/login/user.h"
40 #include "chrome/browser/chromeos/login/user_manager.h" 38 #include "chrome/browser/chromeos/login/user_manager.h"
41 #include "chrome/browser/chromeos/policy/app_pack_updater.h" 39 #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"
44 #include "chrome/browser/policy/browser_policy_connector.h" 40 #include "chrome/browser/policy/browser_policy_connector.h"
45 #else 41 #else
46 #include "chrome/browser/extensions/default_apps.h" 42 #include "chrome/browser/extensions/default_apps.h"
47 #endif 43 #endif
48 44
49 #if defined(OS_WIN) 45 #if defined(OS_WIN)
50 #include "chrome/browser/extensions/external_registry_loader_win.h" 46 #include "chrome/browser/extensions/external_registry_loader_win.h"
51 #endif 47 #endif
52 48
53 using content::BrowserThread; 49 using content::BrowserThread;
54 50
55 namespace extensions { 51 namespace extensions {
56 52
57 // Constants for keeping track of extension preferences in a dictionary. 53 // Constants for keeping track of extension preferences in a dictionary.
58 const char ExternalProviderImpl::kExternalCrx[] = "external_crx"; 54 const char ExternalProviderImpl::kExternalCrx[] = "external_crx";
59 const char ExternalProviderImpl::kExternalVersion[] = "external_version"; 55 const char ExternalProviderImpl::kExternalVersion[] = "external_version";
60 const char ExternalProviderImpl::kExternalUpdateUrl[] = "external_update_url"; 56 const char ExternalProviderImpl::kExternalUpdateUrl[] = "external_update_url";
61 const char ExternalProviderImpl::kSupportedLocales[] = "supported_locales"; 57 const char ExternalProviderImpl::kSupportedLocales[] = "supported_locales";
62 const char ExternalProviderImpl::kIsBookmarkApp[] = "is_bookmark_app"; 58 const char ExternalProviderImpl::kIsBookmarkApp[] = "is_bookmark_app";
63 const char ExternalProviderImpl::kIsFromWebstore[] = "is_from_webstore"; 59 const char ExternalProviderImpl::kIsFromWebstore[] = "is_from_webstore";
64 const char ExternalProviderImpl::kKeepIfPresent[] = "keep_if_present"; 60 const char ExternalProviderImpl::kKeepIfPresent[] = "keep_if_present";
65 const char ExternalProviderImpl::kRequirePermissionsConsent[] = 61 const char ExternalProviderImpl::kRequirePermissionsConsent[] =
66 "require_permissions_consent"; 62 "require_permissions_consent";
67 63
68 ExternalProviderImpl::ExternalProviderImpl( 64 ExternalProviderImpl::ExternalProviderImpl(VisitorInterface* service,
69 VisitorInterface* service, 65 ExternalLoader* loader,
70 const scoped_refptr<ExternalLoader>& loader, 66 Profile* profile,
71 Profile* profile, 67 Manifest::Location crx_location,
72 Manifest::Location crx_location, 68 Manifest::Location download_location,
73 Manifest::Location download_location, 69 int creation_flags)
74 int creation_flags)
75 : crx_location_(crx_location), 70 : crx_location_(crx_location),
76 download_location_(download_location), 71 download_location_(download_location),
77 service_(service), 72 service_(service),
78 ready_(false), 73 ready_(false),
79 loader_(loader), 74 loader_(loader),
80 profile_(profile), 75 profile_(profile),
81 creation_flags_(creation_flags), 76 creation_flags_(creation_flags),
82 auto_acknowledge_(false) { 77 auto_acknowledge_(false) {
83 loader_->Init(this); 78 loader_->Init(this);
84 } 79 }
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after
344 *location = loc; 339 *location = loc;
345 340
346 return true; 341 return true;
347 } 342 }
348 343
349 // static 344 // static
350 void ExternalProviderImpl::CreateExternalProviders( 345 void ExternalProviderImpl::CreateExternalProviders(
351 VisitorInterface* service, 346 VisitorInterface* service,
352 Profile* profile, 347 Profile* profile,
353 ProviderCollection* provider_list) { 348 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
377 // Policies are mandatory so they can't be skipped with command line flag. 349 // Policies are mandatory so they can't be skipped with command line flag.
378 if (external_loader) { 350 provider_list->push_back(
379 provider_list->push_back( 351 linked_ptr<ExternalProviderInterface>(
380 linked_ptr<ExternalProviderInterface>( 352 new ExternalProviderImpl(
381 new ExternalProviderImpl( 353 service,
382 service, 354 new ExternalPolicyLoader(profile),
383 external_loader, 355 profile,
384 profile, 356 Manifest::INVALID_LOCATION,
385 crx_location, 357 Manifest::EXTERNAL_POLICY_DOWNLOAD,
386 Manifest::EXTERNAL_POLICY_DOWNLOAD, 358 Extension::NO_FLAGS)));
387 Extension::NO_FLAGS)));
388 }
389 359
390 // In tests don't install extensions from default external sources. 360 // In tests don't install extensions from default external sources.
391 // It would only slowdown tests and make them flaky. 361 // It would only slowdown tests and make them flaky.
392 if (CommandLine::ForCurrentProcess()->HasSwitch( 362 if (CommandLine::ForCurrentProcess()->HasSwitch(
393 switches::kDisableDefaultApps)) 363 switches::kDisableDefaultApps))
394 return; 364 return;
395 365
396 // No external app install in app mode. 366 // No external app install in app mode.
397 if (chrome::IsRunningInForcedAppMode()) 367 if (chrome::IsRunningInForcedAppMode())
398 return; 368 return;
(...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after
528 service, 498 service,
529 new ExternalComponentLoader(), 499 new ExternalComponentLoader(),
530 profile, 500 profile,
531 Manifest::INVALID_LOCATION, 501 Manifest::INVALID_LOCATION,
532 Manifest::EXTERNAL_COMPONENT, 502 Manifest::EXTERNAL_COMPONENT,
533 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT))); 503 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT)));
534 } 504 }
535 } 505 }
536 506
537 } // namespace extensions 507 } // namespace extensions
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698