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

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

Issue 7888047: Added Instant preference syncing and tests. (Closed) Base URL: http://git.chromium.org/git/chromium.git@trunk
Patch Set: Add ability for applications to sync position on NTP Created 9 years, 2 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
« no previous file with comments | « chrome/browser/extensions/extension_service.h ('k') | chrome/browser/extensions/extension_sync_data.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_service.cc
diff --git a/chrome/browser/extensions/extension_service.cc b/chrome/browser/extensions/extension_service.cc
index fc0935be23244ee1e4b780a16762b0465c7ad75e..9f3b0457af9111fd5dcc895b473f05d5cc72c6f6 100644
--- a/chrome/browser/extensions/extension_service.cc
+++ b/chrome/browser/extensions/extension_service.cc
@@ -897,7 +897,9 @@ bool ExtensionService::UninstallExtension(
if (sync_bundle) {
ExtensionSyncData extension_sync_data(*extension,
IsExtensionEnabled(extension_id),
- IsIncognitoEnabled(extension_id));
+ IsIncognitoEnabled(extension_id),
+ GetAppLaunchIndex(extension_id),
+ GetPageIndex(extension_id));
sync_change = extension_sync_data.GetSyncChange(SyncChange::ACTION_DELETE);
}
@@ -1735,7 +1737,9 @@ void ExtensionService::SyncExtensionChangeIfNeeded(const Extension& extension) {
if (sync_bundle) {
ExtensionSyncData extension_sync_data(extension,
IsExtensionEnabled(extension.id()),
- IsIncognitoEnabled(extension.id()));
+ IsIncognitoEnabled(extension.id()),
+ GetAppLaunchIndex(extension.id()),
+ GetPageIndex(extension.id()));
SyncChangeList sync_change_list(1, extension_sync_data.GetSyncChange(
sync_bundle->HasExtensionId(extension.id()) ?
@@ -1880,6 +1884,13 @@ SyncError ExtensionService::ProcessSyncChanges(
ProcessExtensionSyncData(extension_sync_data, *bundle);
}
+ // Because the sync data includes the positions of applications it is
+ // possible for the applications to have been reordered due to the sync.
+ NotificationService::current()->Notify(
+ chrome::NOTIFICATION_EXTENSION_LAUNCHER_REORDERED,
+ Source<ExtensionService>(this),
+ NotificationService::NoDetails());
+
return SyncError();
}
@@ -1898,7 +1909,9 @@ void ExtensionService::GetSyncDataListHelper(
sync_data_list->push_back(
ExtensionSyncData(extension,
IsExtensionEnabled(extension.id()),
- IsIncognitoEnabled(extension.id())));
+ IsIncognitoEnabled(extension.id()),
+ GetAppLaunchIndex(extension.id()),
+ GetPageIndex(extension.id())));
}
}
}
@@ -1949,6 +1962,8 @@ void ExtensionService::ProcessExtensionSyncData(
DisableExtension(id);
}
SetIsIncognitoEnabled(id, extension_sync_data.incognito_enabled());
+ SetAppLaunchIndex(id, extension_sync_data.app_launch_index());
+ SetPageIndex(id, extension_sync_data.page_index());
if (extension) {
// If the extension is already installed, check if it's outdated.
@@ -2040,6 +2055,44 @@ bool ExtensionService::CanLoadInIncognito(const Extension* extension) const {
IsIncognitoEnabled(extension->id());
}
+void ExtensionService::SetAppLauncherOrder(
+ const std::vector<std::string>& extension_ids) {
+ extension_prefs_->SetAppLauncherOrder(extension_ids);
+
+ for (size_t i=0; i < extension_ids.size(); ++i) {
+ SetAppLaunchIndex(extension_ids[i], i);
+ }
+}
+
+int32 ExtensionService::GetAppLaunchIndex(const std::string& extension_id)
+ const {
+ return extension_prefs_->GetAppLaunchIndex(extension_id);
+}
+
+void ExtensionService::SetAppLaunchIndex(const std::string& extension_id,
+ int32 app_launch_index) {
+ extension_prefs_->SetAppLaunchIndex(extension_id, app_launch_index);
+
+ const Extension* extension = GetInstalledExtension(extension_id);
+ if (extension) {
+ SyncExtensionChangeIfNeeded(*extension);
+ }
+}
+
+int32 ExtensionService::GetPageIndex(const std::string& extension_id) const {
+ return extension_prefs_->GetPageIndex(extension_id);
+}
+
+void ExtensionService::SetPageIndex(const std::string& extension_id,
+ int32 page_index) {
+ extension_prefs_->SetPageIndex(extension_id, page_index);
+
+ const Extension* extension = GetInstalledExtension(extension_id);
+ if (extension) {
+ SyncExtensionChangeIfNeeded(*extension);
+ }
+}
+
bool ExtensionService::AllowFileAccess(const Extension* extension) {
return (CommandLine::ForCurrentProcess()->HasSwitch(
switches::kDisableExtensionsFileAccessCheck) ||
« no previous file with comments | « chrome/browser/extensions/extension_service.h ('k') | chrome/browser/extensions/extension_sync_data.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698