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

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

Issue 2780963002: ash: Fix system tray avatar not updated regression (Closed)
Patch Set: resized_ -> resized_image_ 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>
11 #include <set> 11 #include <set>
12 #include <string> 12 #include <string>
13 #include <utility> 13 #include <utility>
14 #include <vector> 14 #include <vector>
15 15
16 #include "ash/common/login_status.h" 16 #include "ash/common/login_status.h"
17 #include "ash/common/shell_delegate.h" 17 #include "ash/common/shell_delegate.h"
18 #include "ash/common/system/chromeos/power/power_status.h" 18 #include "ash/common/system/chromeos/power/power_status.h"
19 #include "ash/common/system/chromeos/session/logout_button_observer.h" 19 #include "ash/common/system/chromeos/session/logout_button_observer.h"
20 #include "ash/common/system/date/clock_observer.h" 20 #include "ash/common/system/date/clock_observer.h"
21 #include "ash/common/system/ime/ime_observer.h" 21 #include "ash/common/system/ime/ime_observer.h"
22 #include "ash/common/system/tray/system_tray_notifier.h" 22 #include "ash/common/system/tray/system_tray_notifier.h"
23 #include "ash/common/system/tray_accessibility.h" 23 #include "ash/common/system/tray_accessibility.h"
24 #include "ash/common/system/user/user_observer.h"
25 #include "ash/shell.h" 24 #include "ash/shell.h"
26 #include "ash/system/chromeos/rotation/tray_rotation_lock.h" 25 #include "ash/system/chromeos/rotation/tray_rotation_lock.h"
27 #include "base/callback.h" 26 #include "base/callback.h"
28 #include "base/logging.h" 27 #include "base/logging.h"
29 #include "base/memory/ptr_util.h" 28 #include "base/memory/ptr_util.h"
30 #include "base/metrics/user_metrics.h" 29 #include "base/metrics/user_metrics.h"
31 #include "base/strings/utf_string_conversions.h" 30 #include "base/strings/utf_string_conversions.h"
32 #include "base/sys_info.h" 31 #include "base/sys_info.h"
33 #include "base/time/time.h" 32 #include "base/time/time.h"
34 #include "chrome/browser/browser_process.h" 33 #include "chrome/browser/browser_process.h"
(...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after
138 registrar_->Add(this, 137 registrar_->Add(this,
139 chrome::NOTIFICATION_PROFILE_DESTROYED, 138 chrome::NOTIFICATION_PROFILE_DESTROYED,
140 content::NotificationService::AllSources()); 139 content::NotificationService::AllSources());
141 140
142 AccessibilityManager* accessibility_manager = AccessibilityManager::Get(); 141 AccessibilityManager* accessibility_manager = AccessibilityManager::Get();
143 CHECK(accessibility_manager); 142 CHECK(accessibility_manager);
144 accessibility_subscription_ = accessibility_manager->RegisterCallback( 143 accessibility_subscription_ = accessibility_manager->RegisterCallback(
145 base::Bind(&SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged, 144 base::Bind(&SystemTrayDelegateChromeOS::OnAccessibilityStatusChanged,
146 base::Unretained(this))); 145 base::Unretained(this)));
147 146
148 user_manager::UserManager::Get()->AddObserver(this);
149 user_manager::UserManager::Get()->AddSessionStateObserver(this); 147 user_manager::UserManager::Get()->AddSessionStateObserver(this);
150 } 148 }
151 149
152 void SystemTrayDelegateChromeOS::Initialize() { 150 void SystemTrayDelegateChromeOS::Initialize() {
153 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this); 151 DBusThreadManager::Get()->GetSessionManagerClient()->AddObserver(this);
154 152
155 input_method::InputMethodManager::Get()->AddObserver(this); 153 input_method::InputMethodManager::Get()->AddObserver(this);
156 input_method::InputMethodManager::Get()->AddImeMenuObserver(this); 154 input_method::InputMethodManager::Get()->AddImeMenuObserver(this);
157 ui::ime::InputMethodMenuManager::GetInstance()->AddObserver(this); 155 ui::ime::InputMethodMenuManager::GetInstance()->AddObserver(this);
158 156
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 StopObservingAppWindowRegistry(); 199 StopObservingAppWindowRegistry();
202 StopObservingCustodianInfoChanges(); 200 StopObservingCustodianInfoChanges();
203 201
204 policy::BrowserPolicyConnectorChromeOS* connector = 202 policy::BrowserPolicyConnectorChromeOS* connector =
205 g_browser_process->platform_part()->browser_policy_connector_chromeos(); 203 g_browser_process->platform_part()->browser_policy_connector_chromeos();
206 policy::DeviceCloudPolicyManagerChromeOS* policy_manager = 204 policy::DeviceCloudPolicyManagerChromeOS* policy_manager =
207 connector->GetDeviceCloudPolicyManager(); 205 connector->GetDeviceCloudPolicyManager();
208 if (policy_manager) 206 if (policy_manager)
209 policy_manager->core()->store()->RemoveObserver(this); 207 policy_manager->core()->store()->RemoveObserver(this);
210 208
211 user_manager::UserManager::Get()->RemoveObserver(this);
212 user_manager::UserManager::Get()->RemoveSessionStateObserver(this); 209 user_manager::UserManager::Get()->RemoveSessionStateObserver(this);
213 } 210 }
214 211
215 ash::LoginStatus SystemTrayDelegateChromeOS::GetUserLoginStatus() const { 212 ash::LoginStatus SystemTrayDelegateChromeOS::GetUserLoginStatus() const {
216 return SystemTrayClient::GetUserLoginStatus(); 213 return SystemTrayClient::GetUserLoginStatus();
217 } 214 }
218 215
219 std::string SystemTrayDelegateChromeOS::GetEnterpriseDomain() const { 216 std::string SystemTrayDelegateChromeOS::GetEnterpriseDomain() const {
220 return enterprise_domain_; 217 return enterprise_domain_;
221 } 218 }
(...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after
416 return have_session_length_limit_; 413 return have_session_length_limit_;
417 } 414 }
418 415
419 int SystemTrayDelegateChromeOS::GetSystemTrayMenuWidth() { 416 int SystemTrayDelegateChromeOS::GetSystemTrayMenuWidth() {
420 return l10n_util::GetLocalizedContentsWidthInPixels( 417 return l10n_util::GetLocalizedContentsWidthInPixels(
421 IDS_SYSTEM_TRAY_MENU_BUBBLE_WIDTH_PIXELS); 418 IDS_SYSTEM_TRAY_MENU_BUBBLE_WIDTH_PIXELS);
422 } 419 }
423 420
424 void SystemTrayDelegateChromeOS::ActiveUserWasChanged() { 421 void SystemTrayDelegateChromeOS::ActiveUserWasChanged() {
425 SetProfile(ProfileManager::GetActiveUserProfile()); 422 SetProfile(ProfileManager::GetActiveUserProfile());
426 GetSystemTrayNotifier()->NotifyUserUpdate();
427 } 423 }
428 424
429 bool SystemTrayDelegateChromeOS::IsSearchKeyMappedToCapsLock() { 425 bool SystemTrayDelegateChromeOS::IsSearchKeyMappedToCapsLock() {
430 return search_key_mapped_to_ == input_method::kCapsLockKey; 426 return search_key_mapped_to_ == input_method::kCapsLockKey;
431 } 427 }
432 428
433 void SystemTrayDelegateChromeOS::AddCustodianInfoTrayObserver( 429 void SystemTrayDelegateChromeOS::AddCustodianInfoTrayObserver(
434 ash::CustodianInfoTrayObserver* observer) { 430 ash::CustodianInfoTrayObserver* observer) {
435 custodian_info_changed_observers_.AddObserver(observer); 431 custodian_info_changed_observers_.AddObserver(observer);
436 } 432 }
437 433
438 void SystemTrayDelegateChromeOS::RemoveCustodianInfoTrayObserver( 434 void SystemTrayDelegateChromeOS::RemoveCustodianInfoTrayObserver(
439 ash::CustodianInfoTrayObserver* observer) { 435 ash::CustodianInfoTrayObserver* observer) {
440 custodian_info_changed_observers_.RemoveObserver(observer); 436 custodian_info_changed_observers_.RemoveObserver(observer);
441 } 437 }
442 438
443 std::unique_ptr<ash::SystemTrayItem> 439 std::unique_ptr<ash::SystemTrayItem>
444 SystemTrayDelegateChromeOS::CreateRotationLockTrayItem(ash::SystemTray* tray) { 440 SystemTrayDelegateChromeOS::CreateRotationLockTrayItem(ash::SystemTray* tray) {
445 return base::MakeUnique<ash::TrayRotationLock>(tray); 441 return base::MakeUnique<ash::TrayRotationLock>(tray);
446 } 442 }
447 443
448 void SystemTrayDelegateChromeOS::UserAddedToSession(
449 const user_manager::User* active_user) {
450 GetSystemTrayNotifier()->NotifyUserAddedToSession();
451 }
452
453 void SystemTrayDelegateChromeOS::ActiveUserChanged(
454 const user_manager::User* /* active_user */) {
455 }
456
457 void SystemTrayDelegateChromeOS::UserChangedChildStatus( 444 void SystemTrayDelegateChromeOS::UserChangedChildStatus(
458 user_manager::User* user) { 445 user_manager::User* user) {
459 Profile* user_profile = ProfileHelper::Get()->GetProfileByUser(user); 446 Profile* user_profile = ProfileHelper::Get()->GetProfileByUser(user);
460 447
461 // Returned user_profile might be NULL on restoring Users on browser start. 448 // Returned user_profile might be NULL on restoring Users on browser start.
462 // At some point profile is not yet fully initiated. 449 // At some point profile is not yet fully initiated.
463 if (session_started_ && user_profile && user_profile_ == user_profile) 450 if (session_started_ && user_profile && user_profile_ == user_profile)
464 ash::Shell::Get()->UpdateAfterLoginStatusChange(GetUserLoginStatus()); 451 ash::Shell::Get()->UpdateAfterLoginStatusChange(GetUserLoginStatus());
465 } 452 }
466 453
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
706 // Overridden from CloudPolicyStore::Observer 693 // Overridden from CloudPolicyStore::Observer
707 void SystemTrayDelegateChromeOS::OnStoreLoaded( 694 void SystemTrayDelegateChromeOS::OnStoreLoaded(
708 policy::CloudPolicyStore* store) { 695 policy::CloudPolicyStore* store) {
709 UpdateEnterpriseDomain(); 696 UpdateEnterpriseDomain();
710 } 697 }
711 698
712 void SystemTrayDelegateChromeOS::OnStoreError(policy::CloudPolicyStore* store) { 699 void SystemTrayDelegateChromeOS::OnStoreError(policy::CloudPolicyStore* store) {
713 UpdateEnterpriseDomain(); 700 UpdateEnterpriseDomain();
714 } 701 }
715 702
716 void SystemTrayDelegateChromeOS::OnUserImageChanged(
717 const user_manager::User& user) {
718 // This is also invoked on login screen when user avatar is loaded from file.
719 if (GetUserLoginStatus() != ash::LoginStatus::NOT_LOGGED_IN)
720 GetSystemTrayNotifier()->NotifyUserUpdate();
721 }
722
723 // Overridden from chrome::BrowserListObserver. 703 // Overridden from chrome::BrowserListObserver.
724 void SystemTrayDelegateChromeOS::OnBrowserRemoved(Browser* browser) { 704 void SystemTrayDelegateChromeOS::OnBrowserRemoved(Browser* browser) {
725 NotifyIfLastWindowClosed(); 705 NotifyIfLastWindowClosed();
726 } 706 }
727 707
728 // Overridden from extensions::AppWindowRegistry::Observer. 708 // Overridden from extensions::AppWindowRegistry::Observer.
729 void SystemTrayDelegateChromeOS::OnAppWindowRemoved( 709 void SystemTrayDelegateChromeOS::OnAppWindowRemoved(
730 extensions::AppWindow* app_window) { 710 extensions::AppWindow* app_window) {
731 NotifyIfLastWindowClosed(); 711 NotifyIfLastWindowClosed();
732 } 712 }
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
790 LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while " 770 LOG(WARNING) << "SystemTrayDelegateChromeOS::GetChildUserMessage call while "
791 << "ENABLE_SUPERVISED_USERS undefined."; 771 << "ENABLE_SUPERVISED_USERS undefined.";
792 return base::string16(); 772 return base::string16();
793 } 773 }
794 774
795 ash::SystemTrayDelegate* CreateSystemTrayDelegate() { 775 ash::SystemTrayDelegate* CreateSystemTrayDelegate() {
796 return new SystemTrayDelegateChromeOS(); 776 return new SystemTrayDelegateChromeOS();
797 } 777 }
798 778
799 } // namespace chromeos 779 } // 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