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 like in ProfileShortcutManagerWin::OnProfileAdded. We | |
sail
2011/12/13 19:36:18
Can you explain in the comment why order matters?
SteveT
2011/12/13 20:20:47
Did my best to beef up the comments. Unfortunately
| |
135 // also need to re-fetch the index, as SetIsUsingGAIANameOfProfileAtIndex | |
136 // may alter it. | |
137 cache.SetIsUsingGAIANameOfProfileAtIndex(profile_index, true); | |
138 profile_index = cache.GetIndexOfProfileWithPath(profile_->GetPath()); | |
134 cache.SetIsUsingGAIAPictureOfProfileAtIndex(profile_index, true); | 139 cache.SetIsUsingGAIAPictureOfProfileAtIndex(profile_index, true); |
135 cache.SetIsUsingGAIANameOfProfileAtIndex(profile_index, true); | |
136 } | 140 } |
137 } | 141 } |
138 | 142 |
139 void GAIAInfoUpdateService::Observe( | 143 void GAIAInfoUpdateService::Observe( |
140 int type, | 144 int type, |
141 const content::NotificationSource& source, | 145 const content::NotificationSource& source, |
142 const content::NotificationDetails& details) { | 146 const content::NotificationDetails& details) { |
143 if (type == chrome::NOTIFICATION_PREF_CHANGED) { | 147 if (type == chrome::NOTIFICATION_PREF_CHANGED) { |
144 std::string* name = content::Details<std::string>(details).ptr(); | 148 std::string* name = content::Details<std::string>(details).ptr(); |
145 if (prefs::kGoogleServicesUsername == *name) | 149 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_; | 187 const base::TimeDelta update_delta = base::Time::Now() - last_updated_; |
184 | 188 |
185 base::TimeDelta delta; | 189 base::TimeDelta delta; |
186 if (update_delta < base::TimeDelta() || update_delta > desired_delta) | 190 if (update_delta < base::TimeDelta() || update_delta > desired_delta) |
187 delta = base::TimeDelta::FromSeconds(kMinUpdateIntervalSeconds); | 191 delta = base::TimeDelta::FromSeconds(kMinUpdateIntervalSeconds); |
188 else | 192 else |
189 delta = desired_delta - update_delta; | 193 delta = desired_delta - update_delta; |
190 | 194 |
191 timer_.Start(FROM_HERE, delta, this, &GAIAInfoUpdateService::Update); | 195 timer_.Start(FROM_HERE, delta, this, &GAIAInfoUpdateService::Update); |
192 } | 196 } |
OLD | NEW |