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

Unified Diff: ash/launcher/launcher_view.cc

Issue 23606016: Refactor LauncherItemController and LauncherItemDelegate (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix for unittest.. 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 3491b1b7f17a5b5700511a2c798d3ec2aef9f494..7d79a80e7f5ac376c15c896eb1178e419f606fd9 100644
--- a/ash/launcher/launcher_view.cc
+++ b/ash/launcher/launcher_view.cc
@@ -985,8 +985,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 && !item_delegate->IsDraggable()) {
CancelDrag(-1);
return;
}
@@ -1003,8 +1003,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 && !item_delegate->IsDraggable()) {
CancelDrag(-1);
return;
}
@@ -1531,9 +1531,9 @@ void LauncherView::PointerPressedOnButton(views::View* view,
return;
LauncherItemDelegate* item_delegate = item_manager_->GetLauncherItemDelegate(
- model_->items()[index].type);
+ model_->items()[index].id);
if (view_model_->view_size() <= 1 ||
- !item_delegate->IsDraggable(model_->items()[index]))
+ (item_delegate && !item_delegate->IsDraggable()))
return; // View is being deleted or not draggable, ignore request.
ShelfLayoutManager* shelf = tooltip_->shelf_layout_manager();
@@ -1603,8 +1603,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 ? item_delegate->GetTitle() : base::string16();
}
void LauncherView::ButtonPressed(views::Button* sender,
@@ -1663,8 +1663,9 @@ 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);
+ if (item_delegate)
+ item_delegate->ItemSelected(event);
ShowListMenuForView(model_->items()[view_index], sender, event);
}
@@ -1675,8 +1676,9 @@ 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);
+ if (item_delegate)
+ 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.
@@ -1709,10 +1711,11 @@ void LauncherView::ShowContextMenuForView(views::View* source,
}
scoped_ptr<ui::MenuModel> menu_model;
LauncherItemDelegate* item_delegate = item_manager_->GetLauncherItemDelegate(
- model_->items()[view_index].type);
- menu_model.reset(item_delegate->CreateContextMenu(
- model_->items()[view_index],
- source->GetWidget()->GetNativeView()->GetRootWindow()));
+ model_->items()[view_index].id);
+ if (item_delegate) {
+ menu_model.reset(item_delegate->CreateContextMenu(
+ source->GetWidget()->GetNativeView()->GetRootWindow()));
+ }
if (!menu_model)
return;
@@ -1867,8 +1870,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 ? item_delegate->ShouldShowTooltip() : false;
}
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