| OLD | NEW |
| 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 <algorithm> | 7 #include <algorithm> |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 #include <vector> | 10 #include <vector> |
| (...skipping 852 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 863 return ash::Shell::GetInstance()->system_tray_notifier(); | 863 return ash::Shell::GetInstance()->system_tray_notifier(); |
| 864 } | 864 } |
| 865 | 865 |
| 866 void SystemTrayDelegateChromeOS::SetProfile(Profile* profile) { | 866 void SystemTrayDelegateChromeOS::SetProfile(Profile* profile) { |
| 867 // Stop observing the AppWindowRegistry of the current |user_profile_|. | 867 // Stop observing the AppWindowRegistry of the current |user_profile_|. |
| 868 StopObservingAppWindowRegistry(); | 868 StopObservingAppWindowRegistry(); |
| 869 | 869 |
| 870 user_profile_ = profile; | 870 user_profile_ = profile; |
| 871 | 871 |
| 872 // Start observing the AppWindowRegistry of the newly set |user_profile_|. | 872 // Start observing the AppWindowRegistry of the newly set |user_profile_|. |
| 873 apps::AppWindowRegistry::Get(user_profile_)->AddObserver(this); | 873 extensions::AppWindowRegistry::Get(user_profile_)->AddObserver(this); |
| 874 | 874 |
| 875 PrefService* prefs = profile->GetPrefs(); | 875 PrefService* prefs = profile->GetPrefs(); |
| 876 user_pref_registrar_.reset(new PrefChangeRegistrar); | 876 user_pref_registrar_.reset(new PrefChangeRegistrar); |
| 877 user_pref_registrar_->Init(prefs); | 877 user_pref_registrar_->Init(prefs); |
| 878 user_pref_registrar_->Add( | 878 user_pref_registrar_->Add( |
| 879 prefs::kUse24HourClock, | 879 prefs::kUse24HourClock, |
| 880 base::Bind(&SystemTrayDelegateChromeOS::UpdateClockType, | 880 base::Bind(&SystemTrayDelegateChromeOS::UpdateClockType, |
| 881 base::Unretained(this))); | 881 base::Unretained(this))); |
| 882 user_pref_registrar_->Add( | 882 user_pref_registrar_->Add( |
| 883 prefs::kLanguageRemapSearchKeyTo, | 883 prefs::kLanguageRemapSearchKeyTo, |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1005 have_session_length_limit_ = false; | 1005 have_session_length_limit_ = false; |
| 1006 session_length_limit_ = base::TimeDelta(); | 1006 session_length_limit_ = base::TimeDelta(); |
| 1007 } | 1007 } |
| 1008 GetSystemTrayNotifier()->NotifySessionLengthLimitChanged(); | 1008 GetSystemTrayNotifier()->NotifySessionLengthLimitChanged(); |
| 1009 } | 1009 } |
| 1010 | 1010 |
| 1011 void SystemTrayDelegateChromeOS::StopObservingAppWindowRegistry() { | 1011 void SystemTrayDelegateChromeOS::StopObservingAppWindowRegistry() { |
| 1012 if (!user_profile_) | 1012 if (!user_profile_) |
| 1013 return; | 1013 return; |
| 1014 | 1014 |
| 1015 apps::AppWindowRegistry* registry = | 1015 extensions::AppWindowRegistry* registry = |
| 1016 apps::AppWindowRegistry::Factory::GetForBrowserContext(user_profile_, | 1016 extensions::AppWindowRegistry::Factory::GetForBrowserContext( |
| 1017 false); | 1017 user_profile_, false); |
| 1018 if (registry) | 1018 if (registry) |
| 1019 registry->RemoveObserver(this); | 1019 registry->RemoveObserver(this); |
| 1020 } | 1020 } |
| 1021 | 1021 |
| 1022 void SystemTrayDelegateChromeOS::NotifyIfLastWindowClosed() { | 1022 void SystemTrayDelegateChromeOS::NotifyIfLastWindowClosed() { |
| 1023 if (!user_profile_) | 1023 if (!user_profile_) |
| 1024 return; | 1024 return; |
| 1025 | 1025 |
| 1026 BrowserList* browser_list = | 1026 BrowserList* browser_list = |
| 1027 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); | 1027 BrowserList::GetInstance(chrome::HOST_DESKTOP_TYPE_ASH); |
| 1028 for (BrowserList::const_iterator it = browser_list->begin(); | 1028 for (BrowserList::const_iterator it = browser_list->begin(); |
| 1029 it != browser_list->end(); | 1029 it != browser_list->end(); |
| 1030 ++it) { | 1030 ++it) { |
| 1031 if ((*it)->profile()->IsSameProfile(user_profile_)) { | 1031 if ((*it)->profile()->IsSameProfile(user_profile_)) { |
| 1032 // The current user has at least one open browser window. | 1032 // The current user has at least one open browser window. |
| 1033 return; | 1033 return; |
| 1034 } | 1034 } |
| 1035 } | 1035 } |
| 1036 | 1036 |
| 1037 if (!apps::AppWindowRegistry::Get(user_profile_)->app_windows().empty()) { | 1037 if (!extensions::AppWindowRegistry::Get( |
| 1038 user_profile_)->app_windows().empty()) { |
| 1038 // The current user has at least one open app window. | 1039 // The current user has at least one open app window. |
| 1039 return; | 1040 return; |
| 1040 } | 1041 } |
| 1041 | 1042 |
| 1042 GetSystemTrayNotifier()->NotifyLastWindowClosed(); | 1043 GetSystemTrayNotifier()->NotifyLastWindowClosed(); |
| 1043 } | 1044 } |
| 1044 | 1045 |
| 1045 // LoginState::Observer overrides. | 1046 // LoginState::Observer overrides. |
| 1046 void SystemTrayDelegateChromeOS::LoggedInStateChanged() { | 1047 void SystemTrayDelegateChromeOS::LoggedInStateChanged() { |
| 1047 // It apparently sometimes takes a while after login before the current user | 1048 // It apparently sometimes takes a while after login before the current user |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1273 void SystemTrayDelegateChromeOS::UserAddedToSession( | 1274 void SystemTrayDelegateChromeOS::UserAddedToSession( |
| 1274 const std::string& user_id) { | 1275 const std::string& user_id) { |
| 1275 GetSystemTrayNotifier()->NotifyUserAddedToSession(); | 1276 GetSystemTrayNotifier()->NotifyUserAddedToSession(); |
| 1276 } | 1277 } |
| 1277 | 1278 |
| 1278 // Overridden from chrome::BrowserListObserver. | 1279 // Overridden from chrome::BrowserListObserver. |
| 1279 void SystemTrayDelegateChromeOS::OnBrowserRemoved(Browser* browser) { | 1280 void SystemTrayDelegateChromeOS::OnBrowserRemoved(Browser* browser) { |
| 1280 NotifyIfLastWindowClosed(); | 1281 NotifyIfLastWindowClosed(); |
| 1281 } | 1282 } |
| 1282 | 1283 |
| 1283 // Overridden from apps::AppWindowRegistry::Observer. | 1284 // Overridden from extensions::AppWindowRegistry::Observer. |
| 1284 void SystemTrayDelegateChromeOS::OnAppWindowRemoved( | 1285 void SystemTrayDelegateChromeOS::OnAppWindowRemoved( |
| 1285 apps::AppWindow* app_window) { | 1286 extensions::AppWindow* app_window) { |
| 1286 NotifyIfLastWindowClosed(); | 1287 NotifyIfLastWindowClosed(); |
| 1287 } | 1288 } |
| 1288 | 1289 |
| 1289 void SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged( | 1290 void SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged( |
| 1290 const AccessibilityStatusEventDetails& details) { | 1291 const AccessibilityStatusEventDetails& details) { |
| 1291 if (details.notification_type == ACCESSIBILITY_MANAGER_SHUTDOWN) | 1292 if (details.notification_type == ACCESSIBILITY_MANAGER_SHUTDOWN) |
| 1292 accessibility_subscription_.reset(); | 1293 accessibility_subscription_.reset(); |
| 1293 else | 1294 else |
| 1294 OnAccessibilityModeChanged(details.notify); | 1295 OnAccessibilityModeChanged(details.notify); |
| 1295 } | 1296 } |
| 1296 | 1297 |
| 1297 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { | 1298 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { |
| 1298 return new SystemTrayDelegateChromeOS(); | 1299 return new SystemTrayDelegateChromeOS(); |
| 1299 } | 1300 } |
| 1300 | 1301 |
| 1301 } // namespace chromeos | 1302 } // namespace chromeos |
| OLD | NEW |