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

Side by Side Diff: ash/shelf/shelf_window_watcher_item_delegate.cc

Issue 2860503002: mash: Replace int ShelfIDs with AppLaunchID strings. (Closed)
Patch Set: Fix struct traits typo. 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 unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/shelf/shelf_window_watcher_item_delegate.h" 5 #include "ash/shelf/shelf_window_watcher_item_delegate.h"
6 6
7 #include "ash/public/cpp/window_properties.h" 7 #include "ash/public/cpp/window_properties.h"
8 #include "ash/shelf/shelf_controller.h" 8 #include "ash/shelf/shelf_controller.h"
9 #include "ash/shelf/shelf_model.h" 9 #include "ash/shelf/shelf_model.h"
10 #include "ash/shell.h" 10 #include "ash/shell.h"
11 #include "ash/wm/window_state.h" 11 #include "ash/wm/window_state.h"
12 #include "ash/wm/window_util.h" 12 #include "ash/wm/window_util.h"
13 #include "ash/wm_window.h" 13 #include "ash/wm_window.h"
14 #include "ui/aura/window.h" 14 #include "ui/aura/window.h"
15 #include "ui/events/event_constants.h" 15 #include "ui/events/event_constants.h"
16 16
17 namespace ash { 17 namespace ash {
18 18
19 namespace { 19 namespace {
20 20
21 ShelfItemType GetShelfItemType(ShelfID id) { 21 ShelfItemType GetShelfItemType(const ShelfID& id) {
22 ShelfModel* model = Shell::Get()->shelf_controller()->model(); 22 ShelfModel* model = Shell::Get()->shelf_controller()->model();
23 ShelfItems::const_iterator item = model->ItemByID(id); 23 ShelfItems::const_iterator item = model->ItemByID(id);
24 return item == model->items().end() ? TYPE_UNDEFINED : item->type; 24 return item == model->items().end() ? TYPE_UNDEFINED : item->type;
25 } 25 }
26 26
27 } // namespace 27 } // namespace
28 28
29 ShelfWindowWatcherItemDelegate::ShelfWindowWatcherItemDelegate(ShelfID id, 29 ShelfWindowWatcherItemDelegate::ShelfWindowWatcherItemDelegate(
30 WmWindow* window) 30 const ShelfID& id,
31 : ShelfItemDelegate(AppLaunchId()), id_(id), window_(window) { 31 WmWindow* window)
32 DCHECK_NE(kInvalidShelfID, id_); 32 : ShelfItemDelegate(id), window_(window) {
33 DCHECK(!id.IsNull());
33 DCHECK(window_); 34 DCHECK(window_);
34 } 35 }
35 36
36 ShelfWindowWatcherItemDelegate::~ShelfWindowWatcherItemDelegate() {} 37 ShelfWindowWatcherItemDelegate::~ShelfWindowWatcherItemDelegate() {}
37 38
38 void ShelfWindowWatcherItemDelegate::ItemSelected( 39 void ShelfWindowWatcherItemDelegate::ItemSelected(
39 std::unique_ptr<ui::Event> event, 40 std::unique_ptr<ui::Event> event,
40 int64_t display_id, 41 int64_t display_id,
41 ShelfLaunchSource source, 42 ShelfLaunchSource source,
42 const ItemSelectedCallback& callback) { 43 const ItemSelectedCallback& callback) {
43 // Move panels attached on another display to the current display. 44 // Move panels attached on another display to the current display.
44 if (GetShelfItemType(id_) == TYPE_APP_PANEL && 45 if (GetShelfItemType(shelf_id()) == TYPE_APP_PANEL &&
45 window_->aura_window()->GetProperty(kPanelAttachedKey) && 46 window_->aura_window()->GetProperty(kPanelAttachedKey) &&
46 wm::MoveWindowToDisplay(window_->aura_window(), display_id)) { 47 wm::MoveWindowToDisplay(window_->aura_window(), display_id)) {
47 window_->Activate(); 48 window_->Activate();
48 callback.Run(SHELF_ACTION_WINDOW_ACTIVATED, base::nullopt); 49 callback.Run(SHELF_ACTION_WINDOW_ACTIVATED, base::nullopt);
49 return; 50 return;
50 } 51 }
51 52
52 if (window_->IsActive()) { 53 if (window_->IsActive()) {
53 if (event && event->type() == ui::ET_KEY_RELEASED) { 54 if (event && event->type() == ui::ET_KEY_RELEASED) {
54 window_->Animate(::wm::WINDOW_ANIMATION_TYPE_BOUNCE); 55 window_->Animate(::wm::WINDOW_ANIMATION_TYPE_BOUNCE);
55 callback.Run(SHELF_ACTION_NONE, base::nullopt); 56 callback.Run(SHELF_ACTION_NONE, base::nullopt);
56 return; 57 return;
57 } 58 }
58 window_->Minimize(); 59 window_->Minimize();
59 callback.Run(SHELF_ACTION_WINDOW_MINIMIZED, base::nullopt); 60 callback.Run(SHELF_ACTION_WINDOW_MINIMIZED, base::nullopt);
60 return; 61 return;
61 } 62 }
62 window_->Activate(); 63 window_->Activate();
63 callback.Run(SHELF_ACTION_WINDOW_ACTIVATED, base::nullopt); 64 callback.Run(SHELF_ACTION_WINDOW_ACTIVATED, base::nullopt);
64 } 65 }
65 66
66 void ShelfWindowWatcherItemDelegate::ExecuteCommand(uint32_t command_id, 67 void ShelfWindowWatcherItemDelegate::ExecuteCommand(uint32_t command_id,
67 int32_t event_flags) {} 68 int32_t event_flags) {}
68 69
69 void ShelfWindowWatcherItemDelegate::Close() { 70 void ShelfWindowWatcherItemDelegate::Close() {
70 window_->CloseWidget(); 71 window_->CloseWidget();
71 } 72 }
72 73
73 } // namespace ash 74 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf_window_watcher_item_delegate.h ('k') | ash/shelf/shelf_window_watcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698