diff options
Diffstat (limited to 'chrome/browser')
-rw-r--r-- | chrome/browser/chromeos/status/network_menu.cc | 2 | ||||
-rw-r--r-- | chrome/browser/extensions/file_manager_util.cc | 13 | ||||
-rw-r--r-- | chrome/browser/resources/file_manager/js/file_manager.js | 36 | ||||
-rw-r--r-- | chrome/browser/sync/engine/net/url_translator.cc | 4 | ||||
-rw-r--r-- | chrome/browser/translate/translate_manager.cc | 2 |
5 files changed, 43 insertions, 14 deletions
diff --git a/chrome/browser/chromeos/status/network_menu.cc b/chrome/browser/chromeos/status/network_menu.cc index cdbc0db..72a1716 100644 --- a/chrome/browser/chromeos/status/network_menu.cc +++ b/chrome/browser/chromeos/status/network_menu.cc @@ -1487,7 +1487,7 @@ void NetworkMenu::ShowTabbedNetworkSettings(const Network* network) const { return; std::string page = StringPrintf("%s?servicePath=%s&networkType=%d", chrome::kInternetOptionsSubPage, - EscapeUrlEncodedData(network->service_path()).c_str(), + EscapeUrlEncodedData(network->service_path(), true).c_str(), network->type()); browser->ShowOptionsTab(page); } diff --git a/chrome/browser/extensions/file_manager_util.cc b/chrome/browser/extensions/file_manager_util.cc index 833e817..7beef7c 100644 --- a/chrome/browser/extensions/file_manager_util.cc +++ b/chrome/browser/extensions/file_manager_util.cc @@ -16,7 +16,7 @@ #include "content/browser/browser_thread.h" #include "content/browser/user_metrics.h" #include "grit/generated_resources.h" -#include "third_party/libjingle/source/talk/base/urlencode.h" +#include "net/base/escape.h" #include "ui/base/l10n/l10n_util.h" #include "webkit/fileapi/file_system_context.h" #include "webkit/fileapi/file_system_mount_point_provider.h" @@ -112,16 +112,17 @@ GURL FileManagerUtil::GetFileBrowserUrlWithParams( std::string json = GetArgumentsJson(type, title, default_path, file_types, file_type_index, default_extension); return GURL(FileManagerUtil::GetFileBrowserUrl().spec() + "?" + - UrlEncodeStringWithoutEncodingSpaceAsPlus(json)); + EscapeUrlEncodedData(json, false)); } + // static void FileManagerUtil::ShowFullTabUrl(Profile*, const FilePath& default_path) { std::string json = GetArgumentsJson(SelectFileDialog::SELECT_NONE, string16(), default_path, NULL, 0, FilePath::StringType()); GURL url(std::string(kBaseFileBrowserUrl) + "?" + - UrlEncodeStringWithoutEncodingSpaceAsPlus(json)); + EscapeUrlEncodedData(json, false)); Browser* browser = BrowserList::GetLastActive(); if (!browser) return; @@ -130,7 +131,6 @@ void FileManagerUtil::ShowFullTabUrl(Profile*, browser->ShowSingletonTab(GURL(url)); } - void FileManagerUtil::ViewItem(const FilePath& full_path, bool enqueue) { std::string ext = full_path.Extension(); // For things supported natively by the browser, we should open it @@ -138,7 +138,7 @@ void FileManagerUtil::ViewItem(const FilePath& full_path, bool enqueue) { if (IsSupportedBrowserExtension(ext.data())) { std::string path; path = "file://"; - path.append(full_path.value()); + path.append(EscapeUrlEncodedData(full_path.value(), false)); if (!BrowserThread::CurrentlyOn(BrowserThread::UI)) { bool result = BrowserThread::PostTask( BrowserThread::UI, FROM_HERE, @@ -190,9 +190,9 @@ std::string FileManagerUtil::GetArgumentsJson( arg_value.SetString("defaultPath", default_path.value()); arg_value.SetString("defaultExtension", default_extension); - ListValue* types_list = new ListValue(); if (file_types) { + ListValue* types_list = new ListValue(); for (size_t i = 0; i < file_types->extensions.size(); ++i) { ListValue* extensions_list = new ListValue(); for (size_t j = 0; j < file_types->extensions[i].size(); ++j) { @@ -213,6 +213,7 @@ std::string FileManagerUtil::GetArgumentsJson( types_list->Set(i, dict); } + arg_value.Set("typeList", types_list); } std::string rv; diff --git a/chrome/browser/resources/file_manager/js/file_manager.js b/chrome/browser/resources/file_manager/js/file_manager.js index 53128e2..0be9c83 100644 --- a/chrome/browser/resources/file_manager/js/file_manager.js +++ b/chrome/browser/resources/file_manager/js/file_manager.js @@ -54,6 +54,9 @@ function FileManager(dialogDom, rootEntries, params) { this.defaultPath_ = this.params_.defaultPath || '/'; + // Optional list of file types. + this.fileTypes_ = this.params_.typeList; + // This is set to just the directory portion of defaultPath in initDialogType. this.defaultFolder_ = '/'; @@ -555,6 +558,29 @@ FileManager.prototype = { }; /** + * "Save a file" dialog is supposed to have a combo box with available + * file types. Selecting an item filters files by extension and specifies how + * file should be saved. + * @return {intener} Index of selected type from this.fileTypes_ + 1. 0 + * means value is not specified. + */ + FileManager.prototype.getSelectedFilterIndex_= function(fileName) { + // TODO(serya): Implement the combo box + // For now try to guess choice by file extension. + if (!this.fileTypes_ || this.fileTypes_.length == 0) return 0; + + var extension = /\.[^\.]+$/.exec(fileName); + extension = extension ? extension[0].substring(1).toLowerCase() : ""; + var result = 0; // Use first type by default. + for (var i = 0; i < this.fileTypes_.length; i++) { + if (this.fileTypes_[i].extensions.indexOf(extension)) { + result = i; + } + } + return result + 1; // 1-based index. + }; + + /** * Force the canExecute events to be dispatched. */ FileManager.prototype.updateCommands_ = function() { @@ -2080,8 +2106,9 @@ FileManager.prototype = { if (!filename) throw new Error('Missing filename!'); - chrome.fileBrowserPrivate.selectFile(currentDirUrl + encodeURI(filename), - 0); + chrome.fileBrowserPrivate.selectFile( + currentDirUrl + encodeURIComponent(filename), + this.getSelectedFilterIndex_(filename)); window.close(); return; } @@ -2102,7 +2129,7 @@ FileManager.prototype = { continue; } - ary.push(currentDirUrl + encodeURI(entry.name)); + ary.push(currentDirUrl + encodeURIComponent(entry.name)); } // Multi-file selection has no other restrictions. @@ -2131,7 +2158,8 @@ FileManager.prototype = { throw new Error('Selected entry is not a file!'); } - chrome.fileBrowserPrivate.selectFile(ary[0], 0); + chrome.fileBrowserPrivate.selectFile( + ary[0], this.getSelectedFilterIndex_(ary[0])); window.close(); }; diff --git a/chrome/browser/sync/engine/net/url_translator.cc b/chrome/browser/sync/engine/net/url_translator.cc index 4b91e54..c96c9d3 100644 --- a/chrome/browser/sync/engine/net/url_translator.cc +++ b/chrome/browser/sync/engine/net/url_translator.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2010 The Chromium Authors. All rights reserved. +// Copyright (c) 2011 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. // @@ -27,7 +27,7 @@ string CgiEscapeString(const char* src) { } string CgiEscapeString(const string& src) { - return EscapeUrlEncodedData(src); + return EscapeUrlEncodedData(src, true); } // This method appends the query string to the sync server path. diff --git a/chrome/browser/translate/translate_manager.cc b/chrome/browser/translate/translate_manager.cc index e3a4f4a..38e8325 100644 --- a/chrome/browser/translate/translate_manager.cc +++ b/chrome/browser/translate/translate_manager.cc @@ -499,7 +499,7 @@ void TranslateManager::ReportLanguageDetectionError(TabContents* tab_contents) { GURL page_url = tab_contents->controller().GetActiveEntry()->url(); std::string report_error_url(kReportLanguageDetectionErrorURL); report_error_url += "?client=cr&action=langidc&u="; - report_error_url += EscapeUrlEncodedData(page_url.spec()); + report_error_url += EscapeUrlEncodedData(page_url.spec(), true); report_error_url += "&sl="; TranslateTabHelper* helper = TabContentsWrapper::GetCurrentWrapperForContents( |