| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2013 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/extension_service.h" | 5 #include "chrome/browser/extensions/extension_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <iterator> | 8 #include <iterator> |
| 9 #include <set> | 9 #include <set> |
| 10 | 10 |
| (...skipping 19 matching lines...) Expand all Loading... |
| 30 #include "chrome/browser/extensions/extension_sync_service.h" | 30 #include "chrome/browser/extensions/extension_sync_service.h" |
| 31 #include "chrome/browser/extensions/extension_util.h" | 31 #include "chrome/browser/extensions/extension_util.h" |
| 32 #include "chrome/browser/extensions/external_install_manager.h" | 32 #include "chrome/browser/extensions/external_install_manager.h" |
| 33 #include "chrome/browser/extensions/external_provider_impl.h" | 33 #include "chrome/browser/extensions/external_provider_impl.h" |
| 34 #include "chrome/browser/extensions/install_verifier.h" | 34 #include "chrome/browser/extensions/install_verifier.h" |
| 35 #include "chrome/browser/extensions/installed_loader.h" | 35 #include "chrome/browser/extensions/installed_loader.h" |
| 36 #include "chrome/browser/extensions/pending_extension_manager.h" | 36 #include "chrome/browser/extensions/pending_extension_manager.h" |
| 37 #include "chrome/browser/extensions/permissions_updater.h" | 37 #include "chrome/browser/extensions/permissions_updater.h" |
| 38 #include "chrome/browser/extensions/shared_module_service.h" | 38 #include "chrome/browser/extensions/shared_module_service.h" |
| 39 #include "chrome/browser/extensions/unpacked_installer.h" | 39 #include "chrome/browser/extensions/unpacked_installer.h" |
| 40 #include "chrome/browser/extensions/updater/chrome_extension_downloader_factory.
h" |
| 40 #include "chrome/browser/extensions/updater/extension_cache.h" | 41 #include "chrome/browser/extensions/updater/extension_cache.h" |
| 41 #include "chrome/browser/extensions/updater/extension_downloader.h" | 42 #include "chrome/browser/extensions/updater/extension_downloader.h" |
| 42 #include "chrome/browser/extensions/updater/extension_updater.h" | 43 #include "chrome/browser/extensions/updater/extension_updater.h" |
| 44 #include "chrome/browser/google/google_brand.h" |
| 43 #include "chrome/browser/profiles/profile.h" | 45 #include "chrome/browser/profiles/profile.h" |
| 44 #include "chrome/browser/signin/profile_identity_provider.h" | |
| 45 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | |
| 46 #include "chrome/browser/signin/signin_manager_factory.h" | |
| 47 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" | 46 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
| 48 #include "chrome/browser/ui/webui/favicon_source.h" | 47 #include "chrome/browser/ui/webui/favicon_source.h" |
| 49 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" | 48 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" |
| 50 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | |
| 51 #include "chrome/browser/ui/webui/theme_source.h" | 49 #include "chrome/browser/ui/webui/theme_source.h" |
| 52 #include "chrome/common/chrome_switches.h" | 50 #include "chrome/common/chrome_switches.h" |
| 53 #include "chrome/common/crash_keys.h" | 51 #include "chrome/common/crash_keys.h" |
| 54 #include "chrome/common/extensions/extension_constants.h" | 52 #include "chrome/common/extensions/extension_constants.h" |
| 55 #include "chrome/common/extensions/features/feature_channel.h" | 53 #include "chrome/common/extensions/features/feature_channel.h" |
| 56 #include "chrome/common/extensions/manifest_url_handler.h" | 54 #include "chrome/common/extensions/manifest_url_handler.h" |
| 57 #include "chrome/common/pref_names.h" | 55 #include "chrome/common/pref_names.h" |
| 58 #include "chrome/common/url_constants.h" | 56 #include "chrome/common/url_constants.h" |
| 59 #include "components/signin/core/browser/signin_manager.h" | |
| 60 #include "components/startup_metric_utils/startup_metric_utils.h" | 57 #include "components/startup_metric_utils/startup_metric_utils.h" |
| 61 #include "content/public/browser/devtools_agent_host.h" | 58 #include "content/public/browser/devtools_agent_host.h" |
| 62 #include "content/public/browser/notification_service.h" | 59 #include "content/public/browser/notification_service.h" |
| 63 #include "content/public/browser/render_process_host.h" | 60 #include "content/public/browser/render_process_host.h" |
| 64 #include "content/public/browser/storage_partition.h" | 61 #include "content/public/browser/storage_partition.h" |
| 65 #include "extensions/browser/event_router.h" | 62 #include "extensions/browser/event_router.h" |
| 66 #include "extensions/browser/extension_host.h" | 63 #include "extensions/browser/extension_host.h" |
| 67 #include "extensions/browser/extension_prefs.h" | 64 #include "extensions/browser/extension_prefs.h" |
| 68 #include "extensions/browser/extension_registry.h" | 65 #include "extensions/browser/extension_registry.h" |
| 69 #include "extensions/browser/extension_system.h" | 66 #include "extensions/browser/extension_system.h" |
| (...skipping 15 matching lines...) Expand all Loading... |
| 85 #include "chrome/browser/chromeos/extensions/install_limiter.h" | 82 #include "chrome/browser/chromeos/extensions/install_limiter.h" |
| 86 #include "webkit/browser/fileapi/file_system_backend.h" | 83 #include "webkit/browser/fileapi/file_system_backend.h" |
| 87 #include "webkit/browser/fileapi/file_system_context.h" | 84 #include "webkit/browser/fileapi/file_system_context.h" |
| 88 #endif | 85 #endif |
| 89 | 86 |
| 90 using content::BrowserContext; | 87 using content::BrowserContext; |
| 91 using content::BrowserThread; | 88 using content::BrowserThread; |
| 92 using content::DevToolsAgentHost; | 89 using content::DevToolsAgentHost; |
| 93 using extensions::CrxInstaller; | 90 using extensions::CrxInstaller; |
| 94 using extensions::Extension; | 91 using extensions::Extension; |
| 95 using extensions::ExtensionDownloader; | |
| 96 using extensions::ExtensionDownloaderDelegate; | |
| 97 using extensions::ExtensionIdSet; | 92 using extensions::ExtensionIdSet; |
| 98 using extensions::ExtensionInfo; | 93 using extensions::ExtensionInfo; |
| 99 using extensions::ExtensionRegistry; | 94 using extensions::ExtensionRegistry; |
| 100 using extensions::ExtensionSet; | 95 using extensions::ExtensionSet; |
| 101 using extensions::FeatureSwitch; | 96 using extensions::FeatureSwitch; |
| 102 using extensions::InstallVerifier; | 97 using extensions::InstallVerifier; |
| 103 using extensions::ManagementPolicy; | 98 using extensions::ManagementPolicy; |
| 104 using extensions::Manifest; | 99 using extensions::Manifest; |
| 105 using extensions::PermissionMessage; | 100 using extensions::PermissionMessage; |
| 106 using extensions::PermissionMessages; | 101 using extensions::PermissionMessages; |
| 107 using extensions::PermissionSet; | 102 using extensions::PermissionSet; |
| 108 using extensions::SharedModuleInfo; | 103 using extensions::SharedModuleInfo; |
| 109 using extensions::SharedModuleService; | 104 using extensions::SharedModuleService; |
| 110 using extensions::UnloadedExtensionInfo; | 105 using extensions::UnloadedExtensionInfo; |
| 111 | 106 |
| 112 namespace errors = extensions::manifest_errors; | 107 namespace errors = extensions::manifest_errors; |
| 113 | 108 |
| 114 namespace { | 109 namespace { |
| 115 | 110 |
| 116 // Wait this many seconds after an extensions becomes idle before updating it. | 111 // Wait this many seconds after an extensions becomes idle before updating it. |
| 117 const int kUpdateIdleDelay = 5; | 112 const int kUpdateIdleDelay = 5; |
| 118 | 113 |
| 119 #if defined(ENABLE_EXTENSIONS) | |
| 120 scoped_ptr<IdentityProvider> CreateWebstoreIdentityProvider(Profile* profile) { | |
| 121 return make_scoped_ptr<IdentityProvider>(new ProfileIdentityProvider( | |
| 122 SigninManagerFactory::GetForProfile(profile), | |
| 123 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), | |
| 124 LoginUIServiceFactory::GetForProfile(profile))); | |
| 125 } | |
| 126 #endif // defined(ENABLE_EXTENSIONS) | |
| 127 | |
| 128 } // namespace | 114 } // namespace |
| 129 | 115 |
| 130 // ExtensionService. | 116 // ExtensionService. |
| 131 | 117 |
| 132 void ExtensionService::CheckExternalUninstall(const std::string& id) { | 118 void ExtensionService::CheckExternalUninstall(const std::string& id) { |
| 133 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 119 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 134 | 120 |
| 135 // Check if the providers know about this extension. | 121 // Check if the providers know about this extension. |
| 136 extensions::ProviderCollection::const_iterator i; | 122 extensions::ProviderCollection::const_iterator i; |
| 137 for (i = external_extension_providers_.begin(); | 123 for (i = external_extension_providers_.begin(); |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 317 switches::kExtensionsUpdateFrequency), | 303 switches::kExtensionsUpdateFrequency), |
| 318 &update_frequency); | 304 &update_frequency); |
| 319 } | 305 } |
| 320 updater_.reset(new extensions::ExtensionUpdater( | 306 updater_.reset(new extensions::ExtensionUpdater( |
| 321 this, | 307 this, |
| 322 extension_prefs, | 308 extension_prefs, |
| 323 profile->GetPrefs(), | 309 profile->GetPrefs(), |
| 324 profile, | 310 profile, |
| 325 update_frequency, | 311 update_frequency, |
| 326 extensions::ExtensionCache::GetInstance(), | 312 extensions::ExtensionCache::GetInstance(), |
| 327 base::Bind(&ExtensionService::CreateExtensionDownloader, | 313 base::Bind(ChromeExtensionDownloaderFactory::CreateForProfile, |
| 328 base::Unretained(this)))); | 314 profile))); |
| 329 } | 315 } |
| 330 | 316 |
| 331 component_loader_.reset( | 317 component_loader_.reset( |
| 332 new extensions::ComponentLoader(this, | 318 new extensions::ComponentLoader(this, |
| 333 profile->GetPrefs(), | 319 profile->GetPrefs(), |
| 334 g_browser_process->local_state(), | 320 g_browser_process->local_state(), |
| 335 profile)); | 321 profile)); |
| 336 | 322 |
| 337 if (extensions_enabled_) { | 323 if (extensions_enabled_) { |
| 338 extensions::ExternalProviderImpl::CreateExternalProviders( | 324 extensions::ExternalProviderImpl::CreateExternalProviders( |
| (...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 579 installer->set_delete_source(file_ownership_passed); | 565 installer->set_delete_source(file_ownership_passed); |
| 580 installer->set_install_cause(extension_misc::INSTALL_CAUSE_UPDATE); | 566 installer->set_install_cause(extension_misc::INSTALL_CAUSE_UPDATE); |
| 581 installer->InstallCrx(extension_path); | 567 installer->InstallCrx(extension_path); |
| 582 | 568 |
| 583 if (out_crx_installer) | 569 if (out_crx_installer) |
| 584 *out_crx_installer = installer.get(); | 570 *out_crx_installer = installer.get(); |
| 585 | 571 |
| 586 return true; | 572 return true; |
| 587 } | 573 } |
| 588 | 574 |
| 589 scoped_ptr<ExtensionDownloader> ExtensionService::CreateExtensionDownloader( | |
| 590 ExtensionDownloaderDelegate* delegate) { | |
| 591 scoped_ptr<ExtensionDownloader> downloader; | |
| 592 #if defined(ENABLE_EXTENSIONS) | |
| 593 scoped_ptr<IdentityProvider> identity_provider = | |
| 594 CreateWebstoreIdentityProvider(profile_); | |
| 595 downloader.reset(new ExtensionDownloader( | |
| 596 delegate, | |
| 597 profile_->GetRequestContext())); | |
| 598 downloader->SetWebstoreIdentityProvider(identity_provider.Pass()); | |
| 599 #endif | |
| 600 return downloader.Pass(); | |
| 601 } | |
| 602 | |
| 603 void ExtensionService::ReloadExtensionImpl( | 575 void ExtensionService::ReloadExtensionImpl( |
| 604 // "transient" because the process of reloading may cause the reference | 576 // "transient" because the process of reloading may cause the reference |
| 605 // to become invalid. Instead, use |extension_id|, a copy. | 577 // to become invalid. Instead, use |extension_id|, a copy. |
| 606 const std::string& transient_extension_id, | 578 const std::string& transient_extension_id, |
| 607 bool be_noisy) { | 579 bool be_noisy) { |
| 608 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 580 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
| 609 | 581 |
| 610 // If the extension is already reloading, don't reload again. | 582 // If the extension is already reloading, don't reload again. |
| 611 if (extension_prefs_->GetDisableReasons(transient_extension_id) & | 583 if (extension_prefs_->GetDisableReasons(transient_extension_id) & |
| 612 Extension::DISABLE_RELOAD) { | 584 Extension::DISABLE_RELOAD) { |
| (...skipping 1749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2362 } | 2334 } |
| 2363 | 2335 |
| 2364 void ExtensionService::OnProfileDestructionStarted() { | 2336 void ExtensionService::OnProfileDestructionStarted() { |
| 2365 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); | 2337 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); |
| 2366 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); | 2338 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); |
| 2367 it != ids_to_unload.end(); | 2339 it != ids_to_unload.end(); |
| 2368 ++it) { | 2340 ++it) { |
| 2369 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); | 2341 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); |
| 2370 } | 2342 } |
| 2371 } | 2343 } |
| OLD | NEW |