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

Unified Diff: ash/shelf/shelf_view.cc

Issue 2833173002: mash: Support ShelfModel access in Chrome. (Closed)
Patch Set: Address comments; fix test failures. 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 62a52fafc3e1f587719e263f92ab7479bba82d5a..75efc9b480088129bee3522d4e3ea011e438a7f0 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"
@@ -463,10 +464,22 @@ 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> pointer_event;
+ if (Shell::GetAshConfig() == Config::MASH &&
+ ui::PointerEvent::CanConvertFrom(event)) {
+ if (event.IsMouseEvent())
+ pointer_event = base::MakeUnique<ui::PointerEvent>(*event.AsMouseEvent());
+ else if (event.IsTouchEvent())
+ pointer_event = base::MakeUnique<ui::PointerEvent>(*event.AsTouchEvent());
+ else
+ NOTREACHED() << "Need conversion of event to pointer event.";
+ }
+ const ui::Event* event_to_pass = pointer_event ? pointer_event.get() : &event;
model_->GetShelfItemDelegate(item.id)->ItemSelected(
- ui::Event::Clone(event), display_id, LAUNCH_FROM_UNKNOWN,
+ ui::Event::Clone(*event_to_pass), display_id, LAUNCH_FROM_UNKNOWN,
base::Bind(&ShelfView::AfterItemSelected, weak_factory_.GetWeakPtr(),
- item, sender, base::Passed(ui::Event::Clone(event)),
+ item, sender, base::Passed(ui::Event::Clone(*event_to_pass)),
ink_drop));
}
@@ -1594,6 +1607,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