OLD | NEW |
(Empty) | |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #ifndef CHROME_BROWSER_UI_WEBUI_PROFILE_INFO_WATCHER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_PROFILE_INFO_WATCHER_H_ |
| 7 |
| 8 #include <string> |
| 9 |
| 10 #include "base/callback.h" |
| 11 #include "base/macros.h" |
| 12 #include "base/prefs/pref_member.h" |
| 13 #include "chrome/browser/profiles/profile_info_cache_observer.h" |
| 14 |
| 15 class Profile; |
| 16 class SigninManagerBase; |
| 17 |
| 18 // Watches profiles for changes in their cached info (e.g. the authenticated |
| 19 // username changes). |
| 20 class ProfileInfoWatcher : public ProfileInfoCacheObserver { |
| 21 public: |
| 22 ProfileInfoWatcher(Profile* profile, const base::Closure& callback); |
| 23 ~ProfileInfoWatcher() override; |
| 24 |
| 25 // Gets the authenticated username (e.g. username@gmail.com) for |profile_|. |
| 26 std::string GetAuthenticatedUsername() const; |
| 27 |
| 28 private: |
| 29 // ProfileInfoCacheObserver: |
| 30 void OnProfileAuthInfoChanged(const base::FilePath& profile_path) override; |
| 31 |
| 32 // Gets the SigninManagerBase for |profile_|. |
| 33 SigninManagerBase* GetSigninManager() const; |
| 34 |
| 35 // Runs |callback_| when a profile changes. No-ops if |GetSigninManager()| |
| 36 // returns nullptr. |
| 37 void RunCallback(); |
| 38 |
| 39 // Weak reference to the profile this class observes. |
| 40 Profile* const profile_; |
| 41 |
| 42 // Called when the authenticated username changes. |
| 43 base::Closure callback_; |
| 44 |
| 45 BooleanPrefMember signin_allowed_pref_; |
| 46 |
| 47 DISALLOW_COPY_AND_ASSIGN(ProfileInfoWatcher); |
| 48 }; |
| 49 |
| 50 #endif // CHROME_BROWSER_UI_WEBUI_PROFILE_INFO_WATCHER_H_ |
OLD | NEW |