| OLD | NEW |
| 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 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 #ifndef CHROME_BROWSER_CHROMEOS_PROFILES_PROFILE_HELPER_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_PROFILES_PROFILE_HELPER_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_PROFILES_PROFILE_HELPER_H_ | 6 #define CHROME_BROWSER_CHROMEOS_PROFILES_PROFILE_HELPER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| 11 #include "base/basictypes.h" | 11 #include "base/basictypes.h" |
| 12 #include "base/callback_forward.h" | 12 #include "base/callback_forward.h" |
| 13 #include "base/files/file_path.h" |
| 13 #include "chrome/browser/browsing_data/browsing_data_remover.h" | 14 #include "chrome/browser/browsing_data/browsing_data_remover.h" |
| 14 #include "chrome/browser/chromeos/login/user_manager.h" | 15 #include "chrome/browser/chromeos/login/user_manager.h" |
| 15 | 16 |
| 16 class Profile; | 17 class Profile; |
| 17 | 18 |
| 18 namespace chromeos { | 19 namespace chromeos { |
| 19 | 20 |
| 20 class ProfileHelper : public BrowsingDataRemover::Observer, | 21 class ProfileHelper : public BrowsingDataRemover::Observer, |
| 21 public UserManager::UserSessionStateObserver { | 22 public UserManager::UserSessionStateObserver { |
| 22 public: | 23 public: |
| 24 // Chrome OS profile directories have custom prefix. |
| 25 // Profile path format: [user_data_dir]/u-[$hash] |
| 26 // Ex.: /home/chronos/u-0123456789 |
| 27 static const char kProfileDirPrefix[]; |
| 28 |
| 23 ProfileHelper(); | 29 ProfileHelper(); |
| 24 virtual ~ProfileHelper(); | 30 virtual ~ProfileHelper(); |
| 25 | 31 |
| 26 // Returns Profile instance that corresponds to |user_id_hash|. | 32 // Returns Profile instance that corresponds to |user_id_hash|. |
| 27 static Profile* GetProfileByUserIdHash(const std::string& user_id_hash); | 33 static Profile* GetProfileByUserIdHash(const std::string& user_id_hash); |
| 28 | 34 |
| 29 // Returns OffTheRecord profile for use during signing phase. | 35 // Returns OffTheRecord profile for use during signing phase. |
| 30 static Profile* GetSigninProfile(); | 36 static Profile* GetSigninProfile(); |
| 31 | 37 |
| 38 // Returns user_id hash for |profile| instance or empty string if hash |
| 39 // could not be extracted from |profile|. |
| 40 static std::string GetUserIdHashFromProfile(Profile* profile); |
| 41 |
| 32 // Returns true if |profile| is the signin Profile. This can be used during | 42 // Returns true if |profile| is the signin Profile. This can be used during |
| 33 // construction of the signin Profile to determine if that Profile is the | 43 // construction of the signin Profile to determine if that Profile is the |
| 34 // signin Profile. | 44 // signin Profile. |
| 35 static bool IsSigninProfile(Profile* profile); | 45 static bool IsSigninProfile(Profile* profile); |
| 36 | 46 |
| 37 // Initialize a bunch of services that are tied to a browser profile. | 47 // Initialize a bunch of services that are tied to a browser profile. |
| 38 // TODO(dzhioev): Investigate whether or not this method is needed. | 48 // TODO(dzhioev): Investigate whether or not this method is needed. |
| 39 static void ProfileStartup(Profile* profile, bool process_startup); | 49 static void ProfileStartup(Profile* profile, bool process_startup); |
| 40 | 50 |
| 51 // Returns active user profile dir in a format [u-$hash]. |
| 52 base::FilePath GetActiveUserProfileDir(); |
| 53 |
| 41 // Should called once after UserManager instance has been created. | 54 // Should called once after UserManager instance has been created. |
| 42 void Initialize(); | 55 void Initialize(); |
| 43 | 56 |
| 44 // Returns hash for active user ID which is used to identify that user profile | 57 // Returns hash for active user ID which is used to identify that user profile |
| 45 // on Chrome OS. | 58 // on Chrome OS. |
| 46 std::string active_user_id_hash() { return active_user_id_hash_; } | 59 std::string active_user_id_hash() { return active_user_id_hash_; } |
| 47 | 60 |
| 48 // Clears site data (cookies, history, etc) for signin profile. | 61 // Clears site data (cookies, history, etc) for signin profile. |
| 49 // Callback can be empty. Not thread-safe. | 62 // Callback can be empty. Not thread-safe. |
| 50 void ClearSigninProfile(const base::Closure& on_clear_callback); | 63 void ClearSigninProfile(const base::Closure& on_clear_callback); |
| 51 | 64 |
| 52 private: | 65 private: |
| 66 friend class ProfileHelperTest; |
| 67 |
| 53 // UserManager::UserSessionStateObserver implementation: | 68 // UserManager::UserSessionStateObserver implementation: |
| 54 virtual void ActiveUserHashChanged(const std::string& hash) OVERRIDE; | 69 virtual void ActiveUserHashChanged(const std::string& hash) OVERRIDE; |
| 55 | 70 |
| 56 // BrowsingDataRemover::Observer implementation: | 71 // BrowsingDataRemover::Observer implementation: |
| 57 virtual void OnBrowsingDataRemoverDone() OVERRIDE; | 72 virtual void OnBrowsingDataRemoverDone() OVERRIDE; |
| 58 | 73 |
| 59 // Identifies path to active user profile on Chrome OS. | 74 // Identifies path to active user profile on Chrome OS. |
| 60 std::string active_user_id_hash_; | 75 std::string active_user_id_hash_; |
| 61 | 76 |
| 62 // True if signin profile clearing now. | 77 // True if signin profile clearing now. |
| 63 bool signin_profile_clear_requested_; | 78 bool signin_profile_clear_requested_; |
| 64 | 79 |
| 65 // List of callbacks called after signin profile clearance. | 80 // List of callbacks called after signin profile clearance. |
| 66 std::vector<base::Closure> on_clear_callbacks_; | 81 std::vector<base::Closure> on_clear_callbacks_; |
| 67 | 82 |
| 68 DISALLOW_COPY_AND_ASSIGN(ProfileHelper); | 83 DISALLOW_COPY_AND_ASSIGN(ProfileHelper); |
| 69 }; | 84 }; |
| 70 | 85 |
| 71 } // namespace chromeos | 86 } // namespace chromeos |
| 72 | 87 |
| 73 #endif // CHROME_BROWSER_CHROMEOS_PROFILES_PROFILE_HELPER_H_ | 88 #endif // CHROME_BROWSER_CHROMEOS_PROFILES_PROFILE_HELPER_H_ |
| 74 | 89 |
| OLD | NEW |