Index: chrome/browser/dom_ui/app_launcher_handler.cc |
diff --git a/chrome/browser/dom_ui/app_launcher_handler.cc b/chrome/browser/dom_ui/app_launcher_handler.cc |
index f1679c744118aa9641027c901e13bf9e9fb127c7..b5c9142b27e723992b21e598d71387865db9c55c 100644 |
--- a/chrome/browser/dom_ui/app_launcher_handler.cc |
+++ b/chrome/browser/dom_ui/app_launcher_handler.cc |
@@ -157,6 +157,8 @@ void AppLauncherHandler::RegisterMessages() { |
NewCallback(this, &AppLauncherHandler::HandleHideAppsPromo)); |
dom_ui_->RegisterMessageCallback("createAppShortcut", |
NewCallback(this, &AppLauncherHandler::HandleCreateAppShortcut)); |
+ dom_ui_->RegisterMessageCallback("reorderApps", |
+ NewCallback(this, &AppLauncherHandler::HandleReorderApps)); |
} |
void AppLauncherHandler::Observe(NotificationType type, |
@@ -168,6 +170,7 @@ void AppLauncherHandler::Observe(NotificationType type, |
switch (type.value) { |
case NotificationType::EXTENSION_LOADED: |
case NotificationType::EXTENSION_UNLOADED: |
+ case NotificationType::EXTENSION_LAUNCHER_REORDERED: |
if (dom_ui_->tab_contents()) |
HandleGetApps(NULL); |
break; |
@@ -257,6 +260,8 @@ void AppLauncherHandler::HandleGetApps(const ListValue* args) { |
NotificationService::AllSources()); |
registrar_.Add(this, NotificationType::EXTENSION_UNLOADED, |
NotificationService::AllSources()); |
+ registrar_.Add(this, NotificationType::EXTENSION_LAUNCHER_REORDERED, |
+ NotificationService::AllSources()); |
} |
if (pref_change_registrar_.IsEmpty()) { |
pref_change_registrar_.Init( |
@@ -387,6 +392,17 @@ void AppLauncherHandler::HandleCreateAppShortcut(const ListValue* args) { |
browser->profile(), extension); |
} |
+void AppLauncherHandler::HandleReorderApps(const ListValue* args) { |
+ std::vector<std::string> extension_ids; |
+ for (size_t i = 0; i < args->GetSize(); ++i) { |
+ std::string value; |
+ if (args->GetString(i, &value)) |
+ extension_ids.push_back(value); |
+ } |
+ |
+ extensions_service_->extension_prefs()->SetAppLauncherOrder(extension_ids); |
+} |
+ |
// static |
void AppLauncherHandler::RecordWebStoreLaunch(bool promo_active) { |
if (!promo_active) return; |