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/command_line.h" | 7 #include "base/command_line.h" |
8 #include "chrome/browser/browser_process.h" | 8 #include "chrome/browser/browser_process.h" |
9 #include "chrome/browser/prefs/pref_service.h" | 9 #include "chrome/browser/prefs/pref_service.h" |
10 #include "chrome/browser/profiles/profile.h" | 10 #include "chrome/browser/profiles/profile.h" |
(...skipping 111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
122 return; | 122 return; |
123 | 123 |
124 cache.SetGAIANameOfProfileAtIndex(profile_index, full_name); | 124 cache.SetGAIANameOfProfileAtIndex(profile_index, full_name); |
125 // The profile index may have changed. | 125 // The profile index may have changed. |
126 profile_index = cache.GetIndexOfProfileWithPath(profile_->GetPath()); | 126 profile_index = cache.GetIndexOfProfileWithPath(profile_->GetPath()); |
127 if (profile_index == std::string::npos) | 127 if (profile_index == std::string::npos) |
128 return; | 128 return; |
129 if (picture_status == ProfileDownloader::PICTURE_SUCCESS) { | 129 if (picture_status == ProfileDownloader::PICTURE_SUCCESS) { |
130 profile_->GetPrefs()->SetString(prefs::kProfileGAIAInfoPictureURL, | 130 profile_->GetPrefs()->SetString(prefs::kProfileGAIAInfoPictureURL, |
131 picture_url); | 131 picture_url); |
132 gfx::Image gfx_image(bitmap); | 132 gfx::Image gfx_image(new SkBitmap(bitmap)); |
133 cache.SetGAIAPictureOfProfileAtIndex(profile_index, &gfx_image); | 133 cache.SetGAIAPictureOfProfileAtIndex(profile_index, &gfx_image); |
134 } else if (picture_status == ProfileDownloader::PICTURE_DEFAULT) { | 134 } else if (picture_status == ProfileDownloader::PICTURE_DEFAULT) { |
135 cache.SetGAIAPictureOfProfileAtIndex(profile_index, NULL); | 135 cache.SetGAIAPictureOfProfileAtIndex(profile_index, NULL); |
136 } | 136 } |
137 | 137 |
138 // If this profile hasn't switched to using GAIA information for the profile | 138 // If this profile hasn't switched to using GAIA information for the profile |
139 // name and picture then switch it now. Once the profile has switched this | 139 // name and picture then switch it now. Once the profile has switched this |
140 // preference guards against clobbering the user's custom settings. | 140 // preference guards against clobbering the user's custom settings. |
141 if (!cache.GetHasMigratedToGAIAInfoOfProfileAtIndex(profile_index)) { | 141 if (!cache.GetHasMigratedToGAIAInfoOfProfileAtIndex(profile_index)) { |
142 cache.SetHasMigratedToGAIAInfoOfProfileAtIndex(profile_index, true); | 142 cache.SetHasMigratedToGAIAInfoOfProfileAtIndex(profile_index, true); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
198 const base::TimeDelta update_delta = base::Time::Now() - last_updated_; | 198 const base::TimeDelta update_delta = base::Time::Now() - last_updated_; |
199 | 199 |
200 base::TimeDelta delta; | 200 base::TimeDelta delta; |
201 if (update_delta < base::TimeDelta() || update_delta > desired_delta) | 201 if (update_delta < base::TimeDelta() || update_delta > desired_delta) |
202 delta = base::TimeDelta::FromSeconds(kMinUpdateIntervalSeconds); | 202 delta = base::TimeDelta::FromSeconds(kMinUpdateIntervalSeconds); |
203 else | 203 else |
204 delta = desired_delta - update_delta; | 204 delta = desired_delta - update_delta; |
205 | 205 |
206 timer_.Start(FROM_HERE, delta, this, &GAIAInfoUpdateService::Update); | 206 timer_.Start(FROM_HERE, delta, this, &GAIAInfoUpdateService::Update); |
207 } | 207 } |
OLD | NEW |