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

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

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

Powered by Google App Engine
This is Rietveld 408576698