Convert file url to lowercase to make it match a file handler pattern.


BUG=
TEST=


Review URL: http://codereview.chromium.org/9700011

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@126891 0039d316-1c4b-4281-b951-d872f2087c98
parent 0148e6e1
......@@ -548,10 +548,6 @@ bool GetFileTasksFileBrowserFunction::RunImpl() {
std::string file_url;
if (!files_list->GetString(i, &file_url))
return false;
// We need case-insensitive matching, and pattern in handler is already
// in lower case.
StringToLowerASCII(&file_url);
file_urls.push_back(GURL(file_url));
}
......
......@@ -6,9 +6,11 @@
#include "base/bind.h"
#include "base/file_util.h"
#include "base/i18n/case_conversion.h"
#include "base/json/json_writer.h"
#include "base/string_util.h"
#include "base/stringprintf.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/chromeos/extensions/file_manager_util.h"
#include "chrome/browser/extensions/extension_event_router.h"
#include "chrome/browser/extensions/extension_service.h"
......@@ -23,6 +25,7 @@
#include "content/public/browser/render_process_host.h"
#include "content/public/browser/site_instance.h"
#include "content/public/browser/web_contents.h"
#include "net/base/escape.h"
#include "webkit/fileapi/file_system_context.h"
#include "webkit/fileapi/file_system_mount_point_provider.h"
#include "webkit/fileapi/file_system_util.h"
......@@ -96,6 +99,14 @@ URLPatternSet GetAllMatchingPatterns(const FileBrowserHandler* handler,
typedef std::set<const FileBrowserHandler*> ActionSet;
std::string EscapedUtf8ToLower(const std::string& str) {
string16 utf16 = UTF8ToUTF16(
net::UnescapeURLComponent(str, net::UnescapeRule::NORMAL));
return net::EscapeUrlEncodedData(
UTF16ToUTF8(base::i18n::ToLower(utf16)),
false /* do not replace space with plus */);
}
bool GetFileBrowserHandlers(Profile* profile,
const GURL& selected_file_url,
ActionSet* results) {
......@@ -103,6 +114,10 @@ bool GetFileBrowserHandlers(Profile* profile,
if (!service)
return false; // In unit-tests, we may not have an ExtensionService.
// We need case-insensitive matching, and pattern in the handler is already
// in lower case.
const GURL lowercase_url(EscapedUtf8ToLower(selected_file_url.spec()));
for (ExtensionSet::const_iterator iter = service->extensions()->begin();
iter != service->extensions()->end();
++iter) {
......@@ -118,7 +133,7 @@ bool GetFileBrowserHandlers(Profile* profile,
action_iter != extension->file_browser_handlers()->end();
++action_iter) {
const FileBrowserHandler* action = action_iter->get();
if (!action->MatchesURL(selected_file_url))
if (!action->MatchesURL(lowercase_url))
continue;
results->insert(action_iter->get());
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment