summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/autocomplete/autocomplete.cc8
-rw-r--r--chrome/browser/autocomplete/autocomplete.h3
-rw-r--r--chrome/browser/autocomplete/history_contents_provider.cc6
-rw-r--r--chrome/browser/autocomplete/history_url_provider.cc35
-rw-r--r--chrome/browser/autocomplete/search_provider.cc7
-rw-r--r--chrome/browser/bookmarks/bookmark_table_model.cc6
-rw-r--r--chrome/browser/bookmarks/bookmark_utils.cc3
-rw-r--r--chrome/browser/cocoa/status_bubble_mac_unittest.mm8
-rw-r--r--chrome/browser/gtk/options/passwords_exceptions_page_gtk.cc2
-rw-r--r--chrome/browser/gtk/options/passwords_page_gtk.cc4
-rw-r--r--chrome/browser/gtk/options/url_picker_dialog_gtk.cc3
-rw-r--r--chrome/browser/net/browser_url_util.cc6
-rw-r--r--chrome/browser/net/url_fixer_upper.cc8
-rw-r--r--chrome/browser/toolbar_model.cc4
-rw-r--r--chrome/browser/views/bookmark_editor_view.cc5
-rw-r--r--chrome/browser/views/url_picker.cc6
16 files changed, 53 insertions, 61 deletions
diff --git a/chrome/browser/autocomplete/autocomplete.cc b/chrome/browser/autocomplete/autocomplete.cc
index b6d7764..1278a9b 100644
--- a/chrome/browser/autocomplete/autocomplete.cc
+++ b/chrome/browser/autocomplete/autocomplete.cc
@@ -595,10 +595,14 @@ void AutocompleteProvider::UpdateStarredStateOfMatches() {
std::wstring AutocompleteProvider::StringForURLDisplay(
const GURL& url,
- bool check_accept_lang) const {
+ bool check_accept_lang,
+ bool trim_http) const {
std::wstring languages = (check_accept_lang && profile_) ?
profile_->GetPrefs()->GetString(prefs::kAcceptLanguages) : std::wstring();
- return net::FormatUrl(url, languages);
+ const net::FormatUrlTypes format_types = trim_http ?
+ net::kFormatUrlOmitAll : net::kFormatUrlOmitUsernamePassword;
+ return net::FormatUrl(url, languages, format_types, UnescapeRule::SPACES,
+ NULL, NULL, NULL);
}
// AutocompleteResult ---------------------------------------------------------
diff --git a/chrome/browser/autocomplete/autocomplete.h b/chrome/browser/autocomplete/autocomplete.h
index 124783f1..54bd9ff 100644
--- a/chrome/browser/autocomplete/autocomplete.h
+++ b/chrome/browser/autocomplete/autocomplete.h
@@ -561,7 +561,8 @@ class AutocompleteProvider
// "Accept Languages" when check_accept_lang is true. Otherwise, it's called
// with an empty list.
std::wstring StringForURLDisplay(const GURL& url,
- bool check_accept_lang) const;
+ bool check_accept_lang,
+ bool trim_http) const;
// The profile associated with the AutocompleteProvider. Reference is not
// owned by us.
diff --git a/chrome/browser/autocomplete/history_contents_provider.cc b/chrome/browser/autocomplete/history_contents_provider.cc
index ac81c31..1e72ceb 100644
--- a/chrome/browser/autocomplete/history_contents_provider.cc
+++ b/chrome/browser/autocomplete/history_contents_provider.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -207,11 +207,9 @@ AutocompleteMatch HistoryContentsProvider::ResultToMatch(
// Also show star in popup.
AutocompleteMatch match(this, score, false, MatchInTitle(result) ?
AutocompleteMatch::HISTORY_TITLE : AutocompleteMatch::HISTORY_BODY);
- match.fill_into_edit = StringForURLDisplay(result.url(), true);
+ match.fill_into_edit = StringForURLDisplay(result.url(), true, trim_http_);
match.destination_url = result.url();
match.contents = match.fill_into_edit;
- if (trim_http_)
- TrimHttpPrefix(&match.contents);
match.contents_class.push_back(
ACMatchClassification(0, ACMatchClassification::URL));
match.description = result.title();
diff --git a/chrome/browser/autocomplete/history_url_provider.cc b/chrome/browser/autocomplete/history_url_provider.cc
index 2708d47..8462925 100644
--- a/chrome/browser/autocomplete/history_url_provider.cc
+++ b/chrome/browser/autocomplete/history_url_provider.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -256,11 +256,9 @@ AutocompleteMatch HistoryURLProvider::SuggestExactInput(
const GURL& url = input.canonicalized_url();
if (url.is_valid()) {
match.destination_url = url;
- match.fill_into_edit = StringForURLDisplay(url, false);
+ match.fill_into_edit = StringForURLDisplay(url, false, trim_http);
// NOTE: Don't set match.input_location (to allow inline autocompletion)
// here, it's surprising and annoying.
- // Trim off "http://" if the user didn't type it.
- const size_t offset = trim_http ? TrimHttpPrefix(&match.fill_into_edit) : 0;
// Try to highlight "innermost" match location. If we fix up "w" into
// "www.w.com", we want to highlight the fifth character, not the first.
@@ -272,7 +270,7 @@ AutocompleteMatch HistoryURLProvider::SuggestExactInput(
// to not contain the user's input at all. In this case don't mark anything
// as a match.
const size_t match_location = (best_prefix == NULL) ?
- std::wstring::npos : best_prefix->prefix.length() - offset;
+ std::wstring::npos : best_prefix->prefix.length();
AutocompleteMatch::ClassifyLocationInString(match_location,
input.text().length(),
match.contents.length(),
@@ -828,17 +826,13 @@ AutocompleteMatch HistoryURLProvider::HistoryMatchToACMatch(
DCHECK(match.destination_url.is_valid());
size_t inline_autocomplete_offset =
history_match.input_location + params->input.text().length();
+ const net::FormatUrlTypes format_types =
+ (params->trim_http && !history_match.match_in_scheme) ?
+ net::kFormatUrlOmitAll : net::kFormatUrlOmitUsernamePassword;
match.fill_into_edit = net::FormatUrl(info.url(),
- match_type == WHAT_YOU_TYPED ? std::wstring() : params->languages, true,
- UnescapeRule::SPACES, NULL, NULL, &inline_autocomplete_offset);
- size_t offset = 0;
- if (params->trim_http && !history_match.match_in_scheme) {
- offset = TrimHttpPrefix(&match.fill_into_edit);
- if (inline_autocomplete_offset != std::wstring::npos) {
- DCHECK(inline_autocomplete_offset >= offset);
- inline_autocomplete_offset -= offset;
- }
- }
+ match_type == WHAT_YOU_TYPED ? std::wstring() : params->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) ||
@@ -846,15 +840,8 @@ AutocompleteMatch HistoryURLProvider::HistoryMatchToACMatch(
size_t match_start = history_match.input_location;
match.contents = net::FormatUrl(info.url(),
- match_type == WHAT_YOU_TYPED ? std::wstring() : params->languages, true,
- UnescapeRule::SPACES, NULL, NULL, &match_start);
- if (offset) {
- TrimHttpPrefix(&match.contents);
- if (match_start != std::wstring::npos) {
- DCHECK(match_start >= offset);
- match_start -= offset;
- }
- }
+ match_type == WHAT_YOU_TYPED ? std::wstring() : params->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/autocomplete/search_provider.cc b/chrome/browser/autocomplete/search_provider.cc
index 9a01fef..acba81e 100644
--- a/chrome/browser/autocomplete/search_provider.cc
+++ b/chrome/browser/autocomplete/search_provider.cc
@@ -737,10 +737,9 @@ AutocompleteMatch SearchProvider::NavigationToMatch(
AutocompleteMatch match(this, relevance, false,
AutocompleteMatch::NAVSUGGEST);
match.destination_url = navigation.url;
- match.contents = StringForURLDisplay(navigation.url, true);
- if (!url_util::FindAndCompareScheme(WideToUTF8(input_text),
- chrome::kHttpScheme, NULL))
- TrimHttpPrefix(&match.contents);
+ const bool trim_http = !url_util::FindAndCompareScheme(
+ WideToUTF8(input_text), chrome::kHttpScheme, NULL);
+ match.contents = StringForURLDisplay(navigation.url, true, trim_http);
AutocompleteMatch::ClassifyMatchInString(input_text, match.contents,
ACMatchClassification::URL,
&match.contents_class);
diff --git a/chrome/browser/bookmarks/bookmark_table_model.cc b/chrome/browser/bookmarks/bookmark_table_model.cc
index f7848e4..0ac5416 100644
--- a/chrome/browser/bookmarks/bookmark_table_model.cc
+++ b/chrome/browser/bookmarks/bookmark_table_model.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -325,8 +325,8 @@ std::wstring BookmarkTableModel::GetText(int row, int column_id) {
std::wstring languages = model_ && model_->profile()
? model_->profile()->GetPrefs()->GetString(prefs::kAcceptLanguages)
: std::wstring();
- std::wstring url_text = net::FormatUrl(node->GetURL(), languages, false,
- UnescapeRule::SPACES, NULL, NULL, NULL);
+ std::wstring url_text = net::FormatUrl(node->GetURL(), languages,
+ net::kFormatUrlOmitAll, UnescapeRule::SPACES, NULL, NULL, NULL);
if (base::i18n::IsRTL())
base::i18n::WrapStringWithLTRFormatting(&url_text);
return url_text;
diff --git a/chrome/browser/bookmarks/bookmark_utils.cc b/chrome/browser/bookmarks/bookmark_utils.cc
index 2214e4c..4ffeeb2 100644
--- a/chrome/browser/bookmarks/bookmark_utils.cc
+++ b/chrome/browser/bookmarks/bookmark_utils.cc
@@ -224,7 +224,8 @@ bool DoesBookmarkContainWords(const BookmarkNode* node,
DoesBookmarkTextContainWords(
l10n_util::ToLower(UTF8ToWide(node->GetURL().spec())), words) ||
DoesBookmarkTextContainWords(l10n_util::ToLower(net::FormatUrl(
- node->GetURL(), languages, false, true, NULL, NULL, NULL)), words);
+ node->GetURL(), languages, net::kFormatUrlOmitNothing,
+ UnescapeRule::NORMAL, NULL, NULL, NULL)), words);
}
} // namespace
diff --git a/chrome/browser/cocoa/status_bubble_mac_unittest.mm b/chrome/browser/cocoa/status_bubble_mac_unittest.mm
index 3dd628e..6f4dab4 100644
--- a/chrome/browser/cocoa/status_bubble_mac_unittest.mm
+++ b/chrome/browser/cocoa/status_bubble_mac_unittest.mm
@@ -141,7 +141,7 @@ TEST_F(StatusBubbleMacTest, SetURL) {
EXPECT_TRUE([GetURLText() isEqualToString:@"foopy://"]);
bubble_->SetURL(GURL("http://www.cnn.com"), L"");
EXPECT_TRUE(IsVisible());
- EXPECT_TRUE([GetURLText() isEqualToString:@"http://www.cnn.com/"]);
+ EXPECT_TRUE([GetURLText() isEqualToString:@"www.cnn.com/"]);
}
// Test hiding bubble that's already hidden.
@@ -162,7 +162,7 @@ TEST_F(StatusBubbleMacTest, SetStatusAndURL) {
EXPECT_TRUE([GetBubbleViewText() isEqualToString:@"Status"]);
bubble_->SetURL(GURL("http://www.nytimes.com/"), L"");
EXPECT_TRUE(IsVisible());
- EXPECT_TRUE([GetBubbleViewText() isEqualToString:@"http://www.nytimes.com/"]);
+ EXPECT_TRUE([GetBubbleViewText() isEqualToString:@"www.nytimes.com/"]);
bubble_->SetURL(GURL(), L"");
EXPECT_TRUE(IsVisible());
EXPECT_TRUE([GetBubbleViewText() isEqualToString:@"Status"]);
@@ -170,13 +170,13 @@ TEST_F(StatusBubbleMacTest, SetStatusAndURL) {
EXPECT_FALSE(IsVisible());
bubble_->SetURL(GURL("http://www.nytimes.com/"), L"");
EXPECT_TRUE(IsVisible());
- EXPECT_TRUE([GetBubbleViewText() isEqualToString:@"http://www.nytimes.com/"]);
+ EXPECT_TRUE([GetBubbleViewText() isEqualToString:@"www.nytimes.com/"]);
bubble_->SetStatus(L"Status");
EXPECT_TRUE(IsVisible());
EXPECT_TRUE([GetBubbleViewText() isEqualToString:@"Status"]);
bubble_->SetStatus(L"");
EXPECT_TRUE(IsVisible());
- EXPECT_TRUE([GetBubbleViewText() isEqualToString:@"http://www.nytimes.com/"]);
+ EXPECT_TRUE([GetBubbleViewText() isEqualToString:@"www.nytimes.com/"]);
bubble_->SetURL(GURL(), L"");
EXPECT_FALSE(IsVisible());
}
diff --git a/chrome/browser/gtk/options/passwords_exceptions_page_gtk.cc b/chrome/browser/gtk/options/passwords_exceptions_page_gtk.cc
index 5488e4f..8162610 100644
--- a/chrome/browser/gtk/options/passwords_exceptions_page_gtk.cc
+++ b/chrome/browser/gtk/options/passwords_exceptions_page_gtk.cc
@@ -116,7 +116,7 @@ void PasswordsExceptionsPageGtk::SetExceptionList(
for (size_t i = 0; i < result.size(); ++i) {
exception_list_[i] = *result[i];
std::wstring formatted = net::FormatUrl(result[i]->origin, languages,
- false, UnescapeRule::NONE, NULL, NULL, NULL);
+ net::kFormatUrlOmitAll, UnescapeRule::NONE, NULL, NULL, NULL);
std::string site = WideToUTF8(formatted);
GtkTreeIter iter;
gtk_list_store_insert_with_values(exception_list_store_, &iter, (gint) i,
diff --git a/chrome/browser/gtk/options/passwords_page_gtk.cc b/chrome/browser/gtk/options/passwords_page_gtk.cc
index 0de0403..9ecf89f 100644
--- a/chrome/browser/gtk/options/passwords_page_gtk.cc
+++ b/chrome/browser/gtk/options/passwords_page_gtk.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -160,7 +160,7 @@ void PasswordsPageGtk::SetPasswordList(
for (size_t i = 0; i < result.size(); ++i) {
password_list_[i] = *result[i];
std::wstring formatted = net::FormatUrl(result[i]->origin, languages,
- false, UnescapeRule::NONE, NULL, NULL, NULL);
+ net::kFormatUrlOmitAll, UnescapeRule::NONE, NULL, NULL, NULL);
std::string site = WideToUTF8(formatted);
std::string user = UTF16ToUTF8(result[i]->username_value);
GtkTreeIter iter;
diff --git a/chrome/browser/gtk/options/url_picker_dialog_gtk.cc b/chrome/browser/gtk/options/url_picker_dialog_gtk.cc
index df45b14..b5e5a5b 100644
--- a/chrome/browser/gtk/options/url_picker_dialog_gtk.cc
+++ b/chrome/browser/gtk/options/url_picker_dialog_gtk.cc
@@ -198,7 +198,8 @@ std::string UrlPickerDialogGtk::GetURLForPath(GtkTreePath* path) const {
// Because the url_field_ is user-editable, we set the URL with
// username:password and escaped path and query.
std::wstring formatted = net::FormatUrl(url_table_model_->GetURL(row),
- languages, false, UnescapeRule::NONE, NULL, NULL, NULL);
+ languages, net::kFormatUrlOmitNothing, UnescapeRule::NONE, NULL, NULL,
+ NULL);
return WideToUTF8(formatted);
}
diff --git a/chrome/browser/net/browser_url_util.cc b/chrome/browser/net/browser_url_util.cc
index 9c8ab48..24747b2 100644
--- a/chrome/browser/net/browser_url_util.cc
+++ b/chrome/browser/net/browser_url_util.cc
@@ -1,4 +1,4 @@
-// Copyright (c) 2009 The Chromium Authors. All rights reserved.
+// Copyright (c) 2010 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.
@@ -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, false, UnescapeRule::NONE,
- NULL, NULL, NULL));
+ WideToUTF16(net::FormatUrl(url, languages, net::kFormatUrlOmitNothing,
+ UnescapeRule::NONE, NULL, NULL, NULL));
ScopedClipboardWriter scw(clipboard);
scw.WriteURL(text);
diff --git a/chrome/browser/net/url_fixer_upper.cc b/chrome/browser/net/url_fixer_upper.cc
index edacefd..9d974db 100644
--- a/chrome/browser/net/url_fixer_upper.cc
+++ b/chrome/browser/net/url_fixer_upper.cc
@@ -170,8 +170,9 @@ 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(), true,
- UnescapeRule::NORMAL, NULL, NULL, NULL));
+ return WideToUTF8(net::FormatUrl(file_url, std::wstring(),
+ net::kFormatUrlOmitUsernamePassword, UnescapeRule::NORMAL, NULL,
+ NULL, NULL));
}
// Invalid file URL, just return the input.
@@ -557,7 +558,8 @@ std::string URLFixerUpper::FixupRelativeFile(const FilePath& base_dir,
GURL file_url = net::FilePathToFileURL(full_path);
if (file_url.is_valid())
return WideToUTF8(net::FormatUrl(file_url, std::wstring(),
- true, UnescapeRule::NORMAL, NULL, NULL, NULL));
+ net::kFormatUrlOmitUsernamePassword, UnescapeRule::NORMAL, NULL,
+ NULL, NULL));
// Invalid files fall through to regular processing.
}
diff --git a/chrome/browser/toolbar_model.cc b/chrome/browser/toolbar_model.cc
index add91d8..eeae184 100644
--- a/chrome/browser/toolbar_model.cc
+++ b/chrome/browser/toolbar_model.cc
@@ -53,8 +53,8 @@ std::wstring ToolbarModel::GetText() const {
url = GURL(url.scheme() + ":");
}
}
- return net::FormatUrl(url, languages, true, UnescapeRule::NORMAL, NULL, NULL,
- NULL);
+ return 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 34f8e91..bd61ab3 100644
--- a/chrome/browser/views/bookmark_editor_view.cc
+++ b/chrome/browser/views/bookmark_editor_view.cc
@@ -282,10 +282,9 @@ void BookmarkEditorView::Init() {
std::wstring languages = profile_
? profile_->GetPrefs()->GetString(prefs::kAcceptLanguages)
: std::wstring();
- // The following URL is user-editable. We specify omit_username_password=
- // false and unescape=false to show the original URL except IDN.
+ // The following URL is user-editable, so we don't strip anything from it.
url_text = net::FormatUrl(details_.existing_node->GetURL(), languages,
- false, UnescapeRule::NONE, NULL, NULL, NULL);
+ net::kFormatUrlOmitNothing, UnescapeRule::NONE, NULL, NULL, NULL);
}
url_tf_.SetText(url_text);
url_tf_.SetController(this);
diff --git a/chrome/browser/views/url_picker.cc b/chrome/browser/views/url_picker.cc
index 5f82832..3d275d4 100644
--- a/chrome/browser/views/url_picker.cc
+++ b/chrome/browser/views/url_picker.cc
@@ -221,10 +221,10 @@ void UrlPicker::OnSelectionChanged() {
if (selection >= 0 && selection < url_table_model_->RowCount()) {
std::wstring languages =
profile_->GetPrefs()->GetString(prefs::kAcceptLanguages);
- // Because the url_field_ is user-editable, we set the URL with
- // username:password and escaped path and query.
+ // Because the url_field_ is user-editable, we don't strip anything.
std::wstring formatted = net::FormatUrl(url_table_model_->GetURL(selection),
- languages, false, UnescapeRule::NONE, NULL, NULL, NULL);
+ languages, net::kFormatUrlOmitNothing, UnescapeRule::NONE, NULL, NULL,
+ NULL);
url_field_->SetText(formatted);
GetDialogClientView()->UpdateDialogButtons();
}