| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 // This class keeps track of the currently-active profiles in the runtime. | 5 // This class keeps track of the currently-active profiles in the runtime. |
| 6 | 6 |
| 7 #ifndef CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_ | 7 #ifndef CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_ |
| 8 #define CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_ | 8 #define CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_ |
| 9 | 9 |
| 10 #include <stddef.h> | 10 #include <stddef.h> |
| (...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 // This function is temporary and will soon be moved to ash. As such avoid | 79 // This function is temporary and will soon be moved to ash. As such avoid |
| 80 // using it at all cost. | 80 // using it at all cost. |
| 81 // TODO(skuhne): Move into ash's new user management function. | 81 // TODO(skuhne): Move into ash's new user management function. |
| 82 static Profile* GetActiveUserProfile(); | 82 static Profile* GetActiveUserProfile(); |
| 83 | 83 |
| 84 // Returns a profile for a specific profile directory within the user data | 84 // Returns a profile for a specific profile directory within the user data |
| 85 // dir. This will return an existing profile it had already been created, | 85 // dir. This will return an existing profile it had already been created, |
| 86 // otherwise it will create and manage it. | 86 // otherwise it will create and manage it. |
| 87 // Because this method might synchronously create a new profile, it should | 87 // Because this method might synchronously create a new profile, it should |
| 88 // only be called for the initial profile or in tests, where blocking is | 88 // only be called for the initial profile or in tests, where blocking is |
| 89 // acceptable. | 89 // acceptable. Returns null if creation of the new profile fails. |
| 90 // TODO(bauerb): Migrate calls from other code to GetProfileByPath(), then | 90 // TODO(bauerb): Migrate calls from other code to GetProfileByPath(), then |
| 91 // make this method private. | 91 // make this method private. |
| 92 Profile* GetProfile(const base::FilePath& profile_dir); | 92 Profile* GetProfile(const base::FilePath& profile_dir); |
| 93 | 93 |
| 94 // Returns total number of profiles available on this machine. | 94 // Returns total number of profiles available on this machine. |
| 95 size_t GetNumberOfProfiles(); | 95 size_t GetNumberOfProfiles(); |
| 96 | 96 |
| 97 // Asynchronously loads an existing profile given its |profile_name| within | 97 // Asynchronously loads an existing profile given its |profile_name| within |
| 98 // the user data directory, optionally in |incognito| mode. The |callback| | 98 // the user data directory, optionally in |incognito| mode. The |callback| |
| 99 // will be called with the Profile when it has been loaded, or with a nullptr | 99 // will be called with the Profile when it has been loaded, or with a nullptr |
| (...skipping 29 matching lines...) Expand all Loading... |
| 129 Profile* GetLastUsedProfile(const base::FilePath& user_data_dir); | 129 Profile* GetLastUsedProfile(const base::FilePath& user_data_dir); |
| 130 | 130 |
| 131 // Get the path of the last used profile, or if that's undefined, the default | 131 // Get the path of the last used profile, or if that's undefined, the default |
| 132 // profile. | 132 // profile. |
| 133 base::FilePath GetLastUsedProfileDir(const base::FilePath& user_data_dir); | 133 base::FilePath GetLastUsedProfileDir(const base::FilePath& user_data_dir); |
| 134 | 134 |
| 135 // Get the name of the last used profile, or if that's undefined, the default | 135 // Get the name of the last used profile, or if that's undefined, the default |
| 136 // profile. | 136 // profile. |
| 137 std::string GetLastUsedProfileName(); | 137 std::string GetLastUsedProfileName(); |
| 138 | 138 |
| 139 // Get the Profiles which are currently open, i.e., have open browsers, or | 139 // Get the Profiles which are currently open, i.e. have open browsers or were |
| 140 // were open the last time Chrome was running. The Profiles appear in the | 140 // open the last time Chrome was running. Profiles that fail to initialize are |
| 141 // order they were opened. The last used profile will be on the list, but its | 141 // skipped. The Profiles appear in the order they were opened. The last used |
| 142 // profile will be on the list if it is initialized successfully, but its |
| 142 // index on the list will depend on when it was opened (it is not necessarily | 143 // index on the list will depend on when it was opened (it is not necessarily |
| 143 // the last one). | 144 // the last one). |
| 144 std::vector<Profile*> GetLastOpenedProfiles( | 145 std::vector<Profile*> GetLastOpenedProfiles( |
| 145 const base::FilePath& user_data_dir); | 146 const base::FilePath& user_data_dir); |
| 146 | 147 |
| 147 // Returns created and fully initialized profiles. Note, profiles order is NOT | 148 // Returns created and fully initialized profiles. Note, profiles order is NOT |
| 148 // guaranteed to be related with the creation order. | 149 // guaranteed to be related with the creation order. |
| 149 std::vector<Profile*> GetLoadedProfiles() const; | 150 std::vector<Profile*> GetLoadedProfiles() const; |
| 150 | 151 |
| 151 // If a profile with the given path is currently managed by this object and | 152 // If a profile with the given path is currently managed by this object and |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 bool is_new_profile) override; | 241 bool is_new_profile) override; |
| 241 | 242 |
| 242 protected: | 243 protected: |
| 243 // Does final initial actions. | 244 // Does final initial actions. |
| 244 virtual void DoFinalInit(Profile* profile, bool go_off_the_record); | 245 virtual void DoFinalInit(Profile* profile, bool go_off_the_record); |
| 245 virtual void DoFinalInitForServices(Profile* profile, bool go_off_the_record); | 246 virtual void DoFinalInitForServices(Profile* profile, bool go_off_the_record); |
| 246 virtual void DoFinalInitLogging(Profile* profile); | 247 virtual void DoFinalInitLogging(Profile* profile); |
| 247 | 248 |
| 248 // Creates a new profile by calling into the profile's profile creation | 249 // Creates a new profile by calling into the profile's profile creation |
| 249 // method. Virtual so that unittests can return a TestingProfile instead | 250 // method. Virtual so that unittests can return a TestingProfile instead |
| 250 // of the Profile's result. | 251 // of the Profile's result. Returns null if creation fails. |
| 251 virtual Profile* CreateProfileHelper(const base::FilePath& path); | 252 virtual Profile* CreateProfileHelper(const base::FilePath& path); |
| 252 | 253 |
| 253 // Creates a new profile asynchronously by calling into the profile's | 254 // Creates a new profile asynchronously by calling into the profile's |
| 254 // asynchronous profile creation method. Virtual so that unittests can return | 255 // asynchronous profile creation method. Virtual so that unittests can return |
| 255 // a TestingProfile instead of the Profile's result. | 256 // a TestingProfile instead of the Profile's result. |
| 256 virtual Profile* CreateProfileAsyncHelper(const base::FilePath& path, | 257 virtual Profile* CreateProfileAsyncHelper(const base::FilePath& path, |
| 257 Delegate* delegate); | 258 Delegate* delegate); |
| 258 | 259 |
| 259 private: | 260 private: |
| 260 friend class TestingProfileManager; | 261 friend class TestingProfileManager; |
| (...skipping 26 matching lines...) Expand all Loading... |
| 287 Profile* GetActiveUserOrOffTheRecordProfileFromPath( | 288 Profile* GetActiveUserOrOffTheRecordProfileFromPath( |
| 288 const base::FilePath& user_data_dir); | 289 const base::FilePath& user_data_dir); |
| 289 | 290 |
| 290 // Adds a pre-existing Profile object to the set managed by this | 291 // Adds a pre-existing Profile object to the set managed by this |
| 291 // ProfileManager. This ProfileManager takes ownership of the Profile. | 292 // ProfileManager. This ProfileManager takes ownership of the Profile. |
| 292 // The Profile should not already be managed by this ProfileManager. | 293 // The Profile should not already be managed by this ProfileManager. |
| 293 // Returns true if the profile was added, false otherwise. | 294 // Returns true if the profile was added, false otherwise. |
| 294 bool AddProfile(Profile* profile); | 295 bool AddProfile(Profile* profile); |
| 295 | 296 |
| 296 // Synchronously creates and returns a profile. This handles both the full | 297 // Synchronously creates and returns a profile. This handles both the full |
| 297 // creation and adds it to the set managed by this ProfileManager. | 298 // creation and adds it to the set managed by this ProfileManager. Returns |
| 299 // null if creation fails. |
| 298 Profile* CreateAndInitializeProfile(const base::FilePath& profile_dir); | 300 Profile* CreateAndInitializeProfile(const base::FilePath& profile_dir); |
| 299 | 301 |
| 300 #if !defined(OS_ANDROID) | 302 #if !defined(OS_ANDROID) |
| 301 // Schedules the profile at the given path to be deleted on shutdown, | 303 // Schedules the profile at the given path to be deleted on shutdown, |
| 302 // and marks the new profile as active. | 304 // and marks the new profile as active. |
| 303 void FinishDeletingProfile(const base::FilePath& profile_dir, | 305 void FinishDeletingProfile(const base::FilePath& profile_dir, |
| 304 const base::FilePath& new_active_profile_dir); | 306 const base::FilePath& new_active_profile_dir); |
| 305 #endif | 307 #endif |
| 306 | 308 |
| 307 // Registers profile with given info. Returns pointer to created ProfileInfo | 309 // Registers profile with given info. Returns pointer to created ProfileInfo |
| (...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 417 class ProfileManagerWithoutInit : public ProfileManager { | 419 class ProfileManagerWithoutInit : public ProfileManager { |
| 418 public: | 420 public: |
| 419 explicit ProfileManagerWithoutInit(const base::FilePath& user_data_dir); | 421 explicit ProfileManagerWithoutInit(const base::FilePath& user_data_dir); |
| 420 | 422 |
| 421 protected: | 423 protected: |
| 422 void DoFinalInitForServices(Profile*, bool) override {} | 424 void DoFinalInitForServices(Profile*, bool) override {} |
| 423 void DoFinalInitLogging(Profile*) override {} | 425 void DoFinalInitLogging(Profile*) override {} |
| 424 }; | 426 }; |
| 425 | 427 |
| 426 #endif // CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_ | 428 #endif // CHROME_BROWSER_PROFILES_PROFILE_MANAGER_H_ |
| OLD | NEW |