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

Side by Side Diff: ash/common/system/overview/overview_button_tray.cc

Issue 2734653002: chromeos: Move files in //ash/common to //ash (Closed)
Patch Set: fix a11y tests, fix docs 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 2014 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/system/overview/overview_button_tray.h"
6
7 #include "ash/common/session/session_state_delegate.h"
8 #include "ash/common/shelf/shelf_constants.h"
9 #include "ash/common/system/tray/system_tray_delegate.h"
10 #include "ash/common/system/tray/tray_constants.h"
11 #include "ash/common/wm/maximize_mode/maximize_mode_controller.h"
12 #include "ash/common/wm/overview/window_selector_controller.h"
13 #include "ash/common/wm_shell.h"
14 #include "ash/resources/vector_icons/vector_icons.h"
15 #include "ash/strings/grit/ash_strings.h"
16 #include "ui/base/l10n/l10n_util.h"
17 #include "ui/gfx/paint_vector_icon.h"
18 #include "ui/views/border.h"
19 #include "ui/views/controls/image_view.h"
20
21 namespace ash {
22
23 OverviewButtonTray::OverviewButtonTray(WmShelf* wm_shelf)
24 : TrayBackgroundView(wm_shelf), icon_(new views::ImageView()) {
25 SetInkDropMode(InkDropMode::ON);
26 SetContentsBackground(false);
27
28 icon_->SetImage(CreateVectorIcon(kShelfOverviewIcon, kShelfIconColor));
29 SetIconBorderForShelfAlignment();
30 tray_container()->AddChildView(icon_);
31
32 // Since OverviewButtonTray is located on the rightmost position of a
33 // horizontal shelf, no separator is required.
34 set_separator_visibility(false);
35
36 WmShell::Get()->AddShellObserver(this);
37 WmShell::Get()->GetSessionStateDelegate()->AddSessionStateObserver(this);
38 }
39
40 OverviewButtonTray::~OverviewButtonTray() {
41 WmShell::Get()->RemoveShellObserver(this);
42 WmShell::Get()->GetSessionStateDelegate()->RemoveSessionStateObserver(this);
43 }
44
45 void OverviewButtonTray::UpdateAfterLoginStatusChange(LoginStatus status) {
46 UpdateIconVisibility();
47 }
48
49 bool OverviewButtonTray::PerformAction(const ui::Event& event) {
50 WindowSelectorController* controller =
51 WmShell::Get()->window_selector_controller();
52 // Toggling overview mode will fail if there is no window to show.
53 bool performed = controller->ToggleOverview();
54 WmShell::Get()->RecordUserMetricsAction(UMA_TRAY_OVERVIEW);
55 return performed;
56 }
57
58 void OverviewButtonTray::SessionStateChanged(
59 session_manager::SessionState state) {
60 UpdateIconVisibility();
61 }
62
63 void OverviewButtonTray::OnMaximizeModeStarted() {
64 UpdateIconVisibility();
65 }
66
67 void OverviewButtonTray::OnMaximizeModeEnded() {
68 UpdateIconVisibility();
69 }
70
71 void OverviewButtonTray::OnOverviewModeStarting() {
72 SetIsActive(true);
73 }
74
75 void OverviewButtonTray::OnOverviewModeEnded() {
76 SetIsActive(false);
77 }
78
79 void OverviewButtonTray::ClickedOutsideBubble() {}
80
81 base::string16 OverviewButtonTray::GetAccessibleNameForTray() {
82 return l10n_util::GetStringUTF16(IDS_ASH_OVERVIEW_BUTTON_ACCESSIBLE_NAME);
83 }
84
85 void OverviewButtonTray::HideBubbleWithView(
86 const views::TrayBubbleView* bubble_view) {
87 // This class has no bubbles to hide.
88 }
89
90 void OverviewButtonTray::SetShelfAlignment(ShelfAlignment alignment) {
91 if (alignment == shelf_alignment())
92 return;
93
94 TrayBackgroundView::SetShelfAlignment(alignment);
95 SetIconBorderForShelfAlignment();
96 }
97
98 void OverviewButtonTray::SetIconBorderForShelfAlignment() {
99 // Pad button size to align with other controls in the system tray.
100 const gfx::ImageSkia& image = icon_->GetImage();
101 const int vertical_padding = (kTrayItemSize - image.height()) / 2;
102 const int horizontal_padding = (kTrayItemSize - image.width()) / 2;
103 icon_->SetBorder(views::CreateEmptyBorder(
104 gfx::Insets(vertical_padding, horizontal_padding)));
105 }
106
107 void OverviewButtonTray::UpdateIconVisibility() {
108 // The visibility of the OverviewButtonTray has diverged from
109 // WindowSelectorController::CanSelect. The visibility of the button should
110 // not change during transient times in which CanSelect is false. Such as when
111 // a modal dialog is present.
112 WmShell* shell = WmShell::Get();
113 SessionStateDelegate* session_state_delegate =
114 shell->GetSessionStateDelegate();
115
116 SetVisible(
117 shell->maximize_mode_controller()->IsMaximizeModeWindowManagerEnabled() &&
118 session_state_delegate->IsActiveUserSessionStarted() &&
119 !session_state_delegate->IsScreenLocked() &&
120 session_state_delegate->GetSessionState() ==
121 session_manager::SessionState::ACTIVE &&
122 shell->system_tray_delegate()->GetUserLoginStatus() !=
123 LoginStatus::KIOSK_APP &&
124 shell->system_tray_delegate()->GetUserLoginStatus() !=
125 LoginStatus::ARC_KIOSK_APP);
126 }
127
128 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/overview/overview_button_tray.h ('k') | ash/common/system/status_area_layout_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698