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