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

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

Issue 456063002: ExtensionUpdater: Abstract ExtensionDownloader creation (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 4 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 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 #include "webkit/browser/fileapi/file_system_backend.h" 81 #include "webkit/browser/fileapi/file_system_backend.h"
82 #include "webkit/browser/fileapi/file_system_context.h" 82 #include "webkit/browser/fileapi/file_system_context.h"
83 #endif 83 #endif
84 84
85 // TODO(thestig): Eventually remove the #ifdefs when ExtensionService is no 85 // TODO(thestig): Eventually remove the #ifdefs when ExtensionService is no
86 // longer used on mobile. 86 // longer used on mobile.
87 #if defined(ENABLE_EXTENSIONS) 87 #if defined(ENABLE_EXTENSIONS)
88 #include "chrome/browser/extensions/crx_installer.h" 88 #include "chrome/browser/extensions/crx_installer.h"
89 #include "chrome/browser/extensions/permissions_updater.h" 89 #include "chrome/browser/extensions/permissions_updater.h"
90 #include "chrome/browser/extensions/unpacked_installer.h" 90 #include "chrome/browser/extensions/unpacked_installer.h"
91 #include "chrome/browser/extensions/updater/extension_downloader.h"
91 #include "chrome/browser/extensions/updater/extension_updater.h" 92 #include "chrome/browser/extensions/updater/extension_updater.h"
92 #endif 93 #endif
93 94
94 using content::BrowserContext; 95 using content::BrowserContext;
95 using content::BrowserThread; 96 using content::BrowserThread;
96 using content::DevToolsAgentHost; 97 using content::DevToolsAgentHost;
97 using extensions::CrxInstaller; 98 using extensions::CrxInstaller;
98 using extensions::Extension; 99 using extensions::Extension;
100 using extensions::ExtensionDownloader;
101 using extensions::ExtensionDownloaderDelegate;
99 using extensions::ExtensionIdSet; 102 using extensions::ExtensionIdSet;
100 using extensions::ExtensionInfo; 103 using extensions::ExtensionInfo;
101 using extensions::ExtensionRegistry; 104 using extensions::ExtensionRegistry;
102 using extensions::ExtensionSet; 105 using extensions::ExtensionSet;
103 using extensions::FeatureSwitch; 106 using extensions::FeatureSwitch;
104 using extensions::InstallVerifier; 107 using extensions::InstallVerifier;
105 using extensions::ManagementPolicy; 108 using extensions::ManagementPolicy;
106 using extensions::Manifest; 109 using extensions::Manifest;
107 using extensions::PermissionMessage; 110 using extensions::PermissionMessage;
108 using extensions::PermissionMessages; 111 using extensions::PermissionMessages;
(...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 switches::kExtensionsUpdateFrequency), 323 switches::kExtensionsUpdateFrequency),
321 &update_frequency); 324 &update_frequency);
322 } 325 }
323 updater_.reset(new extensions::ExtensionUpdater( 326 updater_.reset(new extensions::ExtensionUpdater(
324 this, 327 this,
325 extension_prefs, 328 extension_prefs,
326 profile->GetPrefs(), 329 profile->GetPrefs(),
327 profile, 330 profile,
328 update_frequency, 331 update_frequency,
329 extensions::ExtensionCache::GetInstance(), 332 extensions::ExtensionCache::GetInstance(),
330 CreateWebstoreIdentityProvider(profile_))); 333 base::Bind(&ExtensionService::CreateExtensionDownloader,
334 base::Unretained(this))));
Yoyo Zhou 2014/08/11 23:19:28 Why not use weak pointers?
Ken Rockot(use gerrit already) 2014/08/11 23:48:24 Not allowed to use weak pointers when binding to m
331 } 335 }
332 #endif 336 #endif
333 337
334 component_loader_.reset( 338 component_loader_.reset(
335 new extensions::ComponentLoader(this, 339 new extensions::ComponentLoader(this,
336 profile->GetPrefs(), 340 profile->GetPrefs(),
337 g_browser_process->local_state(), 341 g_browser_process->local_state(),
338 profile)); 342 profile));
339 343
340 if (extensions_enabled_) { 344 if (extensions_enabled_) {
(...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after
588 592
589 if (out_crx_installer) 593 if (out_crx_installer)
590 *out_crx_installer = installer.get(); 594 *out_crx_installer = installer.get();
591 595
592 return true; 596 return true;
593 #else 597 #else
594 return false; 598 return false;
595 #endif 599 #endif
596 } 600 }
597 601
602 scoped_ptr<ExtensionDownloader> ExtensionService::CreateExtensionDownloader(
603 ExtensionDownloaderDelegate* delegate) {
604 scoped_ptr<ExtensionDownloader> downloader;
605 #if defined(ENABLE_EXTENSIONS)
606 scoped_ptr<IdentityProvider> identity_provider =
607 CreateWebstoreIdentityProvider(profile_);
608 downloader.reset(new ExtensionDownloader(
609 delegate,
610 profile_->GetRequestContext()));
611 downloader->SetWebstoreIdentityProvider(identity_provider.Pass());
612 #endif
613 return downloader.Pass();
614 }
615
598 void ExtensionService::ReloadExtensionImpl( 616 void ExtensionService::ReloadExtensionImpl(
599 // "transient" because the process of reloading may cause the reference 617 // "transient" because the process of reloading may cause the reference
600 // to become invalid. Instead, use |extension_id|, a copy. 618 // to become invalid. Instead, use |extension_id|, a copy.
601 const std::string& transient_extension_id, 619 const std::string& transient_extension_id,
602 bool be_noisy) { 620 bool be_noisy) {
603 #if defined(ENABLE_EXTENSIONS) 621 #if defined(ENABLE_EXTENSIONS)
604 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); 622 CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
605 623
606 // If the extension is already reloading, don't reload again. 624 // If the extension is already reloading, don't reload again.
607 if (extension_prefs_->GetDisableReasons(transient_extension_id) & 625 if (extension_prefs_->GetDisableReasons(transient_extension_id) &
(...skipping 1767 matching lines...) Expand 10 before | Expand all | Expand 10 after
2375 } 2393 }
2376 2394
2377 void ExtensionService::OnProfileDestructionStarted() { 2395 void ExtensionService::OnProfileDestructionStarted() {
2378 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs(); 2396 ExtensionIdSet ids_to_unload = registry_->enabled_extensions().GetIDs();
2379 for (ExtensionIdSet::iterator it = ids_to_unload.begin(); 2397 for (ExtensionIdSet::iterator it = ids_to_unload.begin();
2380 it != ids_to_unload.end(); 2398 it != ids_to_unload.end();
2381 ++it) { 2399 ++it) {
2382 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN); 2400 UnloadExtension(*it, UnloadedExtensionInfo::REASON_PROFILE_SHUTDOWN);
2383 } 2401 }
2384 } 2402 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698