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,
blacklist_(blacklist),
extension_sync_service_(NULL),
registry_(extensions::ExtensionRegistry::Get(profile)),
pending_extension_manager_(*this, profile),
pending_extension_manager_(profile),
install_directory_(install_directory),
extensions_enabled_(extensions_enabled),
show_extensions_prompts_(true),
......
......@@ -8,9 +8,10 @@
#include "base/logging.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 "extensions/browser/extension_prefs.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/common/extension.h"
#include "url/gurl.h"
......@@ -32,9 +33,8 @@ std::string GetVersionString(const Version& version) {
namespace extensions {
PendingExtensionManager::PendingExtensionManager(
const ExtensionServiceInterface& service,
content::BrowserContext* context)
: service_(service), context_(context) {}
: context_(context) {}
PendingExtensionManager::~PendingExtensionManager() {}
......@@ -93,7 +93,8 @@ bool PendingExtensionManager::AddFromSync(
bool remote_install) {
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
<< " which already exists";
return false;
......@@ -107,9 +108,9 @@ bool PendingExtensionManager::AddFromSync(
return false;
}
const bool kIsFromSync = true;
const Manifest::Location kSyncLocation = Manifest::INTERNAL;
const bool kMarkAcknowledged = false;
static const bool kIsFromSync = true;
static const Manifest::Location kSyncLocation = Manifest::INTERNAL;
static const bool kMarkAcknowledged = false;
return AddExtensionImpl(id,
std::string(),
......@@ -130,17 +131,18 @@ bool PendingExtensionManager::AddFromExtensionImport(
PendingExtensionInfo::ShouldAllowInstallPredicate should_allow_install) {
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
<< " which already exists";
return false;
}
const bool kIsFromSync = false;
const bool kInstallSilently = true;
const Manifest::Location kManifestLocation = Manifest::INTERNAL;
const bool kMarkAcknowledged = false;
const bool kRemoteInstall = false;
static const bool kIsFromSync = false;
static const bool kInstallSilently = true;
static const Manifest::Location kManifestLocation = Manifest::INTERNAL;
static const bool kMarkAcknowledged = false;
static const bool kRemoteInstall = false;
return AddExtensionImpl(id,
std::string(),
......@@ -164,11 +166,12 @@ bool PendingExtensionManager::AddFromExternalUpdateUrl(
bool mark_acknowledged) {
CHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
const bool kIsFromSync = false;
const bool kInstallSilently = true;
const bool kRemoteInstall = false;
static const bool kIsFromSync = false;
static const bool kInstallSilently = true;
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(
location, extension->location())) {
// If the new location has higher priority than the location of an existing
......@@ -208,10 +211,10 @@ bool PendingExtensionManager::AddFromExternalFile(
// installed, but this method assumes that the caller already
// made sure it is not installed. Make all AddFrom*() methods
// consistent.
GURL kUpdateUrl = GURL();
const bool kIsFromSync = false;
const bool kInstallSilently = true;
const bool kRemoteInstall = false;
const GURL& kUpdateUrl = GURL::EmptyGURL();
static const bool kIsFromSync = false;
static const bool kInstallSilently = true;
static const bool kRemoteInstall = false;
return AddExtensionImpl(id,
std::string(),
......
......@@ -11,7 +11,6 @@
#include "chrome/browser/extensions/pending_extension_info.h"
#include "extensions/common/manifest.h"
class ExtensionServiceInterface;
class GURL;
namespace base {
......@@ -39,16 +38,11 @@ void SetupPendingExtensionManagerForTest(
// time, because they involve downloading, unpacking, and installing.
// This class allows us to avoid race cases where multiple sources install
// the same extension.
// The extensions service creates an instance of this class, and manages
// its lifetime. This class should only be used from the UI thread.
// The ExtensionService creates an instance of this class, and manages its
// lifetime. This class should only be used from the UI thread.
class PendingExtensionManager {
public:
// |service| is a reference to the ExtensionService whose pending
// 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);
explicit PendingExtensionManager(content::BrowserContext* context);
~PendingExtensionManager();
// TODO(skerner): Many of these methods can be private once code in
......@@ -141,12 +135,6 @@ class PendingExtensionManager {
// method.
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.
content::BrowserContext* context_;
......
......@@ -276,7 +276,7 @@ int GetAuthUserQueryValue(const GURL& url) {
class MockService : public TestExtensionService {
public:
explicit MockService(TestExtensionPrefs* prefs)
: prefs_(prefs), pending_extension_manager_(*this, &profile_) {}
: prefs_(prefs), pending_extension_manager_(&profile_) {}
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