summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
authormhm@chromium.org <mhm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-03 02:16:32 +0000
committermhm@chromium.org <mhm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2009-06-03 02:16:32 +0000
commita23de85783d944cbb75f09737eb29c60ea87481d (patch)
tree30c4732b42443259134a3f83f574bfaa2a506292 /chrome/browser
parent1b5237ecc1fea39e51e1634acbcdf11bd7ef57b0 (diff)
downloadchromium_src-a23de85783d944cbb75f09737eb29c60ea87481d.zip
chromium_src-a23de85783d944cbb75f09737eb29c60ea87481d.tar.gz
chromium_src-a23de85783d944cbb75f09737eb29c60ea87481d.tar.bz2
Local text file with spaces in filename is urlencoded in tab title
When viewing a local text file with spaces in filename, it is still urlencoded. Filename should be displayed with spaces, not with urlencoding. It would be more user-friendly. Since net::FormatURL is already implemented, using it would be great. But it doesn't escape SPACES, just NORMAL, it doesn't even escape unicode. I plumbed out a unescapeurl that could be used whether we allow conversion of spaces or not. BUG=8775 (http://crbug.com/8775) TEST=Tested whether the input is escaped in the navigational context and ran the net tests New Review: http://codereview.chromium.org/118059 Review URL: http://codereview.chromium.org/56053 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@17462 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/bookmarks/bookmark_table_model.cc4
-rw-r--r--chrome/browser/net/url_fixer_upper.cc6
-rw-r--r--chrome/browser/tab_contents/navigation_controller.cc8
-rw-r--r--chrome/browser/tab_contents/render_view_context_menu.cc3
-rw-r--r--chrome/browser/views/bookmark_editor_view.cc3
-rw-r--r--chrome/browser/views/shelf_item_dialog.cc2
6 files changed, 19 insertions, 7 deletions
diff --git a/chrome/browser/bookmarks/bookmark_table_model.cc b/chrome/browser/bookmarks/bookmark_table_model.cc
index 44978ce..4ff6a57 100644
--- a/chrome/browser/bookmarks/bookmark_table_model.cc
+++ b/chrome/browser/bookmarks/bookmark_table_model.cc
@@ -18,6 +18,7 @@
#include "grit/app_resources.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
+#include "net/base/escape.h"
#include "net/base/net_util.h"
#if defined(TOOLKIT_VIEWS)
@@ -326,7 +327,8 @@ std::wstring BookmarkTableModel::GetText(int row, int column_id) {
? model_->profile()->GetPrefs()->GetString(prefs::kAcceptLanguages)
: std::wstring();
std::wstring url_text =
- net::FormatUrl(node->GetURL(), languages, false, true, NULL, NULL);
+ net::FormatUrl(node->GetURL(), languages, false, UnescapeRule::SPACES,
+ NULL, NULL);
if (l10n_util::GetTextDirection() == l10n_util::RIGHT_TO_LEFT)
l10n_util::WrapStringWithLTRFormatting(&url_text);
return url_text;
diff --git a/chrome/browser/net/url_fixer_upper.cc b/chrome/browser/net/url_fixer_upper.cc
index f2c29ca..4097b88 100644
--- a/chrome/browser/net/url_fixer_upper.cc
+++ b/chrome/browser/net/url_fixer_upper.cc
@@ -121,7 +121,8 @@ static string FixupPath(const 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 WideToUTF8(net::FormatUrl(file_url, std::wstring(), true,
+ UnescapeRule::NORMAL, NULL, NULL));
}
// Invalid file URL, just return the input.
@@ -520,7 +521,8 @@ string URLFixerUpper::FixupRelativeFile(const FilePath& base_dir,
if (is_file) {
GURL file_url = net::FilePathToFileURL(full_path);
if (file_url.is_valid())
- return WideToUTF8(net::FormatUrl(file_url, std::wstring()));
+ return WideToUTF8(net::FormatUrl(file_url, std::wstring(),
+ true, UnescapeRule::NORMAL, 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 2a30087..076d525 100644
--- a/chrome/browser/tab_contents/navigation_controller.cc
+++ b/chrome/browser/tab_contents/navigation_controller.cc
@@ -18,9 +18,13 @@
#include "chrome/browser/tab_contents/site_instance.h"
#include "chrome/common/navigation_types.h"
#include "chrome/common/notification_service.h"
+#include "chrome/common/pref_names.h"
+#include "chrome/common/pref_service.h"
#include "chrome/common/render_messages.h"
#include "chrome/common/url_constants.h"
#include "grit/app_resources.h"
+#include "net/base/escape.h"
+#include "net/base/net_util.h"
#include "webkit/glue/webkit_glue.h"
#if defined(OS_WIN)
@@ -354,8 +358,10 @@ NavigationEntry* NavigationController::CreateNavigationEntry(
entry->set_display_url(url);
entry->set_user_typed_url(url);
if (url.SchemeIsFile()) {
+ std::wstring languages = profile()->GetPrefs()->GetString(
+ prefs::kAcceptLanguages);
entry->set_title(WideToUTF16Hack(
- file_util::GetFilenameFromPath(UTF8ToWide(url.host() + url.path()))));
+ file_util::GetFilenameFromPath(net::FormatUrl(url, languages))));
}
return entry;
}
diff --git a/chrome/browser/tab_contents/render_view_context_menu.cc b/chrome/browser/tab_contents/render_view_context_menu.cc
index 2ee2726..fc387d9 100644
--- a/chrome/browser/tab_contents/render_view_context_menu.cc
+++ b/chrome/browser/tab_contents/render_view_context_menu.cc
@@ -22,6 +22,7 @@
#include "chrome/common/pref_service.h"
#include "chrome/common/url_constants.h"
#include "grit/generated_resources.h"
+#include "net/base/escape.h"
#include "net/base/net_util.h"
#if defined(OS_WIN)
@@ -649,7 +650,7 @@ void RenderViewContextMenu::WriteURLToClipboard(const GURL& url) {
// See crbug.com/2820.
WideToUTF8(net::FormatUrl(
url, profile_->GetPrefs()->GetString(prefs::kAcceptLanguages),
- false, false, NULL, NULL));
+ false, UnescapeRule::NONE, NULL, NULL));
WriteTextToClipboard(UTF8ToUTF16(utf8_text));
DidWriteURLToClipboard(utf8_text);
diff --git a/chrome/browser/views/bookmark_editor_view.cc b/chrome/browser/views/bookmark_editor_view.cc
index 7825433..b845b39 100644
--- a/chrome/browser/views/bookmark_editor_view.cc
+++ b/chrome/browser/views/bookmark_editor_view.cc
@@ -257,7 +257,8 @@ void BookmarkEditorView::Init() {
// The following URL is user-editable. We specify omit_username_password=
// false and unescape=false to show the original URL except IDN.
url_text =
- net::FormatUrl(node_->GetURL(), languages, false, false, NULL, NULL);
+ net::FormatUrl(node_->GetURL(), languages, false, UnescapeRule::NONE,
+ NULL, NULL);
}
url_tf_.SetText(url_text);
url_tf_.SetController(this);
diff --git a/chrome/browser/views/shelf_item_dialog.cc b/chrome/browser/views/shelf_item_dialog.cc
index c80f991..7212c1d 100644
--- a/chrome/browser/views/shelf_item_dialog.cc
+++ b/chrome/browser/views/shelf_item_dialog.cc
@@ -508,7 +508,7 @@ void ShelfItemDialog::OnSelectionChanged() {
// username:password and escaped path and query.
std::wstring formatted = net::FormatUrl(
url_table_model_->GetURL(selection), languages,
- false, false, NULL, NULL);
+ false, UnescapeRule::NONE, NULL, NULL);
url_field_->SetText(formatted);
if (title_field_)
title_field_->SetText(url_table_model_->GetTitle(selection));