diff options
author | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-08 17:38:30 +0000 |
---|---|---|
committer | brettw@chromium.org <brettw@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-10-08 17:38:30 +0000 |
commit | d0767cb54b2b5ee4d9cf00b3ee0fa585826b4036 (patch) | |
tree | 1c2ee733bf62a44c31dc11f76dad53243a84439f /chrome/browser | |
parent | e91d532339c854ff0a082c6562a519647524fa66 (diff) | |
download | chromium_src-d0767cb54b2b5ee4d9cf00b3ee0fa585826b4036.zip chromium_src-d0767cb54b2b5ee4d9cf00b3ee0fa585826b4036.tar.gz chromium_src-d0767cb54b2b5ee4d9cf00b3ee0fa585826b4036.tar.bz2 |
Separate out some more ICU from base and into base/i18n.
This moves string_util_icu. I moved the number formatting function into
base/i18n/number_formatting and just removed the other function in
string_util_icu which was TrimWhitespaceUTF8. It is only used in a few places
and isn't actually helpful (and the fact that it round-trips through UTF-16 is
better for the caller to see).
This takes out the sorting from the FileEnumerator. The comment says the
sorting is not guaranteed. I moved it into file_util_icu as a standalone
function for callers of FileEnumerator to call manually if they need sorted
results. I modified the directory lister to use this sorting instead, and filed
a bug on doing more optimal JS-based sorting.
TEST=none
BUG=none
Review URL: http://codereview.chromium.org/267001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@28405 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/autocomplete/autocomplete.cc | 15 | ||||
-rw-r--r-- | chrome/browser/browser_about_handler.cc | 5 | ||||
-rw-r--r-- | chrome/browser/download/download_item_model.cc | 10 | ||||
-rw-r--r-- | chrome/browser/download/save_package.cc | 3 | ||||
-rw-r--r-- | chrome/browser/net/url_fixer_upper.cc | 14 | ||||
-rw-r--r-- | chrome/browser/shell_integration_linux.cc | 1 | ||||
-rw-r--r-- | chrome/browser/task_manager.cc | 23 | ||||
-rw-r--r-- | chrome/browser/task_manager.h | 6 | ||||
-rw-r--r-- | chrome/browser/views/new_profile_dialog.cc | 4 |
9 files changed, 50 insertions, 31 deletions
diff --git a/chrome/browser/autocomplete/autocomplete.cc b/chrome/browser/autocomplete/autocomplete.cc index 6a2989e..47b3160 100644 --- a/chrome/browser/autocomplete/autocomplete.cc +++ b/chrome/browser/autocomplete/autocomplete.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -8,6 +8,7 @@ #include "app/l10n_util.h" #include "base/basictypes.h" +#include "base/i18n/number_formatting.h" #include "base/string_util.h" #include "chrome/browser/autocomplete/history_url_provider.h" #include "chrome/browser/autocomplete/history_contents_provider.h" @@ -879,12 +880,12 @@ void AutocompleteController::AddHistoryContentsShortcut() { } else { // We can report exact matches when there aren't too many. std::vector<size_t> content_param_offsets; - match.contents = - l10n_util::GetStringF(IDS_OMNIBOX_RECENT_HISTORY, - FormatNumber(history_contents_provider_-> - db_match_count()), - input_.text(), - &content_param_offsets); + match.contents = l10n_util::GetStringF( + IDS_OMNIBOX_RECENT_HISTORY, + UTF16ToWide(base::FormatNumber(history_contents_provider_-> + db_match_count())), + input_.text(), + &content_param_offsets); // content_param_offsets is ordered based on supplied params, we expect // that the second one contains the query (first is the number). diff --git a/chrome/browser/browser_about_handler.cc b/chrome/browser/browser_about_handler.cc index 5a907c5..9c07143 100644 --- a/chrome/browser/browser_about_handler.cc +++ b/chrome/browser/browser_about_handler.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -11,6 +11,7 @@ #include "app/resource_bundle.h" #include "base/file_version_info.h" #include "base/histogram.h" +#include "base/i18n/number_formatting.h" #include "base/path_service.h" #include "base/platform_thread.h" #include "base/stats_table.h" @@ -482,7 +483,7 @@ static void AddIntSyncDetail(ListValue* details, const std::wstring& stat_name, int64 stat_value) { DictionaryValue* val = new DictionaryValue; val->SetString(L"stat_name", stat_name); - val->SetString(L"stat_value", FormatNumber(stat_value)); + val->SetString(L"stat_value", UTF16ToWide(base::FormatNumber(stat_value))); details->Append(val); } diff --git a/chrome/browser/download/download_item_model.cc b/chrome/browser/download/download_item_model.cc index 3ac8d3d..cca2169 100644 --- a/chrome/browser/download/download_item_model.cc +++ b/chrome/browser/download/download_item_model.cc @@ -1,10 +1,11 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. #include "chrome/browser/download/download_item_model.h" #include "app/l10n_util.h" +#include "base/i18n/number_formatting.h" #include "base/string_util.h" #include "chrome/browser/download/download_manager.h" #include "chrome/browser/download/save_package.h" @@ -110,9 +111,10 @@ std::wstring SavePageModel::GetStatusText() { std::wstring status_text; switch (download_->state()) { case DownloadItem::IN_PROGRESS: - status_text = l10n_util::GetStringF(IDS_SAVE_PAGE_PROGRESS, - FormatNumber(size), - FormatNumber(total_size)); + status_text = l10n_util::GetStringF( + IDS_SAVE_PAGE_PROGRESS, + UTF16ToWide(base::FormatNumber(size)), + UTF16ToWide(base::FormatNumber(total_size))); break; case DownloadItem::COMPLETE: status_text = l10n_util::GetString(IDS_SAVE_PAGE_STATUS_COMPLETED); diff --git a/chrome/browser/download/save_package.cc b/chrome/browser/download/save_package.cc index 33c8bfb..1b9eaa9 100644 --- a/chrome/browser/download/save_package.cc +++ b/chrome/browser/download/save_package.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -6,6 +6,7 @@ #include "app/l10n_util.h" #include "base/file_util.h" +#include "base/i18n/file_util_icu.h" #include "base/logging.h" #include "base/message_loop.h" #include "base/stl_util-inl.h" diff --git a/chrome/browser/net/url_fixer_upper.cc b/chrome/browser/net/url_fixer_upper.cc index 498bd6c..b276e02 100644 --- a/chrome/browser/net/url_fixer_upper.cc +++ b/chrome/browser/net/url_fixer_upper.cc @@ -70,6 +70,20 @@ void UTF8PartsToWideParts(const string& text_utf8, UTF8ComponentToWideComponent(text_utf8, parts_utf8.ref); } +TrimPositions TrimWhitespaceUTF8(const std::string& input, + TrimPositions positions, + std::string* output) { + // This implementation is not so fast since it converts the text encoding + // twice. Please feel free to file a bug if this function hurts the + // performance of Chrome. + DCHECK(IsStringUTF8(input)); + std::wstring input_wide = UTF8ToWide(input); + std::wstring output_wide; + TrimPositions result = TrimWhitespace(input_wide, positions, &output_wide); + *output = WideToUTF8(output_wide); + return result; +} + } // namespace // does some basic fixes for input that we want to test for file-ness diff --git a/chrome/browser/shell_integration_linux.cc b/chrome/browser/shell_integration_linux.cc index 3034afb..93aed21 100644 --- a/chrome/browser/shell_integration_linux.cc +++ b/chrome/browser/shell_integration_linux.cc @@ -18,6 +18,7 @@ #include "base/eintr_wrapper.h" #include "base/file_path.h" #include "base/file_util.h" +#include "base/i18n/file_util_icu.h" #include "base/message_loop.h" #include "base/path_service.h" #include "base/process_util.h" diff --git a/chrome/browser/task_manager.cc b/chrome/browser/task_manager.cc index d01e94f..0af61ff 100644 --- a/chrome/browser/task_manager.cc +++ b/chrome/browser/task_manager.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -7,6 +7,7 @@ #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "base/compiler_specific.h" +#include "base/i18n/number_formatting.h" #include "base/process_util.h" #include "base/stats_table.h" #include "base/string_util.h" @@ -128,8 +129,7 @@ std::wstring TaskManagerModel::GetResourcePrivateMemory(int index) const { metrics_map_.find(resources_[index]->GetProcess()); DCHECK(iter != metrics_map_.end()); base::ProcessMetrics* process_metrics = iter->second; - std::wstring number = FormatNumber(GetPrivateMemory(process_metrics)); - return GetMemCellText(&number); + return GetMemCellText(GetPrivateMemory(process_metrics)); } std::wstring TaskManagerModel::GetResourceSharedMemory(int index) const { @@ -138,8 +138,7 @@ std::wstring TaskManagerModel::GetResourceSharedMemory(int index) const { metrics_map_.find(resources_[index]->GetProcess()); DCHECK(iter != metrics_map_.end()); base::ProcessMetrics* process_metrics = iter->second; - std::wstring number = FormatNumber(GetSharedMemory(process_metrics)); - return GetMemCellText(&number); + return GetMemCellText(GetSharedMemory(process_metrics)); } std::wstring TaskManagerModel::GetResourcePhysicalMemory(int index) const { @@ -148,8 +147,7 @@ std::wstring TaskManagerModel::GetResourcePhysicalMemory(int index) const { metrics_map_.find(resources_[index]->GetProcess()); DCHECK(iter != metrics_map_.end()); base::ProcessMetrics* process_metrics = iter->second; - std::wstring number = FormatNumber(GetPhysicalMemory(process_metrics)); - return GetMemCellText(&number); + return GetMemCellText(GetPhysicalMemory(process_metrics)); } std::wstring TaskManagerModel::GetResourceProcessId(int index) const { @@ -166,7 +164,7 @@ std::wstring TaskManagerModel::GetResourceStatsValue(int index, int col_id) std::wstring TaskManagerModel::GetResourceGoatsTeleported(int index) const { DCHECK(index < ResourceCount()); goats_teleported_ += rand() & 4095; - return FormatNumber(goats_teleported_); + return UTF16ToWide(base::FormatNumber(goats_teleported_)); } std::wstring TaskManagerModel::GetResourceWebCoreImageCacheSize( @@ -385,11 +383,12 @@ int TaskManagerModel::GetStatsValue(const TaskManager::Resource* resource, return 0; } -std::wstring TaskManagerModel::GetMemCellText( - std::wstring* number) const { +std::wstring TaskManagerModel::GetMemCellText(int64 number) const { + std::wstring str = UTF16ToWide(base::FormatNumber(number)); + // Adjust number string if necessary. - l10n_util::AdjustStringForLocaleDirection(*number, number); - return l10n_util::GetStringF(IDS_TASK_MANAGER_MEM_CELL_TEXT, *number); + l10n_util::AdjustStringForLocaleDirection(str, &str); + return l10n_util::GetStringF(IDS_TASK_MANAGER_MEM_CELL_TEXT, str); } void TaskManagerModel::StartUpdating() { diff --git a/chrome/browser/task_manager.h b/chrome/browser/task_manager.h index ff402a4..a4ece90 100644 --- a/chrome/browser/task_manager.h +++ b/chrome/browser/task_manager.h @@ -315,9 +315,9 @@ class TaskManagerModel : public URLRequestJobTracker::JobObserver, base::ProcessMetrics** proc_metrics1, base::ProcessMetrics** proc_metrics2) const; - // Given a string containing a number, this function returns the formatted - // string that should be displayed in the task manager's memory cell. - std::wstring GetMemCellText(std::wstring* number) const; + // Given a number, this function returns the formatted string that should be + // displayed in the task manager's memory cell. + std::wstring GetMemCellText(int64 number) const; // The list of providers to the task manager. They are ref counted. ResourceProviderList providers_; diff --git a/chrome/browser/views/new_profile_dialog.cc b/chrome/browser/views/new_profile_dialog.cc index c3b12bb..f0cfded 100644 --- a/chrome/browser/views/new_profile_dialog.cc +++ b/chrome/browser/views/new_profile_dialog.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2009 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -9,7 +9,7 @@ #include "app/l10n_util.h" #include "app/message_box_flags.h" #include "base/logging.h" -#include "base/file_util.h" +#include "base/i18n/file_util_icu.h" #include "chrome/browser/user_data_manager.h" #include "grit/chromium_strings.h" #include "grit/generated_resources.h" |