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/common/system/date/date_default_view.h" | 5 #include "ash/common/system/date/date_default_view.h" |
6 | 6 |
7 #include "ash/common/metrics/user_metrics_action.h" | 7 #include "ash/common/metrics/user_metrics_action.h" |
8 #include "ash/common/session/session_state_delegate.h" | 8 #include "ash/common/session/session_state_delegate.h" |
9 #include "ash/common/shutdown_controller.h" | 9 #include "ash/common/shutdown_controller.h" |
10 #include "ash/common/system/date/date_view.h" | 10 #include "ash/common/system/date/date_view.h" |
11 #include "ash/common/system/tray/special_popup_row.h" | 11 #include "ash/common/system/tray/special_popup_row.h" |
12 #include "ash/common/system/tray/system_tray.h" | 12 #include "ash/common/system/tray/system_tray.h" |
13 #include "ash/common/system/tray/system_tray_controller.h" | 13 #include "ash/common/system/tray/system_tray_controller.h" |
14 #include "ash/common/system/tray/tray_constants.h" | 14 #include "ash/common/system/tray/tray_constants.h" |
15 #include "ash/common/system/tray/tray_popup_header_button.h" | 15 #include "ash/common/system/tray/tray_popup_header_button.h" |
16 #include "ash/common/wm_shell.h" | 16 #include "ash/common/wm_shell.h" |
17 #include "base/i18n/rtl.h" | 17 #include "base/i18n/rtl.h" |
| 18 #include "chromeos/dbus/dbus_thread_manager.h" |
| 19 #include "chromeos/dbus/session_manager_client.h" |
18 #include "grit/ash_resources.h" | 20 #include "grit/ash_resources.h" |
19 #include "grit/ash_strings.h" | 21 #include "grit/ash_strings.h" |
20 #include "ui/base/l10n/l10n_util.h" | 22 #include "ui/base/l10n/l10n_util.h" |
21 #include "ui/views/border.h" | 23 #include "ui/views/border.h" |
22 #include "ui/views/controls/button/button.h" | 24 #include "ui/views/controls/button/button.h" |
23 #include "ui/views/layout/fill_layout.h" | 25 #include "ui/views/layout/fill_layout.h" |
24 #include "ui/views/view.h" | 26 #include "ui/views/view.h" |
25 | 27 |
26 #if defined(OS_CHROMEOS) | |
27 #include "chromeos/dbus/dbus_thread_manager.h" | |
28 #include "chromeos/dbus/session_manager_client.h" | |
29 #endif | |
30 | |
31 namespace { | 28 namespace { |
32 | 29 |
33 // The ISO-639 code for the Hebrew locale. The help icon asset is a '?' which is | 30 // The ISO-639 code for the Hebrew locale. The help icon asset is a '?' which is |
34 // not mirrored in this locale. | 31 // not mirrored in this locale. |
35 const char kHebrewLocale[] = "he"; | 32 const char kHebrewLocale[] = "he"; |
36 | 33 |
37 const int kPaddingVertical = 19; | 34 const int kPaddingVertical = 19; |
38 | 35 |
39 } // namespace | 36 } // namespace |
40 | 37 |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
73 base::i18n::GetConfiguredLocale() == kHebrewLocale) { | 70 base::i18n::GetConfiguredLocale() == kHebrewLocale) { |
74 // The asset for the help button is a question mark '?'. Normally this asset | 71 // The asset for the help button is a question mark '?'. Normally this asset |
75 // is flipped in RTL locales, however Hebrew uses the LTR '?'. So the | 72 // is flipped in RTL locales, however Hebrew uses the LTR '?'. So the |
76 // flipping must be disabled. (crbug.com/475237) | 73 // flipping must be disabled. (crbug.com/475237) |
77 help_button_->EnableCanvasFlippingForRTLUI(false); | 74 help_button_->EnableCanvasFlippingForRTLUI(false); |
78 } | 75 } |
79 help_button_->SetTooltipText( | 76 help_button_->SetTooltipText( |
80 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_HELP)); | 77 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_HELP)); |
81 view->AddViewToRowNonMd(help_button_, true); | 78 view->AddViewToRowNonMd(help_button_, true); |
82 | 79 |
83 #if !defined(OS_WIN) | |
84 if (login != LoginStatus::LOCKED) { | 80 if (login != LoginStatus::LOCKED) { |
85 shutdown_button_ = new TrayPopupHeaderButton( | 81 shutdown_button_ = new TrayPopupHeaderButton( |
86 this, IDR_AURA_UBER_TRAY_SHUTDOWN, IDR_AURA_UBER_TRAY_SHUTDOWN, | 82 this, IDR_AURA_UBER_TRAY_SHUTDOWN, IDR_AURA_UBER_TRAY_SHUTDOWN, |
87 IDR_AURA_UBER_TRAY_SHUTDOWN_HOVER, IDR_AURA_UBER_TRAY_SHUTDOWN_HOVER, | 83 IDR_AURA_UBER_TRAY_SHUTDOWN_HOVER, IDR_AURA_UBER_TRAY_SHUTDOWN_HOVER, |
88 IDS_ASH_STATUS_TRAY_SHUTDOWN); | 84 IDS_ASH_STATUS_TRAY_SHUTDOWN); |
89 shutdown_button_->SetTooltipText( | 85 shutdown_button_->SetTooltipText( |
90 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SHUTDOWN)); | 86 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_SHUTDOWN)); |
91 view->AddViewToRowNonMd(shutdown_button_, true); | 87 view->AddViewToRowNonMd(shutdown_button_, true); |
92 // This object is recreated every time the menu opens. Don't bother updating | 88 // This object is recreated every time the menu opens. Don't bother updating |
93 // the tooltip if the shutdown policy changes while the menu is open. | 89 // the tooltip if the shutdown policy changes while the menu is open. |
94 bool reboot = WmShell::Get()->shutdown_controller()->reboot_on_shutdown(); | 90 bool reboot = WmShell::Get()->shutdown_controller()->reboot_on_shutdown(); |
95 shutdown_button_->SetTooltipText(l10n_util::GetStringUTF16( | 91 shutdown_button_->SetTooltipText(l10n_util::GetStringUTF16( |
96 reboot ? IDS_ASH_STATUS_TRAY_REBOOT : IDS_ASH_STATUS_TRAY_SHUTDOWN)); | 92 reboot ? IDS_ASH_STATUS_TRAY_REBOOT : IDS_ASH_STATUS_TRAY_SHUTDOWN)); |
97 } | 93 } |
98 | 94 |
99 if (shell->GetSessionStateDelegate()->CanLockScreen()) { | 95 if (shell->GetSessionStateDelegate()->CanLockScreen()) { |
100 lock_button_ = new TrayPopupHeaderButton( | 96 lock_button_ = new TrayPopupHeaderButton( |
101 this, IDR_AURA_UBER_TRAY_LOCKSCREEN, IDR_AURA_UBER_TRAY_LOCKSCREEN, | 97 this, IDR_AURA_UBER_TRAY_LOCKSCREEN, IDR_AURA_UBER_TRAY_LOCKSCREEN, |
102 IDR_AURA_UBER_TRAY_LOCKSCREEN_HOVER, | 98 IDR_AURA_UBER_TRAY_LOCKSCREEN_HOVER, |
103 IDR_AURA_UBER_TRAY_LOCKSCREEN_HOVER, IDS_ASH_STATUS_TRAY_LOCK); | 99 IDR_AURA_UBER_TRAY_LOCKSCREEN_HOVER, IDS_ASH_STATUS_TRAY_LOCK); |
104 lock_button_->SetTooltipText( | 100 lock_button_->SetTooltipText( |
105 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_LOCK)); | 101 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_LOCK)); |
106 view->AddViewToRowNonMd(lock_button_, true); | 102 view->AddViewToRowNonMd(lock_button_, true); |
107 } | 103 } |
108 #endif // !defined(OS_WIN) | |
109 } | 104 } |
110 | 105 |
111 DateDefaultView::~DateDefaultView() {} | 106 DateDefaultView::~DateDefaultView() {} |
112 | 107 |
113 views::View* DateDefaultView::GetHelpButtonView() { | 108 views::View* DateDefaultView::GetHelpButtonView() { |
114 return help_button_; | 109 return help_button_; |
115 } | 110 } |
116 | 111 |
117 const views::View* DateDefaultView::GetShutdownButtonViewForTest() const { | 112 const views::View* DateDefaultView::GetShutdownButtonViewForTest() const { |
118 return shutdown_button_; | 113 return shutdown_button_; |
(...skipping 11 matching lines...) Expand all Loading... |
130 const ui::Event& event) { | 125 const ui::Event& event) { |
131 WmShell* shell = WmShell::Get(); | 126 WmShell* shell = WmShell::Get(); |
132 if (sender == help_button_) { | 127 if (sender == help_button_) { |
133 shell->RecordUserMetricsAction(UMA_TRAY_HELP); | 128 shell->RecordUserMetricsAction(UMA_TRAY_HELP); |
134 shell->system_tray_controller()->ShowHelp(); | 129 shell->system_tray_controller()->ShowHelp(); |
135 } else if (sender == shutdown_button_) { | 130 } else if (sender == shutdown_button_) { |
136 shell->RecordUserMetricsAction(UMA_TRAY_SHUT_DOWN); | 131 shell->RecordUserMetricsAction(UMA_TRAY_SHUT_DOWN); |
137 shell->RequestShutdown(); | 132 shell->RequestShutdown(); |
138 } else if (sender == lock_button_) { | 133 } else if (sender == lock_button_) { |
139 shell->RecordUserMetricsAction(UMA_TRAY_LOCK_SCREEN); | 134 shell->RecordUserMetricsAction(UMA_TRAY_LOCK_SCREEN); |
140 #if defined(OS_CHROMEOS) | |
141 chromeos::DBusThreadManager::Get() | 135 chromeos::DBusThreadManager::Get() |
142 ->GetSessionManagerClient() | 136 ->GetSessionManagerClient() |
143 ->RequestLockScreen(); | 137 ->RequestLockScreen(); |
144 #endif | |
145 } else { | 138 } else { |
146 NOTREACHED(); | 139 NOTREACHED(); |
147 } | 140 } |
148 date_view_->CloseSystemBubble(); | 141 date_view_->CloseSystemBubble(); |
149 } | 142 } |
150 | 143 |
151 } // namespace ash | 144 } // namespace ash |
OLD | NEW |