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

Unified Diff: chrome/browser/extensions/extension_service.cc

Issue 9706017: Remove Ordinals Setters and Getters from ExtensionService (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Created 8 years, 9 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/extensions/extension_service.cc
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index 3c0eb11ebdafe8e34e40c44a8687572f08a06ca9..f4c4049501e1618f50ee960df64afa2face943e1 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -445,6 +445,10 @@ ExtensionService::ExtensionService(Profile* profile,
omnibox_icon_manager_.set_padding(gfx::Insets(0, kOmniboxIconPaddingLeft,
0, kOmniboxIconPaddingRight));
+ // Set this as the ExtensionService for extension sorting to ensure it
+ // cause syncs if required.
+ extension_prefs_->extension_sorting()->SetExtensionService(this);
+
// How long is the path to the Extensions directory?
UMA_HISTOGRAM_CUSTOM_COUNTS("Extensions.ExtensionRootPathLength",
install_directory_.value().length(), 0, 500, 100);
@@ -774,8 +778,9 @@ bool ExtensionService::UninstallExtension(
IsIncognitoEnabled(extension_id),
extension_prefs_->GetAppNotificationClientId(extension_id),
extension_prefs_->IsAppNotificationDisabled(extension_id),
- GetAppLaunchOrdinal(extension_id),
- GetPageOrdinal(extension_id));
+ extension_prefs_->extension_sorting()->
+ GetAppLaunchOrdinal(extension_id),
+ extension_prefs_->extension_sorting()->GetPageOrdinal(extension_id));
sync_change = extension_sync_data.GetSyncChange(SyncChange::ACTION_DELETE);
}
@@ -1274,28 +1279,6 @@ bool ExtensionService::SyncBundle::HasPendingExtensionId(const std::string& id)
return pending_sync_data.find(id) != pending_sync_data.end();
}
-void ExtensionService::SyncExtensionChangeIfNeeded(const Extension& extension) {
- SyncBundle* sync_bundle = GetSyncBundleForExtension(extension);
- if (sync_bundle) {
- ExtensionSyncData extension_sync_data(
- extension,
- IsExtensionEnabled(extension.id()),
- IsIncognitoEnabled(extension.id()),
- extension_prefs_->GetAppNotificationClientId(extension.id()),
- extension_prefs_->IsAppNotificationDisabled(extension.id()),
- GetAppLaunchOrdinal(extension.id()),
- GetPageOrdinal(extension.id()));
-
- SyncChangeList sync_change_list(1, extension_sync_data.GetSyncChange(
- sync_bundle->HasExtensionId(extension.id()) ?
- SyncChange::ACTION_UPDATE : SyncChange::ACTION_ADD));
- sync_bundle->sync_processor->ProcessSyncChanges(
- FROM_HERE, sync_change_list);
- sync_bundle->synced_extensions.insert(extension.id());
- sync_bundle->pending_sync_data.erase(extension.id());
- }
-}
-
ExtensionService::SyncBundle* ExtensionService::GetSyncBundleForExtension(
const Extension& extension) {
if (app_sync_bundle_.filter(extension))
@@ -1460,8 +1443,10 @@ void ExtensionService::GetSyncDataListHelper(
IsIncognitoEnabled(extension.id()),
extension_prefs_->GetAppNotificationClientId(extension.id()),
extension_prefs_->IsAppNotificationDisabled(extension.id()),
- GetAppLaunchOrdinal(extension.id()),
- GetPageOrdinal(extension.id())));
+ extension_prefs_->extension_sorting()->
+ GetAppLaunchOrdinal(extension.id()),
+ extension_prefs_->extension_sorting()->
+ GetPageOrdinal(extension.id())));
}
}
}
@@ -1523,8 +1508,12 @@ void ExtensionService::ProcessExtensionSyncData(
if (extension_sync_data.app_launch_ordinal().IsValid() &&
extension_sync_data.page_ordinal().IsValid()) {
- SetAppLaunchOrdinal(id, extension_sync_data.app_launch_ordinal());
- SetPageOrdinal(id, extension_sync_data.page_ordinal());
+ extension_prefs_->extension_sorting()->SetAppLaunchOrdinal(
+ id,
+ extension_sync_data.app_launch_ordinal());
+ extension_prefs_->extension_sorting()->SetPageOrdinal(
+ id,
+ extension_sync_data.page_ordinal());
}
if (extension_installed) {
@@ -1660,52 +1649,6 @@ bool ExtensionService::CanLoadInIncognito(const Extension* extension) const {
IsIncognitoEnabled(extension->id());
}
-StringOrdinal ExtensionService::GetAppLaunchOrdinal(
- const std::string& extension_id) const {
- return
- extension_prefs_->extension_sorting()->GetAppLaunchOrdinal(extension_id);
-}
-
-void ExtensionService::SetAppLaunchOrdinal(
- const std::string& extension_id,
- const StringOrdinal& app_launch_ordinal) {
- // Only apps should set this value, so we check that it is either an app or
- // that it is not yet installed (so we can't be sure it is an app). It is
- // possible to be setting this value through syncing before the app is
- // installed.
- const Extension* ext = GetExtensionById(extension_id, true);
- DCHECK(!ext || ext->is_app());
-
- extension_prefs_->extension_sorting()->SetAppLaunchOrdinal(
- extension_id, app_launch_ordinal);
-
- const Extension* extension = GetInstalledExtension(extension_id);
- if (extension)
- SyncExtensionChangeIfNeeded(*extension);
-}
-
-StringOrdinal ExtensionService::GetPageOrdinal(
- const std::string& extension_id) const {
- return extension_prefs_->extension_sorting()->GetPageOrdinal(extension_id);
-}
-
-void ExtensionService::SetPageOrdinal(const std::string& extension_id,
- const StringOrdinal& page_ordinal) {
- // Only apps should set this value, so we check that it is either an app or
- // that it is not yet installed (so we can't be sure it is an app). It is
- // possible to be setting this value through syncing before the app is
- // installed.
- const Extension* ext = GetExtensionById(extension_id, true);
- DCHECK(!ext || ext->is_app());
-
- extension_prefs_->extension_sorting()->SetPageOrdinal(
- extension_id, page_ordinal);
-
- const Extension* extension = GetInstalledExtension(extension_id);
- if (extension)
- SyncExtensionChangeIfNeeded(*extension);
-}
-
void ExtensionService::OnExtensionMoved(
const std::string& moved_extension_id,
const std::string& predecessor_extension_id,
@@ -2011,6 +1954,29 @@ void ExtensionService::GarbageCollectExtensions() {
}
}
+void ExtensionService::SyncExtensionChangeIfNeeded(const Extension& extension) {
+ SyncBundle* sync_bundle = GetSyncBundleForExtension(extension);
+ if (sync_bundle) {
+ ExtensionSyncData extension_sync_data(
+ extension,
+ IsExtensionEnabled(extension.id()),
+ IsIncognitoEnabled(extension.id()),
+ extension_prefs_->GetAppNotificationClientId(extension.id()),
+ extension_prefs_->IsAppNotificationDisabled(extension.id()),
+ extension_prefs_->extension_sorting()->
+ GetAppLaunchOrdinal(extension.id()),
+ extension_prefs_->extension_sorting()->GetPageOrdinal(extension.id()));
+
+ SyncChangeList sync_change_list(1, extension_sync_data.GetSyncChange(
+ sync_bundle->HasExtensionId(extension.id()) ?
+ SyncChange::ACTION_UPDATE : SyncChange::ACTION_ADD));
+ sync_bundle->sync_processor->ProcessSyncChanges(
+ FROM_HERE, sync_change_list);
+ sync_bundle->synced_extensions.insert(extension.id());
+ sync_bundle->pending_sync_data.erase(extension.id());
+ }
+}
+
void ExtensionService::OnLoadedInstalledExtensions() {
if (updater_.get()) {
updater_->Start();
« no previous file with comments | « chrome/browser/extensions/extension_service.h ('k') | chrome/browser/extensions/extension_service_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698