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

Side by Side Diff: chrome/browser/ui/ash/system_tray_delegate_chromeos.cc

Issue 2427823002: cros: Move system tray delegate widget container code to SystemTrayClient (Closed)
Patch Set: cleanup Created 4 years, 2 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
« no previous file with comments | « chrome/browser/ui/ash/system_tray_delegate_chromeos.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 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 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 "chrome/browser/ui/ash/system_tray_delegate_chromeos.h" 5 #include "chrome/browser/ui/ash/system_tray_delegate_chromeos.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <set> 10 #include <set>
11 #include <string> 11 #include <string>
12 #include <utility> 12 #include <utility>
13 #include <vector> 13 #include <vector>
14 14
15 #include "ash/common/login_status.h" 15 #include "ash/common/login_status.h"
16 #include "ash/common/session/session_state_delegate.h" 16 #include "ash/common/session/session_state_delegate.h"
17 #include "ash/common/session/session_state_observer.h" 17 #include "ash/common/session/session_state_observer.h"
18 #include "ash/common/shell_delegate.h" 18 #include "ash/common/shell_delegate.h"
19 #include "ash/common/shell_window_ids.h"
20 #include "ash/common/system/chromeos/bluetooth/bluetooth_observer.h" 19 #include "ash/common/system/chromeos/bluetooth/bluetooth_observer.h"
21 #include "ash/common/system/chromeos/power/power_status.h" 20 #include "ash/common/system/chromeos/power/power_status.h"
22 #include "ash/common/system/chromeos/session/logout_button_observer.h" 21 #include "ash/common/system/chromeos/session/logout_button_observer.h"
23 #include "ash/common/system/chromeos/shutdown_policy_observer.h" 22 #include "ash/common/system/chromeos/shutdown_policy_observer.h"
24 #include "ash/common/system/date/clock_observer.h" 23 #include "ash/common/system/date/clock_observer.h"
25 #include "ash/common/system/ime/ime_observer.h" 24 #include "ash/common/system/ime/ime_observer.h"
26 #include "ash/common/system/tray/system_tray.h" 25 #include "ash/common/system/tray/system_tray.h"
27 #include "ash/common/system/tray/system_tray_delegate.h" 26 #include "ash/common/system/tray/system_tray_delegate.h"
28 #include "ash/common/system/tray/system_tray_notifier.h" 27 #include "ash/common/system/tray/system_tray_notifier.h"
29 #include "ash/common/system/tray_accessibility.h" 28 #include "ash/common/system/tray_accessibility.h"
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 void ExtractIMEInfo(const input_method::InputMethodDescriptor& ime, 129 void ExtractIMEInfo(const input_method::InputMethodDescriptor& ime,
131 const input_method::InputMethodUtil& util, 130 const input_method::InputMethodUtil& util,
132 ash::IMEInfo* info) { 131 ash::IMEInfo* info) {
133 info->id = ime.id(); 132 info->id = ime.id();
134 info->name = util.GetInputMethodLongName(ime); 133 info->name = util.GetInputMethodLongName(ime);
135 info->medium_name = util.GetInputMethodMediumName(ime); 134 info->medium_name = util.GetInputMethodMediumName(ime);
136 info->short_name = util.GetInputMethodShortName(ime); 135 info->short_name = util.GetInputMethodShortName(ime);
137 info->third_party = extension_ime_util::IsExtensionIME(ime.id()); 136 info->third_party = extension_ime_util::IsExtensionIME(ime.id());
138 } 137 }
139 138
140 gfx::NativeWindow GetNativeWindowByStatus(ash::LoginStatus login_status,
141 bool session_started) {
142 ash::WmShell* wm_shell = ash::WmShell::Get();
143 const bool is_in_secondary_login_screen =
144 wm_shell->GetSessionStateDelegate()->IsInSecondaryLoginScreen();
145
146 int container_id =
147 (!session_started || login_status == ash::LoginStatus::NOT_LOGGED_IN ||
148 login_status == ash::LoginStatus::LOCKED || is_in_secondary_login_screen)
149 ? ash::kShellWindowId_LockSystemModalContainer
150 : ash::kShellWindowId_SystemModalContainer;
151 return ash::Shell::GetContainer(ash::Shell::GetPrimaryRootWindow(),
152 container_id);
153 }
154
155 void BluetoothSetDiscoveringError() { 139 void BluetoothSetDiscoveringError() {
156 LOG(ERROR) << "BluetoothSetDiscovering failed."; 140 LOG(ERROR) << "BluetoothSetDiscovering failed.";
157 } 141 }
158 142
159 void BluetoothDeviceConnectError( 143 void BluetoothDeviceConnectError(
160 device::BluetoothDevice::ConnectErrorCode error_code) { 144 device::BluetoothDevice::ConnectErrorCode error_code) {
161 } 145 }
162 146
163 std::unique_ptr<ash::CastConfigDelegate> CreateCastConfigDelegate() { 147 std::unique_ptr<ash::CastConfigDelegate> CreateCastConfigDelegate() {
164 if (CastConfigDelegateMediaRouter::IsEnabled()) 148 if (CastConfigDelegateMediaRouter::IsEnabled())
(...skipping 10 matching lines...) Expand all
175 PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs(); 159 PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs();
176 prefs->SetBoolean(prefs::kMultiProfileNeverShowIntro, no_show_again); 160 prefs->SetBoolean(prefs::kMultiProfileNeverShowIntro, no_show_again);
177 UserAddingScreen::Get()->Start(); 161 UserAddingScreen::Get()->Start();
178 } 162 }
179 163
180 } // namespace 164 } // namespace
181 165
182 SystemTrayDelegateChromeOS::SystemTrayDelegateChromeOS() 166 SystemTrayDelegateChromeOS::SystemTrayDelegateChromeOS()
183 : user_profile_(NULL), 167 : user_profile_(NULL),
184 search_key_mapped_to_(input_method::kSearchKey), 168 search_key_mapped_to_(input_method::kSearchKey),
185 screen_locked_(false),
186 have_session_start_time_(false), 169 have_session_start_time_(false),
187 have_session_length_limit_(false), 170 have_session_length_limit_(false),
188 should_run_bluetooth_discovery_(false), 171 should_run_bluetooth_discovery_(false),
189 session_started_(false), 172 session_started_(false),
190 cast_config_delegate_(nullptr), 173 cast_config_delegate_(nullptr),
191 networking_config_delegate_(new NetworkingConfigDelegateChromeos()), 174 networking_config_delegate_(new NetworkingConfigDelegateChromeos()),
192 volume_control_delegate_(new VolumeController()), 175 volume_control_delegate_(new VolumeController()),
193 vpn_delegate_(new VPNDelegateChromeOS), 176 vpn_delegate_(new VPNDelegateChromeOS),
194 weak_ptr_factory_(this) { 177 weak_ptr_factory_(this) {
195 // Register notifications on construction so that events such as 178 // Register notifications on construction so that events such as
(...skipping 107 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 286 g_browser_process->platform_part()->browser_policy_connector_chromeos();
304 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = 287 policy::DeviceCloudPolicyManagerChromeOS* policy_manager =
305 connector->GetDeviceCloudPolicyManager(); 288 connector->GetDeviceCloudPolicyManager();
306 if (policy_manager) 289 if (policy_manager)
307 policy_manager->core()->store()->RemoveObserver(this); 290 policy_manager->core()->store()->RemoveObserver(this);
308 291
309 user_manager::UserManager::Get()->RemoveSessionStateObserver(this); 292 user_manager::UserManager::Get()->RemoveSessionStateObserver(this);
310 } 293 }
311 294
312 ash::LoginStatus SystemTrayDelegateChromeOS::GetUserLoginStatus() const { 295 ash::LoginStatus SystemTrayDelegateChromeOS::GetUserLoginStatus() const {
313 if (!LoginState::Get()->IsUserLoggedIn()) 296 return SystemTrayClient::GetUserLoginStatus();
314 return ash::LoginStatus::NOT_LOGGED_IN;
315
316 if (screen_locked_)
317 return ash::LoginStatus::LOCKED;
318
319 LoginState::LoggedInUserType user_type =
320 LoginState::Get()->GetLoggedInUserType();
321 switch (user_type) {
322 case LoginState::LOGGED_IN_USER_NONE:
323 return ash::LoginStatus::NOT_LOGGED_IN;
324 case LoginState::LOGGED_IN_USER_REGULAR:
325 return ash::LoginStatus::USER;
326 case LoginState::LOGGED_IN_USER_OWNER:
327 return ash::LoginStatus::OWNER;
328 case LoginState::LOGGED_IN_USER_GUEST:
329 return ash::LoginStatus::GUEST;
330 case LoginState::LOGGED_IN_USER_PUBLIC_ACCOUNT:
331 return ash::LoginStatus::PUBLIC;
332 case LoginState::LOGGED_IN_USER_SUPERVISED:
333 return ash::LoginStatus::SUPERVISED;
334 case LoginState::LOGGED_IN_USER_KIOSK_APP:
335 return ash::LoginStatus::KIOSK_APP;
336 }
337 NOTREACHED();
338 return ash::LoginStatus::NOT_LOGGED_IN;
339 } 297 }
340 298
341 std::string SystemTrayDelegateChromeOS::GetEnterpriseDomain() const { 299 std::string SystemTrayDelegateChromeOS::GetEnterpriseDomain() const {
342 return enterprise_domain_; 300 return enterprise_domain_;
343 } 301 }
344 302
345 base::string16 SystemTrayDelegateChromeOS::GetEnterpriseMessage() const { 303 base::string16 SystemTrayDelegateChromeOS::GetEnterpriseMessage() const {
346 if (GetEnterpriseDomain().empty()) 304 if (GetEnterpriseDomain().empty())
347 return base::string16(); 305 return base::string16();
348 return l10n_util::GetStringFUTF16(IDS_DEVICE_OWNED_BY_NOTICE, 306 return l10n_util::GetStringFUTF16(IDS_DEVICE_OWNED_BY_NOTICE,
(...skipping 535 matching lines...) Expand 10 before | Expand all | Expand 10 after
884 user_profile_)->app_windows().empty()) { 842 user_profile_)->app_windows().empty()) {
885 // The current user has at least one open app window. 843 // The current user has at least one open app window.
886 return; 844 return;
887 } 845 }
888 846
889 GetSystemTrayNotifier()->NotifyLastWindowClosed(); 847 GetSystemTrayNotifier()->NotifyLastWindowClosed();
890 } 848 }
891 849
892 // Overridden from SessionManagerClient::Observer. 850 // Overridden from SessionManagerClient::Observer.
893 void SystemTrayDelegateChromeOS::ScreenIsLocked() { 851 void SystemTrayDelegateChromeOS::ScreenIsLocked() {
894 screen_locked_ = true;
895 ash::WmShell::Get()->UpdateAfterLoginStatusChange(GetUserLoginStatus()); 852 ash::WmShell::Get()->UpdateAfterLoginStatusChange(GetUserLoginStatus());
896 } 853 }
897 854
898 void SystemTrayDelegateChromeOS::ScreenIsUnlocked() { 855 void SystemTrayDelegateChromeOS::ScreenIsUnlocked() {
899 screen_locked_ = false;
900 ash::WmShell::Get()->UpdateAfterLoginStatusChange(GetUserLoginStatus()); 856 ash::WmShell::Get()->UpdateAfterLoginStatusChange(GetUserLoginStatus());
901 } 857 }
902 858
903 gfx::NativeWindow SystemTrayDelegateChromeOS::GetNativeWindow() const { 859 gfx::NativeWindow SystemTrayDelegateChromeOS::GetNativeWindow() const {
904 bool session_started = ash::WmShell::Get() 860 int container_id = SystemTrayClient::GetDialogParentContainerId();
905 ->GetSessionStateDelegate() 861 return ash::Shell::GetContainer(ash::Shell::GetPrimaryRootWindow(),
906 ->IsActiveUserSessionStarted(); 862 container_id);
907 return GetNativeWindowByStatus(GetUserLoginStatus(), session_started);
908 } 863 }
909 864
910 // content::NotificationObserver implementation. 865 // content::NotificationObserver implementation.
911 void SystemTrayDelegateChromeOS::Observe( 866 void SystemTrayDelegateChromeOS::Observe(
912 int type, 867 int type,
913 const content::NotificationSource& source, 868 const content::NotificationSource& source,
914 const content::NotificationDetails& details) { 869 const content::NotificationDetails& details) {
915 switch (type) { 870 switch (type) {
916 case chrome::NOTIFICATION_UPGRADE_RECOMMENDED: { 871 case chrome::NOTIFICATION_UPGRADE_RECOMMENDED: {
917 ash::UpdateInfo info; 872 ash::UpdateInfo info;
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
1168 LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while " 1123 LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while "
1169 << "ENABLE_SUPERVISED_USERS undefined."; 1124 << "ENABLE_SUPERVISED_USERS undefined.";
1170 return base::string16(); 1125 return base::string16();
1171 } 1126 }
1172 1127
1173 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { 1128 ash::SystemTrayDelegate* CreateSystemTrayDelegate() {
1174 return new SystemTrayDelegateChromeOS(); 1129 return new SystemTrayDelegateChromeOS();
1175 } 1130 }
1176 1131
1177 } // namespace chromeos 1132 } // namespace chromeos
OLDNEW
« no previous file with comments | « chrome/browser/ui/ash/system_tray_delegate_chromeos.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698