Sever PendingExtensionManager's dependency on ExtensionService

PendingExtensionManager has no reason to depend on ExtensionService.  So remove
it.

If there is a desire for PendingExtensionManager to be in /extensions, it would
be very easy to do so - the only thing keeping it in /chrome is a constant.

Review URL: https://codereview.chromium.org/297613002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@271855 0039d316-1c4b-4281-b951-d872f2087c98
parent 815e402d
...@@ -275,7 +275,7 @@ ExtensionService::ExtensionService(Profile* profile, ...@@ -275,7 +275,7 @@ ExtensionService::ExtensionService(Profile* profile,
blacklist_(blacklist), blacklist_(blacklist),
extension_sync_service_(NULL), extension_sync_service_(NULL),
registry_(extensions::ExtensionRegistry::Get(profile)), registry_(extensions::ExtensionRegistry::Get(profile)),
pending_extension_manager_(*this, profile), pending_extension_manager_(profile),
install_directory_(install_directory), install_directory_(install_directory),
extensions_enabled_(extensions_enabled), extensions_enabled_(extensions_enabled),
show_extensions_prompts_(true), show_extensions_prompts_(true),
......
...@@ -8,9 +8,10 @@ ...@@ -8,9 +8,10 @@
#include "base/logging.h" #include "base/logging.h"
#include "base/version.h" #include "base/version.h"
#include "chrome/browser/extensions/extension_service.h" #include "chrome/common/extensions/extension_constants.h"
#include "content/public/browser/browser_thread.h" #include "content/public/browser/browser_thread.h"
#include "extensions/browser/extension_prefs.h" #include "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/common/extension.h" #include "extensions/common/extension.h"
#include "url/gurl.h" #include "url/gurl.h"
...@@ -32,9 +33,8 @@ std::string GetVersionString(const Version& version) { ...@@ -32,9 +33,8 @@ std::string GetVersionString(const Version& version) {
namespace extensions { namespace extensions {
PendingExtensionManager::PendingExtensionManager( PendingExtensionManager::PendingExtensionManager(
const ExtensionServiceInterface& service,
content::BrowserContext* context) content::BrowserContext* context)
: service_(service), context_(context) {} : context_(context) {}
PendingExtensionManager::~PendingExtensionManager() {} PendingExtensionManager::~PendingExtensionManager() {}
...@@ -93,7 +93,8 @@ bool PendingExtensionManager::AddFromSync( ...@@ -93,7 +93,8 @@ bool PendingExtensionManager::AddFromSync(
bool remote_install) { bool remote_install) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (service_.GetInstalledExtension(id)) { if (ExtensionRegistry::Get(context_)->GetExtensionById(
id, ExtensionRegistry::EVERYTHING)) {
LOG(ERROR) << "Trying to add pending extension " << id LOG(ERROR) << "Trying to add pending extension " << id
<< " which already exists"; << " which already exists";
return false; return false;
...@@ -107,9 +108,9 @@ bool PendingExtensionManager::AddFromSync( ...@@ -107,9 +108,9 @@ bool PendingExtensionManager::AddFromSync(
return false; return false;
} }
const bool kIsFromSync = true; static const bool kIsFromSync = true;
const Manifest::Location kSyncLocation = Manifest::INTERNAL; static const Manifest::Location kSyncLocation = Manifest::INTERNAL;
const bool kMarkAcknowledged = false; static const bool kMarkAcknowledged = false;
return AddExtensionImpl(id, return AddExtensionImpl(id,
std::string(), std::string(),
...@@ -130,17 +131,18 @@ bool PendingExtensionManager::AddFromExtensionImport( ...@@ -130,17 +131,18 @@ bool PendingExtensionManager::AddFromExtensionImport(
PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install) { PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
if (service_.GetInstalledExtension(id)) { if (ExtensionRegistry::Get(context_)->GetExtensionById(
id, ExtensionRegistry::EVERYTHING)) {
LOG(ERROR) << "Trying to add pending extension " << id LOG(ERROR) << "Trying to add pending extension " << id
<< " which already exists"; << " which already exists";
return false; return false;
} }
const bool kIsFromSync = false; static const bool kIsFromSync = false;
const bool kInstallSilently = true; static const bool kInstallSilently = true;
const Manifest::Location kManifestLocation = Manifest::INTERNAL; static const Manifest::Location kManifestLocation = Manifest::INTERNAL;
const bool kMarkAcknowledged = false; static const bool kMarkAcknowledged = false;
const bool kRemoteInstall = false; static const bool kRemoteInstall = false;
return AddExtensionImpl(id, return AddExtensionImpl(id,
std::string(), std::string(),
...@@ -164,11 +166,12 @@ bool PendingExtensionManager::AddFromExternalUpdateUrl( ...@@ -164,11 +166,12 @@ bool PendingExtensionManager::AddFromExternalUpdateUrl(
bool mark_acknowledged) { bool mark_acknowledged) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
const bool kIsFromSync = false; static const bool kIsFromSync = false;
const bool kInstallSilently = true; static const bool kInstallSilently = true;
const bool kRemoteInstall = false; static const bool kRemoteInstall = false;
const Extension* extension = service_.GetInstalledExtension(id); const Extension* extension = ExtensionRegistry::Get(context_)
->GetExtensionById(id, ExtensionRegistry::EVERYTHING);
if (extension && location == Manifest::GetHigherPriorityLocation( if (extension && location == Manifest::GetHigherPriorityLocation(
location, extension->location())) { location, extension->location())) {
// If the new location has higher priority than the location of an existing // If the new location has higher priority than the location of an existing
...@@ -208,10 +211,10 @@ bool PendingExtensionManager::AddFromExternalFile( ...@@ -208,10 +211,10 @@ bool PendingExtensionManager::AddFromExternalFile(
// installed, but this method assumes that the caller already // installed, but this method assumes that the caller already
// made sure it is not installed. Make all AddFrom*() methods // made sure it is not installed. Make all AddFrom*() methods
// consistent. // consistent.
GURL kUpdateUrl = GURL(); const GURL& kUpdateUrl = GURL::EmptyGURL();
const bool kIsFromSync = false; static const bool kIsFromSync = false;
const bool kInstallSilently = true; static const bool kInstallSilently = true;
const bool kRemoteInstall = false; static const bool kRemoteInstall = false;
return AddExtensionImpl(id, return AddExtensionImpl(id,
std::string(), std::string(),
......
...@@ -11,7 +11,6 @@ ...@@ -11,7 +11,6 @@
#include "chrome/browser/extensions/pending_extension_info.h" #include "chrome/browser/extensions/pending_extension_info.h"
#include "extensions/common/manifest.h" #include "extensions/common/manifest.h"
class ExtensionServiceInterface;
class GURL; class GURL;
namespace base { namespace base {
...@@ -39,16 +38,11 @@ void SetupPendingExtensionManagerForTest( ...@@ -39,16 +38,11 @@ void SetupPendingExtensionManagerForTest(
// time, because they involve downloading, unpacking, and installing. // time, because they involve downloading, unpacking, and installing.
// This class allows us to avoid race cases where multiple sources install // This class allows us to avoid race cases where multiple sources install
// the same extension. // the same extension.
// The extensions service creates an instance of this class, and manages // The ExtensionService creates an instance of this class, and manages its
// its lifetime. This class should only be used from the UI thread. // lifetime. This class should only be used from the UI thread.
class PendingExtensionManager { class PendingExtensionManager {
public: public:
// |service| is a reference to the ExtensionService whose pending explicit PendingExtensionManager(content::BrowserContext* context);
// extensions we are managing. The service creates an instance of
// this class on construction, and destroys it on destruction.
// The service remains valid over the entire lifetime of this class.
explicit PendingExtensionManager(const ExtensionServiceInterface& service,
content::BrowserContext* context);
~PendingExtensionManager(); ~PendingExtensionManager();
// TODO(skerner): Many of these methods can be private once code in // TODO(skerner): Many of these methods can be private once code in
...@@ -141,12 +135,6 @@ class PendingExtensionManager { ...@@ -141,12 +135,6 @@ class PendingExtensionManager {
// method. // method.
void AddForTesting(const PendingExtensionInfo& pending_extension_info); void AddForTesting(const PendingExtensionInfo& pending_extension_info);
// Reference to the extension service whose pending extensions this class is
// managing. Because this class is a member of |service_|, it is created
// and destroyed with |service_|. We only use methods from the interface
// ExtensionServiceInterface.
const ExtensionServiceInterface& service_;
// The BrowserContext with which the manager is associated. // The BrowserContext with which the manager is associated.
content::BrowserContext* context_; content::BrowserContext* context_;
......
...@@ -276,7 +276,7 @@ int GetAuthUserQueryValue(const GURL& url) { ...@@ -276,7 +276,7 @@ int GetAuthUserQueryValue(const GURL& url) {
class MockService : public TestExtensionService { class MockService : public TestExtensionService {
public: public:
explicit MockService(TestExtensionPrefs* prefs) explicit MockService(TestExtensionPrefs* prefs)
: prefs_(prefs), pending_extension_manager_(*this, &profile_) {} : prefs_(prefs), pending_extension_manager_(&profile_) {}
virtual ~MockService() {} virtual ~MockService() {}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment