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

Unified Diff: ash/launcher/launcher_view.cc

Issue 25823002: Refactor LauncherItemController and LauncherItemDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: 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 | « ash/launcher/launcher_unittest.cc ('k') | ash/launcher/launcher_view_unittest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ash/launcher/launcher_view.cc
diff --git a/ash/launcher/launcher_view.cc b/ash/launcher/launcher_view.cc
index ea0bb4e05976170ddd4d466001a0f50cf6f63a19..81f4aee6050004339f61d4ec4c1dd088e1646319 100644
--- a/ash/launcher/launcher_view.cc
+++ b/ash/launcher/launcher_view.cc
@@ -989,8 +989,8 @@ void LauncherView::PrepareForDrag(Pointer pointer,
// If the item is no longer draggable, bail out.
LauncherItemDelegate* item_delegate = item_manager_->GetLauncherItemDelegate(
- model_->items()[start_drag_index_].type);
- if (!item_delegate->IsDraggable(model_->items()[start_drag_index_])) {
+ model_->items()[start_drag_index_].id);
+ if (!item_delegate->IsDraggable()) {
CancelDrag(-1);
return;
}
@@ -1007,8 +1007,8 @@ void LauncherView::ContinueDrag(const ui::LocatedEvent& event) {
DCHECK_NE(-1, current_index);
LauncherItemDelegate* item_delegate = item_manager_->GetLauncherItemDelegate(
- model_->items()[current_index].type);
- if (!item_delegate->IsDraggable(model_->items()[current_index])) {
+ model_->items()[current_index].id);
+ if (!item_delegate->IsDraggable()) {
CancelDrag(-1);
return;
}
@@ -1541,9 +1541,8 @@ void LauncherView::PointerPressedOnButton(views::View* view,
return;
LauncherItemDelegate* item_delegate = item_manager_->GetLauncherItemDelegate(
- model_->items()[index].type);
- if (view_model_->view_size() <= 1 ||
- !item_delegate->IsDraggable(model_->items()[index]))
+ model_->items()[index].id);
+ if (view_model_->view_size() <= 1 || !item_delegate->IsDraggable())
return; // View is being deleted or not draggable, ignore request.
ShelfLayoutManager* shelf = tooltip_->shelf_layout_manager();
@@ -1613,8 +1612,8 @@ base::string16 LauncherView::GetAccessibleName(const views::View* view) {
return base::string16();
LauncherItemDelegate* item_delegate = item_manager_->GetLauncherItemDelegate(
- model_->items()[view_index].type);
- return item_delegate->GetTitle(model_->items()[view_index]);
+ model_->items()[view_index].id);
+ return item_delegate->GetTitle();
}
void LauncherView::ButtonPressed(views::Button* sender,
@@ -1673,8 +1672,8 @@ void LauncherView::ButtonPressed(views::Button* sender,
LauncherItemDelegate* item_delegate =
item_manager_->GetLauncherItemDelegate(
- model_->items()[view_index].type);
- item_delegate->ItemSelected(model_->items()[view_index], event);
+ model_->items()[view_index].id);
+ item_delegate->ItemSelected(event);
ShowListMenuForView(model_->items()[view_index], sender, event);
}
@@ -1685,8 +1684,8 @@ bool LauncherView::ShowListMenuForView(const LauncherItem& item,
const ui::Event& event) {
scoped_ptr<ash::LauncherMenuModel> menu_model;
LauncherItemDelegate* item_delegate =
- item_manager_->GetLauncherItemDelegate(item.type);
- menu_model.reset(item_delegate->CreateApplicationMenu(item, event.flags()));
+ item_manager_->GetLauncherItemDelegate(item.id);
+ menu_model.reset(item_delegate->CreateApplicationMenu(event.flags()));
// Make sure we have a menu and it has at least two items in addition to the
// application title and the 3 spacing separators.
@@ -1719,9 +1718,8 @@ void LauncherView::ShowContextMenuForView(views::View* source,
}
scoped_ptr<ui::MenuModel> menu_model;
LauncherItemDelegate* item_delegate = item_manager_->GetLauncherItemDelegate(
- model_->items()[view_index].type);
+ model_->items()[view_index].id);
menu_model.reset(item_delegate->CreateContextMenu(
- model_->items()[view_index],
source->GetWidget()->GetNativeView()->GetRootWindow()));
if (!menu_model)
return;
@@ -1882,8 +1880,8 @@ bool LauncherView::ShouldShowTooltipForView(const views::View* view) const {
if (!item)
return true;
LauncherItemDelegate* item_delegate =
- item_manager_->GetLauncherItemDelegate(item->type);
- return item_delegate->ShouldShowTooltip(*item);
+ item_manager_->GetLauncherItemDelegate(item->id);
+ return item_delegate->ShouldShowTooltip();
}
int LauncherView::CalculateShelfDistance(const gfx::Point& coordinate) const {
« no previous file with comments | « ash/launcher/launcher_unittest.cc ('k') | ash/launcher/launcher_view_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698