OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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/system/overview/overview_button_tray.h" | 5 #include "ash/system/overview/overview_button_tray.h" |
6 | 6 |
7 #include "ash/resources/vector_icons/vector_icons.h" | 7 #include "ash/resources/vector_icons/vector_icons.h" |
8 #include "ash/session/session_controller.h" | 8 #include "ash/session/session_controller.h" |
9 #include "ash/shelf/shelf_constants.h" | 9 #include "ash/shelf/shelf_constants.h" |
10 #include "ash/shell.h" | 10 #include "ash/shell.h" |
11 #include "ash/shell_port.h" | 11 #include "ash/shell_port.h" |
12 #include "ash/strings/grit/ash_strings.h" | 12 #include "ash/strings/grit/ash_strings.h" |
13 #include "ash/system/tray/tray_constants.h" | 13 #include "ash/system/tray/tray_constants.h" |
14 #include "ash/system/tray/tray_container.h" | 14 #include "ash/system/tray/tray_container.h" |
15 #include "ash/wm/maximize_mode/maximize_mode_controller.h" | 15 #include "ash/wm/maximize_mode/maximize_mode_controller.h" |
| 16 #include "ash/wm/mru_window_tracker.h" |
16 #include "ash/wm/overview/window_selector_controller.h" | 17 #include "ash/wm/overview/window_selector_controller.h" |
| 18 #include "ash/wm_window.h" |
17 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
18 #include "ui/gfx/paint_vector_icon.h" | 20 #include "ui/gfx/paint_vector_icon.h" |
19 #include "ui/views/border.h" | 21 #include "ui/views/border.h" |
20 #include "ui/views/controls/image_view.h" | 22 #include "ui/views/controls/image_view.h" |
| 23 #include "ui/wm/core/window_util.h" |
21 | 24 |
22 namespace ash { | 25 namespace ash { |
23 | 26 |
24 OverviewButtonTray::OverviewButtonTray(WmShelf* wm_shelf) | 27 OverviewButtonTray::OverviewButtonTray(WmShelf* wm_shelf) |
25 : TrayBackgroundView(wm_shelf), | 28 : TrayBackgroundView(wm_shelf), |
26 icon_(new views::ImageView()), | 29 icon_(new views::ImageView()), |
27 scoped_session_observer_(this) { | 30 scoped_session_observer_(this) { |
28 SetInkDropMode(InkDropMode::ON); | 31 SetInkDropMode(InkDropMode::ON); |
29 | 32 |
30 gfx::ImageSkia image = | 33 gfx::ImageSkia image = |
(...skipping 14 matching lines...) Expand all Loading... |
45 | 48 |
46 OverviewButtonTray::~OverviewButtonTray() { | 49 OverviewButtonTray::~OverviewButtonTray() { |
47 Shell::Get()->RemoveShellObserver(this); | 50 Shell::Get()->RemoveShellObserver(this); |
48 } | 51 } |
49 | 52 |
50 void OverviewButtonTray::UpdateAfterLoginStatusChange(LoginStatus status) { | 53 void OverviewButtonTray::UpdateAfterLoginStatusChange(LoginStatus status) { |
51 UpdateIconVisibility(); | 54 UpdateIconVisibility(); |
52 } | 55 } |
53 | 56 |
54 bool OverviewButtonTray::PerformAction(const ui::Event& event) { | 57 bool OverviewButtonTray::PerformAction(const ui::Event& event) { |
| 58 if (event.type() == ui::ET_GESTURE_TAP) { |
| 59 if (event.AsGestureEvent()->details().tap_count() == 2) { |
| 60 // If the second tap is not on the window selection page, that means we |
| 61 // started on the window selection page. Ignore these double taps. (ie. |
| 62 // treat them as single taps by ignoring the second tap) |
| 63 if (!Shell::Get()->window_selector_controller()->IsSelecting()) |
| 64 return true; |
| 65 |
| 66 MruWindowTracker::WindowList mru_window_list = |
| 67 Shell::Get()->mru_window_tracker()->BuildMruWindowList(); |
| 68 |
| 69 // Switch to the second most recently used window (most recent is the |
| 70 // current window), if it exists. |
| 71 if (mru_window_list.size() > 1) { |
| 72 AnimateInkDrop(views::InkDropState::DEACTIVATED, nullptr); |
| 73 ::wm::ActivateWindow(WmWindow::GetAuraWindow(mru_window_list[1])); |
| 74 return true; |
| 75 } |
| 76 } |
| 77 } |
| 78 |
55 WindowSelectorController* controller = | 79 WindowSelectorController* controller = |
56 Shell::Get()->window_selector_controller(); | 80 Shell::Get()->window_selector_controller(); |
57 // Toggling overview mode will fail if there is no window to show. | 81 // Note: Toggling overview mode will fail if there is no window to show, the |
| 82 // screen is locked, a modal dialog is open or is running in kiosk app |
| 83 // session. |
58 bool performed = controller->ToggleOverview(); | 84 bool performed = controller->ToggleOverview(); |
59 ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_OVERVIEW); | 85 ShellPort::Get()->RecordUserMetricsAction(UMA_TRAY_OVERVIEW); |
60 return performed; | 86 return performed; |
61 } | 87 } |
62 | 88 |
63 void OverviewButtonTray::OnSessionStateChanged( | 89 void OverviewButtonTray::OnSessionStateChanged( |
64 session_manager::SessionState state) { | 90 session_manager::SessionState state) { |
65 UpdateIconVisibility(); | 91 UpdateIconVisibility(); |
66 } | 92 } |
67 | 93 |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
103 SetVisible( | 129 SetVisible( |
104 shell->maximize_mode_controller()->IsMaximizeModeWindowManagerEnabled() && | 130 shell->maximize_mode_controller()->IsMaximizeModeWindowManagerEnabled() && |
105 session_controller->IsActiveUserSessionStarted() && | 131 session_controller->IsActiveUserSessionStarted() && |
106 !session_controller->IsScreenLocked() && | 132 !session_controller->IsScreenLocked() && |
107 session_controller->GetSessionState() == | 133 session_controller->GetSessionState() == |
108 session_manager::SessionState::ACTIVE && | 134 session_manager::SessionState::ACTIVE && |
109 !session_controller->IsKioskSession()); | 135 !session_controller->IsKioskSession()); |
110 } | 136 } |
111 | 137 |
112 } // namespace ash | 138 } // namespace ash |
OLD | NEW |