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 20 matching lines...) Expand all Loading... |
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/extension_cache.h" | 40 #include "chrome/browser/extensions/updater/extension_cache.h" |
| 41 #include "chrome/browser/extensions/updater/extension_downloader.h" |
41 #include "chrome/browser/extensions/updater/extension_updater.h" | 42 #include "chrome/browser/extensions/updater/extension_updater.h" |
42 #include "chrome/browser/profiles/profile.h" | 43 #include "chrome/browser/profiles/profile.h" |
43 #include "chrome/browser/signin/profile_identity_provider.h" | 44 #include "chrome/browser/signin/profile_identity_provider.h" |
44 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 45 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
45 #include "chrome/browser/signin/signin_manager_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" |
49 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 50 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
50 #include "chrome/browser/ui/webui/theme_source.h" | 51 #include "chrome/browser/ui/webui/theme_source.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
84 #include "chrome/browser/chromeos/extensions/install_limiter.h" | 85 #include "chrome/browser/chromeos/extensions/install_limiter.h" |
85 #include "webkit/browser/fileapi/file_system_backend.h" | 86 #include "webkit/browser/fileapi/file_system_backend.h" |
86 #include "webkit/browser/fileapi/file_system_context.h" | 87 #include "webkit/browser/fileapi/file_system_context.h" |
87 #endif | 88 #endif |
88 | 89 |
89 using content::BrowserContext; | 90 using content::BrowserContext; |
90 using content::BrowserThread; | 91 using content::BrowserThread; |
91 using content::DevToolsAgentHost; | 92 using content::DevToolsAgentHost; |
92 using extensions::CrxInstaller; | 93 using extensions::CrxInstaller; |
93 using extensions::Extension; | 94 using extensions::Extension; |
| 95 using extensions::ExtensionDownloader; |
| 96 using extensions::ExtensionDownloaderDelegate; |
94 using extensions::ExtensionIdSet; | 97 using extensions::ExtensionIdSet; |
95 using extensions::ExtensionInfo; | 98 using extensions::ExtensionInfo; |
96 using extensions::ExtensionRegistry; | 99 using extensions::ExtensionRegistry; |
97 using extensions::ExtensionSet; | 100 using extensions::ExtensionSet; |
98 using extensions::FeatureSwitch; | 101 using extensions::FeatureSwitch; |
99 using extensions::InstallVerifier; | 102 using extensions::InstallVerifier; |
100 using extensions::ManagementPolicy; | 103 using extensions::ManagementPolicy; |
101 using extensions::Manifest; | 104 using extensions::Manifest; |
102 using extensions::PermissionMessage; | 105 using extensions::PermissionMessage; |
103 using extensions::PermissionMessages; | 106 using extensions::PermissionMessages; |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
314 switches::kExtensionsUpdateFrequency), | 317 switches::kExtensionsUpdateFrequency), |
315 &update_frequency); | 318 &update_frequency); |
316 } | 319 } |
317 updater_.reset(new extensions::ExtensionUpdater( | 320 updater_.reset(new extensions::ExtensionUpdater( |
318 this, | 321 this, |
319 extension_prefs, | 322 extension_prefs, |
320 profile->GetPrefs(), | 323 profile->GetPrefs(), |
321 profile, | 324 profile, |
322 update_frequency, | 325 update_frequency, |
323 extensions::ExtensionCache::GetInstance(), | 326 extensions::ExtensionCache::GetInstance(), |
324 CreateWebstoreIdentityProvider(profile_))); | 327 base::Bind(&ExtensionService::CreateExtensionDownloader, |
| 328 base::Unretained(this)))); |
325 } | 329 } |
326 | 330 |
327 component_loader_.reset( | 331 component_loader_.reset( |
328 new extensions::ComponentLoader(this, | 332 new extensions::ComponentLoader(this, |
329 profile->GetPrefs(), | 333 profile->GetPrefs(), |
330 g_browser_process->local_state(), | 334 g_browser_process->local_state(), |
331 profile)); | 335 profile)); |
332 | 336 |
333 if (extensions_enabled_) { | 337 if (extensions_enabled_) { |
334 extensions::ExternalProviderImpl::CreateExternalProviders( | 338 extensions::ExternalProviderImpl::CreateExternalProviders( |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
575 installer->set_delete_source(file_ownership_passed); | 579 installer->set_delete_source(file_ownership_passed); |
576 installer->set_install_cause(extension_misc::INSTALL_CAUSE_UPDATE); | 580 installer->set_install_cause(extension_misc::INSTALL_CAUSE_UPDATE); |
577 installer->InstallCrx(extension_path); | 581 installer->InstallCrx(extension_path); |
578 | 582 |
579 if (out_crx_installer) | 583 if (out_crx_installer) |
580 *out_crx_installer = installer.get(); | 584 *out_crx_installer = installer.get(); |
581 | 585 |
582 return true; | 586 return true; |
583 } | 587 } |
584 | 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 |
585 void ExtensionService::ReloadExtensionImpl( | 603 void ExtensionService::ReloadExtensionImpl( |
586 // "transient" because the process of reloading may cause the reference | 604 // "transient" because the process of reloading may cause the reference |
587 // to become invalid. Instead, use |extension_id|, a copy. | 605 // to become invalid. Instead, use |extension_id|, a copy. |
588 const std::string& transient_extension_id, | 606 const std::string& transient_extension_id, |
589 bool be_noisy) { | 607 bool be_noisy) { |
590 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 608 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
591 | 609 |
592 // If the extension is already reloading, don't reload again. | 610 // If the extension is already reloading, don't reload again. |
593 if (extension_prefs_->GetDisableReasons(transient_extension_id) & | 611 if (extension_prefs_->GetDisableReasons(transient_extension_id) & |
594 Extension::DISABLE_RELOAD) { | 612 Extension::DISABLE_RELOAD) { |
(...skipping 1749 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2344 } | 2362 } |
2345 | 2363 |
2346 void ExtensionService::OnProfileDestructionStarted() { | 2364 void ExtensionService::OnProfileDestructionStarted() { |
2347 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); | 2365 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); |
2348 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); | 2366 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); |
2349 it != ids_to_unload.end(); | 2367 it != ids_to_unload.end(); |
2350 ++it) { | 2368 ++it) { |
2351 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); | 2369 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); |
2352 } | 2370 } |
2353 } | 2371 } |
OLD | NEW |