diff options
author | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-31 06:14:17 +0000 |
---|---|---|
committer | viettrungluu@chromium.org <viettrungluu@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-08-31 06:14:17 +0000 |
commit | 9f284f13fd93a37bd8afa4840e91a953f4c9bc51 (patch) | |
tree | 4a5e7e73c5ed978b2e18569080a70c18a821da76 /chrome | |
parent | f33fdc5d17ae9e0439d2e68344da6d5f12dc26a5 (diff) | |
download | chromium_src-9f284f13fd93a37bd8afa4840e91a953f4c9bc51.zip chromium_src-9f284f13fd93a37bd8afa4840e91a953f4c9bc51.tar.gz chromium_src-9f284f13fd93a37bd8afa4840e91a953f4c9bc51.tar.bz2 |
Remove the wstring FormatUrl() functions (and convert remaining users to the string16 verison).
Still to do: Actually convert the code underlying FormatUrl().
BUG=23581
TEST=builds and passes tests
Review URL: http://codereview.chromium.org/3263005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@57968 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
18 files changed, 58 insertions, 58 deletions
diff --git a/chrome/browser/autocomplete/autocomplete.cc b/chrome/browser/autocomplete/autocomplete.cc index a66c84a..e69d413 100644 --- a/chrome/browser/autocomplete/autocomplete.cc +++ b/chrome/browser/autocomplete/autocomplete.cc @@ -648,14 +648,13 @@ void AutocompleteProvider::UpdateStarredStateOfMatches() { std::wstring AutocompleteProvider::StringForURLDisplay(const GURL& url, bool check_accept_lang, bool trim_http) const { - std::wstring languages = (check_accept_lang && profile_) ? - UTF8ToWide(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)) : - std::wstring(); - return net::FormatUrl( + std::string languages = (check_accept_lang && profile_) ? + profile_->GetPrefs()->GetString(prefs::kAcceptLanguages) : std::string(); + return UTF16ToWideHack(net::FormatUrl( url, languages, net::kFormatUrlOmitAll & ~(trim_http ? 0 : net::kFormatUrlOmitHTTP), - UnescapeRule::SPACES, NULL, NULL, NULL); + UnescapeRule::SPACES, NULL, NULL, NULL)); } // AutocompleteResult --------------------------------------------------------- diff --git a/chrome/browser/autocomplete/history_url_provider.cc b/chrome/browser/autocomplete/history_url_provider.cc index c2a2bca..20718f7 100644 --- a/chrome/browser/autocomplete/history_url_provider.cc +++ b/chrome/browser/autocomplete/history_url_provider.cc @@ -876,23 +876,24 @@ AutocompleteMatch HistoryURLProvider::HistoryMatchToACMatch( DCHECK(match.destination_url.is_valid()); size_t inline_autocomplete_offset = history_match.input_location + params->input.text().length(); + std::string languages = (match_type == WHAT_YOU_TYPED) ? + std::string() : WideToUTF8(params->languages); const net::FormatUrlTypes format_types = net::kFormatUrlOmitAll & ~((params->trim_http && !history_match.match_in_scheme) ? 0 : net::kFormatUrlOmitHTTP); match.fill_into_edit = AutocompleteInput::FormattedStringWithEquivalentMeaning(info.url(), - net::FormatUrl(info.url(), match_type == WHAT_YOU_TYPED ? - std::wstring() : params->languages, format_types, UnescapeRule::SPACES, - NULL, NULL, &inline_autocomplete_offset)); + UTF16ToWideHack(net::FormatUrl(info.url(), languages, format_types, + UnescapeRule::SPACES, NULL, NULL, + &inline_autocomplete_offset))); if (!params->input.prevent_inline_autocomplete()) match.inline_autocomplete_offset = inline_autocomplete_offset; DCHECK((match.inline_autocomplete_offset == std::wstring::npos) || (match.inline_autocomplete_offset <= match.fill_into_edit.length())); size_t match_start = history_match.input_location; - match.contents = net::FormatUrl(info.url(), - match_type == WHAT_YOU_TYPED ? std::wstring() : params->languages, - format_types, UnescapeRule::SPACES, NULL, NULL, &match_start); + match.contents = UTF16ToWideHack(net::FormatUrl(info.url(), languages, + format_types, UnescapeRule::SPACES, NULL, NULL, &match_start)); if ((match_start != std::wstring::npos) && (inline_autocomplete_offset != std::wstring::npos) && (inline_autocomplete_offset != match_start)) { diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc index 89b5ea0..ebcf1da 100644 --- a/chrome/browser/browser.cc +++ b/chrome/browser/browser.cc @@ -1415,7 +1415,7 @@ void Browser::WriteCurrentURLToClipboard() { chrome_browser_net::WriteURLToClipboard( contents->GetURL(), - UTF8ToWide(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)), + profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), g_browser_process->clipboard()); } diff --git a/chrome/browser/geolocation/geolocation_permission_context.cc b/chrome/browser/geolocation/geolocation_permission_context.cc index 8183106..0434a99 100644 --- a/chrome/browser/geolocation/geolocation_permission_context.cc +++ b/chrome/browser/geolocation/geolocation_permission_context.cc @@ -92,7 +92,7 @@ class GeolocationConfirmInfoBarDelegate : public ConfirmInfoBarDelegate { TabContents* tab_contents, GeolocationInfoBarQueueController* controller, int render_process_id, int render_view_id, int bridge_id, const GURL& requesting_frame_url, - const std::wstring& display_languages) + const std::string& display_languages) : ConfirmInfoBarDelegate(tab_contents), tab_contents_(tab_contents), controller_(controller), @@ -128,8 +128,7 @@ class GeolocationConfirmInfoBarDelegate : public ConfirmInfoBarDelegate { virtual string16 GetMessageText() const { return l10n_util::GetStringFUTF16( IDS_GEOLOCATION_INFOBAR_QUESTION, - WideToUTF16Hack(net::FormatUrl(requesting_frame_url_.GetOrigin(), - display_languages_))); + net::FormatUrl(requesting_frame_url_.GetOrigin(), display_languages_)); } virtual SkBitmap* GetIcon() const { return ResourceBundle::GetSharedInstance().GetBitmapNamed( @@ -160,7 +159,7 @@ class GeolocationConfirmInfoBarDelegate : public ConfirmInfoBarDelegate { int render_view_id_; int bridge_id_; GURL requesting_frame_url_; - std::wstring display_languages_; + std::string display_languages_; DISALLOW_IMPLICIT_CONSTRUCTORS(GeolocationConfirmInfoBarDelegate); }; @@ -298,7 +297,7 @@ void GeolocationInfoBarQueueController::ShowQueuedInfoBar( tab_contents, this, render_process_id, render_view_id, i->bridge_id, i->requesting_frame, - UTF8ToWide(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages))); + profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)); tab_contents->AddInfoBar(i->infobar_delegate); break; } diff --git a/chrome/browser/history/in_memory_history_backend.cc b/chrome/browser/history/in_memory_history_backend.cc index d07f9a6..b3d5da9 100644 --- a/chrome/browser/history/in_memory_history_backend.cc +++ b/chrome/browser/history/in_memory_history_backend.cc @@ -42,7 +42,7 @@ bool InMemoryHistoryBackend::Init(const FilePath& history_filename, index_.reset(new InMemoryURLIndex()); base::TimeTicks beginning_time = base::TimeTicks::Now(); // TODO(mrossetti): Provide languages when profile is available. - index_->Init(db, NULL); + index_->Init(db, std::string()); UMA_HISTOGRAM_TIMES("Autocomplete.HistoryDatabaseIndexingTime", base::TimeTicks::Now() - beginning_time); } diff --git a/chrome/browser/history/in_memory_url_index.cc b/chrome/browser/history/in_memory_url_index.cc index a9f55ab..5715d39 100644 --- a/chrome/browser/history/in_memory_url_index.cc +++ b/chrome/browser/history/in_memory_url_index.cc @@ -28,9 +28,9 @@ InMemoryURLIndex::~InMemoryURLIndex() {} // Indexing bool InMemoryURLIndex::Init(history::URLDatabase* history_db, - const string16* languages) { + const std::string& languages) { // TODO(mrossetti): Register for profile/language change notifications. - languages_ = *languages; + languages_ = languages; // Reset our indexes. char_word_map_.clear(); word_id_history_map_.clear(); @@ -56,10 +56,10 @@ bool InMemoryURLIndex::Init(history::URLDatabase* history_db, bool InMemoryURLIndex::IndexRow(URLRow row) { const GURL& gurl(row.url()); - string16 url(WideToUTF16(net::FormatUrl(gurl, UTF16ToWide(languages_), + string16 url(net::FormatUrl(gurl, languages_, net::kFormatUrlOmitUsernamePassword, - UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS, NULL, NULL, - NULL))); + UnescapeRule::SPACES | UnescapeRule::URL_SPECIAL_CHARS, + NULL, NULL, NULL)); // TODO(mrossetti): Find or implement a ConvertPercentEncoding and use it // on the url. diff --git a/chrome/browser/history/in_memory_url_index.h b/chrome/browser/history/in_memory_url_index.h index 2b89d02..5f7ee3a 100644 --- a/chrome/browser/history/in_memory_url_index.h +++ b/chrome/browser/history/in_memory_url_index.h @@ -8,6 +8,7 @@ #include <map> #include <set> +#include <string> #include <vector> #include "app/sql/connection.h" @@ -55,7 +56,7 @@ class InMemoryURLIndex { typedef std::vector<string16> String16Vector; // Open and index the URL history database. - bool Init(URLDatabase* history_db, const string16* languages); + bool Init(URLDatabase* history_db, const std::string& languages); // Reset the history index. void Reset(); @@ -158,7 +159,7 @@ class InMemoryURLIndex { WordIDHistoryMap word_id_history_map_; TermCharWordSetVector term_char_word_set_cache_; HistoryInfoMap history_info_map_; - string16 languages_; + std::string languages_; DISALLOW_COPY_AND_ASSIGN(InMemoryURLIndex); }; diff --git a/chrome/browser/history/in_memory_url_index_unittest.cc b/chrome/browser/history/in_memory_url_index_unittest.cc index 8c808f9..f399496 100644 --- a/chrome/browser/history/in_memory_url_index_unittest.cc +++ b/chrome/browser/history/in_memory_url_index_unittest.cc @@ -118,8 +118,7 @@ TEST_F(InMemoryURLIndexTest, Initialization) { while (statement.Step()) ++row_count; EXPECT_EQ(29U, row_count); url_index_.reset(new InMemoryURLIndex); - string16 languages = UTF8ToUTF16("en,ja,hi,zh"); - url_index_->Init(this, &languages); + url_index_->Init(this, "en,ja,hi,zh"); // There should have been 25 of the 29 urls accepted during filtering. EXPECT_EQ(25U, url_index_->history_item_count_); diff --git a/chrome/browser/net/browser_url_util.cc b/chrome/browser/net/browser_url_util.cc index 24747b2..786ab7d 100644 --- a/chrome/browser/net/browser_url_util.cc +++ b/chrome/browser/net/browser_url_util.cc @@ -14,7 +14,7 @@ namespace chrome_browser_net { void WriteURLToClipboard(const GURL& url, - const std::wstring& languages, + const std::string& languages, Clipboard *clipboard) { if (url.is_empty() || !url.is_valid() || !clipboard) return; @@ -23,8 +23,8 @@ void WriteURLToClipboard(const GURL& url, // may not encode non-ASCII characters in UTF-8. See crbug.com/2820. string16 text = url.SchemeIs(chrome::kMailToScheme) ? ASCIIToUTF16(url.path()) : - WideToUTF16(net::FormatUrl(url, languages, net::kFormatUrlOmitNothing, - UnescapeRule::NONE, NULL, NULL, NULL)); + net::FormatUrl(url, languages, net::kFormatUrlOmitNothing, + UnescapeRule::NONE, NULL, NULL, NULL); ScopedClipboardWriter scw(clipboard); scw.WriteURL(text); diff --git a/chrome/browser/net/browser_url_util.h b/chrome/browser/net/browser_url_util.h index 93c96c0..043725f7 100644 --- a/chrome/browser/net/browser_url_util.h +++ b/chrome/browser/net/browser_url_util.h @@ -15,7 +15,7 @@ namespace chrome_browser_net { // Writes a string representation of |url| to the system clipboard. void WriteURLToClipboard(const GURL& url, - const std::wstring& languages, + const std::string& languages, Clipboard *clipboard); } // namespace chrome_browser_net diff --git a/chrome/browser/net/url_fixer_upper.cc b/chrome/browser/net/url_fixer_upper.cc index 3aad8f2..ee8d00b 100644 --- a/chrome/browser/net/url_fixer_upper.cc +++ b/chrome/browser/net/url_fixer_upper.cc @@ -170,7 +170,7 @@ static std::string FixupPath(const std::string& text) { // Here, we know the input looks like a file. GURL file_url = net::FilePathToFileURL(FilePath(filename)); if (file_url.is_valid()) { - return WideToUTF8(net::FormatUrl(file_url, std::wstring(), + return UTF16ToUTF8(net::FormatUrl(file_url, std::string(), net::kFormatUrlOmitUsernamePassword, UnescapeRule::NORMAL, NULL, NULL, NULL)); } @@ -568,7 +568,7 @@ GURL URLFixerUpper::FixupRelativeFile(const FilePath& base_dir, if (is_file) { GURL file_url = net::FilePathToFileURL(full_path); if (file_url.is_valid()) - return GURL(WideToUTF8(net::FormatUrl(file_url, std::wstring(), + return GURL(UTF16ToUTF8(net::FormatUrl(file_url, std::string(), net::kFormatUrlOmitUsernamePassword, UnescapeRule::NORMAL, NULL, NULL, NULL))); // Invalid files fall through to regular processing. diff --git a/chrome/browser/tab_contents/navigation_controller.cc b/chrome/browser/tab_contents/navigation_controller.cc index e1667e2..a416bc9 100644 --- a/chrome/browser/tab_contents/navigation_controller.cc +++ b/chrome/browser/tab_contents/navigation_controller.cc @@ -250,9 +250,9 @@ NavigationEntry* NavigationController::CreateNavigationEntry( // Use the filename as the title, not the full path. // We need to call FormatUrl() to perform URL de-escaping; // it's a bit ugly to grab the filename out of the resulting string. - std::wstring languages = UTF8ToWide(profile->GetPrefs()->GetString( - prefs::kAcceptLanguages)); - std::wstring formatted = net::FormatUrl(url, languages); + std::string languages = + profile->GetPrefs()->GetString(prefs::kAcceptLanguages); + std::wstring formatted = UTF16ToWideHack(net::FormatUrl(url, languages)); std::wstring filename = FilePath::FromWStringHack(formatted).BaseName().ToWStringHack(); entry->set_title(WideToUTF16Hack(filename)); diff --git a/chrome/browser/tab_contents/navigation_entry.cc b/chrome/browser/tab_contents/navigation_entry.cc index 0933f1e..c345958 100644 --- a/chrome/browser/tab_contents/navigation_entry.cc +++ b/chrome/browser/tab_contents/navigation_entry.cc @@ -89,20 +89,20 @@ const string16& NavigationEntry::GetTitleForDisplay( return cached_display_title_; // Use the virtual URL first if any, and fall back on using the real URL. - std::wstring languages; + std::string languages; if (navigation_controller) { - languages = UTF8ToWide(navigation_controller->profile()->GetPrefs()-> - GetString(prefs::kAcceptLanguages)); + languages = navigation_controller->profile()->GetPrefs()-> + GetString(prefs::kAcceptLanguages); } - std::wstring title; + string16 title; std::wstring elided_title; if (!virtual_url_.is_empty()) { title = net::FormatUrl(virtual_url_, languages); } else if (!url_.is_empty()) { title = net::FormatUrl(url_, languages); } - ElideString(title, chrome::kMaxTitleChars, &elided_title); + ElideString(UTF16ToWideHack(title), chrome::kMaxTitleChars, &elided_title); cached_display_title_ = WideToUTF16Hack(elided_title); return cached_display_title_; } diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc index 5b8151d..84ba4c4 100644 --- a/chrome/browser/tab_contents/render_view_context_menu.cc +++ b/chrome/browser/tab_contents/render_view_context_menu.cc @@ -1454,7 +1454,7 @@ void RenderViewContextMenu::Inspect(int x, int y) { void RenderViewContextMenu::WriteURLToClipboard(const GURL& url) { chrome_browser_net::WriteURLToClipboard( url, - UTF8ToWide(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)), + profile_->GetPrefs()->GetString(prefs::kAcceptLanguages), g_browser_process->clipboard()); } diff --git a/chrome/browser/toolbar_model.cc b/chrome/browser/toolbar_model.cc index 5d6185b..e8cdaaf 100644 --- a/chrome/browser/toolbar_model.cc +++ b/chrome/browser/toolbar_model.cc @@ -33,13 +33,12 @@ ToolbarModel::~ToolbarModel() { // ToolbarModel Implementation. std::wstring ToolbarModel::GetText() const { GURL url(chrome::kAboutBlankURL); - std::wstring languages; // Empty if we don't have a |navigation_controller|. + std::string languages; // Empty if we don't have a |navigation_controller|. NavigationController* navigation_controller = GetNavigationController(); if (navigation_controller) { - languages = UTF8ToWide( - navigation_controller->profile()->GetPrefs()->GetString( - prefs::kAcceptLanguages)); + languages = navigation_controller->profile()->GetPrefs()->GetString( + prefs::kAcceptLanguages); NavigationEntry* entry = navigation_controller->GetActiveEntry(); if (!navigation_controller->tab_contents()->ShouldDisplayURL()) { // Explicitly hide the URL for this tab. @@ -54,8 +53,8 @@ std::wstring ToolbarModel::GetText() const { // and pastes it into another program, that program may think the URL ends at // the space. return AutocompleteInput::FormattedStringWithEquivalentMeaning(url, - net::FormatUrl(url, languages, net::kFormatUrlOmitAll, - UnescapeRule::NORMAL, NULL, NULL, NULL)); + UTF16ToWideHack(net::FormatUrl(url, languages, net::kFormatUrlOmitAll, + UnescapeRule::NORMAL, NULL, NULL, NULL))); } ToolbarModel::SecurityLevel ToolbarModel::GetSecurityLevel() const { diff --git a/chrome/browser/views/bookmark_editor_view.cc b/chrome/browser/views/bookmark_editor_view.cc index 9bf525c..6f892a3 100644 --- a/chrome/browser/views/bookmark_editor_view.cc +++ b/chrome/browser/views/bookmark_editor_view.cc @@ -275,11 +275,11 @@ void BookmarkEditorView::Init() { l10n_util::GetString(IDS_BOOMARK_EDITOR_NAME_LABEL)); title_tf_.SetAccessibleName(title_label_->GetText()); - std::wstring url_text; + string16 url_text; if (details_.type == EditDetails::EXISTING_NODE) { - std::wstring languages = profile_ - ? UTF8ToWide(profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)) - : std::wstring(); + std::string languages = profile_ + ? profile_->GetPrefs()->GetString(prefs::kAcceptLanguages) + : std::string(); // Because this gets parsed by FixupURL(), it's safe to omit the scheme or // trailing slash, and unescape most characters, but we need to not drop any // username/password, or unescape anything that changes the meaning. @@ -287,7 +287,7 @@ void BookmarkEditorView::Init() { net::kFormatUrlOmitAll & ~net::kFormatUrlOmitUsernamePassword, UnescapeRule::SPACES, NULL, NULL, NULL); } - url_tf_.SetText(url_text); + url_tf_.SetText(UTF16ToWide(url_text)); url_tf_.SetController(this); url_label_ = new views::Label( diff --git a/chrome/browser/views/status_bubble_views.cc b/chrome/browser/views/status_bubble_views.cc index 9cdf889..1b21457 100644 --- a/chrome/browser/views/status_bubble_views.cc +++ b/chrome/browser/views/status_bubble_views.cc @@ -648,7 +648,8 @@ void StatusBubbleViews::SetURL(const GURL& url, const std::wstring& languages) { url_text_ = gfx::ElideUrl(url, view_->Label::font(), text_width, languages); - std::wstring original_url_text = net::FormatUrl(url, languages); + std::wstring original_url_text = + UTF16ToWideHack(net::FormatUrl(url, WideToUTF8(languages))); // An URL is always treated as a left-to-right string. On right-to-left UIs // we need to explicitly mark the URL as LTR to make sure it is displayed diff --git a/chrome/browser/views/url_picker.cc b/chrome/browser/views/url_picker.cc index 6663bd3..3b9ac40 100644 --- a/chrome/browser/views/url_picker.cc +++ b/chrome/browser/views/url_picker.cc @@ -9,6 +9,7 @@ #include "app/table_model.h" #include "base/keyboard_codes.h" #include "base/stl_util-inl.h" +#include "base/string16.h" #include "base/utf_string_conversions.h" #include "chrome/browser/net/url_fixer_upper.h" #include "chrome/browser/possible_url_model.h" @@ -218,16 +219,16 @@ bool UrlPicker::AcceleratorPressed( void UrlPicker::OnSelectionChanged() { int selection = url_table_->FirstSelectedRow(); if (selection >= 0 && selection < url_table_model_->RowCount()) { - std::wstring languages = UTF8ToWide( - profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)); + std::string languages = + profile_->GetPrefs()->GetString(prefs::kAcceptLanguages); // Because this gets parsed by FixupURL(), it's safe to omit the scheme or // trailing slash, and unescape most characters, but we need to not drop any // username/password, or unescape anything that changes the meaning. - std::wstring formatted = net::FormatUrl(url_table_model_->GetURL(selection), + string16 formatted = net::FormatUrl(url_table_model_->GetURL(selection), languages, net::kFormatUrlOmitAll & ~net::kFormatUrlOmitUsernamePassword, UnescapeRule::SPACES, NULL, NULL, NULL); - url_field_->SetText(formatted); + url_field_->SetText(UTF16ToWide(formatted)); GetDialogClientView()->UpdateDialogButtons(); } } |