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

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

Issue 2797743002: ash: Merge LoginStatus update code path (Closed)
Patch Set: for #2 comments Created 3 years, 8 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 <memory> 10 #include <memory>
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 #include "chrome/browser/ui/browser_list.h" 54 #include "chrome/browser/ui/browser_list.h"
55 #include "chrome/browser/ui/chrome_pages.h" 55 #include "chrome/browser/ui/chrome_pages.h"
56 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h" 56 #include "chrome/browser/ui/scoped_tabbed_browser_displayer.h"
57 #include "chrome/browser/ui/singleton_tabs.h" 57 #include "chrome/browser/ui/singleton_tabs.h"
58 #include "chrome/common/chrome_switches.h" 58 #include "chrome/common/chrome_switches.h"
59 #include "chrome/common/features.h" 59 #include "chrome/common/features.h"
60 #include "chrome/common/pref_names.h" 60 #include "chrome/common/pref_names.h"
61 #include "chrome/common/url_constants.h" 61 #include "chrome/common/url_constants.h"
62 #include "chrome/grit/generated_resources.h" 62 #include "chrome/grit/generated_resources.h"
63 #include "chrome/grit/locale_settings.h" 63 #include "chrome/grit/locale_settings.h"
64 #include "chromeos/dbus/dbus_thread_manager.h"
65 #include "chromeos/dbus/session_manager_client.h"
66 #include "chromeos/login/login_state.h" 64 #include "chromeos/login/login_state.h"
67 #include "chromeos/network/portal_detector/network_portal_detector.h" 65 #include "chromeos/network/portal_detector/network_portal_detector.h"
68 #include "components/google/core/browser/google_util.h" 66 #include "components/google/core/browser/google_util.h"
69 #include "components/policy/core/common/cloud/cloud_policy_store.h" 67 #include "components/policy/core/common/cloud/cloud_policy_store.h"
70 #include "components/prefs/pref_service.h" 68 #include "components/prefs/pref_service.h"
71 #include "components/session_manager/core/session_manager.h" 69 #include "components/session_manager/core/session_manager.h"
72 #include "components/user_manager/user.h" 70 #include "components/user_manager/user.h"
73 #include "components/user_manager/user_manager.h" 71 #include "components/user_manager/user_manager.h"
74 #include "components/user_manager/user_type.h" 72 #include "components/user_manager/user_type.h"
75 #include "content/public/browser/notification_observer.h" 73 #include "content/public/browser/notification_observer.h"
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 content::NotificationService::AllSources()); 133 content::NotificationService::AllSources());
136 registrar_->Add(this, 134 registrar_->Add(this,
137 chrome::NOTIFICATION_PROFILE_DESTROYED, 135 chrome::NOTIFICATION_PROFILE_DESTROYED,
138 content::NotificationService::AllSources()); 136 content::NotificationService::AllSources());
139 137
140 AccessibilityManager* accessibility_manager = AccessibilityManager::Get(); 138 AccessibilityManager* accessibility_manager = AccessibilityManager::Get();
141 CHECK(accessibility_manager); 139 CHECK(accessibility_manager);
142 accessibility_subscription_ = accessibility_manager->RegisterCallback( 140 accessibility_subscription_ = accessibility_manager->RegisterCallback(
143 base::Bind(&SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged, 141 base::Bind(&SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged,
144 base::Unretained(this))); 142 base::Unretained(this)));
145
146 user_manager::UserManager::Get()->AddSessionStateObserver(this);
147 } 143 }
148 144
149 void SystemTrayDelegateChromeOS::Initialize() { 145 void SystemTrayDelegateChromeOS::Initialize() {
150 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this);
151
152 input_method::InputMethodManager::Get()->AddObserver(this); 146 input_method::InputMethodManager::Get()->AddObserver(this);
153 input_method::InputMethodManager::Get()->AddImeMenuObserver(this); 147 input_method::InputMethodManager::Get()->AddImeMenuObserver(this);
154 ui::ime::InputMethodMenuManager::GetInstance()->AddObserver(this); 148 ui::ime::InputMethodMenuManager::GetInstance()->AddObserver(this);
155 149
156 BrowserList::AddObserver(this); 150 BrowserList::AddObserver(this);
157 151
158 local_state_registrar_.reset(new PrefChangeRegistrar); 152 local_state_registrar_.reset(new PrefChangeRegistrar);
159 local_state_registrar_->Init(g_browser_process->local_state()); 153 local_state_registrar_->Init(g_browser_process->local_state());
160 154
161 UpdateSessionStartTime(); 155 UpdateSessionStartTime();
(...skipping 21 matching lines...) Expand all
183 // Unregister PrefChangeRegistrars. 177 // Unregister PrefChangeRegistrars.
184 local_state_registrar_.reset(); 178 local_state_registrar_.reset();
185 user_pref_registrar_.reset(); 179 user_pref_registrar_.reset();
186 180
187 // Unregister content notifications before destroying any components. 181 // Unregister content notifications before destroying any components.
188 registrar_.reset(); 182 registrar_.reset();
189 183
190 // Unregister a11y status subscription. 184 // Unregister a11y status subscription.
191 accessibility_subscription_.reset(); 185 accessibility_subscription_.reset();
192 186
193 DBusThreadManager::Get()->GetSessionManagerClient()->RemoveObserver(this);
194 input_method::InputMethodManager::Get()->RemoveObserver(this); 187 input_method::InputMethodManager::Get()->RemoveObserver(this);
195 ui::ime::InputMethodMenuManager::GetInstance()->RemoveObserver(this); 188 ui::ime::InputMethodMenuManager::GetInstance()->RemoveObserver(this);
196 189
197 BrowserList::RemoveObserver(this); 190 BrowserList::RemoveObserver(this);
198 StopObservingAppWindowRegistry(); 191 StopObservingAppWindowRegistry();
199 StopObservingCustodianInfoChanges(); 192 StopObservingCustodianInfoChanges();
200 193
201 policy::BrowserPolicyConnectorChromeOS* connector = 194 policy::BrowserPolicyConnectorChromeOS* connector =
202 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 195 g_browser_process->platform_part()->browser_policy_connector_chromeos();
203 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = 196 policy::DeviceCloudPolicyManagerChromeOS* policy_manager =
204 connector->GetDeviceCloudPolicyManager(); 197 connector->GetDeviceCloudPolicyManager();
205 if (policy_manager) 198 if (policy_manager)
206 policy_manager->core()->store()->RemoveObserver(this); 199 policy_manager->core()->store()->RemoveObserver(this);
207
208 user_manager::UserManager::Get()->RemoveSessionStateObserver(this);
209 } 200 }
210 201
211 ash::LoginStatus SystemTrayDelegateChromeOS::GetUserLoginStatus() const { 202 ash::LoginStatus SystemTrayDelegateChromeOS::GetUserLoginStatus() const {
212 return SystemTrayClient::GetUserLoginStatus(); 203 return SystemTrayClient::GetUserLoginStatus();
213 } 204 }
214 205
215 std::string SystemTrayDelegateChromeOS::GetEnterpriseDomain() const { 206 std::string SystemTrayDelegateChromeOS::GetEnterpriseDomain() const {
216 return enterprise_domain_; 207 return enterprise_domain_;
217 } 208 }
218 209
(...skipping 209 matching lines...) Expand 10 before | Expand all | Expand 10 after
428 void SystemTrayDelegateChromeOS::RemoveCustodianInfoTrayObserver( 419 void SystemTrayDelegateChromeOS::RemoveCustodianInfoTrayObserver(
429 ash::CustodianInfoTrayObserver* observer) { 420 ash::CustodianInfoTrayObserver* observer) {
430 custodian_info_changed_observers_.RemoveObserver(observer); 421 custodian_info_changed_observers_.RemoveObserver(observer);
431 } 422 }
432 423
433 std::unique_ptr<ash::SystemTrayItem> 424 std::unique_ptr<ash::SystemTrayItem>
434 SystemTrayDelegateChromeOS::CreateRotationLockTrayItem(ash::SystemTray* tray) { 425 SystemTrayDelegateChromeOS::CreateRotationLockTrayItem(ash::SystemTray* tray) {
435 return base::MakeUnique<ash::TrayRotationLock>(tray); 426 return base::MakeUnique<ash::TrayRotationLock>(tray);
436 } 427 }
437 428
438 void SystemTrayDelegateChromeOS::UserChangedChildStatus(
439 user_manager::User* user) {
440 Profile* user_profile = ProfileHelper::Get()->GetProfileByUser(user);
441
442 // Returned user_profile might be NULL on restoring Users on browser start.
443 // At some point profile is not yet fully initiated.
444 if (session_started_ && user_profile && user_profile_ == user_profile)
445 ash::Shell::Get()->UpdateAfterLoginStatusChange(GetUserLoginStatus());
446 }
447
448 ash::SystemTrayNotifier* SystemTrayDelegateChromeOS::GetSystemTrayNotifier() { 429 ash::SystemTrayNotifier* SystemTrayDelegateChromeOS::GetSystemTrayNotifier() {
449 return ash::Shell::Get()->system_tray_notifier(); 430 return ash::Shell::Get()->system_tray_notifier();
450 } 431 }
451 432
452 void SystemTrayDelegateChromeOS::SetProfile(Profile* profile) { 433 void SystemTrayDelegateChromeOS::SetProfile(Profile* profile) {
453 // Stop observing the AppWindowRegistry of the current |user_profile_|. 434 // Stop observing the AppWindowRegistry of the current |user_profile_|.
454 StopObservingAppWindowRegistry(); 435 StopObservingAppWindowRegistry();
455 436
456 // Stop observing custodian info changes of the current |user_profile_|. 437 // Stop observing custodian info changes of the current |user_profile_|.
457 StopObservingCustodianInfoChanges(); 438 StopObservingCustodianInfoChanges();
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 571
591 if (!extensions::AppWindowRegistry::Get( 572 if (!extensions::AppWindowRegistry::Get(
592 user_profile_)->app_windows().empty()) { 573 user_profile_)->app_windows().empty()) {
593 // The current user has at least one open app window. 574 // The current user has at least one open app window.
594 return; 575 return;
595 } 576 }
596 577
597 GetSystemTrayNotifier()->NotifyLastWindowClosed(); 578 GetSystemTrayNotifier()->NotifyLastWindowClosed();
598 } 579 }
599 580
600 // Overridden from SessionManagerClient::Observer.
601 void SystemTrayDelegateChromeOS::ScreenIsLocked() {
602 ash::Shell::Get()->UpdateAfterLoginStatusChange(GetUserLoginStatus());
603 }
604
605 void SystemTrayDelegateChromeOS::ScreenIsUnlocked() {
606 ash::Shell::Get()->UpdateAfterLoginStatusChange(GetUserLoginStatus());
607 }
608
609 // content::NotificationObserver implementation. 581 // content::NotificationObserver implementation.
610 void SystemTrayDelegateChromeOS::Observe( 582 void SystemTrayDelegateChromeOS::Observe(
611 int type, 583 int type,
612 const content::NotificationSource& source, 584 const content::NotificationSource& source,
613 const content::NotificationDetails& details) { 585 const content::NotificationDetails& details) {
614 switch (type) { 586 switch (type) {
615 case chrome::NOTIFICATION_PROFILE_CREATED: { 587 case chrome::NOTIFICATION_PROFILE_CREATED: {
616 SetProfile(content::Source<Profile>(source).ptr()); 588 SetProfile(content::Source<Profile>(source).ptr());
617 registrar_->Remove(this, 589 registrar_->Remove(this,
618 chrome::NOTIFICATION_PROFILE_CREATED, 590 chrome::NOTIFICATION_PROFILE_CREATED,
619 content::NotificationService::AllSources()); 591 content::NotificationService::AllSources());
620 break; 592 break;
621 } 593 }
622 case chrome::NOTIFICATION_PROFILE_DESTROYED: { 594 case chrome::NOTIFICATION_PROFILE_DESTROYED: {
623 if (UnsetProfile(content::Source<Profile>(source).ptr())) { 595 if (UnsetProfile(content::Source<Profile>(source).ptr())) {
624 registrar_->Remove(this, 596 registrar_->Remove(this,
625 chrome::NOTIFICATION_PROFILE_DESTROYED, 597 chrome::NOTIFICATION_PROFILE_DESTROYED,
626 content::NotificationService::AllSources()); 598 content::NotificationService::AllSources());
627 } 599 }
628 break; 600 break;
629 } 601 }
630 case chrome::NOTIFICATION_SESSION_STARTED: { 602 case chrome::NOTIFICATION_SESSION_STARTED: {
631 session_started_ = true; 603 session_started_ = true;
632 ash::Shell::Get()->UpdateAfterLoginStatusChange(GetUserLoginStatus());
633 SetProfile(ProfileManager::GetActiveUserProfile()); 604 SetProfile(ProfileManager::GetActiveUserProfile());
634 break; 605 break;
635 } 606 }
636 default: 607 default:
637 NOTREACHED(); 608 NOTREACHED();
638 } 609 }
639 } 610 }
640 611
641 void SystemTrayDelegateChromeOS::OnLanguageRemapSearchKeyToChanged() { 612 void SystemTrayDelegateChromeOS::OnLanguageRemapSearchKeyToChanged() {
642 search_key_mapped_to_ = user_pref_registrar_->prefs()->GetInteger( 613 search_key_mapped_to_ = user_pref_registrar_->prefs()->GetInteger(
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while " 735 LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while "
765 << "ENABLE_SUPERVISED_USERS undefined."; 736 << "ENABLE_SUPERVISED_USERS undefined.";
766 return base::string16(); 737 return base::string16();
767 } 738 }
768 739
769 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { 740 ash::SystemTrayDelegate* CreateSystemTrayDelegate() {
770 return new SystemTrayDelegateChromeOS(); 741 return new SystemTrayDelegateChromeOS();
771 } 742 }
772 743
773 } // namespace chromeos 744 } // 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