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

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

Issue 2736573002: chromeos: Move files in //ash/common to //ash, part 2 (Closed)
Patch Set: 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "ash/common/shelf/shelf_window_watcher_item_delegate.h"
6
7 #include "ash/common/shelf/shelf_controller.h"
8 #include "ash/common/shelf/shelf_model.h"
9 #include "ash/common/wm/window_state.h"
10 #include "ash/common/wm_shell.h"
11 #include "ash/common/wm_window.h"
12 #include "ash/public/cpp/window_properties.h"
13 #include "ash/wm/window_util.h"
14 #include "ui/aura/window.h"
15 #include "ui/events/event_constants.h"
16
17 namespace ash {
18
19 namespace {
20
21 ShelfItemType GetShelfItemType(ShelfID id) {
22 ShelfModel* model = WmShell::Get()->shelf_controller()->model();
23 ShelfItems::const_iterator item = model->ItemByID(id);
24 return item == model->items().end() ? TYPE_UNDEFINED : item->type;
25 }
26
27 } // namespace
28
29 ShelfWindowWatcherItemDelegate::ShelfWindowWatcherItemDelegate(ShelfID id,
30 WmWindow* window)
31 : id_(id), window_(window) {
32 DCHECK_NE(kInvalidShelfID, id_);
33 DCHECK(window_);
34 }
35
36 ShelfWindowWatcherItemDelegate::~ShelfWindowWatcherItemDelegate() {}
37
38 ShelfAction ShelfWindowWatcherItemDelegate::ItemSelected(
39 ui::EventType event_type,
40 int event_flags,
41 int64_t display_id,
42 ShelfLaunchSource source) {
43 // Move panels attached on another display to the current display.
44 if (GetShelfItemType(id_) == TYPE_APP_PANEL &&
45 window_->aura_window()->GetProperty(kPanelAttachedKey) &&
46 wm::MoveWindowToDisplay(window_->aura_window(), display_id)) {
47 window_->Activate();
48 return SHELF_ACTION_WINDOW_ACTIVATED;
49 }
50
51 if (window_->IsActive()) {
52 if (event_type == ui::ET_KEY_RELEASED) {
53 window_->Animate(::wm::WINDOW_ANIMATION_TYPE_BOUNCE);
54 return SHELF_ACTION_NONE;
55 }
56 window_->Minimize();
57 return SHELF_ACTION_WINDOW_MINIMIZED;
58 }
59 window_->Activate();
60 return SHELF_ACTION_WINDOW_ACTIVATED;
61 }
62
63 ShelfAppMenuItemList ShelfWindowWatcherItemDelegate::GetAppMenuItems(
64 int event_flags) {
65 // Return an empty item list to avoid showing an application menu.
66 return ShelfAppMenuItemList();
67 }
68
69 void ShelfWindowWatcherItemDelegate::ExecuteCommand(uint32_t command_id,
70 int event_flags) {
71 // This delegate does not support showing an application menu.
72 NOTIMPLEMENTED();
73 }
74
75 void ShelfWindowWatcherItemDelegate::Close() {
76 window_->CloseWidget();
77 }
78
79 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/shelf/shelf_window_watcher_item_delegate.h ('k') | ash/common/shelf/shelf_window_watcher_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698