| OLD | NEW |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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_avatar_icon_util.h" | 5 #include "chrome/browser/profiles/profile_avatar_icon_util.h" |
| 6 | 6 |
| 7 #include <memory> | 7 #include <memory> |
| 8 #include <vector> | 8 #include <vector> |
| 9 | 9 |
| 10 #include "base/files/file_util.h" | 10 #include "base/files/file_util.h" |
| (...skipping 527 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 538 if (!file_name.empty()) { | 538 if (!file_name.empty()) { |
| 539 pos = old_path.find(file_name); | 539 pos = old_path.find(file_name); |
| 540 end = pos - 1; | 540 end = pos - 1; |
| 541 } | 541 } |
| 542 } | 542 } |
| 543 | 543 |
| 544 if (pos != std::string::npos) { | 544 if (pos != std::string::npos) { |
| 545 std::string new_path = old_path.substr(0, pos) + new_size_component + | 545 std::string new_path = old_path.substr(0, pos) + new_size_component + |
| 546 old_path.substr(end); | 546 old_path.substr(end); |
| 547 GURL::Replacements replacement; | 547 GURL::Replacements replacement; |
| 548 replacement.SetPathStr(new_path.c_str()); | 548 replacement.SetPathStr(new_path); |
| 549 *new_url = old_url.ReplaceComponents(replacement); | 549 *new_url = old_url.ReplaceComponents(replacement); |
| 550 return new_url->is_valid(); | 550 return new_url->is_valid(); |
| 551 } | 551 } |
| 552 | 552 |
| 553 // We can't set the image size, just use the default size. | 553 // We can't set the image size, just use the default size. |
| 554 *new_url = old_url; | 554 *new_url = old_url; |
| 555 return true; | 555 return true; |
| 556 } | 556 } |
| 557 | 557 |
| 558 std::unique_ptr<base::ListValue> GetDefaultProfileAvatarIconsAndLabels() { | 558 std::unique_ptr<base::ListValue> GetDefaultProfileAvatarIconsAndLabels() { |
| 559 std::unique_ptr<base::ListValue> avatars(new base::ListValue()); | 559 std::unique_ptr<base::ListValue> avatars(new base::ListValue()); |
| 560 | 560 |
| 561 const size_t placeholder_avatar_index = profiles::GetPlaceholderAvatarIndex(); | 561 const size_t placeholder_avatar_index = profiles::GetPlaceholderAvatarIndex(); |
| 562 for (size_t i = 0; i < profiles::GetDefaultAvatarIconCount() && | 562 for (size_t i = 0; i < profiles::GetDefaultAvatarIconCount() && |
| 563 i != placeholder_avatar_index; | 563 i != placeholder_avatar_index; |
| 564 ++i) { | 564 ++i) { |
| 565 std::unique_ptr<base::DictionaryValue> avatar_info( | 565 std::unique_ptr<base::DictionaryValue> avatar_info( |
| 566 new base::DictionaryValue()); | 566 new base::DictionaryValue()); |
| 567 avatar_info->SetString("url", profiles::GetDefaultAvatarIconUrl(i)); | 567 avatar_info->SetString("url", profiles::GetDefaultAvatarIconUrl(i)); |
| 568 avatar_info->SetString( | 568 avatar_info->SetString( |
| 569 "label", l10n_util::GetStringUTF16( | 569 "label", l10n_util::GetStringUTF16( |
| 570 profiles::GetDefaultAvatarLabelResourceIDAtIndex(i))); | 570 profiles::GetDefaultAvatarLabelResourceIDAtIndex(i))); |
| 571 | 571 |
| 572 avatars->Append(std::move(avatar_info)); | 572 avatars->Append(std::move(avatar_info)); |
| 573 } | 573 } |
| 574 return avatars; | 574 return avatars; |
| 575 } | 575 } |
| 576 | 576 |
| 577 } // namespace profiles | 577 } // namespace profiles |
| OLD | NEW |