Chromium Code Reviews| 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 #include "chrome/browser/profiles/gaia_info_update_service.h" | 5 #include "chrome/browser/profiles/gaia_info_update_service.h" |
| 6 | 6 |
| 7 #include "base/prefs/pref_service.h" | 7 #include "base/prefs/pref_service.h" |
| 8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
| 9 #include "chrome/browser/chrome_notification_types.h" | 9 #include "chrome/browser/chrome_notification_types.h" |
| 10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
| (...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 111 downloader->GetProfilePictureStatus(); | 111 downloader->GetProfilePictureStatus(); |
| 112 std::string picture_url = downloader->GetProfilePictureURL(); | 112 std::string picture_url = downloader->GetProfilePictureURL(); |
| 113 | 113 |
| 114 ProfileInfoCache& cache = | 114 ProfileInfoCache& cache = |
| 115 g_browser_process->profile_manager()->GetProfileInfoCache(); | 115 g_browser_process->profile_manager()->GetProfileInfoCache(); |
| 116 size_t profile_index = cache.GetIndexOfProfileWithPath(profile_->GetPath()); | 116 size_t profile_index = cache.GetIndexOfProfileWithPath(profile_->GetPath()); |
| 117 if (profile_index == std::string::npos) | 117 if (profile_index == std::string::npos) |
| 118 return; | 118 return; |
| 119 | 119 |
| 120 cache.SetGAIANameOfProfileAtIndex(profile_index, full_name); | 120 cache.SetGAIANameOfProfileAtIndex(profile_index, full_name); |
| 121 cache.SetGAIAGivenNameOfProfileAtIndex(profile_index, given_name); | |
| 122 | |
| 123 // The profile index may have changed. | 121 // The profile index may have changed. |
| 124 profile_index = cache.GetIndexOfProfileWithPath(profile_->GetPath()); | 122 profile_index = cache.GetIndexOfProfileWithPath(profile_->GetPath()); |
| 123 | |
| 124 cache.SetGAIAGivenNameOfProfileAtIndex(profile_index, given_name); | |
| 125 // The profile index may have changed. | |
| 126 profile_index = cache.GetIndexOfProfileWithPath(profile_->GetPath()); | |
|
Pam (message me for reviews)
2014/07/10 22:39:14
Good catch -- please add a test for the bug.
| |
| 127 | |
| 125 if (profile_index == std::string::npos) | 128 if (profile_index == std::string::npos) |
| 126 return; | 129 return; |
| 127 if (picture_status == ProfileDownloader::PICTURE_SUCCESS) { | 130 if (picture_status == ProfileDownloader::PICTURE_SUCCESS) { |
| 128 profile_->GetPrefs()->SetString(prefs::kProfileGAIAInfoPictureURL, | 131 profile_->GetPrefs()->SetString(prefs::kProfileGAIAInfoPictureURL, |
| 129 picture_url); | 132 picture_url); |
| 130 gfx::Image gfx_image = gfx::Image::CreateFrom1xBitmap(bitmap); | 133 gfx::Image gfx_image = gfx::Image::CreateFrom1xBitmap(bitmap); |
| 131 cache.SetGAIAPictureOfProfileAtIndex(profile_index, &gfx_image); | 134 cache.SetGAIAPictureOfProfileAtIndex(profile_index, &gfx_image); |
| 132 } else if (picture_status == ProfileDownloader::PICTURE_DEFAULT) { | 135 } else if (picture_status == ProfileDownloader::PICTURE_DEFAULT) { |
| 133 cache.SetGAIAPictureOfProfileAtIndex(profile_index, NULL); | 136 cache.SetGAIAPictureOfProfileAtIndex(profile_index, NULL); |
| 134 } | 137 } |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 201 | 204 |
| 202 void GAIAInfoUpdateService::GoogleSigninSucceeded( | 205 void GAIAInfoUpdateService::GoogleSigninSucceeded( |
| 203 const std::string& username, | 206 const std::string& username, |
| 204 const std::string& password) { | 207 const std::string& password) { |
| 205 OnUsernameChanged(username); | 208 OnUsernameChanged(username); |
| 206 } | 209 } |
| 207 | 210 |
| 208 void GAIAInfoUpdateService::GoogleSignedOut(const std::string& username) { | 211 void GAIAInfoUpdateService::GoogleSignedOut(const std::string& username) { |
| 209 OnUsernameChanged(std::string()); | 212 OnUsernameChanged(std::string()); |
| 210 } | 213 } |
| OLD | NEW |