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

Side by Side Diff: chrome/browser/extensions/extension_service.cc

Issue 475423002: Reland: Factor Chrome details out of update manifest fetching. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: uh merge fail? Created 6 years, 3 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) 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 23 matching lines...) Expand all
34 #include "chrome/browser/extensions/extension_sync_service.h" 34 #include "chrome/browser/extensions/extension_sync_service.h"
35 #include "chrome/browser/extensions/extension_util.h" 35 #include "chrome/browser/extensions/extension_util.h"
36 #include "chrome/browser/extensions/external_install_manager.h" 36 #include "chrome/browser/extensions/external_install_manager.h"
37 #include "chrome/browser/extensions/external_provider_impl.h" 37 #include "chrome/browser/extensions/external_provider_impl.h"
38 #include "chrome/browser/extensions/install_verifier.h" 38 #include "chrome/browser/extensions/install_verifier.h"
39 #include "chrome/browser/extensions/installed_loader.h" 39 #include "chrome/browser/extensions/installed_loader.h"
40 #include "chrome/browser/extensions/pending_extension_manager.h" 40 #include "chrome/browser/extensions/pending_extension_manager.h"
41 #include "chrome/browser/extensions/permissions_updater.h" 41 #include "chrome/browser/extensions/permissions_updater.h"
42 #include "chrome/browser/extensions/shared_module_service.h" 42 #include "chrome/browser/extensions/shared_module_service.h"
43 #include "chrome/browser/extensions/unpacked_installer.h" 43 #include "chrome/browser/extensions/unpacked_installer.h"
44 #include "chrome/browser/extensions/updater/chrome_extension_downloader_factory. h"
44 #include "chrome/browser/extensions/updater/extension_cache.h" 45 #include "chrome/browser/extensions/updater/extension_cache.h"
45 #include "chrome/browser/extensions/updater/extension_downloader.h" 46 #include "chrome/browser/extensions/updater/extension_downloader.h"
46 #include "chrome/browser/extensions/updater/extension_updater.h" 47 #include "chrome/browser/extensions/updater/extension_updater.h"
48 #include "chrome/browser/google/google_brand.h"
47 #include "chrome/browser/profiles/profile.h" 49 #include "chrome/browser/profiles/profile.h"
48 #include "chrome/browser/signin/profile_identity_provider.h"
49 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h"
50 #include "chrome/browser/signin/signin_manager_factory.h"
51 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" 50 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
52 #include "chrome/browser/ui/webui/favicon_source.h" 51 #include "chrome/browser/ui/webui/favicon_source.h"
53 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h" 52 #include "chrome/browser/ui/webui/ntp/thumbnail_source.h"
54 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
55 #include "chrome/browser/ui/webui/theme_source.h" 53 #include "chrome/browser/ui/webui/theme_source.h"
56 #include "chrome/common/chrome_switches.h" 54 #include "chrome/common/chrome_switches.h"
57 #include "chrome/common/crash_keys.h" 55 #include "chrome/common/crash_keys.h"
58 #include "chrome/common/extensions/extension_constants.h" 56 #include "chrome/common/extensions/extension_constants.h"
59 #include "chrome/common/extensions/features/feature_channel.h" 57 #include "chrome/common/extensions/features/feature_channel.h"
60 #include "chrome/common/extensions/manifest_url_handler.h" 58 #include "chrome/common/extensions/manifest_url_handler.h"
61 #include "chrome/common/url_constants.h" 59 #include "chrome/common/url_constants.h"
62 #include "components/crx_file/id_util.h" 60 #include "components/crx_file/id_util.h"
63 #include "components/signin/core/browser/signin_manager.h"
64 #include "components/startup_metric_utils/startup_metric_utils.h" 61 #include "components/startup_metric_utils/startup_metric_utils.h"
65 #include "content/public/browser/devtools_agent_host.h" 62 #include "content/public/browser/devtools_agent_host.h"
66 #include "content/public/browser/notification_service.h" 63 #include "content/public/browser/notification_service.h"
67 #include "content/public/browser/render_process_host.h" 64 #include "content/public/browser/render_process_host.h"
68 #include "content/public/browser/storage_partition.h" 65 #include "content/public/browser/storage_partition.h"
69 #include "extensions/browser/event_router.h" 66 #include "extensions/browser/event_router.h"
70 #include "extensions/browser/extension_host.h" 67 #include "extensions/browser/extension_host.h"
71 #include "extensions/browser/extension_prefs.h" 68 #include "extensions/browser/extension_prefs.h"
72 #include "extensions/browser/extension_registry.h" 69 #include "extensions/browser/extension_registry.h"
73 #include "extensions/browser/extension_system.h" 70 #include "extensions/browser/extension_system.h"
(...skipping 14 matching lines...) Expand all
88 #include "chrome/browser/chromeos/extensions/install_limiter.h" 85 #include "chrome/browser/chromeos/extensions/install_limiter.h"
89 #include "storage/browser/fileapi/file_system_backend.h" 86 #include "storage/browser/fileapi/file_system_backend.h"
90 #include "storage/browser/fileapi/file_system_context.h" 87 #include "storage/browser/fileapi/file_system_context.h"
91 #endif 88 #endif
92 89
93 using content::BrowserContext; 90 using content::BrowserContext;
94 using content::BrowserThread; 91 using content::BrowserThread;
95 using content::DevToolsAgentHost; 92 using content::DevToolsAgentHost;
96 using extensions::CrxInstaller; 93 using extensions::CrxInstaller;
97 using extensions::Extension; 94 using extensions::Extension;
98 using extensions::ExtensionDownloader;
99 using extensions::ExtensionDownloaderDelegate;
100 using extensions::ExtensionIdSet; 95 using extensions::ExtensionIdSet;
101 using extensions::ExtensionInfo; 96 using extensions::ExtensionInfo;
102 using extensions::ExtensionRegistry; 97 using extensions::ExtensionRegistry;
103 using extensions::ExtensionSet; 98 using extensions::ExtensionSet;
104 using extensions::FeatureSwitch; 99 using extensions::FeatureSwitch;
105 using extensions::InstallVerifier; 100 using extensions::InstallVerifier;
106 using extensions::ManagementPolicy; 101 using extensions::ManagementPolicy;
107 using extensions::Manifest; 102 using extensions::Manifest;
108 using extensions::PermissionMessage; 103 using extensions::PermissionMessage;
109 using extensions::PermissionMessages; 104 using extensions::PermissionMessages;
110 using extensions::PermissionSet; 105 using extensions::PermissionSet;
111 using extensions::SharedModuleInfo; 106 using extensions::SharedModuleInfo;
112 using extensions::SharedModuleService; 107 using extensions::SharedModuleService;
113 using extensions::UnloadedExtensionInfo; 108 using extensions::UnloadedExtensionInfo;
114 109
115 namespace errors = extensions::manifest_errors; 110 namespace errors = extensions::manifest_errors;
116 111
117 namespace { 112 namespace {
118 113
119 // Wait this many seconds after an extensions becomes idle before updating it. 114 // Wait this many seconds after an extensions becomes idle before updating it.
120 const int kUpdateIdleDelay = 5; 115 const int kUpdateIdleDelay = 5;
121 116
122 scoped_ptr<IdentityProvider> CreateWebstoreIdentityProvider(Profile* profile) {
123 return make_scoped_ptr<IdentityProvider>(new ProfileIdentityProvider(
124 SigninManagerFactory::GetForProfile(profile),
125 ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
126 LoginUIServiceFactory::GetForProfile(profile)));
127 }
128
129 } // namespace 117 } // namespace
130 118
131 // ExtensionService. 119 // ExtensionService.
132 120
133 void ExtensionService::CheckExternalUninstall(const std::string& id) { 121 void ExtensionService::CheckExternalUninstall(const std::string& id) {
134 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 122 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
135 123
136 // Check if the providers know about this extension. 124 // Check if the providers know about this extension.
137 extensions::ProviderCollection::const_iterator i; 125 extensions::ProviderCollection::const_iterator i;
138 for (i = external_extension_providers_.begin(); 126 for (i = external_extension_providers_.begin();
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after
312 switches::kExtensionsUpdateFrequency), 300 switches::kExtensionsUpdateFrequency),
313 &update_frequency); 301 &update_frequency);
314 } 302 }
315 updater_.reset(new extensions::ExtensionUpdater( 303 updater_.reset(new extensions::ExtensionUpdater(
316 this, 304 this,
317 extension_prefs, 305 extension_prefs,
318 profile->GetPrefs(), 306 profile->GetPrefs(),
319 profile, 307 profile,
320 update_frequency, 308 update_frequency,
321 extensions::ExtensionCache::GetInstance(), 309 extensions::ExtensionCache::GetInstance(),
322 base::Bind(&ExtensionService::CreateExtensionDownloader, 310 base::Bind(ChromeExtensionDownloaderFactory::CreateForProfile,
323 base::Unretained(this)))); 311 profile)));
324 } 312 }
325 313
326 component_loader_.reset( 314 component_loader_.reset(
327 new extensions::ComponentLoader(this, 315 new extensions::ComponentLoader(this,
328 profile->GetPrefs(), 316 profile->GetPrefs(),
329 g_browser_process->local_state(), 317 g_browser_process->local_state(),
330 profile)); 318 profile));
331 319
332 if (extensions_enabled_) { 320 if (extensions_enabled_) {
333 extensions::ExternalProviderImpl::CreateExternalProviders( 321 extensions::ExternalProviderImpl::CreateExternalProviders(
(...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after
577 installer->set_delete_source(file_ownership_passed); 565 installer->set_delete_source(file_ownership_passed);
578 installer->set_install_cause(extension_misc::INSTALL_CAUSE_UPDATE); 566 installer->set_install_cause(extension_misc::INSTALL_CAUSE_UPDATE);
579 installer->InstallCrx(extension_path); 567 installer->InstallCrx(extension_path);
580 568
581 if (out_crx_installer) 569 if (out_crx_installer)
582 *out_crx_installer = installer.get(); 570 *out_crx_installer = installer.get();
583 571
584 return true; 572 return true;
585 } 573 }
586 574
587 scoped_ptr<ExtensionDownloader> ExtensionService::CreateExtensionDownloader(
588 ExtensionDownloaderDelegate* delegate) {
589 scoped_ptr<ExtensionDownloader> downloader;
590 scoped_ptr<IdentityProvider> identity_provider =
591 CreateWebstoreIdentityProvider(profile_);
592 downloader.reset(new ExtensionDownloader(
593 delegate,
594 profile_->GetRequestContext()));
595 downloader->SetWebstoreIdentityProvider(identity_provider.Pass());
596 return downloader.Pass();
597 }
598
599 void ExtensionService::ReloadExtensionImpl( 575 void ExtensionService::ReloadExtensionImpl(
600 // "transient" because the process of reloading may cause the reference 576 // "transient" because the process of reloading may cause the reference
601 // to become invalid. Instead, use |extension_id|, a copy. 577 // to become invalid. Instead, use |extension_id|, a copy.
602 const std::string& transient_extension_id, 578 const std::string& transient_extension_id,
603 bool be_noisy) { 579 bool be_noisy) {
604 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 580 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
605 581
606 // If the extension is already reloading, don't reload again. 582 // If the extension is already reloading, don't reload again.
607 if (extension_prefs_->GetDisableReasons(transient_extension_id) & 583 if (extension_prefs_->GetDisableReasons(transient_extension_id) &
608 Extension::DISABLE_RELOAD) { 584 Extension::DISABLE_RELOAD) {
(...skipping 1765 matching lines...) Expand 10 before | Expand all | Expand 10 after
2374 } 2350 }
2375 2351
2376 void ExtensionService::OnProfileDestructionStarted() { 2352 void ExtensionService::OnProfileDestructionStarted() {
2377 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); 2353 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs();
2378 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); 2354 for (ExtensionIdSet::iterator it = ids_to_unload.begin();
2379 it != ids_to_unload.end(); 2355 it != ids_to_unload.end();
2380 ++it) { 2356 ++it) {
2381 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); 2357 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN);
2382 } 2358 }
2383 } 2359 }
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/extensions/external_cache.cc ('k') | chrome/browser/extensions/extension_system_impl.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698