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/ui/webui/options/manage_profile_handler.h" | 5 #include "chrome/browser/ui/webui/options/manage_profile_handler.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/string_number_conversions.h" | 9 #include "base/string_number_conversions.h" |
10 #include "base/utf_string_conversions.h" | 10 #include "base/utf_string_conversions.h" |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 // index. | 176 // index. |
177 profile_index = cache.GetIndexOfProfileWithPath(profile_file_path); | 177 profile_index = cache.GetIndexOfProfileWithPath(profile_file_path); |
178 if (profile_index == std::string::npos) | 178 if (profile_index == std::string::npos) |
179 return; | 179 return; |
180 } | 180 } |
181 | 181 |
182 std::string icon_url; | 182 std::string icon_url; |
183 if (!args->GetString(2, &icon_url)) | 183 if (!args->GetString(2, &icon_url)) |
184 return; | 184 return; |
185 | 185 |
| 186 // Metrics logging variable. |
| 187 bool previously_using_gaia_icon = |
| 188 cache.IsUsingGAIANameOfProfileAtIndex(profile_index); |
| 189 |
186 size_t new_icon_index; | 190 size_t new_icon_index; |
187 if (icon_url == gaia_picture_url_) { | 191 if (icon_url == gaia_picture_url_) { |
188 cache.SetIsUsingGAIAPictureOfProfileAtIndex(profile_index, true); | 192 cache.SetIsUsingGAIAPictureOfProfileAtIndex(profile_index, true); |
| 193 if (!previously_using_gaia_icon) { |
| 194 // Only log if they changed to the GAIA photo. |
| 195 // Selection of GAIA photo as avatar is logged as part of the function |
| 196 // below. |
| 197 ProfileMetrics::LogProfileSwitchGaia(ProfileMetrics::GAIA_OPT_IN); |
| 198 } |
189 } else if (cache.IsDefaultAvatarIconUrl(icon_url, &new_icon_index)) { | 199 } else if (cache.IsDefaultAvatarIconUrl(icon_url, &new_icon_index)) { |
190 PrefService* pref_service = profile->GetPrefs(); | 200 PrefService* pref_service = profile->GetPrefs(); |
191 ProfileMetrics::LogProfileAvatarSelection(new_icon_index); | 201 ProfileMetrics::LogProfileAvatarSelection(new_icon_index); |
192 // Updating the profile preference will cause the cache to be updated for | 202 // Updating the profile preference will cause the cache to be updated for |
193 // this preference. | 203 // this preference. |
194 pref_service->SetInteger(prefs::kProfileAvatarIndex, new_icon_index); | 204 pref_service->SetInteger(prefs::kProfileAvatarIndex, new_icon_index); |
195 cache.SetIsUsingGAIAPictureOfProfileAtIndex(profile_index, false); | 205 cache.SetIsUsingGAIAPictureOfProfileAtIndex(profile_index, false); |
196 } | 206 } |
197 | 207 |
198 ProfileMetrics::LogProfileUpdate(profile_file_path); | 208 ProfileMetrics::LogProfileUpdate(profile_file_path); |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
293 if (i == std::string::npos) | 303 if (i == std::string::npos) |
294 return; | 304 return; |
295 string16 gaia_name = cache.GetGAIANameOfProfileAtIndex(i); | 305 string16 gaia_name = cache.GetGAIANameOfProfileAtIndex(i); |
296 if (gaia_name.empty()) | 306 if (gaia_name.empty()) |
297 return; | 307 return; |
298 | 308 |
299 StringValue gaia_name_value(gaia_name); | 309 StringValue gaia_name_value(gaia_name); |
300 web_ui_->CallJavascriptFunction("ManageProfileOverlay.setProfileName", | 310 web_ui_->CallJavascriptFunction("ManageProfileOverlay.setProfileName", |
301 gaia_name_value); | 311 gaia_name_value); |
302 } | 312 } |
OLD | NEW |