Commit 69cb3774 authored by noms@chromium.org's avatar noms@chromium.org

Fetch a new GAIA picture every time chrome://settings/manageProfile comes up.

(currently we do it once, when a profile is signed in, and henceforth every 24h)

This assumes the --google-profile-info flag is in use (which comes for free
as part of --new-profile-management), and is similar to CrOS, which also forces
an update every time chrome://settings/changePicture is loaded.

I've also deleted the code that forced the "is using the gaia photo" flag to true
on every completed download, as it meant that we'd overwrite any custom avatars
the user may have chosen.

BUG=311013

Review URL: https://codereview.chromium.org/267253004

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@272614 0039d316-1c4b-4281-b951-d872f2087c98
parent 26c155cd
...@@ -132,13 +132,6 @@ void GAIAInfoUpdateService::OnProfileDownloadSuccess( ...@@ -132,13 +132,6 @@ void GAIAInfoUpdateService::OnProfileDownloadSuccess(
} else if (picture_status == ProfileDownloader::PICTURE_DEFAULT) { } else if (picture_status == ProfileDownloader::PICTURE_DEFAULT) {
cache.SetGAIAPictureOfProfileAtIndex(profile_index, NULL); cache.SetGAIAPictureOfProfileAtIndex(profile_index, NULL);
} }
// Order matters here for shortcut management, like in
// ProfileShortcutManagerWin::OnProfileAdded, as the picture update does not
// allow us to change the target, so we have to apply any renaming first. We
// also need to re-fetch the index, as changing the profile name may alter it.
profile_index = cache.GetIndexOfProfileWithPath(profile_->GetPath());
cache.SetIsUsingGAIAPictureOfProfileAtIndex(profile_index, true);
} }
void GAIAInfoUpdateService::OnProfileDownloadFailure( void GAIAInfoUpdateService::OnProfileDownloadFailure(
......
...@@ -116,8 +116,6 @@ TEST_F(GAIAInfoUpdateServiceTest, DownloadSuccess) { ...@@ -116,8 +116,6 @@ TEST_F(GAIAInfoUpdateServiceTest, DownloadSuccess) {
size_t index = GetCache()->GetIndexOfProfileWithPath(profile()->GetPath()); size_t index = GetCache()->GetIndexOfProfileWithPath(profile()->GetPath());
EXPECT_EQ(name, GetCache()->GetNameOfProfileAtIndex(index)); EXPECT_EQ(name, GetCache()->GetNameOfProfileAtIndex(index));
EXPECT_EQ(name, GetCache()->GetGAIANameOfProfileAtIndex(index)); EXPECT_EQ(name, GetCache()->GetGAIANameOfProfileAtIndex(index));
EXPECT_TRUE(gfx::test::IsEqual(
image, GetCache()->GetAvatarIconOfProfileAtIndex(index)));
EXPECT_TRUE(gfx::test::IsEqual( EXPECT_TRUE(gfx::test::IsEqual(
image, *GetCache()->GetGAIAPictureOfProfileAtIndex(index))); image, *GetCache()->GetGAIAPictureOfProfileAtIndex(index)));
EXPECT_EQ(url, service()->GetCachedPictureURL()); EXPECT_EQ(url, service()->GetCachedPictureURL());
......
...@@ -9,6 +9,8 @@ ...@@ -9,6 +9,8 @@
#include "base/prefs/pref_service.h" #include "base/prefs/pref_service.h"
#include "base/strings/utf_string_conversions.h" #include "base/strings/utf_string_conversions.h"
#include "chrome/browser/browser_process.h" #include "chrome/browser/browser_process.h"
#include "chrome/browser/profiles/gaia_info_update_service.h"
#include "chrome/browser/profiles/gaia_info_update_service_factory.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
#include "chrome/browser/profiles/profile_info_cache.h" #include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_manager.h" #include "chrome/browser/profiles/profile_manager.h"
...@@ -17,6 +19,7 @@ ...@@ -17,6 +19,7 @@
#include "chrome/common/chrome_constants.h" #include "chrome/common/chrome_constants.h"
#include "chrome/common/pref_names.h" #include "chrome/common/pref_names.h"
#include "components/signin/core/browser/profile_oauth2_token_service.h" #include "components/signin/core/browser/profile_oauth2_token_service.h"
#include "components/signin/core/common/profile_management_switches.h"
#include "grit/generated_resources.h" #include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h" #include "ui/base/l10n/l10n_util.h"
...@@ -109,4 +112,14 @@ bool IsRegularOrGuestSession(Browser* browser) { ...@@ -109,4 +112,14 @@ bool IsRegularOrGuestSession(Browser* browser) {
return profile->IsGuestSession() || !profile->IsOffTheRecord(); return profile->IsGuestSession() || !profile->IsOffTheRecord();
} }
void UpdateGaiaProfilePhotoIfNeeded(Profile* profile) {
// If the --google-profile-info flag isn't used, then the
// GAIAInfoUpdateService isn't initialized, and we can't download the picture.
if (!switches::IsGoogleProfileInfo())
return;
DCHECK(profile);
GAIAInfoUpdateServiceFactory::GetInstance()->GetForProfile(profile)->Update();
}
} // namespace profiles } // namespace profiles
...@@ -48,6 +48,10 @@ std::vector<std::string> GetSecondaryAccountsForProfile( ...@@ -48,6 +48,10 @@ std::vector<std::string> GetSecondaryAccountsForProfile(
// incognito profiles. // incognito profiles.
bool IsRegularOrGuestSession(Browser* browser); bool IsRegularOrGuestSession(Browser* browser);
// If the --google-profile-info flag is turned on, starts an update for a new
// version of the Gaia profile picture.
void UpdateGaiaProfilePhotoIfNeeded(Profile* profile);
} // namespace profiles } // namespace profiles
#endif // CHROME_BROWSER_PROFILES_PROFILES_STATE_H_ #endif // CHROME_BROWSER_PROFILES_PROFILES_STATE_H_
...@@ -501,6 +501,7 @@ cr.define('options', function() { ...@@ -501,6 +501,7 @@ cr.define('options', function() {
* @private * @private
*/ */
prepareForManageDialog_: function() { prepareForManageDialog_: function() {
chrome.send('refreshGaiaPicture');
var profileInfo = BrowserOptions.getCurrentProfile(); var profileInfo = BrowserOptions.getCurrentProfile();
ManageProfileOverlay.setProfileInfo(profileInfo, 'manage'); ManageProfileOverlay.setProfileInfo(profileInfo, 'manage');
$('manage-profile-overlay-create').hidden = true; $('manage-profile-overlay-create').hidden = true;
......
...@@ -182,6 +182,9 @@ void ManageProfileHandler::RegisterMessages() { ...@@ -182,6 +182,9 @@ void ManageProfileHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback("removeProfileShortcut", web_ui()->RegisterMessageCallback("removeProfileShortcut",
base::Bind(&ManageProfileHandler::RemoveProfileShortcut, base::Bind(&ManageProfileHandler::RemoveProfileShortcut,
base::Unretained(this))); base::Unretained(this)));
web_ui()->RegisterMessageCallback("refreshGaiaPicture",
base::Bind(&ManageProfileHandler::RefreshGaiaPicture,
base::Unretained(this)));
} }
void ManageProfileHandler::Uninitialize() { void ManageProfileHandler::Uninitialize() {
...@@ -520,4 +523,8 @@ void ManageProfileHandler::RemoveProfileShortcut(const base::ListValue* args) { ...@@ -520,4 +523,8 @@ void ManageProfileHandler::RemoveProfileShortcut(const base::ListValue* args) {
OnHasProfileShortcuts(false); OnHasProfileShortcuts(false);
} }
void ManageProfileHandler::RefreshGaiaPicture(const base::ListValue* args) {
profiles::UpdateGaiaProfilePhotoIfNeeded(Profile::FromWebUI(web_ui()));
}
} // namespace options } // namespace options
...@@ -122,6 +122,10 @@ class ManageProfileHandler : public OptionsPageUIHandler, ...@@ -122,6 +122,10 @@ class ManageProfileHandler : public OptionsPageUIHandler,
// shortcut" button. Removes the desktop shortcut for the profile. // shortcut" button. Removes the desktop shortcut for the profile.
void RemoveProfileShortcut(const base::ListValue* args); void RemoveProfileShortcut(const base::ListValue* args);
// Callback for the "refreshGaiaPicture" message, which is called when the
// user is editing an existing profile.
void RefreshGaiaPicture(const base::ListValue* args);
// URL for the current profile's GAIA picture. // URL for the current profile's GAIA picture.
std::string gaia_picture_url_; std::string gaia_picture_url_;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment