Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(52)

Side by Side Diff: chrome/browser/profiles/profile_attributes_storage.cc

Issue 2002783002: Use plural formats and native digits (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: plural: use "=1" instead of "one" for pop-up block infobar Created 4 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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_attributes_storage.h" 5 #include "chrome/browser/profiles/profile_attributes_storage.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/i18n/number_formatting.h"
9 #include "base/i18n/string_compare.h" 10 #include "base/i18n/string_compare.h"
10 #include "base/rand_util.h" 11 #include "base/rand_util.h"
11 #include "base/strings/string_number_conversions.h" 12 #include "base/strings/string_number_conversions.h"
12 #include "base/strings/utf_string_conversions.h" 13 #include "base/strings/utf_string_conversions.h"
13 #include "chrome/browser/profiles/profile_avatar_icon_util.h" 14 #include "chrome/browser/profiles/profile_avatar_icon_util.h"
14 #include "chrome/grit/generated_resources.h" 15 #include "chrome/grit/generated_resources.h"
15 #include "third_party/icu/source/i18n/unicode/coll.h" 16 #include "third_party/icu/source/i18n/unicode/coll.h"
16 #include "ui/base/l10n/l10n_util.h" 17 #include "ui/base/l10n/l10n_util.h"
17 18
18 namespace { 19 namespace {
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
113 std::sort(ret.begin(), ret.end(), 114 std::sort(ret.begin(), ret.end(),
114 ProfileAttributesSortComparator(collator.get())); 115 ProfileAttributesSortComparator(collator.get()));
115 return ret; 116 return ret;
116 } 117 }
117 118
118 base::string16 ProfileAttributesStorage::ChooseNameForNewProfile( 119 base::string16 ProfileAttributesStorage::ChooseNameForNewProfile(
119 size_t icon_index) const { 120 size_t icon_index) const {
120 base::string16 name; 121 base::string16 name;
121 for (int name_index = 1; ; ++name_index) { 122 for (int name_index = 1; ; ++name_index) {
122 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID) 123 #if !defined(OS_CHROMEOS) && !defined(OS_ANDROID)
123 name = l10n_util::GetStringFUTF16Int(IDS_NEW_NUMBERED_PROFILE_NAME, 124 // Using native digits will break IsDefaultProfileName() below because
124 name_index); 125 // it uses sscanf.
126 // TODO(jshin): fix IsDefaultProfileName to handle native digits.
127 name = l10n_util::GetStringFUTF16(IDS_NEW_NUMBERED_PROFILE_NAME,
128 base::IntToString16(name_index));
125 #else 129 #else
126 if (icon_index < profiles::GetGenericAvatarIconCount()) { 130 if (icon_index < profiles::GetGenericAvatarIconCount()) {
127 name = l10n_util::GetStringFUTF16Int(IDS_NUMBERED_PROFILE_NAME, 131 name = l10n_util::GetStringFUTF16Int(IDS_NUMBERED_PROFILE_NAME,
128 name_index); 132 name_index);
129 } else { 133 } else {
134 // TODO(jshin): Check with UX if appending |name_index| to the default
135 // name without a space is intended.
130 name = l10n_util::GetStringUTF16( 136 name = l10n_util::GetStringUTF16(
131 kDefaultNames[icon_index - profiles::GetGenericAvatarIconCount()]); 137 kDefaultNames[icon_index - profiles::GetGenericAvatarIconCount()]);
132 if (name_index > 1) 138 if (name_index > 1)
133 name.append(base::UTF8ToUTF16(base::IntToString(name_index))); 139 name.append(base::FormatNumber(name_index));
134 } 140 }
135 #endif 141 #endif
136 142
137 // Loop through previously named profiles to ensure we're not duplicating. 143 // Loop through previously named profiles to ensure we're not duplicating.
138 std::vector<ProfileAttributesEntry*> entries = 144 std::vector<ProfileAttributesEntry*> entries =
139 const_cast<ProfileAttributesStorage*>(this)->GetAllProfilesAttributes(); 145 const_cast<ProfileAttributesStorage*>(this)->GetAllProfilesAttributes();
140 146
141 if (std::none_of(entries.begin(), entries.end(), 147 if (std::none_of(entries.begin(), entries.end(),
142 [name](ProfileAttributesEntry* entry) { 148 [name](ProfileAttributesEntry* entry) {
143 return entry->GetName() == name; 149 return entry->GetName() == name;
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
191 if (GetRandomAvatarIconIndex(true, true, used_icon_indices, &icon_index)) 197 if (GetRandomAvatarIconIndex(true, true, used_icon_indices, &icon_index))
192 return icon_index; 198 return icon_index;
193 199
194 // Settle for any random icon, even if it's not already used. 200 // Settle for any random icon, even if it's not already used.
195 if (GetRandomAvatarIconIndex(true, false, used_icon_indices, &icon_index)) 201 if (GetRandomAvatarIconIndex(true, false, used_icon_indices, &icon_index))
196 return icon_index; 202 return icon_index;
197 203
198 NOTREACHED(); 204 NOTREACHED();
199 return 0; 205 return 0;
200 } 206 }
OLDNEW
« no previous file with comments | « chrome/browser/media/native_desktop_media_list.cc ('k') | chrome/browser/resources/history/history.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698