| 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/webui/signin/user_manager_screen_handler.h" | 5 #include "chrome/browser/ui/webui/signin/user_manager_screen_handler.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "base/strings/utf_string_conversions.h" | 9 #include "base/strings/utf_string_conversions.h" |
| 10 #include "base/value_conversions.h" | 10 #include "base/value_conversions.h" |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 156 public: | 156 public: |
| 157 ProfileUpdateObserver( | 157 ProfileUpdateObserver( |
| 158 ProfileManager* profile_manager, UserManagerScreenHandler* handler) | 158 ProfileManager* profile_manager, UserManagerScreenHandler* handler) |
| 159 : profile_manager_(profile_manager), | 159 : profile_manager_(profile_manager), |
| 160 user_manager_handler_(handler) { | 160 user_manager_handler_(handler) { |
| 161 DCHECK(profile_manager_); | 161 DCHECK(profile_manager_); |
| 162 DCHECK(user_manager_handler_); | 162 DCHECK(user_manager_handler_); |
| 163 profile_manager_->GetProfileInfoCache().AddObserver(this); | 163 profile_manager_->GetProfileInfoCache().AddObserver(this); |
| 164 } | 164 } |
| 165 | 165 |
| 166 virtual ~ProfileUpdateObserver() { | 166 ~ProfileUpdateObserver() override { |
| 167 DCHECK(profile_manager_); | 167 DCHECK(profile_manager_); |
| 168 profile_manager_->GetProfileInfoCache().RemoveObserver(this); | 168 profile_manager_->GetProfileInfoCache().RemoveObserver(this); |
| 169 } | 169 } |
| 170 | 170 |
| 171 private: | 171 private: |
| 172 // ProfileInfoCacheObserver implementation: | 172 // ProfileInfoCacheObserver implementation: |
| 173 // If any change has been made to a profile, propagate it to all the | 173 // If any change has been made to a profile, propagate it to all the |
| 174 // visible user manager screens. | 174 // visible user manager screens. |
| 175 virtual void OnProfileAdded(const base::FilePath& profile_path) override { | 175 void OnProfileAdded(const base::FilePath& profile_path) override { |
| 176 user_manager_handler_->SendUserList(); | 176 user_manager_handler_->SendUserList(); |
| 177 } | 177 } |
| 178 | 178 |
| 179 virtual void OnProfileWasRemoved( | 179 void OnProfileWasRemoved(const base::FilePath& profile_path, |
| 180 const base::FilePath& profile_path, | 180 const base::string16& profile_name) override { |
| 181 const base::string16& profile_name) override { | |
| 182 // TODO(noms): Change 'SendUserList' to 'removeUser' JS-call when | 181 // TODO(noms): Change 'SendUserList' to 'removeUser' JS-call when |
| 183 // UserManager is able to find pod belonging to removed user. | 182 // UserManager is able to find pod belonging to removed user. |
| 184 user_manager_handler_->SendUserList(); | 183 user_manager_handler_->SendUserList(); |
| 185 } | 184 } |
| 186 | 185 |
| 187 virtual void OnProfileNameChanged( | 186 void OnProfileNameChanged(const base::FilePath& profile_path, |
| 188 const base::FilePath& profile_path, | 187 const base::string16& old_profile_name) override { |
| 189 const base::string16& old_profile_name) override { | |
| 190 user_manager_handler_->SendUserList(); | 188 user_manager_handler_->SendUserList(); |
| 191 } | 189 } |
| 192 | 190 |
| 193 virtual void OnProfileAvatarChanged( | 191 void OnProfileAvatarChanged(const base::FilePath& profile_path) override { |
| 192 user_manager_handler_->SendUserList(); |
| 193 } |
| 194 |
| 195 void OnProfileSigninRequiredChanged( |
| 194 const base::FilePath& profile_path) override { | 196 const base::FilePath& profile_path) override { |
| 195 user_manager_handler_->SendUserList(); | 197 user_manager_handler_->SendUserList(); |
| 196 } | 198 } |
| 197 | |
| 198 virtual void OnProfileSigninRequiredChanged( | |
| 199 const base::FilePath& profile_path) override { | |
| 200 user_manager_handler_->SendUserList(); | |
| 201 } | |
| 202 | 199 |
| 203 ProfileManager* profile_manager_; | 200 ProfileManager* profile_manager_; |
| 204 | 201 |
| 205 UserManagerScreenHandler* user_manager_handler_; // Weak; owns us. | 202 UserManagerScreenHandler* user_manager_handler_; // Weak; owns us. |
| 206 | 203 |
| 207 DISALLOW_COPY_AND_ASSIGN(ProfileUpdateObserver); | 204 DISALLOW_COPY_AND_ASSIGN(ProfileUpdateObserver); |
| 208 }; | 205 }; |
| 209 | 206 |
| 210 // UserManagerScreenHandler --------------------------------------------------- | 207 // UserManagerScreenHandler --------------------------------------------------- |
| 211 | 208 |
| (...skipping 543 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 755 Profile* profile, Profile::CreateStatus profile_create_status) { | 752 Profile* profile, Profile::CreateStatus profile_create_status) { |
| 756 Browser* browser = chrome::FindAnyBrowser(profile, false, desktop_type_); | 753 Browser* browser = chrome::FindAnyBrowser(profile, false, desktop_type_); |
| 757 if (browser && browser->window()) { | 754 if (browser && browser->window()) { |
| 758 OnBrowserWindowReady(browser); | 755 OnBrowserWindowReady(browser); |
| 759 } else { | 756 } else { |
| 760 registrar_.Add(this, | 757 registrar_.Add(this, |
| 761 chrome::NOTIFICATION_BROWSER_WINDOW_READY, | 758 chrome::NOTIFICATION_BROWSER_WINDOW_READY, |
| 762 content::NotificationService::AllSources()); | 759 content::NotificationService::AllSources()); |
| 763 } | 760 } |
| 764 } | 761 } |
| OLD | NEW |