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

Unified Diff: ash/shelf/shelf_view.cc

Issue 2833173002: mash: Support ShelfModel access in Chrome. (Closed)
Patch Set: Refine init pattern; add AppList item in ShelfModel ctor. Created 3 years, 7 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
Index: ash/shelf/shelf_view.cc
diff --git a/ash/shelf/shelf_view.cc b/ash/shelf/shelf_view.cc
index b8c65bc101c8aeac9c4d8efd7ee74bc451e6d508..c78d81f4619cb160428fefccae5dc31ba109f4d8 100644
--- a/ash/shelf/shelf_view.cc
+++ b/ash/shelf/shelf_view.cc
@@ -9,6 +9,7 @@
#include "ash/ash_constants.h"
#include "ash/drag_drop/drag_image_view.h"
+#include "ash/public/cpp/config.h"
#include "ash/public/cpp/shelf_item_delegate.h"
#include "ash/scoped_root_window_for_new_windows.h"
#include "ash/screen_util.h"
@@ -464,10 +465,21 @@ void ShelfView::ButtonPressed(views::Button* sender,
// Notify the item of its selection; handle the result in AfterItemSelected.
const ShelfItem& item = model_->items()[last_pressed_index_];
+ // Mash requires conversion of mouse and touch events to pointer events.
+ std::unique_ptr<ui::Event> passed_event = ui::Event::Clone(event);
+ if (Shell::GetAshConfig() == Config::MASH &&
+ ui::PointerEvent::CanConvertFrom(event)) {
+ if (event.IsMouseEvent())
+ passed_event = base::MakeUnique<ui::PointerEvent>(*event.AsMouseEvent());
+ else if (event.IsTouchEvent())
+ passed_event = base::MakeUnique<ui::PointerEvent>(*event.AsTouchEvent());
+ else
+ NOTREACHED() << "Need conversion of event to pointer event.";
+ }
model_->GetShelfItemDelegate(item.id)->ItemSelected(
- ui::Event::Clone(event), display_id, LAUNCH_FROM_UNKNOWN,
+ ui::Event::Clone(*passed_event), display_id, LAUNCH_FROM_UNKNOWN,
James Cook 2017/05/30 22:47:47 Can you avoid cloning the event twice? Maybe move
msw 2017/05/31 16:55:21 Done. This miserable client code is a sign of poor
base::Bind(&ShelfView::AfterItemSelected, weak_factory_.GetWeakPtr(),
- item, sender, base::Passed(ui::Event::Clone(event)),
+ item, sender, base::Passed(ui::Event::Clone(*passed_event)),
ink_drop));
}
@@ -1596,6 +1608,9 @@ void ShelfView::ShelfItemMoved(int start_index, int target_index) {
AnimateToIdealBounds();
}
+void ShelfView::ShelfItemDelegateChanged(const ShelfID& id,
+ ShelfItemDelegate* delegate) {}
+
void ShelfView::AfterItemSelected(
const ShelfItem& item,
views::Button* sender,

Powered by Google App Engine
This is Rietveld 408576698