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

Side by Side Diff: ash/common/system/tiles/tiles_default_view.cc

Issue 2591553002: Remove non-cros support from ash/common/system. (Closed)
Patch Set: jc review + rebase Created 4 years 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
« no previous file with comments | « ash/common/system/system_notifier.cc ('k') | ash/common/system/tiles/tray_tiles_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/tiles/tiles_default_view.h" 5 #include "ash/common/system/tiles/tiles_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/tray/system_menu_button.h" 10 #include "ash/common/system/tray/system_menu_button.h"
11 #include "ash/common/system/tray/system_tray.h" 11 #include "ash/common/system/tray/system_tray.h"
12 #include "ash/common/system/tray/system_tray_controller.h" 12 #include "ash/common/system/tray/system_tray_controller.h"
13 #include "ash/common/system/tray/system_tray_delegate.h" 13 #include "ash/common/system/tray/system_tray_delegate.h"
14 #include "ash/common/system/tray/system_tray_item.h" 14 #include "ash/common/system/tray/system_tray_item.h"
15 #include "ash/common/system/tray/tray_constants.h" 15 #include "ash/common/system/tray/tray_constants.h"
16 #include "ash/common/system/tray/tray_popup_utils.h" 16 #include "ash/common/system/tray/tray_popup_utils.h"
17 #include "ash/common/wm_shell.h" 17 #include "ash/common/wm_shell.h"
18 #include "ash/resources/vector_icons/vector_icons.h" 18 #include "ash/resources/vector_icons/vector_icons.h"
19 #include "chromeos/dbus/dbus_thread_manager.h"
20 #include "chromeos/dbus/session_manager_client.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/gfx/geometry/insets.h" 23 #include "ui/gfx/geometry/insets.h"
22 #include "ui/views/border.h" 24 #include "ui/views/border.h"
23 #include "ui/views/controls/button/custom_button.h" 25 #include "ui/views/controls/button/custom_button.h"
24 #include "ui/views/controls/separator.h" 26 #include "ui/views/controls/separator.h"
25 #include "ui/views/layout/box_layout.h" 27 #include "ui/views/layout/box_layout.h"
26 28
27 #if defined(OS_CHROMEOS)
28 #include "chromeos/dbus/dbus_thread_manager.h"
29 #include "chromeos/dbus/session_manager_client.h"
30 #endif
31
32 namespace { 29 namespace {
33 30
34 // The ISO-639 code for the Hebrew locale. The help icon asset is a '?' which is 31 // The ISO-639 code for the Hebrew locale. The help icon asset is a '?' which is
35 // not mirrored in this locale. 32 // not mirrored in this locale.
36 const char kHebrewLocale[] = "he"; 33 const char kHebrewLocale[] = "he";
37 34
38 } // namespace 35 } // namespace
39 36
40 namespace ash { 37 namespace ash {
41 38
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
80 // The asset for the help button is a question mark '?'. Normally this asset 77 // The asset for the help button is a question mark '?'. Normally this asset
81 // is flipped in RTL locales, however Hebrew uses the LTR '?'. So the 78 // is flipped in RTL locales, however Hebrew uses the LTR '?'. So the
82 // flipping must be disabled. (crbug.com/475237) 79 // flipping must be disabled. (crbug.com/475237)
83 help_button_->EnableCanvasFlippingForRTLUI(false); 80 help_button_->EnableCanvasFlippingForRTLUI(false);
84 } 81 }
85 if (disable_buttons) 82 if (disable_buttons)
86 help_button_->SetEnabled(false); 83 help_button_->SetEnabled(false);
87 AddChildView(help_button_); 84 AddChildView(help_button_);
88 AddChildView(TrayPopupUtils::CreateVerticalSeparator()); 85 AddChildView(TrayPopupUtils::CreateVerticalSeparator());
89 86
90 #if !defined(OS_WIN)
91 lock_button_ = 87 lock_button_ =
92 new SystemMenuButton(this, TrayPopupInkDropStyle::HOST_CENTERED, 88 new SystemMenuButton(this, TrayPopupInkDropStyle::HOST_CENTERED,
93 kSystemMenuLockIcon, IDS_ASH_STATUS_TRAY_LOCK); 89 kSystemMenuLockIcon, IDS_ASH_STATUS_TRAY_LOCK);
94 if (disable_buttons || !shell->GetSessionStateDelegate()->CanLockScreen()) 90 if (disable_buttons || !shell->GetSessionStateDelegate()->CanLockScreen())
95 lock_button_->SetEnabled(false); 91 lock_button_->SetEnabled(false);
96 92
97 AddChildView(lock_button_); 93 AddChildView(lock_button_);
98 AddChildView(TrayPopupUtils::CreateVerticalSeparator()); 94 AddChildView(TrayPopupUtils::CreateVerticalSeparator());
99 95
100 power_button_ = 96 power_button_ =
101 new SystemMenuButton(this, TrayPopupInkDropStyle::HOST_CENTERED, 97 new SystemMenuButton(this, TrayPopupInkDropStyle::HOST_CENTERED,
102 kSystemMenuPowerIcon, IDS_ASH_STATUS_TRAY_SHUTDOWN); 98 kSystemMenuPowerIcon, IDS_ASH_STATUS_TRAY_SHUTDOWN);
103 AddChildView(power_button_); 99 AddChildView(power_button_);
104 // This object is recreated every time the menu opens. Don't bother updating 100 // This object is recreated every time the menu opens. Don't bother updating
105 // the tooltip if the shutdown policy changes while the menu is open. 101 // the tooltip if the shutdown policy changes while the menu is open.
106 bool reboot = WmShell::Get()->shutdown_controller()->reboot_on_shutdown(); 102 bool reboot = WmShell::Get()->shutdown_controller()->reboot_on_shutdown();
107 power_button_->SetTooltipText(l10n_util::GetStringUTF16( 103 power_button_->SetTooltipText(l10n_util::GetStringUTF16(
108 reboot ? IDS_ASH_STATUS_TRAY_REBOOT : IDS_ASH_STATUS_TRAY_SHUTDOWN)); 104 reboot ? IDS_ASH_STATUS_TRAY_REBOOT : IDS_ASH_STATUS_TRAY_SHUTDOWN));
109 #endif // !defined(OS_WIN)
110 } 105 }
111 106
112 void TilesDefaultView::ButtonPressed(views::Button* sender, 107 void TilesDefaultView::ButtonPressed(views::Button* sender,
113 const ui::Event& event) { 108 const ui::Event& event) {
114 DCHECK(sender); 109 DCHECK(sender);
115 WmShell* shell = WmShell::Get(); 110 WmShell* shell = WmShell::Get();
116 if (sender == settings_button_) { 111 if (sender == settings_button_) {
117 shell->RecordUserMetricsAction(UMA_TRAY_SETTINGS); 112 shell->RecordUserMetricsAction(UMA_TRAY_SETTINGS);
118 shell->system_tray_controller()->ShowSettings(); 113 shell->system_tray_controller()->ShowSettings();
119 } else if (sender == help_button_) { 114 } else if (sender == help_button_) {
120 shell->RecordUserMetricsAction(UMA_TRAY_HELP); 115 shell->RecordUserMetricsAction(UMA_TRAY_HELP);
121 shell->system_tray_controller()->ShowHelp(); 116 shell->system_tray_controller()->ShowHelp();
122 } else if (sender == lock_button_) { 117 } else if (sender == lock_button_) {
123 shell->RecordUserMetricsAction(UMA_TRAY_LOCK_SCREEN); 118 shell->RecordUserMetricsAction(UMA_TRAY_LOCK_SCREEN);
124 #if defined(OS_CHROMEOS)
125 chromeos::DBusThreadManager::Get() 119 chromeos::DBusThreadManager::Get()
126 ->GetSessionManagerClient() 120 ->GetSessionManagerClient()
127 ->RequestLockScreen(); 121 ->RequestLockScreen();
128 #endif
129 } else if (sender == power_button_) { 122 } else if (sender == power_button_) {
130 shell->RecordUserMetricsAction(UMA_TRAY_SHUT_DOWN); 123 shell->RecordUserMetricsAction(UMA_TRAY_SHUT_DOWN);
131 shell->RequestShutdown(); 124 shell->RequestShutdown();
132 } 125 }
133 126
134 owner_->system_tray()->CloseSystemBubble(); 127 owner_->system_tray()->CloseSystemBubble();
135 } 128 }
136 129
137 views::View* TilesDefaultView::GetHelpButtonView() const { 130 views::View* TilesDefaultView::GetHelpButtonView() const {
138 return help_button_; 131 return help_button_;
139 } 132 }
140 133
141 const views::CustomButton* TilesDefaultView::GetShutdownButtonViewForTest() 134 const views::CustomButton* TilesDefaultView::GetShutdownButtonViewForTest()
142 const { 135 const {
143 return power_button_; 136 return power_button_;
144 } 137 }
145 138
146 } // namespace ash 139 } // namespace ash
OLDNEW
« no previous file with comments | « ash/common/system/system_notifier.cc ('k') | ash/common/system/tiles/tray_tiles_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698