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

Side by Side Diff: ash/common/shelf/wm_shelf.cc

Issue 2718563008: mash: Use mojo for ShelfItemDelegate and [app] MenuItem. (Closed)
Patch Set: Address comments. Created 3 years, 9 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ash/common/shelf/wm_shelf.h" 5 #include "ash/common/shelf/wm_shelf.h"
6 6
7 #include "ash/common/shelf/shelf_controller.h" 7 #include "ash/common/shelf/shelf_controller.h"
8 #include "ash/common/shelf/shelf_delegate.h" 8 #include "ash/common/shelf/shelf_delegate.h"
9 #include "ash/common/shelf/shelf_item_delegate.h"
10 #include "ash/common/shelf/shelf_layout_manager.h" 9 #include "ash/common/shelf/shelf_layout_manager.h"
11 #include "ash/common/shelf/shelf_locking_manager.h" 10 #include "ash/common/shelf/shelf_locking_manager.h"
12 #include "ash/common/shelf/shelf_model.h" 11 #include "ash/common/shelf/shelf_model.h"
13 #include "ash/common/shelf/shelf_widget.h" 12 #include "ash/common/shelf/shelf_widget.h"
14 #include "ash/common/shelf/wm_shelf_observer.h" 13 #include "ash/common/shelf/wm_shelf_observer.h"
15 #include "ash/common/system/tray/system_tray_delegate.h" 14 #include "ash/common/system/tray/system_tray_delegate.h"
16 #include "ash/common/wm_shell.h" 15 #include "ash/common/wm_shell.h"
17 #include "ash/common/wm_window.h" 16 #include "ash/common/wm_window.h"
18 #include "ash/public/cpp/shell_window_ids.h" 17 #include "ash/public/cpp/shell_window_ids.h"
18 #include "ash/public/interfaces/shelf.mojom.h"
19 #include "ash/root_window_controller.h" 19 #include "ash/root_window_controller.h"
20 #include "ash/shelf/shelf_bezel_event_handler.h" 20 #include "ash/shelf/shelf_bezel_event_handler.h"
21 #include "ash/shell.h" 21 #include "ash/shell.h"
22 #include "base/logging.h" 22 #include "base/logging.h"
23 #include "base/memory/ptr_util.h" 23 #include "base/memory/ptr_util.h"
24 #include "ui/aura/env.h" 24 #include "ui/aura/env.h"
25 #include "ui/display/types/display_constants.h" 25 #include "ui/display/types/display_constants.h"
26 #include "ui/gfx/geometry/rect.h" 26 #include "ui/gfx/geometry/rect.h"
27 27
28 namespace ash { 28 namespace ash {
29 29
30 namespace {
31
32 // A callback that does nothing after shelf item selection handling.
33 void NoopCallback(ShelfAction,
34 base::Optional<std::vector<mojom::MenuItemPtr>>) {}
35
36 } // namespace
37
30 // WmShelf::AutoHideEventHandler ----------------------------------------------- 38 // WmShelf::AutoHideEventHandler -----------------------------------------------
31 39
32 // Forwards mouse and gesture events to ShelfLayoutManager for auto-hide. 40 // Forwards mouse and gesture events to ShelfLayoutManager for auto-hide.
33 // TODO(mash): Add similar event handling support for mash. 41 // TODO(mash): Add similar event handling support for mash.
34 class WmShelf::AutoHideEventHandler : public ui::EventHandler { 42 class WmShelf::AutoHideEventHandler : public ui::EventHandler {
35 public: 43 public:
36 explicit AutoHideEventHandler(ShelfLayoutManager* shelf_layout_manager) 44 explicit AutoHideEventHandler(ShelfLayoutManager* shelf_layout_manager)
37 : shelf_layout_manager_(shelf_layout_manager) { 45 : shelf_layout_manager_(shelf_layout_manager) {
38 Shell::GetInstance()->AddPreTargetHandler(this); 46 Shell::GetInstance()->AddPreTargetHandler(this);
39 } 47 }
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 if (found_index >= 0 && (indexes_left == -1 || item_index < 0)) { 292 if (found_index >= 0 && (indexes_left == -1 || item_index < 0)) {
285 // Then set this one as active (or advance to the next item of its kind). 293 // Then set this one as active (or advance to the next item of its kind).
286 ActivateShelfItem(found_index); 294 ActivateShelfItem(found_index);
287 } 295 }
288 } 296 }
289 297
290 // static 298 // static
291 void WmShelf::ActivateShelfItem(int item_index) { 299 void WmShelf::ActivateShelfItem(int item_index) {
292 ShelfModel* shelf_model = WmShell::Get()->shelf_model(); 300 ShelfModel* shelf_model = WmShell::Get()->shelf_model();
293 const ShelfItem& item = shelf_model->items()[item_index]; 301 const ShelfItem& item = shelf_model->items()[item_index];
294 ShelfItemDelegate* item_delegate = shelf_model->GetShelfItemDelegate(item.id); 302 mojom::ShelfItemDelegate* item_delegate =
295 item_delegate->ItemSelected(ui::ET_KEY_RELEASED, ui::EF_NONE, 303 shelf_model->GetShelfItemDelegate(item.id);
296 display::kInvalidDisplayId, LAUNCH_FROM_UNKNOWN); 304 std::unique_ptr<ui::Event> event = base::MakeUnique<ui::KeyEvent>(
305 ui::ET_KEY_RELEASED, ui::VKEY_UNKNOWN, ui::EF_NONE);
306 item_delegate->ItemSelected(std::move(event), display::kInvalidDisplayId,
307 LAUNCH_FROM_UNKNOWN, base::Bind(&NoopCallback));
297 } 308 }
298 309
299 bool WmShelf::ProcessGestureEvent(const ui::GestureEvent& event) { 310 bool WmShelf::ProcessGestureEvent(const ui::GestureEvent& event) {
300 // Can be called at login screen. 311 // Can be called at login screen.
301 if (!shelf_layout_manager_) 312 if (!shelf_layout_manager_)
302 return false; 313 return false;
303 return shelf_layout_manager_->ProcessGestureEvent(event); 314 return shelf_layout_manager_->ProcessGestureEvent(event);
304 } 315 }
305 316
306 void WmShelf::AddObserver(WmShelfObserver* observer) { 317 void WmShelf::AddObserver(WmShelfObserver* observer) {
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
366 377
367 void WmShelf::OnBackgroundUpdated(ShelfBackgroundType background_type, 378 void WmShelf::OnBackgroundUpdated(ShelfBackgroundType background_type,
368 AnimationChangeType change_type) { 379 AnimationChangeType change_type) {
369 if (background_type == GetBackgroundType()) 380 if (background_type == GetBackgroundType())
370 return; 381 return;
371 for (auto& observer : observers_) 382 for (auto& observer : observers_)
372 observer.OnBackgroundTypeChanged(background_type, change_type); 383 observer.OnBackgroundTypeChanged(background_type, change_type);
373 } 384 }
374 385
375 } // namespace ash 386 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/shelf/shelf_window_watcher_item_delegate.cc ('k') | ash/common/test/test_shelf_item_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698