OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 "chrome/browser/browser_process.h" | 7 #include "chrome/browser/browser_process.h" |
8 #include "chrome/browser/prefs/pref_service.h" | 8 #include "chrome/browser/prefs/pref_service.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/profiles/profile_info_cache.h" | 10 #include "chrome/browser/profiles/profile_info_cache.h" |
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
124 cache.SetGAIAPictureOfProfileAtIndex(profile_index, &gfx_image); | 124 cache.SetGAIAPictureOfProfileAtIndex(profile_index, &gfx_image); |
125 } else if (picture_status == ProfileDownloader::PICTURE_DEFAULT) { | 125 } else if (picture_status == ProfileDownloader::PICTURE_DEFAULT) { |
126 cache.SetGAIAPictureOfProfileAtIndex(profile_index, NULL); | 126 cache.SetGAIAPictureOfProfileAtIndex(profile_index, NULL); |
127 } | 127 } |
128 | 128 |
129 // If this profile hasn't switched to using GAIA information for the profile | 129 // If this profile hasn't switched to using GAIA information for the profile |
130 // name and picture then switch it now. Once the profile has switched this | 130 // name and picture then switch it now. Once the profile has switched this |
131 // preference guards against clobbering the user's custom settings. | 131 // preference guards against clobbering the user's custom settings. |
132 if (!cache.GetHasMigratedToGAIAInfoOfProfileAtIndex(profile_index)) { | 132 if (!cache.GetHasMigratedToGAIAInfoOfProfileAtIndex(profile_index)) { |
133 cache.SetHasMigratedToGAIAInfoOfProfileAtIndex(profile_index, true); | 133 cache.SetHasMigratedToGAIAInfoOfProfileAtIndex(profile_index, true); |
| 134 // Order matters here for shortcut management, like in |
| 135 // ProfileShortcutManagerWin::OnProfileAdded, as the picture update does not |
| 136 // allow us to change the target, so we have to apply any renaming first. We |
| 137 // also need to re-fetch the index, as SetIsUsingGAIANameOfProfileAtIndex |
| 138 // may alter it. |
| 139 cache.SetIsUsingGAIANameOfProfileAtIndex(profile_index, true); |
| 140 profile_index = cache.GetIndexOfProfileWithPath(profile_->GetPath()); |
134 cache.SetIsUsingGAIAPictureOfProfileAtIndex(profile_index, true); | 141 cache.SetIsUsingGAIAPictureOfProfileAtIndex(profile_index, true); |
135 cache.SetIsUsingGAIANameOfProfileAtIndex(profile_index, true); | |
136 } | 142 } |
137 } | 143 } |
138 | 144 |
139 void GAIAInfoUpdateService::Observe( | 145 void GAIAInfoUpdateService::Observe( |
140 int type, | 146 int type, |
141 const content::NotificationSource& source, | 147 const content::NotificationSource& source, |
142 const content::NotificationDetails& details) { | 148 const content::NotificationDetails& details) { |
143 if (type == chrome::NOTIFICATION_PREF_CHANGED) { | 149 if (type == chrome::NOTIFICATION_PREF_CHANGED) { |
144 std::string* name = content::Details<std::string>(details).ptr(); | 150 std::string* name = content::Details<std::string>(details).ptr(); |
145 if (prefs::kGoogleServicesUsername == *name) | 151 if (prefs::kGoogleServicesUsername == *name) |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
183 const base::TimeDelta update_delta = base::Time::Now() - last_updated_; | 189 const base::TimeDelta update_delta = base::Time::Now() - last_updated_; |
184 | 190 |
185 base::TimeDelta delta; | 191 base::TimeDelta delta; |
186 if (update_delta < base::TimeDelta() || update_delta > desired_delta) | 192 if (update_delta < base::TimeDelta() || update_delta > desired_delta) |
187 delta = base::TimeDelta::FromSeconds(kMinUpdateIntervalSeconds); | 193 delta = base::TimeDelta::FromSeconds(kMinUpdateIntervalSeconds); |
188 else | 194 else |
189 delta = desired_delta - update_delta; | 195 delta = desired_delta - update_delta; |
190 | 196 |
191 timer_.Start(FROM_HERE, delta, this, &GAIAInfoUpdateService::Update); | 197 timer_.Start(FROM_HERE, delta, this, &GAIAInfoUpdateService::Update); |
192 } | 198 } |
OLD | NEW |