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

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

Issue 2381753002: Use mojo SystemTray interfaces for both mash and classic ash (Closed)
Patch Set: review comments 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
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>
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after
178 void OnAcceptMultiprofilesIntro(bool no_show_again) { 178 void OnAcceptMultiprofilesIntro(bool no_show_again) {
179 PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs(); 179 PrefService* prefs = ProfileManager::GetActiveUserProfile()->GetPrefs();
180 prefs->SetBoolean(prefs::kMultiProfileNeverShowIntro, no_show_again); 180 prefs->SetBoolean(prefs::kMultiProfileNeverShowIntro, no_show_again);
181 UserAddingScreen::Get()->Start(); 181 UserAddingScreen::Get()->Start();
182 } 182 }
183 183
184 } // namespace 184 } // namespace
185 185
186 SystemTrayDelegateChromeOS::SystemTrayDelegateChromeOS() 186 SystemTrayDelegateChromeOS::SystemTrayDelegateChromeOS()
187 : user_profile_(NULL), 187 : user_profile_(NULL),
188 clock_type_(base::GetHourClockType()),
189 search_key_mapped_to_(input_method::kSearchKey), 188 search_key_mapped_to_(input_method::kSearchKey),
190 screen_locked_(false), 189 screen_locked_(false),
191 have_session_start_time_(false), 190 have_session_start_time_(false),
192 have_session_length_limit_(false), 191 have_session_length_limit_(false),
193 should_run_bluetooth_discovery_(false), 192 should_run_bluetooth_discovery_(false),
194 session_started_(false), 193 session_started_(false),
195 cast_config_delegate_(nullptr), 194 cast_config_delegate_(nullptr),
196 networking_config_delegate_(new NetworkingConfigDelegateChromeos()), 195 networking_config_delegate_(new NetworkingConfigDelegateChromeos()),
197 volume_control_delegate_(new VolumeController()), 196 volume_control_delegate_(new VolumeController()),
198 vpn_delegate_(new VPNDelegateChromeOS), 197 vpn_delegate_(new VPNDelegateChromeOS),
(...skipping 30 matching lines...) Expand all
229 new ShutdownPolicyHandler(CrosSettings::Get(), this)); 228 new ShutdownPolicyHandler(CrosSettings::Get(), this));
230 } 229 }
231 230
232 void SystemTrayDelegateChromeOS::Initialize() { 231 void SystemTrayDelegateChromeOS::Initialize() {
233 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); 232 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this);
234 233
235 input_method::InputMethodManager::Get()->AddObserver(this); 234 input_method::InputMethodManager::Get()->AddObserver(this);
236 input_method::InputMethodManager::Get()->AddImeMenuObserver(this); 235 input_method::InputMethodManager::Get()->AddImeMenuObserver(this);
237 ui::ime::InputMethodMenuManager::GetInstance()->AddObserver(this); 236 ui::ime::InputMethodMenuManager::GetInstance()->AddObserver(this);
238 237
239 g_browser_process->platform_part()->GetSystemClock()->AddObserver(this);
240
241 OnSystemClockChanged(g_browser_process->platform_part()->GetSystemClock());
242
243 device::BluetoothAdapterFactory::GetAdapter( 238 device::BluetoothAdapterFactory::GetAdapter(
244 base::Bind(&SystemTrayDelegateChromeOS::InitializeOnAdapterReady, 239 base::Bind(&SystemTrayDelegateChromeOS::InitializeOnAdapterReady,
245 weak_ptr_factory_.GetWeakPtr())); 240 weak_ptr_factory_.GetWeakPtr()));
246 241
247 ash::WmShell::Get()->GetSessionStateDelegate()->AddSessionStateObserver(this); 242 ash::WmShell::Get()->GetSessionStateDelegate()->AddSessionStateObserver(this);
248 243
249 if (CrasAudioHandler::IsInitialized()) 244 if (CrasAudioHandler::IsInitialized())
250 CrasAudioHandler::Get()->AddAudioObserver(this); 245 CrasAudioHandler::Get()->AddAudioObserver(this);
251 246
252 BrowserList::AddObserver(this); 247 BrowserList::AddObserver(this);
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 // Unregister PrefChangeRegistrars. 281 // Unregister PrefChangeRegistrars.
287 local_state_registrar_.reset(); 282 local_state_registrar_.reset();
288 user_pref_registrar_.reset(); 283 user_pref_registrar_.reset();
289 284
290 // Unregister content notifications before destroying any components. 285 // Unregister content notifications before destroying any components.
291 registrar_.reset(); 286 registrar_.reset();
292 287
293 // Unregister a11y status subscription. 288 // Unregister a11y status subscription.
294 accessibility_subscription_.reset(); 289 accessibility_subscription_.reset();
295 290
296 g_browser_process->platform_part()->GetSystemClock()->RemoveObserver(this);
297 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this); 291 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this);
298 input_method::InputMethodManager::Get()->RemoveObserver(this); 292 input_method::InputMethodManager::Get()->RemoveObserver(this);
299 ui::ime::InputMethodMenuManager::GetInstance()->RemoveObserver(this); 293 ui::ime::InputMethodMenuManager::GetInstance()->RemoveObserver(this);
300 if (bluetooth_adapter_) 294 if (bluetooth_adapter_)
301 bluetooth_adapter_->RemoveObserver(this); 295 bluetooth_adapter_->RemoveObserver(this);
302 ash::WmShell::Get()->GetSessionStateDelegate()->RemoveSessionStateObserver( 296 ash::WmShell::Get()->GetSessionStateDelegate()->RemoveSessionStateObserver(
303 this); 297 this);
304 298
305 if (CrasAudioHandler::IsInitialized()) 299 if (CrasAudioHandler::IsInitialized())
306 CrasAudioHandler::Get()->RemoveAudioObserver(this); 300 CrasAudioHandler::Get()->RemoveAudioObserver(this);
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
396 390
397 bool SystemTrayDelegateChromeOS::IsUserChild() const { 391 bool SystemTrayDelegateChromeOS::IsUserChild() const {
398 return user_manager::UserManager::Get()->IsLoggedInAsChildUser(); 392 return user_manager::UserManager::Get()->IsLoggedInAsChildUser();
399 } 393 }
400 394
401 void SystemTrayDelegateChromeOS::GetSystemUpdateInfo( 395 void SystemTrayDelegateChromeOS::GetSystemUpdateInfo(
402 ash::UpdateInfo* info) const { 396 ash::UpdateInfo* info) const {
403 GetUpdateInfo(UpgradeDetector::GetInstance(), info); 397 GetUpdateInfo(UpgradeDetector::GetInstance(), info);
404 } 398 }
405 399
406 base::HourClockType SystemTrayDelegateChromeOS::GetHourClockType() const {
407 return clock_type_;
408 }
409
410 void SystemTrayDelegateChromeOS::ShowSettings() { 400 void SystemTrayDelegateChromeOS::ShowSettings() {
411 SystemTrayCommon::ShowSettings(); 401 SystemTrayCommon::ShowSettings();
412 } 402 }
413 403
414 bool SystemTrayDelegateChromeOS::ShouldShowSettings() { 404 bool SystemTrayDelegateChromeOS::ShouldShowSettings() {
415 ash::WmShell* wm_shell = ash::WmShell::Get(); 405 ash::WmShell* wm_shell = ash::WmShell::Get();
416 return ChromeUserManager::Get()->GetCurrentUserFlow()->ShouldShowSettings() && 406 return ChromeUserManager::Get()->GetCurrentUserFlow()->ShouldShowSettings() &&
417 !wm_shell->GetSessionStateDelegate()->IsInSecondaryLoginScreen(); 407 !wm_shell->GetSessionStateDelegate()->IsInSecondaryLoginScreen();
418 } 408 }
419 409
420 void SystemTrayDelegateChromeOS::ShowDateSettings() {
421 SystemTrayCommon::ShowDateSettings();
422 }
423
424 void SystemTrayDelegateChromeOS::ShowSetTimeDialog() { 410 void SystemTrayDelegateChromeOS::ShowSetTimeDialog() {
425 // TODO(mash): Refactor out GetNativeWindow and move to SystemTrayCommon. 411 // TODO(mash): Refactor out GetNativeWindow and move to SystemTrayCommon.
426 SetTimeDialog::ShowDialog(GetNativeWindow()); 412 SetTimeDialog::ShowDialog(GetNativeWindow());
427 } 413 }
428 414
429 void SystemTrayDelegateChromeOS::ShowNetworkSettingsForGuid( 415 void SystemTrayDelegateChromeOS::ShowNetworkSettingsForGuid(
430 const std::string& guid) { 416 const std::string& guid) {
431 // TODO(mash): Refactor out SessionStateDelegate and move to SystemTrayCommon. 417 // TODO(mash): Refactor out SessionStateDelegate and move to SystemTrayCommon.
432 ash::WmShell* wm_shell = ash::WmShell::Get(); 418 ash::WmShell* wm_shell = ash::WmShell::Get();
433 if (LoginState::Get()->IsUserLoggedIn() && 419 if (LoginState::Get()->IsUserLoggedIn() &&
(...skipping 473 matching lines...) Expand 10 before | Expand all | Expand 10 after
907 } 893 }
908 894
909 bool SystemTrayDelegateChromeOS::UnsetProfile(Profile* profile) { 895 bool SystemTrayDelegateChromeOS::UnsetProfile(Profile* profile) {
910 if (profile != user_profile_) 896 if (profile != user_profile_)
911 return false; 897 return false;
912 user_pref_registrar_.reset(); 898 user_pref_registrar_.reset();
913 user_profile_ = NULL; 899 user_profile_ = NULL;
914 return true; 900 return true;
915 } 901 }
916 902
917 bool SystemTrayDelegateChromeOS::GetShouldUse24HourClockForTesting() const {
918 return g_browser_process->platform_part()
919 ->GetSystemClock()
920 ->ShouldUse24HourClock();
921 }
922
923 void SystemTrayDelegateChromeOS::OnSystemClockChanged(
924 system::SystemClock* system_clock) {
925 const bool use_24_hour_clock = system_clock->ShouldUse24HourClock();
926 clock_type_ = use_24_hour_clock ? base::k24HourClock : base::k12HourClock;
927 GetSystemTrayNotifier()->NotifyDateFormatChanged();
928 }
929
930 void SystemTrayDelegateChromeOS::UpdateShowLogoutButtonInTray() { 903 void SystemTrayDelegateChromeOS::UpdateShowLogoutButtonInTray() {
931 GetSystemTrayNotifier()->NotifyShowLoginButtonChanged( 904 GetSystemTrayNotifier()->NotifyShowLoginButtonChanged(
932 user_pref_registrar_->prefs()->GetBoolean( 905 user_pref_registrar_->prefs()->GetBoolean(
933 prefs::kShowLogoutButtonInTray)); 906 prefs::kShowLogoutButtonInTray));
934 } 907 }
935 908
936 void SystemTrayDelegateChromeOS::UpdateLogoutDialogDuration() { 909 void SystemTrayDelegateChromeOS::UpdateLogoutDialogDuration() {
937 const int duration_ms = 910 const int duration_ms =
938 user_pref_registrar_->prefs()->GetInteger(prefs::kLogoutDialogDurationMs); 911 user_pref_registrar_->prefs()->GetInteger(prefs::kLogoutDialogDurationMs);
939 GetSystemTrayNotifier()->NotifyLogoutDialogDurationChanged( 912 GetSystemTrayNotifier()->NotifyLogoutDialogDurationChanged(
(...skipping 352 matching lines...) Expand 10 before | Expand all | Expand 10 after
1292 LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while " 1265 LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while "
1293 << "ENABLE_SUPERVISED_USERS undefined."; 1266 << "ENABLE_SUPERVISED_USERS undefined.";
1294 return base::string16(); 1267 return base::string16();
1295 } 1268 }
1296 1269
1297 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { 1270 ash::SystemTrayDelegate* CreateSystemTrayDelegate() {
1298 return new SystemTrayDelegateChromeOS(); 1271 return new SystemTrayDelegateChromeOS();
1299 } 1272 }
1300 1273
1301 } // namespace chromeos 1274 } // namespace chromeos
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698