summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/extensions/extension_service.cc4
-rw-r--r--chrome/browser/extensions/extension_service.h33
-rw-r--r--chrome/browser/extensions/extension_updater.cc4
-rw-r--r--chrome/browser/extensions/extension_updater.h8
-rw-r--r--chrome/browser/extensions/extension_updater_unittest.cc31
-rw-r--r--chrome/browser/extensions/pending_extension_manager.cc2
-rw-r--r--chrome/browser/extensions/pending_extension_manager.h8
-rw-r--r--chrome/browser/sync/glue/extension_change_processor.cc2
-rw-r--r--chrome/browser/sync/glue/extension_sync.cc27
-rw-r--r--chrome/browser/sync/glue/extension_sync.h10
-rw-r--r--chrome/browser/sync/glue/extension_util.cc3
-rw-r--r--chrome/browser/sync/glue/extension_util.h6
-rw-r--r--chrome/browser/sync/glue/theme_util.cc3
13 files changed, 95 insertions, 46 deletions
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index 3bcd3f9..f5e8c7e 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -1053,6 +1053,10 @@ const ExtensionPrefs& ExtensionService::const_extension_prefs() const {
return *extension_prefs_;
}
+ExtensionUpdater* ExtensionService::updater() {
+ return updater_.get();
+}
+
void ExtensionService::CheckAdminBlacklist() {
std::vector<std::string> to_be_removed;
// Loop through extensions list, unload installed extensions.
diff --git a/chrome/browser/extensions/extension_service.h b/chrome/browser/extensions/extension_service.h
index 9843a1b..a8f55ee 100644
--- a/chrome/browser/extensions/extension_service.h
+++ b/chrome/browser/extensions/extension_service.h
@@ -47,27 +47,40 @@ class Profile;
class Version;
// This is an interface class to encapsulate the dependencies that
-// ExtensionUpdater has on ExtensionService. This allows easy mocking.
-class ExtensionUpdateService {
+// various classes have on ExtensionService. This allows easy mocking.
+class ExtensionServiceInterface {
public:
- virtual ~ExtensionUpdateService() {}
+ virtual ~ExtensionServiceInterface() {}
virtual const ExtensionList* extensions() const = 0;
+ virtual const ExtensionList* disabled_extensions() const = 0;
virtual PendingExtensionManager* pending_extension_manager() = 0;
virtual void UpdateExtension(const std::string& id,
const FilePath& path,
const GURL& download_url) = 0;
virtual const Extension* GetExtensionById(const std::string& id,
bool include_disabled) const = 0;
+
+ virtual void UninstallExtension(const std::string& extension_id,
+ bool external_uninstall) = 0;
+
+ virtual void EnableExtension(const std::string& extension_id) = 0;
+ virtual void DisableExtension(const std::string& extension_id) = 0;
+
virtual void UpdateExtensionBlacklist(
const std::vector<std::string>& blacklist) = 0;
virtual void CheckAdminBlacklist() = 0;
virtual bool HasInstalledExtensions() = 0;
+ virtual void SetIsIncognitoEnabled(const Extension* extension,
+ bool enabled) = 0;
+
// TODO(skerner): Change to const ExtensionPrefs& extension_prefs() const,
// ExtensionPrefs* mutable_extension_prefs().
virtual ExtensionPrefs* extension_prefs() = 0;
virtual const ExtensionPrefs& const_extension_prefs() const = 0;
+ virtual ExtensionUpdater* updater() = 0;
+
virtual Profile* profile() = 0;
};
@@ -75,7 +88,7 @@ class ExtensionUpdateService {
class ExtensionService
: public base::RefCountedThreadSafe<ExtensionService,
BrowserThread::DeleteOnUIThread>,
- public ExtensionUpdateService,
+ public ExtensionServiceInterface,
public ExternalExtensionProviderInterface::VisitorInterface,
public NotificationObserver {
public:
@@ -156,7 +169,7 @@ class ExtensionService
// Whether this extension can run in an incognito window.
bool IsIncognitoEnabled(const Extension* extension);
- void SetIsIncognitoEnabled(const Extension* extension, bool enabled);
+ virtual void SetIsIncognitoEnabled(const Extension* extension, bool enabled);
// Returns true if the given extension can see events and data from another
// sub-profile (incognito to original profile, or vice versa).
@@ -217,13 +230,13 @@ class ExtensionService
// callers should never set to true.
// TODO(aa): Remove |external_uninstall| -- this information should be passed
// to ExtensionPrefs some other way.
- void UninstallExtension(const std::string& extension_id,
- bool external_uninstall);
+ virtual void UninstallExtension(const std::string& extension_id,
+ bool external_uninstall);
// Enable or disable an extension. No action if the extension is already
// enabled/disabled.
- void EnableExtension(const std::string& extension_id);
- void DisableExtension(const std::string& extension_id);
+ virtual void EnableExtension(const std::string& extension_id);
+ virtual void DisableExtension(const std::string& extension_id);
// Updates the |extension|'s granted permissions lists to include all
// permissions in the |extension|'s manifest.
@@ -347,7 +360,7 @@ class ExtensionService
bool is_ready() { return ready_; }
// Note that this may return NULL if autoupdate is not turned on.
- ExtensionUpdater* updater() { return updater_.get(); }
+ virtual ExtensionUpdater* updater();
ExtensionToolbarModel* toolbar_model() { return &toolbar_model_; }
diff --git a/chrome/browser/extensions/extension_updater.cc b/chrome/browser/extensions/extension_updater.cc
index 868991d..22af3a1 100644
--- a/chrome/browser/extensions/extension_updater.cc
+++ b/chrome/browser/extensions/extension_updater.cc
@@ -205,7 +205,7 @@ static int CalculateActivePingDays(const Time& last_active_ping_day,
} // namespace
ManifestFetchesBuilder::ManifestFetchesBuilder(
- ExtensionUpdateService* service) : service_(service) {
+ ExtensionServiceInterface* service) : service_(service) {
DCHECK(service_);
}
@@ -422,7 +422,7 @@ ExtensionUpdater::ExtensionFetch::ExtensionFetch(const std::string& i,
ExtensionUpdater::ExtensionFetch::~ExtensionFetch() {}
-ExtensionUpdater::ExtensionUpdater(ExtensionUpdateService* service,
+ExtensionUpdater::ExtensionUpdater(ExtensionServiceInterface* service,
PrefService* prefs,
int frequency_seconds)
: alive_(false), service_(service), frequency_seconds_(frequency_seconds),
diff --git a/chrome/browser/extensions/extension_updater.h b/chrome/browser/extensions/extension_updater.h
index 07c90bf..328762b 100644
--- a/chrome/browser/extensions/extension_updater.h
+++ b/chrome/browser/extensions/extension_updater.h
@@ -102,7 +102,7 @@ class ManifestFetchData {
// extensions and pending extensions.
class ManifestFetchesBuilder {
public:
- explicit ManifestFetchesBuilder(ExtensionUpdateService* service);
+ explicit ManifestFetchesBuilder(ExtensionServiceInterface* service);
~ManifestFetchesBuilder();
void AddExtension(const Extension& extension);
@@ -138,7 +138,7 @@ class ManifestFetchesBuilder {
Extension::Type extension_type,
GURL update_url,
const std::string& update_url_data);
- ExtensionUpdateService* service_;
+ ExtensionServiceInterface* service_;
// List of data on fetches we're going to do. We limit the number of
// extensions grouped together in one batch to avoid running into the limits
@@ -166,7 +166,7 @@ class ExtensionUpdater
// Holds a pointer to the passed |service|, using it for querying installed
// extensions and installing updated ones. The |frequency_seconds| parameter
// controls how often update checks are scheduled.
- ExtensionUpdater(ExtensionUpdateService* service,
+ ExtensionUpdater(ExtensionServiceInterface* service,
PrefService* prefs,
int frequency_seconds);
@@ -317,7 +317,7 @@ class ExtensionUpdater
ExtensionFetch current_extension_fetch_;
// Pointer back to the service that owns this ExtensionUpdater.
- ExtensionUpdateService* service_;
+ ExtensionServiceInterface* service_;
base::OneShotTimer<ExtensionUpdater> timer_;
int frequency_seconds_;
diff --git a/chrome/browser/extensions/extension_updater_unittest.cc b/chrome/browser/extensions/extension_updater_unittest.cc
index 1e48668..5c93424 100644
--- a/chrome/browser/extensions/extension_updater_unittest.cc
+++ b/chrome/browser/extensions/extension_updater_unittest.cc
@@ -48,7 +48,7 @@ const ManifestFetchData::PingData kNeverPingedData(
} // namespace
// Base class for further specialized test classes.
-class MockService : public ExtensionUpdateService {
+class MockService : public ExtensionServiceInterface {
public:
MockService()
: pending_extension_manager_(ALLOW_THIS_IN_INITIALIZER_LIST(*this)) {}
@@ -59,6 +59,11 @@ class MockService : public ExtensionUpdateService {
return NULL;
}
+ virtual const ExtensionList* disabled_extensions() const {
+ ADD_FAILURE();
+ return NULL;
+ }
+
virtual PendingExtensionManager* pending_extension_manager() {
ADD_FAILURE() << "Subclass should override this if it will "
<< "be accessed by a test.";
@@ -77,6 +82,20 @@ class MockService : public ExtensionUpdateService {
return NULL;
}
+ virtual void UninstallExtension(const std::string& extension_id,
+ bool external_uninstall) {
+ FAIL();
+ }
+
+ virtual void EnableExtension(const std::string& extension_id) {
+ FAIL();
+ }
+
+ virtual void DisableExtension(const std::string& extension_id) {
+ FAIL();
+ }
+
+
virtual void UpdateExtensionBlacklist(
const std::vector<std::string>& blacklist) {
FAIL();
@@ -91,11 +110,21 @@ class MockService : public ExtensionUpdateService {
return false;
}
+ virtual void SetIsIncognitoEnabled(const Extension* extension,
+ bool enabled) {
+ FAIL();
+ }
+
virtual ExtensionPrefs* extension_prefs() { return prefs_.prefs(); }
virtual const ExtensionPrefs& const_extension_prefs() const {
return prefs_.const_prefs();
}
+ virtual ExtensionUpdater* updater() {
+ ADD_FAILURE();
+ return NULL;
+ }
+
virtual Profile* profile() { return &profile_; }
PrefService* pref_service() { return prefs_.pref_service(); }
diff --git a/chrome/browser/extensions/pending_extension_manager.cc b/chrome/browser/extensions/pending_extension_manager.cc
index 17290bf..313cd482 100644
--- a/chrome/browser/extensions/pending_extension_manager.cc
+++ b/chrome/browser/extensions/pending_extension_manager.cc
@@ -23,7 +23,7 @@ bool AlwaysInstall(const Extension& extension) {
} // namespace
PendingExtensionManager::PendingExtensionManager(
- const ExtensionUpdateService& service)
+ const ExtensionServiceInterface& service)
: service_(service) {
}
diff --git a/chrome/browser/extensions/pending_extension_manager.h b/chrome/browser/extensions/pending_extension_manager.h
index e163945..4a6b4fd4 100644
--- a/chrome/browser/extensions/pending_extension_manager.h
+++ b/chrome/browser/extensions/pending_extension_manager.h
@@ -12,7 +12,7 @@
#include "chrome/browser/extensions/pending_extension_info.h"
#include "chrome/common/extensions/extension.h"
-class ExtensionUpdateService;
+class ExtensionServiceInterface;
class GURL;
// Class PendingExtensionManager manages the set of extensions which are
@@ -33,7 +33,7 @@ class PendingExtensionManager {
// 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 ExtensionUpdateService& service);
+ explicit PendingExtensionManager(const ExtensionServiceInterface& service);
~PendingExtensionManager();
// TODO(skerner): Many of these methods can be private once code in
@@ -106,8 +106,8 @@ class PendingExtensionManager {
// 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
- // ExtensionUpdateService.
- const ExtensionUpdateService& service_;
+ // ExtensionServiceInterface.
+ const ExtensionServiceInterface& service_;
// A map from extension id to the pending extension info for that extension.
PendingExtensionMap pending_extension_map_;
diff --git a/chrome/browser/sync/glue/extension_change_processor.cc b/chrome/browser/sync/glue/extension_change_processor.cc
index b3e2e45..030ac34 100644
--- a/chrome/browser/sync/glue/extension_change_processor.cc
+++ b/chrome/browser/sync/glue/extension_change_processor.cc
@@ -96,7 +96,7 @@ void ExtensionChangeProcessor::ApplyChangesFromSyncModel(
if (!running()) {
return;
}
- ExtensionService* extensions_service =
+ ExtensionServiceInterface* extensions_service =
GetExtensionServiceFromProfile(profile_);
for (int i = 0; i < change_count; ++i) {
const sync_api::SyncManager::ChangeRecord& change = changes[i];
diff --git a/chrome/browser/sync/glue/extension_sync.cc b/chrome/browser/sync/glue/extension_sync.cc
index 11decc7..a5d2172 100644
--- a/chrome/browser/sync/glue/extension_sync.cc
+++ b/chrome/browser/sync/glue/extension_sync.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -33,17 +33,18 @@ bool RootNodeHasChildren(const char* tag,
return true;
}
-ExtensionService* GetExtensionServiceFromProfile(
+ExtensionServiceInterface* GetExtensionServiceFromProfile(
Profile* profile) {
CHECK(profile);
- ExtensionService* extensions_service = profile->GetExtensionService();
+ ExtensionServiceInterface* extensions_service =
+ profile->GetExtensionService();
CHECK(extensions_service);
return extensions_service;
}
namespace {
-ExtensionService* GetExtensionServiceFromProfileSyncService(
+ExtensionServiceInterface* GetExtensionServiceFromProfileSyncService(
ProfileSyncService* sync_service) {
CHECK(sync_service);
return GetExtensionServiceFromProfile(sync_service->profile());
@@ -80,7 +81,7 @@ ExtensionData* SetOrCreateExtensionData(
void ReadClientDataFromExtensionList(
const ExtensionList& extensions,
IsValidAndSyncablePredicate is_valid_and_syncable,
- ExtensionService* extensions_service,
+ ExtensionServiceInterface* extensions_service,
std::set<std::string>* unsynced_extensions,
ExtensionDataMap* extension_data_map) {
for (ExtensionList::const_iterator it = extensions.begin();
@@ -110,7 +111,7 @@ void ReadClientDataFromExtensionList(
// enabled and disabled extensions from |extensions_service|.
void SlurpClientData(
IsValidAndSyncablePredicate is_valid_and_syncable,
- ExtensionService* extensions_service,
+ ExtensionServiceInterface* extensions_service,
std::set<std::string>* unsynced_extensions,
ExtensionDataMap* extension_data_map) {
const ExtensionList* extensions = extensions_service->extensions();
@@ -190,7 +191,7 @@ bool SlurpServerData(
bool SlurpExtensionData(const ExtensionSyncTraits& traits,
ProfileSyncService* sync_service,
ExtensionDataMap* extension_data_map) {
- ExtensionService* extensions_service =
+ ExtensionServiceInterface* extensions_service =
GetExtensionServiceFromProfileSyncService(sync_service);
std::set<std::string> unsynced_extensions;
@@ -258,7 +259,7 @@ bool UpdateServer(
// new version.
void TryUpdateClient(
IsValidAndSyncablePredicate is_valid_and_syncable,
- ExtensionService* extensions_service,
+ ExtensionServiceInterface* extensions_service,
ExtensionData* extension_data) {
DCHECK(!extension_data->NeedsUpdate(ExtensionData::SERVER));
DCHECK(extension_data->NeedsUpdate(ExtensionData::CLIENT));
@@ -305,7 +306,7 @@ void TryUpdateClient(
//
// TODO(akalin): Combine this with the similar function in
// theme_util.cc.
-void NudgeExtensionUpdater(ExtensionService* extensions_service) {
+void NudgeExtensionUpdater(ExtensionServiceInterface* extensions_service) {
ExtensionUpdater* extension_updater = extensions_service->updater();
// Auto-updates should now be on always (see the construction of the
// ExtensionService in ProfileImpl::InitExtensions()).
@@ -329,7 +330,7 @@ bool FlushExtensionData(const ExtensionSyncTraits& traits,
return false;
}
- ExtensionService* extensions_service =
+ ExtensionServiceInterface* extensions_service =
GetExtensionServiceFromProfileSyncService(sync_service);
// Update server and client as necessary.
@@ -376,7 +377,7 @@ bool UpdateServerData(const ExtensionSyncTraits& traits,
return false;
}
- ExtensionService* extensions_service =
+ ExtensionServiceInterface* extensions_service =
GetExtensionServiceFromProfileSyncService(sync_service);
sync_pb::ExtensionSpecifics client_data;
GetExtensionSpecifics(extension, extensions_service->extension_prefs(),
@@ -435,7 +436,7 @@ void RemoveServerData(const ExtensionSyncTraits& traits,
void UpdateClient(const ExtensionSyncTraits& traits,
const sync_pb::ExtensionSpecifics& server_data,
- ExtensionService* extensions_service) {
+ ExtensionServiceInterface* extensions_service) {
DcheckIsExtensionSpecificsValid(server_data);
ExtensionData extension_data =
ExtensionData::FromData(ExtensionData::SERVER, server_data);
@@ -468,7 +469,7 @@ void UpdateClient(const ExtensionSyncTraits& traits,
void RemoveFromClient(const ExtensionSyncTraits& traits,
const std::string& id,
- ExtensionService* extensions_service) {
+ ExtensionServiceInterface* extensions_service) {
const Extension* extension = extensions_service->GetExtensionById(id, true);
if (extension) {
if (traits.is_valid_and_syncable(*extension)) {
diff --git a/chrome/browser/sync/glue/extension_sync.h b/chrome/browser/sync/glue/extension_sync.h
index af7f9a5..c237b0a 100644
--- a/chrome/browser/sync/glue/extension_sync.h
+++ b/chrome/browser/sync/glue/extension_sync.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -13,7 +13,7 @@
#include <string>
class Extension;
-class ExtensionService;
+class ExtensionServiceInterface;
class Profile;
class ProfileSyncService;
@@ -38,7 +38,7 @@ bool RootNodeHasChildren(const char* tag,
ProfileSyncService* sync_service,
bool* has_children);
-ExtensionService* GetExtensionServiceFromProfile(Profile* profile);
+ExtensionServiceInterface* GetExtensionServiceFromProfile(Profile* profile);
// Fills |extension_data_map| with both client-side information about
// installed extensions and the server-side information about
@@ -74,12 +74,12 @@ void RemoveServerData(const ExtensionSyncTraits& traits,
// Starts updating the client data from the given server data.
void UpdateClient(const ExtensionSyncTraits& traits,
const sync_pb::ExtensionSpecifics& server_data,
- ExtensionService* extensions_service);
+ ExtensionServiceInterface* extensions_service);
// Removes existing client data for the given extension.
void RemoveFromClient(const ExtensionSyncTraits& traits,
const std::string& id,
- ExtensionService* extensions_service);
+ ExtensionServiceInterface* extensions_service);
} // namespace browser_sync
diff --git a/chrome/browser/sync/glue/extension_util.cc b/chrome/browser/sync/glue/extension_util.cc
index e04752f..e94ba11 100644
--- a/chrome/browser/sync/glue/extension_util.cc
+++ b/chrome/browser/sync/glue/extension_util.cc
@@ -182,7 +182,8 @@ bool IsExtensionOutdated(const Extension& extension,
void SetExtensionProperties(
const sync_pb::ExtensionSpecifics& specifics,
- ExtensionService* extensions_service, const Extension* extension) {
+ ExtensionServiceInterface* extensions_service,
+ const Extension* extension) {
DcheckIsExtensionSpecificsValid(specifics);
CHECK(extensions_service);
CHECK(extension);
diff --git a/chrome/browser/sync/glue/extension_util.h b/chrome/browser/sync/glue/extension_util.h
index e908650..a68a066 100644
--- a/chrome/browser/sync/glue/extension_util.h
+++ b/chrome/browser/sync/glue/extension_util.h
@@ -1,4 +1,4 @@
-// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
@@ -13,7 +13,7 @@
class Extension;
class ExtensionPrefs;
-class ExtensionService;
+class ExtensionServiceInterface;
struct UninstalledExtensionInfo;
namespace sync_pb {
@@ -101,7 +101,7 @@ bool IsExtensionOutdated(const Extension& extension,
// valid.
void SetExtensionProperties(
const sync_pb::ExtensionSpecifics& specifics,
- ExtensionService* extensions_service, const Extension* extension);
+ ExtensionServiceInterface* extensions_service, const Extension* extension);
// Merge |specifics| into |merged_specifics|. Both must be valid and
// have the same ID. The merge policy is currently to copy the
diff --git a/chrome/browser/sync/glue/theme_util.cc b/chrome/browser/sync/glue/theme_util.cc
index 2f71b67..3d700da 100644
--- a/chrome/browser/sync/glue/theme_util.cc
+++ b/chrome/browser/sync/glue/theme_util.cc
@@ -93,7 +93,8 @@ void SetCurrentThemeFromThemeSpecifics(
std::string id(theme_specifics.custom_theme_id());
GURL update_url(theme_specifics.custom_theme_update_url());
VLOG(1) << "Applying theme " << id << " with update_url " << update_url;
- ExtensionService* extensions_service = profile->GetExtensionService();
+ ExtensionServiceInterface* extensions_service =
+ profile->GetExtensionService();
CHECK(extensions_service);
const Extension* extension = extensions_service->GetExtensionById(id, true);
if (extension) {