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

Unified Diff: chrome/browser/profiles/profile_impl.cc

Issue 8511064: GAIA Profile info prototype (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: test Created 9 years, 1 month 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
« no previous file with comments | « chrome/browser/profiles/profile_impl.h ('k') | chrome/browser/profiles/profile_info_cache.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/profiles/profile_impl.cc
diff --git a/chrome/browser/profiles/profile_impl.cc b/chrome/browser/profiles/profile_impl.cc
index 11313d844bf9a7888016bcb1e6ed33a457e17da1..80e58d6d424e961b28657ef3ddaca84fefd31e0a 100644
--- a/chrome/browser/profiles/profile_impl.cc
+++ b/chrome/browser/profiles/profile_impl.cc
@@ -139,10 +139,92 @@
#include "chrome/browser/chromeos/proxy_config_service_impl.h"
#endif
+#include "chrome/browser/gaia_userinfo/profile_image_downloader.h"
+
using base::Time;
using base::TimeDelta;
using content::BrowserThread;
+const char kHasMigratedToGAIAInfo[] = "test_profile_has_migrated_to_gaia_info";
+
+
+class GAIAInfoUpdater : public ProfileImageDownloader::Delegate {
+ public:
+ explicit GAIAInfoUpdater(Profile* profile);
+ bool IsFinishedUpdating();
+
+ // ProfileImageDownloader::Delegate:
+ virtual int GetDesiredImageSize() OVERRIDE;
+ virtual std::string GetProfileUserName() OVERRIDE;
+ virtual Profile* GetProfile() OVERRIDE;
+ virtual void OnDownloadSuccess(const SkBitmap& image,
+ const string16& full_name) OVERRIDE;
+ virtual void OnDownloadFailure() OVERRIDE;
+ virtual void OnDownloadDefaultImage() OVERRIDE;
+
+ private:
+ Profile* profile_;
+ bool is_finished_updating_;
+ scoped_ptr<ProfileImageDownloader> profile_image_downloader_;
+};
+
+GAIAInfoUpdater::GAIAInfoUpdater(Profile* profile)
+ : profile_(profile),
+ is_finished_updating_(false) {
+ profile_image_downloader_.reset(new ProfileImageDownloader(this));
+ profile_image_downloader_->Start();
+}
+
+bool GAIAInfoUpdater::IsFinishedUpdating() {
+ return is_finished_updating_;
+}
+
+int GAIAInfoUpdater::GetDesiredImageSize() {
+ return 256;
+}
+
+std::string GAIAInfoUpdater::GetProfileUserName() {
+ return profile_->GetPrefs()->GetString(prefs::kGoogleServicesUsername);
+}
+
+Profile* GAIAInfoUpdater::GetProfile() {
+ return profile_;
+}
+
+void GAIAInfoUpdater::OnDownloadSuccess(const SkBitmap& image,
+ const string16& full_name) {
+ fprintf(stderr, "%s\n", __func__);
+ ProfileInfoCache& cache =
+ g_browser_process->profile_manager()->GetProfileInfoCache();
+ size_t profile_index = cache.GetIndexOfProfileWithPath(profile_->GetPath());
+ if (profile_index != std::string::npos) {
+ cache.SetGAIANameOfProfileAtIndex(profile_index, full_name);
+ cache.SetGAIAPictureOfProfileAtIndex(profile_index, image);
+
+ if (!profile_->GetPrefs()->GetBoolean(kHasMigratedToGAIAInfo)) {
+ fprintf(stderr, "%s, migrating to gaia image and name\n", __func__);
+ profile_->GetPrefs()->SetBoolean(kHasMigratedToGAIAInfo, true);
+ if (!image.isNull()) {
+ cache.SetIsUsingCustomAvatarIconForProfileAtIndex(profile_index, true);
+ }
+ if (!full_name.empty()) {
+ cache.SetIsUsingGAIANameForProfileAtIndex(profile_index, true);
+ }
+ }
+ }
+ is_finished_updating_ = true;
+}
+
+void GAIAInfoUpdater::OnDownloadFailure() {
+ fprintf(stderr, "%s\n", __func__);
+ is_finished_updating_ = true;
+}
+
+void GAIAInfoUpdater::OnDownloadDefaultImage() {
+ fprintf(stderr, "%s\n", __func__);
+ is_finished_updating_ = true;
+}
+
namespace {
// Delay, in milliseconds, before we explicitly create the SessionService.
@@ -250,6 +332,10 @@ void ProfileImpl::RegisterUserPrefs(PrefService* prefs) {
// result in using PasswordStoreX in CreatePasswordStore() below.
PasswordStoreX::RegisterUserPrefs(prefs);
#endif
+
+ prefs->RegisterBooleanPref(kHasMigratedToGAIAInfo,
+ false,
+ PrefService::UNSYNCABLE_PREF);
}
ProfileImpl::ProfileImpl(const FilePath& path,
@@ -1358,6 +1444,17 @@ void ProfileImpl::Observe(int type,
}
}
+void ProfileImpl::UpdateGAIAProfileInfo() {
+ if (gaia_info_updated_.get() && !gaia_info_updated_->IsFinishedUpdating()) {
+ fprintf(stderr, "%s, skipping updating because old one is pending\n",
+ __func__);
+ return;
+ }
+
+ fprintf(stderr, "%s, starting new GAIA profile info update\n", __func__);
+ gaia_info_updated_.reset(new GAIAInfoUpdater(this));
+}
+
void ProfileImpl::StopCreateSessionServiceTimer() {
create_session_service_timer_.Stop();
}
@@ -1595,3 +1692,4 @@ SpellCheckProfile* ProfileImpl::GetSpellCheckProfile() {
spellcheck_profile_.reset(new SpellCheckProfile(path_));
return spellcheck_profile_.get();
}
+
« no previous file with comments | « chrome/browser/profiles/profile_impl.h ('k') | chrome/browser/profiles/profile_info_cache.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698