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/character_encoding.h" | 5 #include "chrome/browser/character_encoding.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <set> | 8 #include <set> |
9 | 9 |
10 #include "base/logging.h" | 10 #include "base/logging.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "base/string_tokenizer.h" | |
13 #include "base/string_util.h" | 12 #include "base/string_util.h" |
13 #include "base/strings/string_tokenizer.h" | |
viettrungluu
2013/02/01 17:54:15
...
| |
14 #include "base/utf_string_conversions.h" | 14 #include "base/utf_string_conversions.h" |
15 #include "chrome/app/chrome_command_ids.h" | 15 #include "chrome/app/chrome_command_ids.h" |
16 #include "content/public/browser/browser_thread.h" | 16 #include "content/public/browser/browser_thread.h" |
17 #include "grit/generated_resources.h" | 17 #include "grit/generated_resources.h" |
18 #include "third_party/icu/public/common/unicode/ucnv.h" | 18 #include "third_party/icu/public/common/unicode/ucnv.h" |
19 #include "ui/base/l10n/l10n_util.h" | 19 #include "ui/base/l10n/l10n_util.h" |
20 #include "ui/base/l10n/l10n_util_collator.h" | 20 #include "ui/base/l10n/l10n_util_collator.h" |
21 | 21 |
22 using content::BrowserThread; | 22 using content::BrowserThread; |
23 | 23 |
(...skipping 210 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
234 | 234 |
235 const int kDefaultEncodingMenusLength = arraysize(kDefaultEncodingMenus); | 235 const int kDefaultEncodingMenusLength = arraysize(kDefaultEncodingMenus); |
236 | 236 |
237 // Parse the input |encoding_list| which is a encoding list separated with | 237 // Parse the input |encoding_list| which is a encoding list separated with |
238 // comma, get available encoding ids and save them to |available_list|. | 238 // comma, get available encoding ids and save them to |available_list|. |
239 // The parameter |maximum_size| indicates maximum size of encoding items we | 239 // The parameter |maximum_size| indicates maximum size of encoding items we |
240 // want to get from the |encoding_list|. | 240 // want to get from the |encoding_list|. |
241 void ParseEncodingListSeparatedWithComma( | 241 void ParseEncodingListSeparatedWithComma( |
242 const std::string& encoding_list, std::vector<int>* const available_list, | 242 const std::string& encoding_list, std::vector<int>* const available_list, |
243 size_t maximum_size) { | 243 size_t maximum_size) { |
244 StringTokenizer tokenizer(encoding_list, ","); | 244 base::StringTokenizer tokenizer(encoding_list, ","); |
245 while (tokenizer.GetNext()) { | 245 while (tokenizer.GetNext()) { |
246 int id = CharacterEncoding::GetCommandIdByCanonicalEncodingName( | 246 int id = CharacterEncoding::GetCommandIdByCanonicalEncodingName( |
247 tokenizer.token()); | 247 tokenizer.token()); |
248 // Ignore invalid encoding. | 248 // Ignore invalid encoding. |
249 if (!id) | 249 if (!id) |
250 continue; | 250 continue; |
251 available_list->push_back(id); | 251 available_list->push_back(id); |
252 if (available_list->size() == maximum_size) | 252 if (available_list->size() == maximum_size) |
253 return; | 253 return; |
254 } | 254 } |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
537 // Insert new encoding to head of selected encoding list. | 537 // Insert new encoding to head of selected encoding list. |
538 *selected_encodings = encoding_name; | 538 *selected_encodings = encoding_name; |
539 // Generate the string for rest selected encoding list. | 539 // Generate the string for rest selected encoding list. |
540 for (std::vector<int>::const_iterator it = selected_encoding_list.begin(); | 540 for (std::vector<int>::const_iterator it = selected_encoding_list.begin(); |
541 it != selected_encoding_list.end(); ++it) { | 541 it != selected_encoding_list.end(); ++it) { |
542 selected_encodings->append(1, L','); | 542 selected_encodings->append(1, L','); |
543 selected_encodings->append(GetCanonicalEncodingNameByCommandId(*it)); | 543 selected_encodings->append(GetCanonicalEncodingNameByCommandId(*it)); |
544 } | 544 } |
545 return true; | 545 return true; |
546 } | 546 } |
OLD | NEW |