diff options
author | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-30 00:50:04 +0000 |
---|---|---|
committer | avi@chromium.org <avi@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-30 00:50:04 +0000 |
commit | bdaab67c485eee51a098c7b34544c5d18bf725af (patch) | |
tree | 31e0c087b57c538ef91b6598040f2b7f2293505d | |
parent | fbc7678b2f73707962861c99eb4c809604ddd611 (diff) | |
download | chromium_src-bdaab67c485eee51a098c7b34544c5d18bf725af.zip chromium_src-bdaab67c485eee51a098c7b34544c5d18bf725af.tar.gz chromium_src-bdaab67c485eee51a098c7b34544c5d18bf725af.tar.bz2 |
Remove wstring from TableModel.
BUG=23581
TEST=no visible changes; all tests pass
Review URL: http://codereview.chromium.org/6044007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@70290 0039d316-1c4b-4281-b951-d872f2087c98
48 files changed, 295 insertions, 303 deletions
diff --git a/app/table_model.cc b/app/table_model.cc index 4ce5ebb..8a6176e 100644 --- a/app/table_model.cc +++ b/app/table_model.cc @@ -21,7 +21,7 @@ TableColumn::TableColumn() sortable(false) { } -TableColumn::TableColumn(int id, const std::wstring& title, +TableColumn::TableColumn(int id, const string16& title, Alignment alignment, int width) : id(id), @@ -33,7 +33,7 @@ TableColumn::TableColumn(int id, const std::wstring& title, sortable(false) { } -TableColumn::TableColumn(int id, const std::wstring& title, +TableColumn::TableColumn(int id, const string16& title, Alignment alignment, int width, float percent) : id(id), title(title), @@ -54,7 +54,7 @@ TableColumn::TableColumn(int id, Alignment alignment, int width) percent(0), min_visible_width(0), sortable(false) { - title = UTF16ToWide(l10n_util::GetStringUTF16(id)); + title = l10n_util::GetStringUTF16(id); } TableColumn::TableColumn(int id, Alignment alignment, int width, float percent) @@ -64,7 +64,7 @@ TableColumn::TableColumn(int id, Alignment alignment, int width, float percent) percent(percent), min_visible_width(0), sortable(false) { - title = UTF16ToWide(l10n_util::GetStringUTF16(id)); + title = l10n_util::GetStringUTF16(id); } // TableModel ----------------------------------------------------------------- @@ -76,8 +76,8 @@ SkBitmap TableModel::GetIcon(int row) { return SkBitmap(); } -std::wstring TableModel::GetTooltip(int row) { - return std::wstring(); +string16 TableModel::GetTooltip(int row) { + return string16(); } bool TableModel::ShouldIndent(int row) { @@ -105,12 +105,12 @@ int TableModel::GetGroupID(int row) { int TableModel::CompareValues(int row1, int row2, int column_id) { DCHECK(row1 >= 0 && row1 < RowCount() && row2 >= 0 && row2 < RowCount()); - std::wstring value1 = GetText(row1, column_id); - std::wstring value2 = GetText(row2, column_id); + string16 value1 = GetText(row1, column_id); + string16 value2 = GetText(row2, column_id); icu::Collator* collator = GetCollator(); if (collator) - return l10n_util::CompareStringWithCollator(collator, value1, value2); + return l10n_util::CompareString16WithCollator(collator, value1, value2); NOTREACHED(); return 0; diff --git a/app/table_model.h b/app/table_model.h index 78dedf1..76f50b8 100644 --- a/app/table_model.h +++ b/app/table_model.h @@ -6,9 +6,9 @@ #define APP_TABLE_MODEL_H_ #pragma once -#include <string> #include <vector> +#include "base/string16.h" #include "unicode/coll.h" class SkBitmap; @@ -21,7 +21,7 @@ class TableModel { // See HasGroups, get GetGroupID for details as to how this is used. struct Group { // The title text for the group. - std::wstring title; + string16 title; // Unique id for the group. int id; @@ -32,7 +32,7 @@ class TableModel { virtual int RowCount() = 0; // Returns the value at a particular location in text. - virtual std::wstring GetText(int row, int column_id) = 0; + virtual string16 GetText(int row, int column_id) = 0; // Returns the small icon (16x16) that should be displayed in the first // column before the text. This is only used when the TableView was created @@ -43,7 +43,7 @@ class TableModel { // Returns the tooltip, if any, to show for a particular row. If there are // multiple columns in the row, this will only be shown when hovering over // column zero. - virtual std::wstring GetTooltip(int row); + virtual string16 GetTooltip(int row); // If true, this row should be indented. virtual bool ShouldIndent(int row); @@ -93,9 +93,9 @@ struct TableColumn { }; TableColumn(); - TableColumn(int id, const std::wstring& title, + TableColumn(int id, const string16& title, Alignment alignment, int width); - TableColumn(int id, const std::wstring& title, + TableColumn(int id, const string16& title, Alignment alignment, int width, float percent); // It's common (but not required) to use the title's IDS_* tag as the column @@ -108,7 +108,7 @@ struct TableColumn { int id; // The title for the column. - std::wstring title; + string16 title; // Alignment for the content. Alignment alignment; diff --git a/chrome/browser/chromeos/options/language_config_view.cc b/chrome/browser/chromeos/options/language_config_view.cc index 5646f9a..2e5e56c 100644 --- a/chrome/browser/chromeos/options/language_config_view.cc +++ b/chrome/browser/chromeos/options/language_config_view.cc @@ -236,14 +236,14 @@ void LanguageConfigView::OnSelectionChanged() { right_container_->Layout(); } -std::wstring LanguageConfigView::GetText(int row, int column_id) { +string16 LanguageConfigView::GetText(int row, int column_id) { if (row >= 0 && row < static_cast<int>( model_.num_preferred_language_codes())) { - return UTF16ToWide(input_method::GetLanguageDisplayNameFromCode( - model_.preferred_language_code_at(row))); + return input_method::GetLanguageDisplayNameFromCode( + model_.preferred_language_code_at(row)); } NOTREACHED(); - return L""; + return string16(); } void LanguageConfigView::SetObserver(TableModelObserver* observer) { @@ -413,7 +413,7 @@ views::View* LanguageConfigView::CreateContentsOnLeft() { // Create the language table. std::vector<TableColumn> columns; TableColumn column(0, - l10n_util::GetString( + l10n_util::GetStringUTF16( IDS_OPTIONS_SETTINGS_LANGUAGES_LANGUAGES), TableColumn::LEFT, -1, 0); columns.push_back(column); diff --git a/chrome/browser/chromeos/options/language_config_view.h b/chrome/browser/chromeos/options/language_config_view.h index a7dd980..f625f03 100644 --- a/chrome/browser/chromeos/options/language_config_view.h +++ b/chrome/browser/chromeos/options/language_config_view.h @@ -11,6 +11,7 @@ #include <string> #include "app/table_model.h" +#include "base/compiler_specific.h" #include "chrome/browser/chromeos/options/language_config_model.h" #include "chrome/browser/views/options/options_page_view.h" #include "views/controls/button/native_button.h" @@ -64,9 +65,9 @@ class LanguageConfigView : public TableModel, // LanguageConfigView class, rather than a separate class. // TODO(satorux): Implement TableModel as a separate class once the bug // is fixed. - virtual std::wstring GetText(int row, int column_id); - virtual void SetObserver(TableModelObserver* observer); - virtual int RowCount(); + virtual string16 GetText(int row, int column_id) OVERRIDE; + virtual void SetObserver(TableModelObserver* observer) OVERRIDE; + virtual int RowCount() OVERRIDE; // views::Combobox::Listener overrides: virtual void ItemChanged(views::Combobox* combobox, diff --git a/chrome/browser/content_exceptions_table_model.cc b/chrome/browser/content_exceptions_table_model.cc index dad02b9..6eecfaa 100644 --- a/chrome/browser/content_exceptions_table_model.cc +++ b/chrome/browser/content_exceptions_table_model.cc @@ -100,27 +100,23 @@ int ContentExceptionsTableModel::RowCount() { return static_cast<int>(entries_.size() + off_the_record_entries_.size()); } -std::wstring ContentExceptionsTableModel::GetText(int row, int column_id) { +string16 ContentExceptionsTableModel::GetText(int row, int column_id) { HostContentSettingsMap::PatternSettingPair entry = entry_at(row); switch (column_id) { case IDS_EXCEPTIONS_PATTERN_HEADER: - return UTF8ToWide(entry.first.AsString()); + return UTF8ToUTF16(entry.first.AsString()); case IDS_EXCEPTIONS_ACTION_HEADER: switch (entry.second) { case CONTENT_SETTING_ALLOW: - return UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ALLOW_BUTTON)); + return l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ALLOW_BUTTON); case CONTENT_SETTING_BLOCK: - return UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON)); + return l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON); case CONTENT_SETTING_ASK: - return UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ASK_BUTTON)); + return l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ASK_BUTTON); case CONTENT_SETTING_SESSION_ONLY: - return UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_EXCEPTIONS_SESSION_ONLY_BUTTON)); + return l10n_util::GetStringUTF16(IDS_EXCEPTIONS_SESSION_ONLY_BUTTON); default: NOTREACHED(); } @@ -130,7 +126,7 @@ std::wstring ContentExceptionsTableModel::GetText(int row, int column_id) { NOTREACHED(); } - return std::wstring(); + return string16(); } void ContentExceptionsTableModel::SetObserver(TableModelObserver* observer) { diff --git a/chrome/browser/content_exceptions_table_model.h b/chrome/browser/content_exceptions_table_model.h index e01250b7..a8371fe 100644 --- a/chrome/browser/content_exceptions_table_model.h +++ b/chrome/browser/content_exceptions_table_model.h @@ -9,6 +9,7 @@ #include <string> #include "app/table_model.h" +#include "base/compiler_specific.h" #include "base/ref_counted.h" #include "chrome/common/content_settings.h" #include "chrome/common/content_settings_types.h" @@ -53,9 +54,9 @@ class ContentExceptionsTableModel : public TableModel { bool is_off_the_record); // TableModel overrides: - virtual int RowCount(); - virtual std::wstring GetText(int row, int column_id); - virtual void SetObserver(TableModelObserver* observer); + virtual int RowCount() OVERRIDE; + virtual string16 GetText(int row, int column_id) OVERRIDE; + virtual void SetObserver(TableModelObserver* observer) OVERRIDE; private: HostContentSettingsMap* map(bool is_off_the_record) { diff --git a/chrome/browser/custom_home_pages_table_model.cc b/chrome/browser/custom_home_pages_table_model.cc index 5ada027..f63cf79 100644 --- a/chrome/browser/custom_home_pages_table_model.cc +++ b/chrome/browser/custom_home_pages_table_model.cc @@ -30,7 +30,7 @@ struct CustomHomePagesTableModel::Entry { GURL url; // Page title. If this is empty, we'll display the URL as the entry. - std::wstring title; + string16 title; // Icon for the page. SkBitmap icon; @@ -130,7 +130,7 @@ int CustomHomePagesTableModel::RowCount() { return static_cast<int>(entries_.size()); } -std::wstring CustomHomePagesTableModel::GetText(int row, int column_id) { +string16 CustomHomePagesTableModel::GetText(int row, int column_id) { DCHECK(column_id == 0); DCHECK(row >= 0 && row < RowCount()); return entries_[row].title.empty() ? FormattedURL(row) : entries_[row].title; @@ -141,11 +141,10 @@ SkBitmap CustomHomePagesTableModel::GetIcon(int row) { return entries_[row].icon.isNull() ? *default_favicon_ : entries_[row].icon; } -std::wstring CustomHomePagesTableModel::GetTooltip(int row) { - return entries_[row].title.empty() ? std::wstring() : UTF16ToWideHack( +string16 CustomHomePagesTableModel::GetTooltip(int row) { + return entries_[row].title.empty() ? string16() : l10n_util::GetStringFUTF16(IDS_OPTIONS_STARTUP_PAGE_TOOLTIP, - WideToUTF16Hack(entries_[row].title), - WideToUTF16Hack(FormattedURL(row)))); + entries_[row].title, FormattedURL(row)); } void CustomHomePagesTableModel::SetObserver(TableModelObserver* observer) { @@ -182,7 +181,7 @@ void CustomHomePagesTableModel::OnGotTitle(HistoryService::Handle handle, } entry->title_handle = 0; if (found_url && !row->title().empty()) { - entry->title = UTF16ToWide(row->title()); + entry->title = row->title(); if (observer_) observer_->OnItemsChanged(static_cast<int>(entry_index), 1); } @@ -233,10 +232,10 @@ CustomHomePagesTableModel::Entry* return NULL; } -std::wstring CustomHomePagesTableModel::FormattedURL(int row) const { +string16 CustomHomePagesTableModel::FormattedURL(int row) const { std::string languages = profile_->GetPrefs()->GetString(prefs::kAcceptLanguages); string16 url = net::FormatUrl(entries_[row].url, languages); url = base::i18n::GetDisplayStringInLTRDirectionality(url); - return UTF16ToWide(url); + return url; } diff --git a/chrome/browser/custom_home_pages_table_model.h b/chrome/browser/custom_home_pages_table_model.h index 4115daa..6699fc1 100644 --- a/chrome/browser/custom_home_pages_table_model.h +++ b/chrome/browser/custom_home_pages_table_model.h @@ -10,6 +10,7 @@ #include <vector> #include "app/table_model.h" +#include "base/compiler_specific.h" #include "chrome/browser/history/history.h" #include "chrome/browser/favicon_service.h" @@ -43,11 +44,11 @@ class CustomHomePagesTableModel : public TableModel { std::vector<GURL> GetURLs(); // TableModel overrides: - virtual int RowCount(); - virtual std::wstring GetText(int row, int column_id); - virtual SkBitmap GetIcon(int row); - virtual std::wstring GetTooltip(int row); - virtual void SetObserver(TableModelObserver* observer); + virtual int RowCount() OVERRIDE; + virtual string16 GetText(int row, int column_id) OVERRIDE; + virtual SkBitmap GetIcon(int row) OVERRIDE; + virtual string16 GetTooltip(int row) OVERRIDE; + virtual void SetObserver(TableModelObserver* observer) OVERRIDE; private: // Each item in the model is represented as an Entry. Entry stores the URL, @@ -84,7 +85,7 @@ class CustomHomePagesTableModel : public TableModel { int* entry_index); // Returns the URL for a particular row, formatted for display to the user. - std::wstring FormattedURL(int row) const; + string16 FormattedURL(int row) const; // Set of entries we're showing. std::vector<Entry> entries_; diff --git a/chrome/browser/dom_ui/options/add_startup_page_handler.cc b/chrome/browser/dom_ui/options/add_startup_page_handler.cc index e76da33..33b2326 100644 --- a/chrome/browser/dom_ui/options/add_startup_page_handler.cc +++ b/chrome/browser/dom_ui/options/add_startup_page_handler.cc @@ -75,10 +75,9 @@ void AddStartupPageHandler::OnModelChanged() { ListValue pages; for (int i = 0; i < url_table_model_->RowCount(); ++i) { DictionaryValue* dict = new DictionaryValue(); - dict->SetString("title", WideToUTF16Hack(url_table_model_->GetText( - i, IDS_ASI_PAGE_COLUMN))); - dict->SetString("displayURL", WideToUTF16Hack(url_table_model_->GetText( - i, IDS_ASI_URL_COLUMN))); + dict->SetString("title", url_table_model_->GetText(i, IDS_ASI_PAGE_COLUMN)); + dict->SetString("displayURL", + url_table_model_->GetText(i, IDS_ASI_URL_COLUMN)); dict->SetString("url", url_table_model_->GetURL(i).spec()); pages.Append(dict); } diff --git a/chrome/browser/dom_ui/options/browser_options_handler.cc b/chrome/browser/dom_ui/options/browser_options_handler.cc index 863b461..6d9a9620 100644 --- a/chrome/browser/dom_ui/options/browser_options_handler.cc +++ b/chrome/browser/dom_ui/options/browser_options_handler.cc @@ -281,11 +281,10 @@ void BrowserOptionsHandler::OnModelChanged() { std::vector<GURL> urls = startup_custom_pages_table_model_->GetURLs(); for (int i = 0; i < page_count; ++i) { DictionaryValue* entry = new DictionaryValue(); - entry->SetString("title", WideToUTF16Hack( - startup_custom_pages_table_model_->GetText(i, 0))); + entry->SetString("title", startup_custom_pages_table_model_->GetText(i, 0)); entry->SetString("url", urls[i].spec()); - entry->SetString("tooltip", WideToUTF16Hack( - startup_custom_pages_table_model_->GetTooltip(i))); + entry->SetString("tooltip", + startup_custom_pages_table_model_->GetTooltip(i)); startup_pages.Append(entry); } diff --git a/chrome/browser/dom_ui/options/search_engine_manager_handler.cc b/chrome/browser/dom_ui/options/search_engine_manager_handler.cc index 25ce098..78c8cd3 100644 --- a/chrome/browser/dom_ui/options/search_engine_manager_handler.cc +++ b/chrome/browser/dom_ui/options/search_engine_manager_handler.cc @@ -156,7 +156,7 @@ DictionaryValue* SearchEngineManagerHandler::CreateDictionaryForHeading( TableModel::Groups groups = list_controller_->table_model()->GetGroups(); DictionaryValue* dict = new DictionaryValue(); - dict->SetString("heading", WideToUTF16Hack(groups[group_index].title)); + dict->SetString("heading", groups[group_index].title); return dict; } @@ -165,10 +165,10 @@ DictionaryValue* SearchEngineManagerHandler::CreateDictionaryForEngine( TemplateURLTableModel* table_model = list_controller_->table_model(); DictionaryValue* dict = new DictionaryValue(); - dict->SetString("name", WideToUTF16Hack(table_model->GetText( - index, IDS_SEARCH_ENGINES_EDITOR_DESCRIPTION_COLUMN))); - dict->SetString("keyword", WideToUTF16Hack(table_model->GetText( - index, IDS_SEARCH_ENGINES_EDITOR_KEYWORD_COLUMN))); + dict->SetString("name", table_model->GetText( + index, IDS_SEARCH_ENGINES_EDITOR_DESCRIPTION_COLUMN)); + dict->SetString("keyword", table_model->GetText( + index, IDS_SEARCH_ENGINES_EDITOR_KEYWORD_COLUMN)); const TemplateURL* template_url = list_controller_->GetTemplateURL(index); GURL icon_url = template_url->GetFavIconURL(); if (icon_url.is_valid()) diff --git a/chrome/browser/geolocation/geolocation_exceptions_table_model.cc b/chrome/browser/geolocation/geolocation_exceptions_table_model.cc index 731ac3f7..9bd57fe 100644 --- a/chrome/browser/geolocation/geolocation_exceptions_table_model.cc +++ b/chrome/browser/geolocation/geolocation_exceptions_table_model.cc @@ -138,50 +138,45 @@ int GeolocationExceptionsTableModel::RowCount() { return entries_.size(); } -std::wstring GeolocationExceptionsTableModel::GetText(int row, - int column_id) { +string16 GeolocationExceptionsTableModel::GetText(int row, + int column_id) { const Entry& entry = entries_[row]; if (column_id == IDS_EXCEPTIONS_HOSTNAME_HEADER) { if (entry.origin == entry.embedding_origin) { - return content_settings_helper::OriginToWString(entry.origin); + return content_settings_helper::OriginToString16(entry.origin); } - std::wstring indent(L" "); + string16 indent(ASCIIToUTF16(" ")); if (entry.embedding_origin.is_empty()) { // NOTE: As long as the user cannot add/edit entries from the exceptions // dialog, it's impossible to actually have a non-default setting for some // origin "embedded on any other site", so this row will never appear. If // we add the ability to add/edit exceptions, we'll need to decide when to // display this and how "removing" it will function. - return indent + UTF16ToWideHack(l10n_util::GetStringUTF16( - IDS_EXCEPTIONS_GEOLOCATION_EMBEDDED_ANY_OTHER)); + return indent + l10n_util::GetStringUTF16( + IDS_EXCEPTIONS_GEOLOCATION_EMBEDDED_ANY_OTHER); } - return indent + UTF16ToWideHack(l10n_util::GetStringFUTF16( + return indent + l10n_util::GetStringFUTF16( IDS_EXCEPTIONS_GEOLOCATION_EMBEDDED_ON_HOST, - WideToUTF16Hack( - content_settings_helper::OriginToWString(entry.embedding_origin)))); + content_settings_helper::OriginToString16(entry.embedding_origin)); } if (column_id == IDS_EXCEPTIONS_ACTION_HEADER) { switch (entry.setting) { case CONTENT_SETTING_ALLOW: - return UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ALLOW_BUTTON)); + return l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ALLOW_BUTTON); case CONTENT_SETTING_BLOCK: - return UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON)); + return l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON); case CONTENT_SETTING_ASK: - return UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ASK_BUTTON)); + return l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ASK_BUTTON); case CONTENT_SETTING_DEFAULT: - return UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_EXCEPTIONS_NOT_SET_BUTTON)); + return l10n_util::GetStringUTF16(IDS_EXCEPTIONS_NOT_SET_BUTTON); default: break; } } NOTREACHED(); - return std::wstring(); + return string16(); } void GeolocationExceptionsTableModel::SetObserver( @@ -228,7 +223,7 @@ int GeolocationExceptionsTableModel::CompareValues(int row1, // The entries are at the same "scope". If we're sorting by action, then do // that now. if (column_id == IDS_EXCEPTIONS_ACTION_HEADER) { - int compare_text = l10n_util::CompareStringWithCollator( + int compare_text = l10n_util::CompareString16WithCollator( GetCollator(), GetText(row1, column_id), GetText(row2, column_id)); if (compare_text != 0) return compare_text; diff --git a/chrome/browser/geolocation/geolocation_exceptions_table_model.h b/chrome/browser/geolocation/geolocation_exceptions_table_model.h index 09014b4..d1223e6 100644 --- a/chrome/browser/geolocation/geolocation_exceptions_table_model.h +++ b/chrome/browser/geolocation/geolocation_exceptions_table_model.h @@ -8,6 +8,7 @@ #include <vector> +#include "base/compiler_specific.h" #include "chrome/browser/geolocation/geolocation_content_settings_map.h" #include "chrome/browser/remove_rows_table_model.h" #include "chrome/common/content_settings.h" @@ -37,10 +38,10 @@ class GeolocationExceptionsTableModel : public RemoveRowsTableModel { virtual void RemoveAll(); // TableModel overrides: - virtual int RowCount(); - virtual std::wstring GetText(int row, int column_id); - virtual void SetObserver(TableModelObserver* observer); - virtual int CompareValues(int row1, int row2, int column_id); + virtual int RowCount() OVERRIDE; + virtual string16 GetText(int row, int column_id) OVERRIDE; + virtual void SetObserver(TableModelObserver* observer) OVERRIDE; + virtual int CompareValues(int row1, int row2, int column_id) OVERRIDE; private: void AddEntriesForOrigin( diff --git a/chrome/browser/geolocation/geolocation_exceptions_table_model_unittest.cc b/chrome/browser/geolocation/geolocation_exceptions_table_model_unittest.cc index 68bc752..301a7b2 100644 --- a/chrome/browser/geolocation/geolocation_exceptions_table_model_unittest.cc +++ b/chrome/browser/geolocation/geolocation_exceptions_table_model_unittest.cc @@ -127,17 +127,17 @@ TEST_F(GeolocationExceptionsTableModelTest, GetText) { CreateAllowedSamples(); // Ensure the parent doesn't have any indentation. - std::wstring text(model_->GetText(0, IDS_EXCEPTIONS_HOSTNAME_HEADER)); - EXPECT_EQ(content_settings_helper::OriginToWString(kUrl0), text); + string16 text = model_->GetText(0, IDS_EXCEPTIONS_HOSTNAME_HEADER); + EXPECT_EQ(content_settings_helper::OriginToString16(kUrl0), text); // Ensure there's some indentation on the children nodes. text = model_->GetText(1, IDS_EXCEPTIONS_HOSTNAME_HEADER); - EXPECT_NE(content_settings_helper::OriginToWString(kUrl1), text); - EXPECT_NE(std::wstring::npos, - text.find(content_settings_helper::OriginToWString(kUrl1))); + EXPECT_NE(content_settings_helper::OriginToString16(kUrl1), text); + EXPECT_NE(string16::npos, + text.find(content_settings_helper::OriginToString16(kUrl1))); text = model_->GetText(2, IDS_EXCEPTIONS_HOSTNAME_HEADER); - EXPECT_NE(content_settings_helper::OriginToWString(kUrl2), text); - EXPECT_NE(std::wstring::npos, - text.find(content_settings_helper::OriginToWString(kUrl2))); + EXPECT_NE(content_settings_helper::OriginToString16(kUrl2), text); + EXPECT_NE(string16::npos, + text.find(content_settings_helper::OriginToString16(kUrl2))); } diff --git a/chrome/browser/gtk/gtk_tree.cc b/chrome/browser/gtk/gtk_tree.cc index 744a4a6..46307da 100644 --- a/chrome/browser/gtk/gtk_tree.cc +++ b/chrome/browser/gtk/gtk_tree.cc @@ -220,7 +220,7 @@ void TableAdapter::OnModelChanged() { COL_WEIGHT_SET, TRUE, COL_TITLE, - WideToUTF8(it->title).c_str(), + UTF16ToUTF8(it->title).c_str(), COL_IS_HEADER, TRUE, -1); diff --git a/chrome/browser/gtk/keyword_editor_view.cc b/chrome/browser/gtk/keyword_editor_view.cc index c4b98da..63931b9 100644 --- a/chrome/browser/gtk/keyword_editor_view.cc +++ b/chrome/browser/gtk/keyword_editor_view.cc @@ -233,9 +233,9 @@ void KeywordEditorView::SetColumnValues(int model_row, GtkTreeIter* iter) { // has an effect. So we just set it to normal. COL_WEIGHT, PANGO_WEIGHT_NORMAL, COL_WEIGHT_SET, TRUE, - COL_TITLE, WideToUTF8(table_model_->GetText( + COL_TITLE, UTF16ToUTF8(table_model_->GetText( model_row, IDS_SEARCH_ENGINES_EDITOR_DESCRIPTION_COLUMN)).c_str(), - COL_KEYWORD, WideToUTF8(table_model_->GetText( + COL_KEYWORD, UTF16ToUTF8(table_model_->GetText( model_row, IDS_SEARCH_ENGINES_EDITOR_KEYWORD_COLUMN)).c_str(), -1); g_object_unref(pixbuf); @@ -311,7 +311,7 @@ void KeywordEditorView::OnModelChanged() { list_store_, &iter, COL_WEIGHT, PANGO_WEIGHT_BOLD, COL_WEIGHT_SET, TRUE, - COL_TITLE, WideToUTF8(groups[0].title).c_str(), + COL_TITLE, UTF16ToUTF8(groups[0].title).c_str(), COL_IS_HEADER, TRUE, -1); // First group separator. @@ -334,7 +334,7 @@ void KeywordEditorView::OnModelChanged() { list_store_, &iter, COL_WEIGHT, PANGO_WEIGHT_BOLD, COL_WEIGHT_SET, TRUE, - COL_TITLE, WideToUTF8(groups[1].title).c_str(), + COL_TITLE, UTF16ToUTF8(groups[1].title).c_str(), COL_IS_HEADER, TRUE, -1); // Second group separator. diff --git a/chrome/browser/gtk/keyword_editor_view_unittest.cc b/chrome/browser/gtk/keyword_editor_view_unittest.cc index 636d6bd..1f06fb8 100644 --- a/chrome/browser/gtk/keyword_editor_view_unittest.cc +++ b/chrome/browser/gtk/keyword_editor_view_unittest.cc @@ -68,9 +68,9 @@ class KeywordEditorViewTest : public testing::Test { KeywordEditorView::COL_TITLE, &name, KeywordEditorView::COL_IS_HEADER, &is_header, -1); - if (name && WideToUTF8(groups[0].title) == name) + if (name && UTF16ToUTF8(groups[0].title) == name) parts.push_back("!"); - else if (name && WideToUTF8(groups[1].title) == name) + else if (name && UTF16ToUTF8(groups[1].title) == name) parts.push_back("@"); else if (is_header) parts.push_back("_"); diff --git a/chrome/browser/gtk/options/content_exceptions_window_gtk.cc b/chrome/browser/gtk/options/content_exceptions_window_gtk.cc index 6a1fc88..1189096 100644 --- a/chrome/browser/gtk/options/content_exceptions_window_gtk.cc +++ b/chrome/browser/gtk/options/content_exceptions_window_gtk.cc @@ -184,13 +184,13 @@ ContentExceptionsWindowGtk::ContentExceptionsWindowGtk( } void ContentExceptionsWindowGtk::SetColumnValues(int row, GtkTreeIter* iter) { - std::wstring pattern = model_->GetText(row, IDS_EXCEPTIONS_PATTERN_HEADER); + string16 pattern = model_->GetText(row, IDS_EXCEPTIONS_PATTERN_HEADER); gtk_list_store_set(list_store_, iter, COL_PATTERN, - WideToUTF8(pattern).c_str(), -1); + UTF16ToUTF8(pattern).c_str(), -1); - std::wstring action = model_->GetText(row, IDS_EXCEPTIONS_ACTION_HEADER); + string16 action = model_->GetText(row, IDS_EXCEPTIONS_ACTION_HEADER); gtk_list_store_set(list_store_, iter, COL_ACTION, - WideToUTF8(action).c_str(), -1); + UTF16ToUTF8(action).c_str(), -1); bool is_off_the_record = model_->entry_is_off_the_record(row); PangoStyle style = diff --git a/chrome/browser/gtk/options/general_page_gtk.cc b/chrome/browser/gtk/options/general_page_gtk.cc index 61f806e..1df3769 100644 --- a/chrome/browser/gtk/options/general_page_gtk.cc +++ b/chrome/browser/gtk/options/general_page_gtk.cc @@ -599,14 +599,14 @@ void GeneralPageGtk::SaveStartupPref() { void GeneralPageGtk::SetColumnValues(int row, GtkTreeIter* iter) { SkBitmap bitmap = startup_custom_pages_table_model_->GetIcon(row); GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&bitmap); - std::wstring text = startup_custom_pages_table_model_->GetText(row, 0); + string16 text = startup_custom_pages_table_model_->GetText(row, 0); std::string tooltip = - WideToUTF8(startup_custom_pages_table_model_->GetTooltip(row)); + UTF16ToUTF8(startup_custom_pages_table_model_->GetTooltip(row)); gchar* escaped_tooltip = g_markup_escape_text(tooltip.c_str(), tooltip.size()); gtk_list_store_set(startup_custom_pages_store_, iter, COL_FAVICON, pixbuf, - COL_URL, WideToUTF8(text).c_str(), + COL_URL, UTF16ToUTF8(text).c_str(), COL_TOOLTIP, escaped_tooltip, -1); g_object_unref(pixbuf); diff --git a/chrome/browser/gtk/options/languages_page_gtk.cc b/chrome/browser/gtk/options/languages_page_gtk.cc index 9bb8732..6a400db 100644 --- a/chrome/browser/gtk/options/languages_page_gtk.cc +++ b/chrome/browser/gtk/options/languages_page_gtk.cc @@ -275,9 +275,9 @@ void LanguagesPageGtk::Init() { } void LanguagesPageGtk::SetColumnValues(int row, GtkTreeIter* iter) { - std::wstring lang = language_order_table_model_->GetText(row, 0); + string16 lang = language_order_table_model_->GetText(row, 0); gtk_list_store_set(language_order_store_, iter, - COL_LANG, WideToUTF8(lang).c_str(), + COL_LANG, UTF16ToUTF8(lang).c_str(), -1); } diff --git a/chrome/browser/gtk/options/simple_content_exceptions_window.cc b/chrome/browser/gtk/options/simple_content_exceptions_window.cc index 682cca1..58676f3 100644 --- a/chrome/browser/gtk/options/simple_content_exceptions_window.cc +++ b/chrome/browser/gtk/options/simple_content_exceptions_window.cc @@ -157,13 +157,13 @@ SimpleContentExceptionsWindow::~SimpleContentExceptionsWindow() {} void SimpleContentExceptionsWindow::SetColumnValues(int row, GtkTreeIter* iter) { - std::wstring hostname = model_->GetText(row, IDS_EXCEPTIONS_HOSTNAME_HEADER); + string16 hostname = model_->GetText(row, IDS_EXCEPTIONS_HOSTNAME_HEADER); gtk_list_store_set(list_store_, iter, gtk_tree::TableAdapter::COL_TITLE, - WideToUTF8(hostname).c_str(), -1); + UTF16ToUTF8(hostname).c_str(), -1); - std::wstring action = model_->GetText(row, IDS_EXCEPTIONS_ACTION_HEADER); + string16 action = model_->GetText(row, IDS_EXCEPTIONS_ACTION_HEADER); gtk_list_store_set(list_store_, iter, COL_ACTION, - WideToUTF8(action).c_str(), -1); + UTF16ToUTF8(action).c_str(), -1); } void SimpleContentExceptionsWindow::OnAnyModelUpdateStart() { diff --git a/chrome/browser/gtk/options/url_picker_dialog_gtk.cc b/chrome/browser/gtk/options/url_picker_dialog_gtk.cc index 2d00873..9f7ed06 100644 --- a/chrome/browser/gtk/options/url_picker_dialog_gtk.cc +++ b/chrome/browser/gtk/options/url_picker_dialog_gtk.cc @@ -208,12 +208,12 @@ std::string UrlPickerDialogGtk::GetURLForPath(GtkTreePath* path) const { void UrlPickerDialogGtk::SetColumnValues(int row, GtkTreeIter* iter) { SkBitmap bitmap = url_table_model_->GetIcon(row); GdkPixbuf* pixbuf = gfx::GdkPixbufFromSkBitmap(&bitmap); - std::wstring title = url_table_model_->GetText(row, IDS_ASI_PAGE_COLUMN); - std::wstring url = url_table_model_->GetText(row, IDS_ASI_URL_COLUMN); + string16 title = url_table_model_->GetText(row, IDS_ASI_PAGE_COLUMN); + string16 url = url_table_model_->GetText(row, IDS_ASI_URL_COLUMN); gtk_list_store_set(history_list_store_, iter, COL_FAVICON, pixbuf, - COL_TITLE, WideToUTF8(title).c_str(), - COL_DISPLAY_URL, WideToUTF8(url).c_str(), + COL_TITLE, UTF16ToUTF8(title).c_str(), + COL_DISPLAY_URL, UTF16ToUTF8(url).c_str(), -1); g_object_unref(pixbuf); } diff --git a/chrome/browser/language_order_table_model.cc b/chrome/browser/language_order_table_model.cc index c1a4103..90501d8 100644 --- a/chrome/browser/language_order_table_model.cc +++ b/chrome/browser/language_order_table_model.cc @@ -39,12 +39,12 @@ void LanguageOrderTableModel::SetObserver(TableModelObserver* observer) { observer_ = observer; } -std::wstring LanguageOrderTableModel::GetText(int row, int column_id) { +string16 LanguageOrderTableModel::GetText(int row, int column_id) { DCHECK(row >= 0 && row < RowCount()); const std::string app_locale = g_browser_process->GetApplicationLocale(); - return UTF16ToWide(l10n_util::GetDisplayNameForLocale(languages_.at(row), - app_locale, - true)); + return l10n_util::GetDisplayNameForLocale(languages_.at(row), + app_locale, + true); } bool LanguageOrderTableModel::Add(const std::string& language) { diff --git a/chrome/browser/language_order_table_model.h b/chrome/browser/language_order_table_model.h index 9cfdf4c..d23f638 100644 --- a/chrome/browser/language_order_table_model.h +++ b/chrome/browser/language_order_table_model.h @@ -11,6 +11,7 @@ #include "app/table_model.h" #include "base/basictypes.h" +#include "base/compiler_specific.h" class TableModelObserver; @@ -43,9 +44,9 @@ class LanguageOrderTableModel : public TableModel { std::string GetLanguageList(); // TableModel overrides: - virtual int RowCount(); - virtual std::wstring GetText(int row, int column_id); - virtual void SetObserver(TableModelObserver* observer); + virtual int RowCount() OVERRIDE; + virtual string16 GetText(int row, int column_id) OVERRIDE; + virtual void SetObserver(TableModelObserver* observer) OVERRIDE; private: // Set of entries we're showing. diff --git a/chrome/browser/notifications/notification_exceptions_table_model.cc b/chrome/browser/notifications/notification_exceptions_table_model.cc index da40c70..e70536c 100644 --- a/chrome/browser/notifications/notification_exceptions_table_model.cc +++ b/chrome/browser/notifications/notification_exceptions_table_model.cc @@ -7,8 +7,6 @@ #include "app/l10n_util.h" #include "app/table_model_observer.h" #include "base/auto_reset.h" -// TODO(avi): remove when conversions not needed any more -#include "base/utf_string_conversions.h" #include "chrome/common/content_settings.h" #include "chrome/common/content_settings_helper.h" #include "chrome/common/content_settings_types.h" @@ -72,28 +70,26 @@ int NotificationExceptionsTableModel::RowCount() { return static_cast<int>(entries_.size()); } -std::wstring NotificationExceptionsTableModel::GetText(int row, - int column_id) { +string16 NotificationExceptionsTableModel::GetText(int row, + int column_id) { const Entry& entry = entries_[row]; if (column_id == IDS_EXCEPTIONS_HOSTNAME_HEADER) { - return content_settings_helper::OriginToWString(entry.origin); + return content_settings_helper::OriginToString16(entry.origin); } if (column_id == IDS_EXCEPTIONS_ACTION_HEADER) { switch (entry.setting) { case CONTENT_SETTING_ALLOW: - return UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ALLOW_BUTTON)); + return l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ALLOW_BUTTON); case CONTENT_SETTING_BLOCK: - return UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON)); + return l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON); default: break; } } NOTREACHED(); - return std::wstring(); + return string16(); } void NotificationExceptionsTableModel::SetObserver( diff --git a/chrome/browser/notifications/notification_exceptions_table_model.h b/chrome/browser/notifications/notification_exceptions_table_model.h index 107b2ec..de19963 100644 --- a/chrome/browser/notifications/notification_exceptions_table_model.h +++ b/chrome/browser/notifications/notification_exceptions_table_model.h @@ -6,9 +6,9 @@ #define CHROME_BROWSER_NOTIFICATIONS_NOTIFICATION_EXCEPTIONS_TABLE_MODEL_H_ #pragma once -#include <string> #include <vector> +#include "base/compiler_specific.h" #include "chrome/browser/notifications/desktop_notification_service.h" #include "chrome/browser/remove_rows_table_model.h" #include "chrome/common/notification_observer.h" @@ -26,9 +26,9 @@ class NotificationExceptionsTableModel : public RemoveRowsTableModel, virtual void RemoveAll(); // Overridden from TableModel: - virtual int RowCount(); - virtual std::wstring GetText(int row, int column_id); - virtual void SetObserver(TableModelObserver* observer); + virtual int RowCount() OVERRIDE; + virtual string16 GetText(int row, int column_id) OVERRIDE; + virtual void SetObserver(TableModelObserver* observer) OVERRIDE; // Overridden from NotificationObserver: virtual void Observe(NotificationType type, diff --git a/chrome/browser/notifications/notification_exceptions_table_model_unittest.cc b/chrome/browser/notifications/notification_exceptions_table_model_unittest.cc index 4752a80..4fdcb24 100644 --- a/chrome/browser/notifications/notification_exceptions_table_model_unittest.cc +++ b/chrome/browser/notifications/notification_exceptions_table_model_unittest.cc @@ -74,34 +74,29 @@ TEST_F(NotificationExceptionsTableModelTest, AlphabeticalOrder) { FillData(); EXPECT_EQ(5, model_->RowCount()); - EXPECT_EQ(L"allowed.com", + EXPECT_EQ(ASCIIToUTF16("allowed.com"), model_->GetText(0, IDS_EXCEPTIONS_HOSTNAME_HEADER)); - EXPECT_EQ(UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ALLOW_BUTTON)), + EXPECT_EQ(l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ALLOW_BUTTON), model_->GetText(0, IDS_EXCEPTIONS_ACTION_HEADER)); - EXPECT_EQ(L"denied.com", + EXPECT_EQ(ASCIIToUTF16("denied.com"), model_->GetText(1, IDS_EXCEPTIONS_HOSTNAME_HEADER)); - EXPECT_EQ(UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON)), + EXPECT_EQ(l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON), model_->GetText(1, IDS_EXCEPTIONS_ACTION_HEADER)); - EXPECT_EQ(L"denied2.com", + EXPECT_EQ(ASCIIToUTF16("denied2.com"), model_->GetText(2, IDS_EXCEPTIONS_HOSTNAME_HEADER)); - EXPECT_EQ(UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON)), + EXPECT_EQ(l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON), model_->GetText(2, IDS_EXCEPTIONS_ACTION_HEADER)); - EXPECT_EQ(L"e-allowed2.com", + EXPECT_EQ(ASCIIToUTF16("e-allowed2.com"), model_->GetText(3, IDS_EXCEPTIONS_HOSTNAME_HEADER)); - EXPECT_EQ(UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ALLOW_BUTTON)), + EXPECT_EQ(l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ALLOW_BUTTON), model_->GetText(3, IDS_EXCEPTIONS_ACTION_HEADER)); - EXPECT_EQ(L"f-denied3.com", + EXPECT_EQ(ASCIIToUTF16("f-denied3.com"), model_->GetText(4, IDS_EXCEPTIONS_HOSTNAME_HEADER)); - EXPECT_EQ(UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON)), + EXPECT_EQ(l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON), model_->GetText(4, IDS_EXCEPTIONS_ACTION_HEADER)); } diff --git a/chrome/browser/plugin_exceptions_table_model.cc b/chrome/browser/plugin_exceptions_table_model.cc index 0dc7c8b..a8cc464 100644 --- a/chrome/browser/plugin_exceptions_table_model.cc +++ b/chrome/browser/plugin_exceptions_table_model.cc @@ -75,23 +75,21 @@ int PluginExceptionsTableModel::RowCount() { return settings_.size(); } -std::wstring PluginExceptionsTableModel::GetText(int row, int column_id) { +string16 PluginExceptionsTableModel::GetText(int row, int column_id) { DCHECK_GE(row, 0); DCHECK_LT(row, static_cast<int>(settings_.size())); SettingsEntry& entry = settings_[row]; switch (column_id) { case IDS_EXCEPTIONS_PATTERN_HEADER: case IDS_EXCEPTIONS_HOSTNAME_HEADER: - return UTF8ToWide(entry.pattern.AsString()); + return UTF8ToUTF16(entry.pattern.AsString()); case IDS_EXCEPTIONS_ACTION_HEADER: switch (entry.setting) { case CONTENT_SETTING_ALLOW: - return UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ALLOW_BUTTON)); + return l10n_util::GetStringUTF16(IDS_EXCEPTIONS_ALLOW_BUTTON); case CONTENT_SETTING_BLOCK: - return UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON)); + return l10n_util::GetStringUTF16(IDS_EXCEPTIONS_BLOCK_BUTTON); default: NOTREACHED(); } @@ -101,7 +99,7 @@ std::wstring PluginExceptionsTableModel::GetText(int row, int column_id) { NOTREACHED(); } - return std::wstring(); + return string16(); } bool PluginExceptionsTableModel::HasGroups() { @@ -156,7 +154,7 @@ void PluginExceptionsTableModel::LoadSettings() { plugin, &otr_settings); } - std::wstring title = UTF16ToWide(plugins[i].GetGroupName()); + string16 title = plugins[i].GetGroupName(); for (HostContentSettingsMap::SettingsForOneType::iterator setting_it = settings.begin(); setting_it != settings.end(); ++setting_it) { SettingsEntry entry = { diff --git a/chrome/browser/plugin_exceptions_table_model.h b/chrome/browser/plugin_exceptions_table_model.h index 045c218..009ab35 100644 --- a/chrome/browser/plugin_exceptions_table_model.h +++ b/chrome/browser/plugin_exceptions_table_model.h @@ -10,6 +10,7 @@ #include <string> #include <vector> +#include "base/compiler_specific.h" #include "chrome/browser/content_settings/host_content_settings_map.h" #include "chrome/browser/remove_rows_table_model.h" #include "chrome/common/notification_observer.h" @@ -34,12 +35,12 @@ class PluginExceptionsTableModel : public RemoveRowsTableModel, virtual void RemoveAll(); // TableModel methods: - virtual int RowCount(); - virtual std::wstring GetText(int row, int column_id); - virtual void SetObserver(TableModelObserver* observer); - virtual bool HasGroups(); - virtual Groups GetGroups(); - virtual int GetGroupID(int row); + virtual int RowCount() OVERRIDE; + virtual string16 GetText(int row, int column_id) OVERRIDE; + virtual void SetObserver(TableModelObserver* observer) OVERRIDE; + virtual bool HasGroups() OVERRIDE; + virtual Groups GetGroups() OVERRIDE; + virtual int GetGroupID(int row) OVERRIDE; // NotificationObserver methods: virtual void Observe(NotificationType type, diff --git a/chrome/browser/possible_url_model.cc b/chrome/browser/possible_url_model.cc index 3d4d662..31bfd2b 100644 --- a/chrome/browser/possible_url_model.cc +++ b/chrome/browser/possible_url_model.cc @@ -125,14 +125,14 @@ const std::wstring& PossibleURLModel::GetTitle(int row) { return results_[row].title; } -std::wstring PossibleURLModel::GetText(int row, int col_id) { +string16 PossibleURLModel::GetText(int row, int col_id) { if (row < 0 || row >= RowCount()) { NOTREACHED(); - return std::wstring(); + return string16(); } if (col_id == IDS_ASI_PAGE_COLUMN) { - std::wstring title = GetTitle(row); + string16 title = WideToUTF16Hack(GetTitle(row)); // TODO(xji): Consider adding a special case if the title text is a URL, // since those should always have LTR directionality. Please refer to // http://crbug.com/6726 for more information. @@ -143,7 +143,7 @@ std::wstring PossibleURLModel::GetText(int row, int col_id) { // TODO(brettw): this should probably pass the GURL up so the URL elider // can be used at a higher level when we know the width. string16 url = results_[row].display_url.display_url(); - return UTF16ToWide(base::i18n::GetDisplayStringInLTRDirectionality(url)); + return base::i18n::GetDisplayStringInLTRDirectionality(url); } SkBitmap PossibleURLModel::GetIcon(int row) { diff --git a/chrome/browser/possible_url_model.h b/chrome/browser/possible_url_model.h index 0c0b531..8bd61c6 100644 --- a/chrome/browser/possible_url_model.h +++ b/chrome/browser/possible_url_model.h @@ -11,6 +11,7 @@ #include <vector> #include "app/table_model.h" +#include "base/compiler_specific.h" #include "chrome/browser/history/history.h" class SkBitmap; @@ -32,25 +33,21 @@ class PossibleURLModel : public TableModel { void OnHistoryQueryComplete(HistoryService::Handle h, history::QueryResults* result); - virtual int RowCount(); - const GURL& GetURL(int row); - const std::wstring& GetTitle(int row); - virtual std::wstring GetText(int row, int col_id); - - virtual SkBitmap GetIcon(int row); - - virtual int CompareValues(int row1, int row2, int column_id); - virtual void OnFavIconAvailable(FaviconService::Handle h, bool fav_icon_available, scoped_refptr<RefCountedMemory> data, bool expired, GURL icon_url); - virtual void SetObserver(TableModelObserver* observer); + // TableModel overrides + virtual int RowCount() OVERRIDE; + virtual string16 GetText(int row, int col_id) OVERRIDE; + virtual SkBitmap GetIcon(int row) OVERRIDE; + virtual int CompareValues(int row1, int row2, int column_id) OVERRIDE; + virtual void SetObserver(TableModelObserver* observer) OVERRIDE; private: // The current profile. diff --git a/chrome/browser/search_engines/template_url_table_model.cc b/chrome/browser/search_engines/template_url_table_model.cc index 0acbb37..12189f1 100644 --- a/chrome/browser/search_engines/template_url_table_model.cc +++ b/chrome/browser/search_engines/template_url_table_model.cc @@ -4,9 +4,6 @@ #include "chrome/browser/search_engines/template_url_table_model.h" -#include <string> -#include <vector> - #include "app/l10n_util.h" #include "app/resource_bundle.h" #include "app/table_model_observer.h" @@ -177,21 +174,21 @@ int TemplateURLTableModel::RowCount() { return static_cast<int>(entries_.size()); } -std::wstring TemplateURLTableModel::GetText(int row, int col_id) { +string16 TemplateURLTableModel::GetText(int row, int col_id) { DCHECK(row >= 0 && row < RowCount()); const TemplateURL& url = entries_[row]->template_url(); switch (col_id) { case IDS_SEARCH_ENGINES_EDITOR_DESCRIPTION_COLUMN: { - std::wstring url_short_name = url.short_name(); + string16 url_short_name = WideToUTF16Hack(url.short_name()); // TODO(xji): Consider adding a special case if the short name is a URL, // since those should always be displayed LTR. Please refer to // http://crbug.com/6726 for more information. base::i18n::AdjustStringForLocaleDirection(&url_short_name); if (template_url_model_->GetDefaultSearchProvider() == &url) { - return UTF16ToWideHack( - l10n_util::GetStringFUTF16(IDS_SEARCH_ENGINES_EDITOR_DEFAULT_ENGINE, - WideToUTF16Hack(url_short_name))); + return l10n_util::GetStringFUTF16( + IDS_SEARCH_ENGINES_EDITOR_DEFAULT_ENGINE, + url_short_name); } return url_short_name; } @@ -200,12 +197,12 @@ std::wstring TemplateURLTableModel::GetText(int row, int col_id) { // Keyword should be domain name. Force it to have LTR directionality. string16 keyword = WideToUTF16(url.keyword()); keyword = base::i18n::GetDisplayStringInLTRDirectionality(keyword); - return UTF16ToWide(keyword); + return keyword; } default: NOTREACHED(); - return std::wstring(); + return string16(); } } @@ -226,14 +223,14 @@ TemplateURLTableModel::Groups TemplateURLTableModel::GetGroups() { Groups groups; Group search_engine_group; - search_engine_group.title = UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_SEARCH_ENGINES_EDITOR_MAIN_SEPARATOR)); + search_engine_group.title = + l10n_util::GetStringUTF16(IDS_SEARCH_ENGINES_EDITOR_MAIN_SEPARATOR); search_engine_group.id = kMainGroupID; groups.push_back(search_engine_group); Group other_group; - other_group.title = UTF16ToWideHack( - l10n_util::GetStringUTF16(IDS_SEARCH_ENGINES_EDITOR_OTHER_SEPARATOR)); + other_group.title = + l10n_util::GetStringUTF16(IDS_SEARCH_ENGINES_EDITOR_OTHER_SEPARATOR); other_group.id = kOtherGroupID; groups.push_back(other_group); diff --git a/chrome/browser/search_engines/template_url_table_model.h b/chrome/browser/search_engines/template_url_table_model.h index 03bb43a..95ca739 100644 --- a/chrome/browser/search_engines/template_url_table_model.h +++ b/chrome/browser/search_engines/template_url_table_model.h @@ -6,7 +6,11 @@ #define CHROME_BROWSER_SEARCH_ENGINES_TEMPLATE_URL_TABLE_MODEL_H_ #pragma once +#include <string> +#include <vector> + #include "app/table_model.h" +#include "base/compiler_specific.h" #include "base/string16.h" #include "chrome/browser/search_engines/template_url_model_observer.h" @@ -38,13 +42,13 @@ class TemplateURLTableModel : public TableModel, void Reload(); // TableModel overrides. - virtual int RowCount(); - virtual std::wstring GetText(int row, int column); - virtual SkBitmap GetIcon(int row); - virtual void SetObserver(TableModelObserver* observer); - virtual bool HasGroups(); - virtual Groups GetGroups(); - virtual int GetGroupID(int row); + virtual int RowCount() OVERRIDE; + virtual string16 GetText(int row, int column) OVERRIDE; + virtual SkBitmap GetIcon(int row) OVERRIDE; + virtual void SetObserver(TableModelObserver* observer) OVERRIDE; + virtual bool HasGroups() OVERRIDE; + virtual Groups GetGroups() OVERRIDE; + virtual int GetGroupID(int row) OVERRIDE; // Removes the entry at the specified index. void Remove(int index); diff --git a/chrome/browser/ui/cocoa/keyword_editor_cocoa_controller.mm b/chrome/browser/ui/cocoa/keyword_editor_cocoa_controller.mm index 1a0819f..f8b3aa6 100644 --- a/chrome/browser/ui/cocoa/keyword_editor_cocoa_controller.mm +++ b/chrome/browser/ui/cocoa/keyword_editor_cocoa_controller.mm @@ -295,9 +295,9 @@ static base::LazyInstance<ProfileControllerMap> g_profile_controller_map( DCHECK(!tableColumn); TableModel::Groups groups = controller_->table_model()->GetGroups(); if (row == 0) { - return base::SysWideToNSString(groups[0].title); + return base::SysUTF16ToNSString(groups[0].title); } else { - return base::SysWideToNSString(groups[1].title); + return base::SysUTF16ToNSString(groups[1].title); } } @@ -312,8 +312,8 @@ static base::LazyInstance<ProfileControllerMap> g_profile_controller_map( // The keyword object value is a normal string. int index = [self indexInModelForRow:row]; int columnID = IDS_SEARCH_ENGINES_EDITOR_KEYWORD_COLUMN; - std::wstring text = controller_->table_model()->GetText(index, columnID); - return base::SysWideToNSString(text); + string16 text = controller_->table_model()->GetText(index, columnID); + return base::SysUTF16ToNSString(text); } // And we shouldn't have any other columns... @@ -357,9 +357,9 @@ static base::LazyInstance<ProfileControllerMap> g_profile_controller_map( if ([[tableColumn identifier] isEqualToString:@"name"]) { DCHECK([cell isKindOfClass:[NSButtonCell class]]); NSButtonCell* buttonCell = static_cast<NSButtonCell*>(cell); - std::wstring title = controller_->table_model()->GetText(offsetRow, + string16 title = controller_->table_model()->GetText(offsetRow, IDS_SEARCH_ENGINES_EDITOR_DESCRIPTION_COLUMN); - [buttonCell setTitle:base::SysWideToNSString(title)]; + [buttonCell setTitle:base::SysUTF16ToNSString(title)]; [buttonCell setImage:observer_->GetImageForRow(offsetRow)]; [buttonCell setRefusesFirstResponder:YES]; // Don't push in like a button. [buttonCell setHighlightsBy:NSNoCellMask]; diff --git a/chrome/browser/ui/cocoa/table_model_array_controller.mm b/chrome/browser/ui/cocoa/table_model_array_controller.mm index e732127..02e573d 100644 --- a/chrome/browser/ui/cocoa/table_model_array_controller.mm +++ b/chrome/browser/ui/cocoa/table_model_array_controller.mm @@ -83,7 +83,7 @@ static NSString* const kGroupID = @"_group_id"; for (TableModel::Groups::const_iterator it = groups.begin(); it != groups.end(); ++it) { NSDictionary* group = [NSDictionary dictionaryWithObjectsAndKeys: - base::SysWideToNSString(it->title), groupTitle_.get(), + base::SysUTF16ToNSString(it->title), groupTitle_.get(), [NSNumber numberWithBool:YES], kIsGroupRow, nil]; [self addObject:group]; @@ -191,8 +191,8 @@ static NSString* const kGroupID = @"_group_id"; } for (NSString* identifier in columns_.get()) { int column_id = [[columns_ objectForKey:identifier] intValue]; - std::wstring text = model_->GetText(row, column_id); - [dict setObject:base::SysWideToNSString(text) forKey:identifier]; + string16 text = model_->GetText(row, column_id); + [dict setObject:base::SysUTF16ToNSString(text) forKey:identifier]; } return dict; } diff --git a/chrome/browser/ui/views/autofill_profiles_view_win.cc b/chrome/browser/ui/views/autofill_profiles_view_win.cc index 9c73a62..2f44c5a 100644 --- a/chrome/browser/ui/views/autofill_profiles_view_win.cc +++ b/chrome/browser/ui/views/autofill_profiles_view_win.cc @@ -1266,14 +1266,14 @@ int AutoFillProfilesView::ContentListTableModel::RowCount() { return profiles_->size() + credit_cards_->size(); } -std::wstring AutoFillProfilesView::ContentListTableModel::GetText( +string16 AutoFillProfilesView::ContentListTableModel::GetText( int row, int column_id) { DCHECK(row < static_cast<int>(profiles_->size() + credit_cards_->size())); if (row < static_cast<int>(profiles_->size())) { - return profiles_->at(row).address.Label(); + return WideToUTF16Hack(profiles_->at(row).address.Label()); } else { row -= profiles_->size(); - return credit_cards_->at(row).credit_card.PreviewSummary(); + return WideToUTF16Hack(credit_cards_->at(row).credit_card.PreviewSummary()); } } diff --git a/chrome/browser/ui/views/autofill_profiles_view_win.h b/chrome/browser/ui/views/autofill_profiles_view_win.h index 6dbe8dd..ef8dbe4 100644 --- a/chrome/browser/ui/views/autofill_profiles_view_win.h +++ b/chrome/browser/ui/views/autofill_profiles_view_win.h @@ -12,6 +12,7 @@ #include "app/combobox_model.h" #include "app/table_model.h" +#include "base/compiler_specific.h" #include "base/string16.h" #include "chrome/browser/autofill/autofill_dialog.h" #include "chrome/browser/autofill/autofill_profile.h" @@ -398,12 +399,12 @@ class AutoFillProfilesView : public views::View, void UpdateItem(int index); // TableModel members: - virtual int RowCount(); - virtual std::wstring GetText(int row, int column_id); - virtual bool HasGroups() { return true; } - virtual TableModel::Groups GetGroups(); - virtual int GetGroupID(int row); - virtual void SetObserver(TableModelObserver* observer); + virtual int RowCount() OVERRIDE; + virtual string16 GetText(int row, int column_id) OVERRIDE; + virtual bool HasGroups() OVERRIDE { return true; } + virtual TableModel::Groups GetGroups() OVERRIDE; + virtual int GetGroupID(int row) OVERRIDE; + virtual void SetObserver(TableModelObserver* observer) OVERRIDE; private: std::vector<EditableSetInfo>* profiles_; diff --git a/chrome/browser/ui/views/hung_renderer_view.cc b/chrome/browser/ui/views/hung_renderer_view.cc index b50debf..8f4c925 100644 --- a/chrome/browser/ui/views/hung_renderer_view.cc +++ b/chrome/browser/ui/views/hung_renderer_view.cc @@ -48,7 +48,7 @@ class HungPagesTableModel : public views::GroupTableModel { // Overridden from views::GroupTableModel: virtual int RowCount(); - virtual std::wstring GetText(int row, int column_id); + virtual string16 GetText(int row, int column_id); virtual SkBitmap GetIcon(int row); virtual void SetObserver(TableModelObserver* observer); virtual void GetGroupRangeForItem(int item, views::GroupRange* range); @@ -89,11 +89,11 @@ int HungPagesTableModel::RowCount() { return static_cast<int>(tab_contentses_.size()); } -std::wstring HungPagesTableModel::GetText(int row, int column_id) { +string16 HungPagesTableModel::GetText(int row, int column_id) { DCHECK(row >= 0 && row < RowCount()); - std::wstring title = UTF16ToWideHack(tab_contentses_[row]->GetTitle()); + string16 title = tab_contentses_[row]->GetTitle(); if (title.empty()) - title = UTF16ToWideHack(TabContents::GetDefaultTitle()); + title = TabContents::GetDefaultTitle(); // TODO(xji): Consider adding a special case if the title text is a URL, // since those should always have LTR directionality. Please refer to // http://crbug.com/6726 for more information. diff --git a/chrome/browser/ui/views/options/exceptions_page_view.cc b/chrome/browser/ui/views/options/exceptions_page_view.cc index eb5d8c6..42277ec 100644 --- a/chrome/browser/ui/views/options/exceptions_page_view.cc +++ b/chrome/browser/ui/views/options/exceptions_page_view.cc @@ -29,7 +29,7 @@ ExceptionsTableModel::ExceptionsTableModel(Profile* profile) ExceptionsTableModel::~ExceptionsTableModel() { } -std::wstring ExceptionsTableModel::GetText(int row, int col_id) { +string16 ExceptionsTableModel::GetText(int row, int col_id) { DCHECK_EQ(col_id, IDS_PASSWORDS_PAGE_VIEW_SITE_COLUMN); return PasswordsTableModel::GetText(row, col_id); } diff --git a/chrome/browser/ui/views/options/exceptions_page_view.h b/chrome/browser/ui/views/options/exceptions_page_view.h index decb69b..618b408 100644 --- a/chrome/browser/ui/views/options/exceptions_page_view.h +++ b/chrome/browser/ui/views/options/exceptions_page_view.h @@ -8,6 +8,7 @@ #include <vector> +#include "base/compiler_specific.h" #include "chrome/browser/views/options/options_page_view.h" #include "chrome/browser/views/options/passwords_page_view.h" #include "views/controls/table/table_view_observer.h" @@ -22,8 +23,8 @@ class ExceptionsTableModel : public PasswordsTableModel { virtual ~ExceptionsTableModel(); // TableModel methods. - virtual std::wstring GetText(int row, int column); - virtual int CompareValues(int row1, int row2, int col_id); + virtual string16 GetText(int row, int column) OVERRIDE; + virtual int CompareValues(int row1, int row2, int col_id) OVERRIDE; // PasswordStoreConsumer implementation. virtual void OnPasswordStoreRequestDone( diff --git a/chrome/browser/ui/views/options/passwords_page_view.cc b/chrome/browser/ui/views/options/passwords_page_view.cc index cdb3187..ec69c13 100644 --- a/chrome/browser/ui/views/options/passwords_page_view.cc +++ b/chrome/browser/ui/views/options/passwords_page_view.cc @@ -70,24 +70,23 @@ int PasswordsTableModel::RowCount() { return static_cast<int>(saved_signons_.size()); } -std::wstring PasswordsTableModel::GetText(int row, - int col_id) { +string16 PasswordsTableModel::GetText(int row, + int col_id) { switch (col_id) { case IDS_PASSWORDS_PAGE_VIEW_SITE_COLUMN: { // Site. // Force URL to have LTR directionality. std::wstring url(saved_signons_[row]->display_url.display_url()); - url = UTF16ToWide(base::i18n::GetDisplayStringInLTRDirectionality( - WideToUTF16(url))); - return url; + return base::i18n::GetDisplayStringInLTRDirectionality( + WideToUTF16Hack(url)); } case IDS_PASSWORDS_PAGE_VIEW_USERNAME_COLUMN: { // Username. std::wstring username = GetPasswordFormAt(row)->username_value; base::i18n::AdjustStringForLocaleDirection(&username); - return username; + return WideToUTF16Hack(username); } default: NOTREACHED() << "Invalid column."; - return std::wstring(); + return string16(); } } diff --git a/chrome/browser/ui/views/options/passwords_page_view.h b/chrome/browser/ui/views/options/passwords_page_view.h index f465b57..39428bf 100644 --- a/chrome/browser/ui/views/options/passwords_page_view.h +++ b/chrome/browser/ui/views/options/passwords_page_view.h @@ -10,6 +10,7 @@ #include "app/table_model.h" #include "app/text_elider.h" +#include "base/compiler_specific.h" #include "base/scoped_ptr.h" #include "base/stl_util-inl.h" #include "chrome/browser/password_manager/password_store.h" @@ -69,10 +70,10 @@ class PasswordsTableModel : public TableModel, virtual ~PasswordsTableModel(); // TableModel methods. - virtual int RowCount(); - virtual std::wstring GetText(int row, int column); - virtual int CompareValues(int row1, int row2, int column_id); - virtual void SetObserver(TableModelObserver* observer); + virtual int RowCount() OVERRIDE; + virtual string16 GetText(int row, int column) OVERRIDE; + virtual int CompareValues(int row1, int row2, int column_id) OVERRIDE; + virtual void SetObserver(TableModelObserver* observer) OVERRIDE; // Delete the PasswordForm at specified row from the database (and remove // from view). diff --git a/chrome/browser/ui/views/task_manager_view.cc b/chrome/browser/ui/views/task_manager_view.cc index 99061c6..79e6cbe 100644 --- a/chrome/browser/ui/views/task_manager_view.cc +++ b/chrome/browser/ui/views/task_manager_view.cc @@ -7,6 +7,7 @@ #include "app/l10n_util.h" #include "app/table_model_observer.h" #include "base/command_line.h" +#include "base/compiler_specific.h" #include "base/metrics/stats_table.h" #include "base/utf_string_conversions.h" #include "chrome/app/chrome_command_ids.h" @@ -57,12 +58,12 @@ class TaskManagerTableModel : public views::GroupTableModel, } // GroupTableModel. - int RowCount(); - std::wstring GetText(int row, int column); - SkBitmap GetIcon(int row); - void GetGroupRangeForItem(int item, views::GroupRange* range); - void SetObserver(TableModelObserver* observer); - virtual int CompareValues(int row1, int row2, int column_id); + int RowCount() OVERRIDE; + string16 GetText(int row, int column) OVERRIDE; + SkBitmap GetIcon(int row) OVERRIDE; + void GetGroupRangeForItem(int item, views::GroupRange* range) OVERRIDE; + void SetObserver(TableModelObserver* observer) OVERRIDE; + virtual int CompareValues(int row1, int row2, int column_id) OVERRIDE; // TaskManagerModelObserver. virtual void OnModelChanged(); @@ -79,70 +80,70 @@ int TaskManagerTableModel::RowCount() { return model_->ResourceCount(); } -std::wstring TaskManagerTableModel::GetText(int row, int col_id) { +string16 TaskManagerTableModel::GetText(int row, int col_id) { switch (col_id) { case IDS_TASK_MANAGER_PAGE_COLUMN: // Process - return UTF16ToWide(model_->GetResourceTitle(row)); + return model_->GetResourceTitle(row); case IDS_TASK_MANAGER_NET_COLUMN: // Net - return UTF16ToWide(model_->GetResourceNetworkUsage(row)); + return model_->GetResourceNetworkUsage(row); case IDS_TASK_MANAGER_CPU_COLUMN: // CPU if (!model_->IsResourceFirstInGroup(row)) - return std::wstring(); - return UTF16ToWide(model_->GetResourceCPUUsage(row)); + return string16(); + return model_->GetResourceCPUUsage(row); case IDS_TASK_MANAGER_PRIVATE_MEM_COLUMN: // Memory if (!model_->IsResourceFirstInGroup(row)) - return std::wstring(); - return UTF16ToWide(model_->GetResourcePrivateMemory(row)); + return string16(); + return model_->GetResourcePrivateMemory(row); case IDS_TASK_MANAGER_SHARED_MEM_COLUMN: // Memory if (!model_->IsResourceFirstInGroup(row)) - return std::wstring(); - return UTF16ToWide(model_->GetResourceSharedMemory(row)); + return string16(); + return model_->GetResourceSharedMemory(row); case IDS_TASK_MANAGER_PHYSICAL_MEM_COLUMN: // Memory if (!model_->IsResourceFirstInGroup(row)) - return std::wstring(); - return UTF16ToWide(model_->GetResourcePhysicalMemory(row)); + return string16(); + return model_->GetResourcePhysicalMemory(row); case IDS_TASK_MANAGER_PROCESS_ID_COLUMN: if (!model_->IsResourceFirstInGroup(row)) - return std::wstring(); - return UTF16ToWide(model_->GetResourceProcessId(row)); + return string16(); + return model_->GetResourceProcessId(row); case IDS_TASK_MANAGER_GOATS_TELEPORTED_COLUMN: // Goats Teleported! - return UTF16ToWide(model_->GetResourceGoatsTeleported(row)); + return model_->GetResourceGoatsTeleported(row); case IDS_TASK_MANAGER_WEBCORE_IMAGE_CACHE_COLUMN: if (!model_->IsResourceFirstInGroup(row)) - return std::wstring(); - return UTF16ToWide(model_->GetResourceWebCoreImageCacheSize(row)); + return string16(); + return model_->GetResourceWebCoreImageCacheSize(row); case IDS_TASK_MANAGER_WEBCORE_SCRIPTS_CACHE_COLUMN: if (!model_->IsResourceFirstInGroup(row)) - return std::wstring(); - return UTF16ToWide(model_->GetResourceWebCoreScriptsCacheSize(row)); + return string16(); + return model_->GetResourceWebCoreScriptsCacheSize(row); case IDS_TASK_MANAGER_WEBCORE_CSS_CACHE_COLUMN: if (!model_->IsResourceFirstInGroup(row)) - return std::wstring(); - return UTF16ToWide(model_->GetResourceWebCoreCSSCacheSize(row)); + return string16(); + return model_->GetResourceWebCoreCSSCacheSize(row); case IDS_TASK_MANAGER_SQLITE_MEMORY_USED_COLUMN: if (!model_->IsResourceFirstInGroup(row)) - return std::wstring(); - return UTF16ToWide(model_->GetResourceSqliteMemoryUsed(row)); + return string16(); + return model_->GetResourceSqliteMemoryUsed(row); case IDS_TASK_MANAGER_JAVASCRIPT_MEMORY_ALLOCATED_COLUMN: if (!model_->IsResourceFirstInGroup(row)) - return std::wstring(); - return UTF16ToWide(model_->GetResourceV8MemoryAllocatedSize(row)); + return string16(); + return model_->GetResourceV8MemoryAllocatedSize(row); default: NOTREACHED(); - return std::wstring(); + return string16(); } } @@ -407,7 +408,7 @@ void TaskManagerView::UpdateStatsCounters() { // stat names not in the string table would be filtered out. // TODO(erikkay): Width is hard-coded right now, so many column // names are clipped. - TableColumn col(i, ASCIIToWide(row), TableColumn::RIGHT, 90, 0); + TableColumn col(i, ASCIIToUTF16(row), TableColumn::RIGHT, 90, 0); col.sortable = true; columns_.push_back(col); tab_table_->AddColumn(col); diff --git a/chrome/common/content_settings_helper.cc b/chrome/common/content_settings_helper.cc index 482a759..18997c7 100644 --- a/chrome/common/content_settings_helper.cc +++ b/chrome/common/content_settings_helper.cc @@ -19,8 +19,8 @@ std::string OriginToString(const GURL& origin) { return scheme_component + origin.host() + port_component; } -std::wstring OriginToWString(const GURL& origin) { - return UTF8ToWide(OriginToString(origin)); +string16 OriginToString16(const GURL& origin) { + return UTF8ToUTF16(OriginToString(origin)); } } // namespace content_settings_helper diff --git a/chrome/common/content_settings_helper.h b/chrome/common/content_settings_helper.h index ab1c603..f361121 100644 --- a/chrome/common/content_settings_helper.h +++ b/chrome/common/content_settings_helper.h @@ -8,6 +8,8 @@ #include <string> +#include "base/string16.h" + class GURL; namespace content_settings_helper { @@ -15,7 +17,7 @@ namespace content_settings_helper { // Return simplified string representing origin. If origin is using http or // the standard port, those parts are not included in the output. std::string OriginToString(const GURL& origin); -std::wstring OriginToWString(const GURL& origin); +string16 OriginToString16(const GURL& origin); } // namespace content_settings_helper diff --git a/chrome/common/content_settings_helper_unittest.cc b/chrome/common/content_settings_helper_unittest.cc index d46eda6..f20a1a2 100644 --- a/chrome/common/content_settings_helper_unittest.cc +++ b/chrome/common/content_settings_helper_unittest.cc @@ -4,10 +4,11 @@ #include "chrome/common/content_settings_helper.h" +#include "base/utf_string_conversions.h" #include "googleurl/src/gurl.h" #include "testing/gtest/include/gtest/gtest.h" -TEST(ContentSettingsHelperTest, OriginToWString) { +TEST(ContentSettingsHelperTest, OriginToString16) { // Urls with "http": const GURL kUrl0("http://www.foo.com/bar"); const GURL kUrl1("http://foo.com/bar"); @@ -23,20 +24,24 @@ TEST(ContentSettingsHelperTest, OriginToWString) { const GURL kUrl7("https://foo.com:81/bar"); // Now check the first group of urls with just "http": - EXPECT_EQ(L"www.foo.com", content_settings_helper::OriginToWString(kUrl0)); - EXPECT_EQ(L"foo.com", content_settings_helper::OriginToWString(kUrl1)); + EXPECT_EQ(ASCIIToUTF16("www.foo.com"), + content_settings_helper::OriginToString16(kUrl0)); + EXPECT_EQ(ASCIIToUTF16("foo.com"), + content_settings_helper::OriginToString16(kUrl1)); - EXPECT_EQ(L"www.foo.com:81", content_settings_helper::OriginToWString(kUrl2)); - EXPECT_EQ(L"foo.com:81", content_settings_helper::OriginToWString(kUrl3)); + EXPECT_EQ(ASCIIToUTF16("www.foo.com:81"), + content_settings_helper::OriginToString16(kUrl2)); + EXPECT_EQ(ASCIIToUTF16("foo.com:81"), + content_settings_helper::OriginToString16(kUrl3)); // Now check the second group of urls with "https": - EXPECT_EQ(L"https://www.foo.com", - content_settings_helper::OriginToWString(kUrl4)); - EXPECT_EQ(L"https://foo.com", - content_settings_helper::OriginToWString(kUrl5)); - - EXPECT_EQ(L"https://www.foo.com:81", - content_settings_helper::OriginToWString(kUrl6)); - EXPECT_EQ(L"https://foo.com:81", - content_settings_helper::OriginToWString(kUrl7)); + EXPECT_EQ(ASCIIToUTF16("https://www.foo.com"), + content_settings_helper::OriginToString16(kUrl4)); + EXPECT_EQ(ASCIIToUTF16("https://foo.com"), + content_settings_helper::OriginToString16(kUrl5)); + + EXPECT_EQ(ASCIIToUTF16("https://www.foo.com:81"), + content_settings_helper::OriginToString16(kUrl6)); + EXPECT_EQ(ASCIIToUTF16("https://foo.com:81"), + content_settings_helper::OriginToString16(kUrl7)); } diff --git a/views/controls/table/native_table_gtk.cc b/views/controls/table/native_table_gtk.cc index 75f724b..fb12ef4 100644 --- a/views/controls/table/native_table_gtk.cc +++ b/views/controls/table/native_table_gtk.cc @@ -278,7 +278,7 @@ void NativeTableGtk::CreateNativeControl() { void NativeTableGtk::InsertTextColumn(const TableColumn& column, int index) { GtkCellRenderer* renderer = gtk_cell_renderer_text_new(); gtk_tree_view_insert_column_with_attributes(tree_view_, -1, - WideToUTF8(column.title).c_str(), + UTF16ToUTF8(column.title).c_str(), renderer, "text", index, NULL); } @@ -290,7 +290,7 @@ void NativeTableGtk::InsertIconAndTextColumn(const TableColumn& column, " at this point."; GtkTreeViewColumn* gtk_column = gtk_tree_view_column_new(); - gtk_tree_view_column_set_title(gtk_column, WideToUTF8(column.title).c_str()); + gtk_tree_view_column_set_title(gtk_column, UTF16ToUTF8(column.title).c_str()); GtkCellRenderer* renderer = gtk_cell_renderer_pixbuf_new(); gtk_tree_view_column_pack_start(gtk_column, renderer, FALSE); // First we set the icon renderer at index 0. @@ -315,8 +315,8 @@ void NativeTableGtk::SetRowData(int row_index, GtkTreeIter* iter) { for (size_t i = 0; i < table_->GetVisibleColumnCount(); ++i, ++gtk_column_index) { std::string text = - WideToUTF8(table_->model()->GetText(row_index, - table_->GetVisibleColumnAt(i).id)); + UTF16ToUTF8(table_->model()->GetText(row_index, + table_->GetVisibleColumnAt(i).id)); gtk_list_store_set(gtk_model_, iter, gtk_column_index, text.c_str(), -1); } } diff --git a/views/controls/table/table_view_unittest.cc b/views/controls/table/table_view_unittest.cc index 2959534..bc51c4a 100644 --- a/views/controls/table/table_view_unittest.cc +++ b/views/controls/table/table_view_unittest.cc @@ -6,6 +6,7 @@ #include "app/table_model.h" #include "app/table_model_observer.h" +#include "base/compiler_specific.h" #include "base/message_loop.h" #include "base/string_number_conversions.h" #include "base/utf_string_conversions.h" @@ -47,10 +48,10 @@ class TestTableModel : public TableModel { void ChangeRow(int row, int c1_value, int c2_value); // TableModel - virtual int RowCount(); - virtual std::wstring GetText(int row, int column_id); - virtual void SetObserver(TableModelObserver* observer); - virtual int CompareValues(int row1, int row2, int column_id); + virtual int RowCount() OVERRIDE; + virtual string16 GetText(int row, int column_id) OVERRIDE; + virtual void SetObserver(TableModelObserver* observer) OVERRIDE; + virtual int CompareValues(int row1, int row2, int column_id) OVERRIDE; private: TableModelObserver* observer_; @@ -69,9 +70,9 @@ class GroupTestTableModel : public TestTableModel { virtual Groups GetGroups() { Groups groups; Group group1, group2; - group1.title = L"Group 1"; + group1.title = ASCIIToUTF16("Group 1"); group1.id = 0; - group2.title = L"Group 2"; + group2.title = ASCIIToUTF16("Group 2"); group2.id = 0; groups.push_back(group1); groups.push_back(group2); @@ -116,8 +117,8 @@ int TestTableModel::RowCount() { return static_cast<int>(rows_.size()); } -std::wstring TestTableModel::GetText(int row, int column_id) { - return UTF8ToWide(base::IntToString(rows_[row][column_id])); +string16 TestTableModel::GetText(int row, int column_id) { + return UTF8ToUTF16(base::IntToString(rows_[row][column_id])); } void TestTableModel::SetObserver(TableModelObserver* observer) { |