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

Unified Diff: chrome/browser/ui/app_list/extension_app_model_builder.cc

Issue 29613004: Sync app order for extension items (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 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/ui/app_list/extension_app_model_builder.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/app_list/extension_app_model_builder.cc
diff --git a/chrome/browser/ui/app_list/extension_app_model_builder.cc b/chrome/browser/ui/app_list/extension_app_model_builder.cc
index 767bb7b7f2ed10f74577dcc0877f3675b88f544a..1f17f6d6d6e57d2a05263034ef1582e481badfd5 100644
--- a/chrome/browser/ui/app_list/extension_app_model_builder.cc
+++ b/chrome/browser/ui/app_list/extension_app_model_builder.cc
@@ -48,11 +48,13 @@ ExtensionAppModelBuilder::ExtensionAppModelBuilder(
model_(model),
highlighted_app_pending_(false),
tracker_(NULL) {
+ model_->apps()->AddObserver(this);
SwitchProfile(profile); // Builds the model.
}
ExtensionAppModelBuilder::~ExtensionAppModelBuilder() {
OnShutdown();
+ model_->apps()->RemoveObserver(this);
}
void ExtensionAppModelBuilder::OnBeginExtensionInstall(
@@ -239,3 +241,40 @@ void ExtensionAppModelBuilder::UpdateHighlight() {
item->SetHighlighted(true);
highlighted_app_pending_ = false;
}
+
+void ExtensionAppModelBuilder::ListItemsAdded(size_t start, size_t count) {
+}
+
+void ExtensionAppModelBuilder::ListItemsRemoved(size_t start, size_t count) {
+}
+
+void ExtensionAppModelBuilder::ListItemMoved(size_t index,
+ size_t target_index) {
+ app_list::AppListModel::Apps* app_list = model_->apps();
+ app_list::AppListItemModel* item = app_list->GetItemAt(target_index);
+ if (item->GetAppType() != ExtensionAppItem::kAppType)
+ return;
+
+ ExtensionAppItem* prev = NULL;
+ for (size_t idx = target_index; idx > 1; --idx) {
+ app_list::AppListItemModel* item = app_list->GetItemAt(idx - 1);
+ if (item->GetAppType() == ExtensionAppItem::kAppType) {
+ prev = static_cast<ExtensionAppItem*>(item);
+ break;
+ }
+ }
+ ExtensionAppItem* next = NULL;
+ for (size_t idx = target_index; idx < app_list->item_count() - 1; ++idx) {
+ app_list::AppListItemModel* item = app_list->GetItemAt(idx + 1);
+ if (item->GetAppType() == ExtensionAppItem::kAppType) {
+ next = static_cast<ExtensionAppItem*>(item);
+ break;
+ }
+ }
+ if (prev || next)
+ static_cast<ExtensionAppItem*>(item)->Move(prev, next);
+}
+
+void ExtensionAppModelBuilder::ListItemsChanged(size_t start, size_t count) {
+ NOTREACHED();
+}
« no previous file with comments | « chrome/browser/ui/app_list/extension_app_model_builder.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698