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/profile_info_cache.h" | 5 #include "chrome/browser/profiles/profile_info_cache.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/files/file_util.h" | 8 #include "base/files/file_util.h" |
9 #include "base/i18n/case_conversion.h" | 9 #include "base/i18n/case_conversion.h" |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
(...skipping 453 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
464 std::string icon_url; | 464 std::string icon_url; |
465 GetInfoForProfileAtIndex(index)->GetString(kAvatarIconKey, &icon_url); | 465 GetInfoForProfileAtIndex(index)->GetString(kAvatarIconKey, &icon_url); |
466 size_t icon_index = 0; | 466 size_t icon_index = 0; |
467 if (!profiles::IsDefaultAvatarIconUrl(icon_url, &icon_index)) | 467 if (!profiles::IsDefaultAvatarIconUrl(icon_url, &icon_index)) |
468 DLOG(WARNING) << "Unknown avatar icon: " << icon_url; | 468 DLOG(WARNING) << "Unknown avatar icon: " << icon_url; |
469 | 469 |
470 return icon_index; | 470 return icon_index; |
471 } | 471 } |
472 | 472 |
473 void ProfileInfoCache::SetProfileActiveTimeAtIndex(size_t index) { | 473 void ProfileInfoCache::SetProfileActiveTimeAtIndex(size_t index) { |
| 474 if (base::Time::Now() - GetProfileActiveTimeAtIndex(index) < |
| 475 base::TimeDelta::FromHours(1)) { |
| 476 return; |
| 477 } |
| 478 |
474 scoped_ptr<base::DictionaryValue> info( | 479 scoped_ptr<base::DictionaryValue> info( |
475 GetInfoForProfileAtIndex(index)->DeepCopy()); | 480 GetInfoForProfileAtIndex(index)->DeepCopy()); |
476 info->SetDouble(kActiveTimeKey, base::Time::Now().ToDoubleT()); | 481 info->SetDouble(kActiveTimeKey, base::Time::Now().ToDoubleT()); |
477 // This takes ownership of |info|. | 482 // This takes ownership of |info|. |
478 SetInfoForProfileAtIndex(index, info.release()); | 483 SetInfoForProfileAtIndex(index, info.release()); |
479 } | 484 } |
480 | 485 |
481 void ProfileInfoCache::SetNameOfProfileAtIndex(size_t index, | 486 void ProfileInfoCache::SetNameOfProfileAtIndex(size_t index, |
482 const base::string16& name) { | 487 const base::string16& name) { |
483 scoped_ptr<base::DictionaryValue> info( | 488 scoped_ptr<base::DictionaryValue> info( |
(...skipping 690 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1174 std::vector<base::FilePath>::const_iterator it; | 1179 std::vector<base::FilePath>::const_iterator it; |
1175 for (it = profiles_to_rename.begin(); it != profiles_to_rename.end(); ++it) { | 1180 for (it = profiles_to_rename.begin(); it != profiles_to_rename.end(); ++it) { |
1176 size_t profile_index = GetIndexOfProfileWithPath(*it); | 1181 size_t profile_index = GetIndexOfProfileWithPath(*it); |
1177 SetProfileIsUsingDefaultNameAtIndex(profile_index, true); | 1182 SetProfileIsUsingDefaultNameAtIndex(profile_index, true); |
1178 // This will assign a new "Person %d" type name and re-sort the cache. | 1183 // This will assign a new "Person %d" type name and re-sort the cache. |
1179 SetNameOfProfileAtIndex(profile_index, ChooseNameForNewProfile( | 1184 SetNameOfProfileAtIndex(profile_index, ChooseNameForNewProfile( |
1180 GetAvatarIconIndexOfProfileAtIndex(profile_index))); | 1185 GetAvatarIconIndexOfProfileAtIndex(profile_index))); |
1181 } | 1186 } |
1182 #endif | 1187 #endif |
1183 } | 1188 } |
OLD | NEW |