Extensions cleanup: Merge IsSyncableApp+Extension, ShouldSyncApp+Extension
[chromium-blink-merge.git] / chrome / browser / extensions / external_provider_impl.cc
blob125a67c7d1fb19d2b5e0575e6efecfc978704af9
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
3 // found in the LICENSE file.
5 #include "chrome/browser/extensions/external_provider_impl.h"
7 #include <set>
8 #include <vector>
10 #include "base/command_line.h"
11 #include "base/files/file_path.h"
12 #include "base/logging.h"
13 #include "base/memory/linked_ptr.h"
14 #include "base/metrics/field_trial.h"
15 #include "base/prefs/pref_service.h"
16 #include "base/strings/string_util.h"
17 #include "base/trace_event/trace_event.h"
18 #include "base/values.h"
19 #include "base/version.h"
20 #include "chrome/browser/app_mode/app_mode_utils.h"
21 #include "chrome/browser/browser_process.h"
22 #include "chrome/browser/extensions/extension_management.h"
23 #include "chrome/browser/extensions/extension_migrator.h"
24 #include "chrome/browser/extensions/extension_service.h"
25 #include "chrome/browser/extensions/external_component_loader.h"
26 #include "chrome/browser/extensions/external_policy_loader.h"
27 #include "chrome/browser/extensions/external_pref_loader.h"
28 #include "chrome/browser/policy/profile_policy_connector.h"
29 #include "chrome/browser/policy/profile_policy_connector_factory.h"
30 #include "chrome/browser/profiles/profile.h"
31 #include "chrome/common/chrome_paths.h"
32 #include "chrome/common/chrome_switches.h"
33 #include "chrome/common/extensions/extension_constants.h"
34 #include "chrome/common/pref_names.h"
35 #include "components/crx_file/id_util.h"
36 #include "content/public/browser/browser_thread.h"
37 #include "extensions/browser/extension_system.h"
38 #include "extensions/browser/external_provider_interface.h"
39 #include "extensions/common/extension.h"
40 #include "extensions/common/manifest.h"
41 #include "ui/base/l10n/l10n_util.h"
43 #if defined(OS_CHROMEOS)
44 #include "chrome/browser/chromeos/app_mode/kiosk_app_manager.h"
45 #include "chrome/browser/chromeos/customization/customization_document.h"
46 #include "chrome/browser/chromeos/extensions/device_local_account_external_policy_loader.h"
47 #include "chrome/browser/chromeos/policy/browser_policy_connector_chromeos.h"
48 #include "chrome/browser/chromeos/policy/device_local_account.h"
49 #include "chrome/browser/chromeos/policy/device_local_account_policy_service.h"
50 #include "chrome/browser/chromeos/profiles/profile_helper.h"
51 #include "components/user_manager/user.h"
52 #else
53 #include "chrome/browser/extensions/default_apps.h"
54 #endif
56 #if defined(OS_WIN)
57 #include "chrome/browser/extensions/external_registry_loader_win.h"
58 #endif
60 using content::BrowserThread;
62 namespace extensions {
64 // Constants for keeping track of extension preferences in a dictionary.
65 const char ExternalProviderImpl::kInstallParam[] = "install_parameter";
66 const char ExternalProviderImpl::kExternalCrx[] = "external_crx";
67 const char ExternalProviderImpl::kExternalVersion[] = "external_version";
68 const char ExternalProviderImpl::kExternalUpdateUrl[] = "external_update_url";
69 const char ExternalProviderImpl::kIsBookmarkApp[] = "is_bookmark_app";
70 const char ExternalProviderImpl::kIsFromWebstore[] = "is_from_webstore";
71 const char ExternalProviderImpl::kKeepIfPresent[] = "keep_if_present";
72 const char ExternalProviderImpl::kWasInstalledByOem[] = "was_installed_by_oem";
73 const char ExternalProviderImpl::kSupportedLocales[] = "supported_locales";
74 const char ExternalProviderImpl::kMayBeUntrusted[] = "may_be_untrusted";
75 const char ExternalProviderImpl::kMinProfileCreatedByVersion[] =
76 "min_profile_created_by_version";
77 const char ExternalProviderImpl::kDoNotInstallForEnterprise[] =
78 "do_not_install_for_enterprise";
80 ExternalProviderImpl::ExternalProviderImpl(
81 VisitorInterface* service,
82 const scoped_refptr<ExternalLoader>& loader,
83 Profile* profile,
84 Manifest::Location crx_location,
85 Manifest::Location download_location,
86 int creation_flags)
87 : crx_location_(crx_location),
88 download_location_(download_location),
89 service_(service),
90 ready_(false),
91 loader_(loader),
92 profile_(profile),
93 creation_flags_(creation_flags),
94 auto_acknowledge_(false),
95 install_immediately_(false) {
96 loader_->Init(this);
99 ExternalProviderImpl::~ExternalProviderImpl() {
100 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
101 loader_->OwnerShutdown();
104 void ExternalProviderImpl::VisitRegisteredExtension() {
105 // The loader will call back to SetPrefs.
106 loader_->StartLoading();
109 void ExternalProviderImpl::SetPrefs(base::DictionaryValue* prefs) {
110 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
112 // Check if the service is still alive. It is possible that it went
113 // away while |loader_| was working on the FILE thread.
114 if (!service_) return;
116 prefs_.reset(prefs);
117 ready_ = true; // Queries for extensions are allowed from this point.
119 // Set of unsupported extensions that need to be deleted from prefs_.
120 std::set<std::string> unsupported_extensions;
122 // Notify ExtensionService about all the extensions this provider has.
123 for (base::DictionaryValue::Iterator i(*prefs_); !i.IsAtEnd(); i.Advance()) {
124 const std::string& extension_id = i.key();
125 const base::DictionaryValue* extension = NULL;
127 if (!crx_file::id_util::IdIsValid(extension_id)) {
128 LOG(WARNING) << "Malformed extension dictionary: key "
129 << extension_id.c_str() << " is not a valid id.";
130 continue;
133 if (!i.value().GetAsDictionary(&extension)) {
134 LOG(WARNING) << "Malformed extension dictionary: key "
135 << extension_id.c_str()
136 << " has a value that is not a dictionary.";
137 continue;
140 base::FilePath::StringType external_crx;
141 const base::Value* external_version_value = NULL;
142 std::string external_version;
143 std::string external_update_url;
145 bool has_external_crx = extension->GetString(kExternalCrx, &external_crx);
147 bool has_external_version = false;
148 if (extension->Get(kExternalVersion, &external_version_value)) {
149 if (external_version_value->IsType(base::Value::TYPE_STRING)) {
150 external_version_value->GetAsString(&external_version);
151 has_external_version = true;
152 } else {
153 LOG(WARNING) << "Malformed extension dictionary for extension: "
154 << extension_id.c_str() << ". " << kExternalVersion
155 << " value must be a string.";
156 continue;
160 bool has_external_update_url = extension->GetString(kExternalUpdateUrl,
161 &external_update_url);
162 if (has_external_crx != has_external_version) {
163 LOG(WARNING) << "Malformed extension dictionary for extension: "
164 << extension_id.c_str() << ". " << kExternalCrx
165 << " and " << kExternalVersion << " must be used together.";
166 continue;
169 if (has_external_crx == has_external_update_url) {
170 LOG(WARNING) << "Malformed extension dictionary for extension: "
171 << extension_id.c_str() << ". Exactly one of the "
172 << "followng keys should be used: " << kExternalCrx
173 << ", " << kExternalUpdateUrl << ".";
174 continue;
177 // Check that extension supports current browser locale.
178 const base::ListValue* supported_locales = NULL;
179 if (extension->GetList(kSupportedLocales, &supported_locales)) {
180 std::vector<std::string> browser_locales;
181 l10n_util::GetParentLocales(g_browser_process->GetApplicationLocale(),
182 &browser_locales);
184 size_t num_locales = supported_locales->GetSize();
185 bool locale_supported = false;
186 for (size_t j = 0; j < num_locales; j++) {
187 std::string current_locale;
188 if (supported_locales->GetString(j, &current_locale) &&
189 l10n_util::IsValidLocaleSyntax(current_locale)) {
190 current_locale = l10n_util::NormalizeLocale(current_locale);
191 if (std::find(browser_locales.begin(), browser_locales.end(),
192 current_locale) != browser_locales.end()) {
193 locale_supported = true;
194 break;
196 } else {
197 LOG(WARNING) << "Unrecognized locale '" << current_locale
198 << "' found as supported locale for extension: "
199 << extension_id;
203 if (!locale_supported) {
204 unsupported_extensions.insert(extension_id);
205 VLOG(1) << "Skip installing (or uninstall) external extension: "
206 << extension_id << " because the extension doesn't support "
207 << "the browser locale.";
208 continue;
212 int creation_flags = creation_flags_;
213 bool is_bookmark_app;
214 if (extension->GetBoolean(kIsBookmarkApp, &is_bookmark_app) &&
215 is_bookmark_app) {
216 creation_flags |= Extension::FROM_BOOKMARK;
218 bool is_from_webstore = false;
219 if (extension->GetBoolean(kIsFromWebstore, &is_from_webstore) &&
220 is_from_webstore) {
221 creation_flags |= Extension::FROM_WEBSTORE;
223 bool keep_if_present = false;
224 if (extension->GetBoolean(kKeepIfPresent, &keep_if_present) &&
225 keep_if_present && profile_) {
226 ExtensionServiceInterface* extension_service =
227 ExtensionSystem::Get(profile_)->extension_service();
228 const Extension* extension = extension_service ?
229 extension_service->GetExtensionById(extension_id, true) : NULL;
230 if (!extension) {
231 unsupported_extensions.insert(extension_id);
232 VLOG(1) << "Skip installing (or uninstall) external extension: "
233 << extension_id << " because the extension should be kept "
234 << "only if it is already installed.";
235 continue;
238 bool was_installed_by_oem = false;
239 if (extension->GetBoolean(kWasInstalledByOem, &was_installed_by_oem) &&
240 was_installed_by_oem) {
241 creation_flags |= Extension::WAS_INSTALLED_BY_OEM;
243 bool may_be_untrusted = false;
244 if (extension->GetBoolean(kMayBeUntrusted, &may_be_untrusted) &&
245 may_be_untrusted) {
246 creation_flags |= Extension::MAY_BE_UNTRUSTED;
249 if (!HandleMinProfileVersion(extension, extension_id,
250 &unsupported_extensions)) {
251 continue;
254 if (!HandleDoNotInstallForEnterprise(extension, extension_id,
255 &unsupported_extensions)) {
256 continue;
259 std::string install_parameter;
260 extension->GetString(kInstallParam, &install_parameter);
262 if (has_external_crx) {
263 if (crx_location_ == Manifest::INVALID_LOCATION) {
264 LOG(WARNING) << "This provider does not support installing external "
265 << "extensions from crx files.";
266 continue;
268 if (external_crx.find(base::FilePath::kParentDirectory) !=
269 base::StringPiece::npos) {
270 LOG(WARNING) << "Path traversal not allowed in path: "
271 << external_crx.c_str();
272 continue;
275 // If the path is relative, and the provider has a base path,
276 // build the absolute path to the crx file.
277 base::FilePath path(external_crx);
278 if (!path.IsAbsolute()) {
279 base::FilePath base_path = loader_->GetBaseCrxFilePath();
280 if (base_path.empty()) {
281 LOG(WARNING) << "File path " << external_crx.c_str()
282 << " is relative. An absolute path is required.";
283 continue;
285 path = base_path.Append(external_crx);
288 Version version(external_version);
289 if (!version.IsValid()) {
290 LOG(WARNING) << "Malformed extension dictionary for extension: "
291 << extension_id.c_str() << ". Invalid version string \""
292 << external_version << "\".";
293 continue;
295 service_->OnExternalExtensionFileFound(extension_id, &version, path,
296 crx_location_, creation_flags,
297 auto_acknowledge_,
298 install_immediately_);
299 } else { // if (has_external_update_url)
300 CHECK(has_external_update_url); // Checking of keys above ensures this.
301 if (download_location_ == Manifest::INVALID_LOCATION) {
302 LOG(WARNING) << "This provider does not support installing external "
303 << "extensions from update URLs.";
304 continue;
306 GURL update_url(external_update_url);
307 if (!update_url.is_valid()) {
308 LOG(WARNING) << "Malformed extension dictionary for extension: "
309 << extension_id.c_str() << ". Key " << kExternalUpdateUrl
310 << " has value \"" << external_update_url
311 << "\", which is not a valid URL.";
312 continue;
314 service_->OnExternalExtensionUpdateUrlFound(extension_id,
315 install_parameter,
316 update_url,
317 download_location_,
318 creation_flags,
319 auto_acknowledge_);
323 for (std::set<std::string>::iterator it = unsupported_extensions.begin();
324 it != unsupported_extensions.end(); ++it) {
325 // Remove extension for the list of know external extensions. The extension
326 // will be uninstalled later because provider doesn't provide it anymore.
327 prefs_->Remove(*it, NULL);
330 service_->OnExternalProviderReady(this);
333 void ExternalProviderImpl::ServiceShutdown() {
334 service_ = NULL;
337 bool ExternalProviderImpl::IsReady() const {
338 return ready_;
341 bool ExternalProviderImpl::HasExtension(
342 const std::string& id) const {
343 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
344 CHECK(prefs_.get());
345 CHECK(ready_);
346 return prefs_->HasKey(id);
349 bool ExternalProviderImpl::GetExtensionDetails(
350 const std::string& id, Manifest::Location* location,
351 scoped_ptr<Version>* version) const {
352 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
353 CHECK(prefs_.get());
354 CHECK(ready_);
355 base::DictionaryValue* extension = NULL;
356 if (!prefs_->GetDictionary(id, &extension))
357 return false;
359 Manifest::Location loc = Manifest::INVALID_LOCATION;
360 if (extension->HasKey(kExternalUpdateUrl)) {
361 loc = download_location_;
363 } else if (extension->HasKey(kExternalCrx)) {
364 loc = crx_location_;
366 std::string external_version;
367 if (!extension->GetString(kExternalVersion, &external_version))
368 return false;
370 if (version)
371 version->reset(new Version(external_version));
373 } else {
374 NOTREACHED(); // Chrome should not allow prefs to get into this state.
375 return false;
378 if (location)
379 *location = loc;
381 return true;
384 bool ExternalProviderImpl::HandleMinProfileVersion(
385 const base::DictionaryValue* extension,
386 const std::string& extension_id,
387 std::set<std::string>* unsupported_extensions) {
388 std::string min_profile_created_by_version;
389 if (profile_ &&
390 extension->GetString(kMinProfileCreatedByVersion,
391 &min_profile_created_by_version)) {
392 Version profile_version(
393 profile_->GetPrefs()->GetString(prefs::kProfileCreatedByVersion));
394 Version min_version(min_profile_created_by_version);
395 if (min_version.IsValid() && profile_version.CompareTo(min_version) < 0) {
396 unsupported_extensions->insert(extension_id);
397 VLOG(1) << "Skip installing (or uninstall) external extension: "
398 << extension_id
399 << " profile.created_by_version: " << profile_version.GetString()
400 << " min_profile_created_by_version: "
401 << min_profile_created_by_version;
402 return false;
405 return true;
408 bool ExternalProviderImpl::HandleDoNotInstallForEnterprise(
409 const base::DictionaryValue* extension,
410 const std::string& extension_id,
411 std::set<std::string>* unsupported_extensions) {
412 bool do_not_install_for_enterprise = false;
413 if (extension->GetBoolean(kDoNotInstallForEnterprise,
414 &do_not_install_for_enterprise) &&
415 do_not_install_for_enterprise) {
416 const policy::ProfilePolicyConnector* const connector =
417 policy::ProfilePolicyConnectorFactory::GetForBrowserContext(profile_);
418 if (connector->IsManaged()) {
419 unsupported_extensions->insert(extension_id);
420 VLOG(1) << "Skip installing (or uninstall) external extension "
421 << extension_id << " restricted for managed user";
422 return false;
425 return true;
428 // static
429 void ExternalProviderImpl::CreateExternalProviders(
430 VisitorInterface* service,
431 Profile* profile,
432 ProviderCollection* provider_list) {
433 TRACE_EVENT0("browser,startup",
434 "ExternalProviderImpl::CreateExternalProviders");
435 scoped_refptr<ExternalLoader> external_loader;
436 scoped_refptr<ExternalLoader> external_recommended_loader;
437 extensions::Manifest::Location crx_location = Manifest::INVALID_LOCATION;
438 #if defined(OS_CHROMEOS)
439 policy::BrowserPolicyConnectorChromeOS* connector =
440 g_browser_process->platform_part()->browser_policy_connector_chromeos();
441 bool is_chrome_os_public_session = false;
442 const user_manager::User* user =
443 chromeos::ProfileHelper::Get()->GetUserByProfile(profile);
444 policy::DeviceLocalAccount::Type account_type;
445 if (user &&
446 connector->IsEnterpriseManaged() &&
447 policy::IsDeviceLocalAccountUser(user->email(), &account_type)) {
448 if (account_type == policy::DeviceLocalAccount::TYPE_PUBLIC_SESSION)
449 is_chrome_os_public_session = true;
450 policy::DeviceLocalAccountPolicyBroker* broker =
451 connector->GetDeviceLocalAccountPolicyService()->GetBrokerForUser(
452 user->email());
453 if (broker) {
454 external_loader = broker->extension_loader();
455 crx_location = Manifest::EXTERNAL_POLICY;
456 } else {
457 NOTREACHED();
459 } else {
460 external_loader = new ExternalPolicyLoader(
461 ExtensionManagementFactory::GetForBrowserContext(profile),
462 ExternalPolicyLoader::FORCED);
463 external_recommended_loader = new ExternalPolicyLoader(
464 ExtensionManagementFactory::GetForBrowserContext(profile),
465 ExternalPolicyLoader::RECOMMENDED);
467 #else
468 external_loader = new ExternalPolicyLoader(
469 ExtensionManagementFactory::GetForBrowserContext(profile),
470 ExternalPolicyLoader::FORCED);
471 external_recommended_loader = new ExternalPolicyLoader(
472 ExtensionManagementFactory::GetForBrowserContext(profile),
473 ExternalPolicyLoader::RECOMMENDED);
474 #endif
476 // Policies are mandatory so they can't be skipped with command line flag.
477 if (external_loader.get()) {
478 provider_list->push_back(
479 linked_ptr<ExternalProviderInterface>(
480 new ExternalProviderImpl(
481 service,
482 external_loader,
483 profile,
484 crx_location,
485 Manifest::EXTERNAL_POLICY_DOWNLOAD,
486 Extension::NO_FLAGS)));
489 // Load the KioskAppExternalProvider when running in kiosk mode.
490 if (chrome::IsRunningInForcedAppMode()) {
491 #if defined(OS_CHROMEOS)
492 chromeos::KioskAppManager* kiosk_app_manager =
493 chromeos::KioskAppManager::Get();
494 DCHECK(kiosk_app_manager);
495 if (kiosk_app_manager && !kiosk_app_manager->external_loader_created()) {
496 scoped_ptr<ExternalProviderImpl> kiosk_app_provider(
497 new ExternalProviderImpl(
498 service, kiosk_app_manager->CreateExternalLoader(), profile,
499 Manifest::EXTERNAL_PREF, Manifest::INVALID_LOCATION,
500 Extension::NO_FLAGS));
501 kiosk_app_provider->set_auto_acknowledge(true);
502 kiosk_app_provider->set_install_immediately(true);
503 provider_list->push_back(
504 linked_ptr<ExternalProviderInterface>(kiosk_app_provider.release()));
506 #endif
507 return;
510 // Extensions provided by recommended policies.
511 if (external_recommended_loader.get()) {
512 provider_list->push_back(linked_ptr<ExternalProviderInterface>(
513 new ExternalProviderImpl(service,
514 external_recommended_loader,
515 profile,
516 crx_location,
517 Manifest::EXTERNAL_PREF_DOWNLOAD,
518 Extension::NO_FLAGS)));
521 // In tests don't install extensions from default external sources.
522 // It would only slowdown tests and make them flaky.
523 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
524 switches::kDisableDefaultApps))
525 return;
527 // On Mac OS, items in /Library/... should be written by the superuser.
528 // Check that all components of the path are writable by root only.
529 ExternalPrefLoader::Options check_admin_permissions_on_mac;
530 #if defined(OS_MACOSX)
531 check_admin_permissions_on_mac =
532 ExternalPrefLoader::ENSURE_PATH_CONTROLLED_BY_ADMIN;
533 #else
534 check_admin_permissions_on_mac = ExternalPrefLoader::NONE;
535 #endif
537 #if !defined(OS_WIN)
538 int bundled_extension_creation_flags = Extension::NO_FLAGS;
539 #endif
540 #if defined(OS_CHROMEOS)
541 bundled_extension_creation_flags = Extension::FROM_WEBSTORE |
542 Extension::WAS_INSTALLED_BY_DEFAULT;
544 if (!is_chrome_os_public_session) {
545 int external_apps_path_id = profile->IsSupervised() ?
546 chrome::DIR_SUPERVISED_USERS_DEFAULT_APPS :
547 chrome::DIR_STANDALONE_EXTERNAL_EXTENSIONS;
548 ExternalPrefLoader::Options pref_load_flags =
549 profile->IsNewProfile()
550 ? ExternalPrefLoader::DELAY_LOAD_UNTIL_PRIORITY_SYNC
551 : ExternalPrefLoader::NONE;
552 provider_list->push_back(
553 linked_ptr<ExternalProviderInterface>(new ExternalProviderImpl(
554 service, new ExternalPrefLoader(external_apps_path_id,
555 pref_load_flags, profile),
556 profile, Manifest::EXTERNAL_PREF, Manifest::EXTERNAL_PREF_DOWNLOAD,
557 bundled_extension_creation_flags)));
559 // OEM default apps.
560 int oem_extension_creation_flags =
561 bundled_extension_creation_flags | Extension::WAS_INSTALLED_BY_OEM;
562 chromeos::ServicesCustomizationDocument* customization =
563 chromeos::ServicesCustomizationDocument::GetInstance();
564 provider_list->push_back(linked_ptr<ExternalProviderInterface>(
565 new ExternalProviderImpl(service,
566 customization->CreateExternalLoader(profile),
567 profile,
568 Manifest::EXTERNAL_PREF,
569 Manifest::EXTERNAL_PREF_DOWNLOAD,
570 oem_extension_creation_flags)));
572 #elif defined(OS_LINUX)
573 if (!profile->IsLegacySupervised()) {
574 provider_list->push_back(
575 linked_ptr<ExternalProviderInterface>(
576 new ExternalProviderImpl(
577 service,
578 new ExternalPrefLoader(
579 chrome::DIR_STANDALONE_EXTERNAL_EXTENSIONS,
580 ExternalPrefLoader::NONE,
581 NULL),
582 profile,
583 Manifest::EXTERNAL_PREF,
584 Manifest::EXTERNAL_PREF_DOWNLOAD,
585 bundled_extension_creation_flags)));
587 #endif
589 if (!profile->IsLegacySupervised()) {
590 #if defined(OS_WIN)
591 provider_list->push_back(
592 linked_ptr<ExternalProviderInterface>(
593 new ExternalProviderImpl(
594 service,
595 new ExternalRegistryLoader,
596 profile,
597 Manifest::EXTERNAL_REGISTRY,
598 Manifest::EXTERNAL_PREF_DOWNLOAD,
599 Extension::NO_FLAGS)));
600 #else
601 provider_list->push_back(
602 linked_ptr<ExternalProviderInterface>(
603 new ExternalProviderImpl(
604 service,
605 new ExternalPrefLoader(chrome::DIR_EXTERNAL_EXTENSIONS,
606 check_admin_permissions_on_mac,
607 NULL),
608 profile,
609 Manifest::EXTERNAL_PREF,
610 Manifest::EXTERNAL_PREF_DOWNLOAD,
611 bundled_extension_creation_flags)));
613 // Define a per-user source of external extensions.
614 #if defined(OS_MACOSX)
615 provider_list->push_back(
616 linked_ptr<ExternalProviderInterface>(
617 new ExternalProviderImpl(
618 service,
619 new ExternalPrefLoader(chrome::DIR_USER_EXTERNAL_EXTENSIONS,
620 ExternalPrefLoader::NONE,
621 NULL),
622 profile,
623 Manifest::EXTERNAL_PREF,
624 Manifest::EXTERNAL_PREF_DOWNLOAD,
625 Extension::NO_FLAGS)));
626 #endif
627 #endif
629 #if !defined(OS_CHROMEOS)
630 // The default apps are installed as INTERNAL but use the external
631 // extension installer codeflow.
632 provider_list->push_back(
633 linked_ptr<ExternalProviderInterface>(
634 new default_apps::Provider(
635 profile,
636 service,
637 new ExternalPrefLoader(chrome::DIR_DEFAULT_APPS,
638 ExternalPrefLoader::NONE,
639 NULL),
640 Manifest::INTERNAL,
641 Manifest::INTERNAL,
642 Extension::FROM_WEBSTORE |
643 Extension::WAS_INSTALLED_BY_DEFAULT)));
644 #endif
646 scoped_ptr<ExternalProviderImpl> drive_migration_provider(
647 new ExternalProviderImpl(
648 service,
649 new ExtensionMigrator(profile,
650 extension_misc::kDriveHostedAppId,
651 extension_misc::kDriveExtensionId),
652 profile,
653 Manifest::EXTERNAL_PREF,
654 Manifest::EXTERNAL_PREF_DOWNLOAD,
655 Extension::FROM_WEBSTORE |
656 Extension::WAS_INSTALLED_BY_DEFAULT));
657 drive_migration_provider->set_auto_acknowledge(true);
658 provider_list->push_back(linked_ptr<ExternalProviderInterface>(
659 drive_migration_provider.release()));
662 provider_list->push_back(
663 linked_ptr<ExternalProviderInterface>(
664 new ExternalProviderImpl(
665 service,
666 new ExternalComponentLoader(profile),
667 profile,
668 Manifest::INVALID_LOCATION,
669 Manifest::EXTERNAL_COMPONENT,
670 Extension::FROM_WEBSTORE | Extension::WAS_INSTALLED_BY_DEFAULT)));
673 } // namespace extensions