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

Unified Diff: chrome/browser/profiles/profile_metadata_storage.h

Issue 1214483002: Improve the ProfileInfoCache API. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 6 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/profiles/profile_metadata_storage.h
diff --git a/chrome/browser/profiles/profile_metadata_storage.h b/chrome/browser/profiles/profile_metadata_storage.h
new file mode 100644
index 0000000000000000000000000000000000000000..d266dc740c4212c76e73c72251061fb7bd5b8fb8
--- /dev/null
+++ b/chrome/browser/profiles/profile_metadata_storage.h
@@ -0,0 +1,113 @@
+// Copyright (c) 2015 The Chromium Authors. All rights reserved.
noms (inactive) 2015/06/29 17:10:40 The 2014-and-after style says there's no (c) neede
anthonyvd 2015/06/30 21:24:52 Done.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_PROFILES_PROFILE_METADATA_STORAGE_H_
+#define CHROME_BROWSER_PROFILES_PROFILE_METADATA_STORAGE_H_
+
+class ProfileInfoCache;
+
+class ProfileMetadataStorage {
+ public:
+ // Represents one profile's metadata.
+ class ProfileMetadataEntry {
noms (inactive) 2015/06/29 17:10:40 I don't love `metadata` (to me, metadata is like t
Mike Lerman 2015/06/29 19:14:37 I was okay with ProfileMetadata, though I'm also o
anthonyvd 2015/06/30 21:24:53 Done and done. I preferred moving away from Profi
+ public:
+ base::string16 GetName() const;
noms (inactive) 2015/06/29 17:10:40 I'm so confused. This just has getters, but doesn'
anthonyvd 2015/06/30 21:24:53 I completely agree that it's kind of weird. The id
+ base::string16 GetShortcutName() const;
+ base::FilePath GetPath() const;
+ base::Time GetActiveTime() const;
+ base::string16 GetUserName() const;
+ const gfx::Image& GetAvatarIcon();
+ std::string GetLocalAuthCredentials() const;
+ std::string GetPasswordChangeDetectionToken() const;
+ // Note that a return value of false could mean an error in collection or
+ // that there are currently no background apps running. However, the action
+ // which results is the same in both cases (thus far).
+ bool GetBackgroundStatus() const;
+ base::string16 GetGAIAName() const;
+ base::string16 GetGAIAGivenName() const;
+ std::string GetGAIAId() const;
+ // Returns the GAIA picture for the given profile. This may return NULL
+ // if the profile does not have a GAIA picture or if the picture must be
+ // loaded from disk.
+ const gfx::Image* GetGAIAPicture() const;
+ bool IsUsingGAIAPicture() const;
+ bool IsSupervised() const;
+ bool IsChild() const;
+ bool IsLegacySupervised() const;
+ bool IsOmitted() const;
+ bool IsSigninRequired() const;
+ std::string GetSupervisedUserId() const;
+ bool IsEphemeral() const;
+ bool IsUsingDefaultName() const;
+ bool IsAuthenticated() const;
+ bool IsUsingDefaultAvatar() const;
+ bool IsAuthError() const;
+ size_t GetAvatarIconIndex() const;
+
+ void SetName(const base::string16& name);
+ void SetShortcutName(const base::string16& name);
+ void SetIsOmitted(bool is_omitted);
+ void SetSupervisedUserId(const std::string& id);
+ void SetLocalAuthCredentials(const std::string& auth);
+ void SetPasswordChangeDetectionToken(const std::string& token);
+ void SetBackgroundStatus(bool running_background_apps);
+ void SetGAIAName(const base::string16& name);
+ void SetGAIAGivenName(const base::string16& name);
+ void SetGAIAPicture(const gfx::Image* image);
+ void SetIsUsingGAIAPicture(bool value);
+ void SetIsSigninRequired(bool value);
+ void SetIsEphemeral(bool value);
+ void SetIsUsingDefaultName(bool value);
+ void SetIsUsingDefaultAvatar(bool value);
+ void SetIsAuthError(bool value);
+ void SetAvatarIconIndex(size_t icon_index);
+
+ void SetAuthInfo(const std::string& gaia_id,
+ const base::string16& user_name);
+
+ private:
+ // These members are an implementation detail meant to smooth the migration
noms (inactive) 2015/06/29 17:10:40 Probably safe to add a TODO here :)
anthonyvd 2015/06/30 21:24:53 Done.
+ // of the ProfileInfoCache to the ProfileMetadataStorage interface. They can
+ // be safely removed once the ProfileInfoCache stops using indices
+ // internally.
+ friend class ProfileInfoCache;
+ size_t profile_index_;
+ ProfileInfoCache* profile_info_cache_;
Mike Lerman 2015/06/29 19:14:37 I imagine you will one day have member variables f
anthonyvd 2015/06/30 21:24:53 Do you think the own above w.r.t. Monica's comment
+ };
+
+ ProfileMetadataStorage() {}
+ ~ProfileMetadataStorage() {}
+
+ // If the |supervised_user_id| is non-empty, the profile will be marked to be
+ // omitted from the avatar-menu list on desktop versions. This is used while a
+ // supervised user is in the process of being registered with the server. Use
+ // SetIsOmittedProfileAtIndex() to clear the flag when the profile is ready to
anthonyvd 2015/06/25 21:38:37 Oops, need to update that comment.
anthonyvd 2015/06/30 21:24:53 Done.
+ // be shown in the menu.
+ virtual void AddProfile(const base::FilePath& profile_path,
+ const base::string16& name,
+ const std::string& gaia_id,
+ const base::string16& user_name,
+ size_t icon_index,
+ const std::string& supervised_user_id) = 0;
+ virtual void DeleteProfile(const base::FilePath& profile_path) = 0;
+
+ // Returns a vector containing one metadata entry per known profile. They are
+ // not sorted in any particular order.
+ virtual std::vector<ProfileMetadataEntry> GetAllProfilesMetadata() = 0;
+
+ // Populates |entry| with the data for the profile at |path| and returns true
+ // if the operation is successful and |entry| can be used. Returns false
+ // otherwise.
+ // |entry| should not be cached as it will not reflect subsequent changes to
+ // the profile's metadata.
+ virtual bool GetProfileMetadataWithPath(
+ const base::FilePath& path, ProfileMetadataEntry* entry) = 0;
Mike Lerman 2015/06/29 19:14:37 Perhaps make the second parameter a *& rather than
anthonyvd 2015/06/30 21:24:53 I'm not too sure about that. The pointer-to-pointe
Mike Lerman 2015/07/02 18:01:30 I agree with your analysis of the two options, and
anthonyvd 2015/07/07 21:05:32 I went ahead and implemented 2) without the actual
+
+ // Returns the amount of known profiles.
Mike Lerman 2015/06/29 19:14:37 s/amount/count? quantity? numeracy?/
anthonyvd 2015/06/30 21:24:53 Done.
+ virtual size_t GetNumberOfProfiles() const = 0;
+
+ DISALLOW_COPY_AND_ASSIGN(ProfileMetadataStorage);
+};
+
+#endif // CHROME_BROWSER_PROFILES_PROFILE_METADATA_STORAGE_H_

Powered by Google App Engine
This is Rietveld 408576698