Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2568)

Unified Diff: chrome/browser/chromeos/extensions/file_handler_util.cc

Issue 9700011: Convert file url to lowercase to make it match a file handler pattern. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/extensions/file_browser_private_api.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/chromeos/extensions/file_handler_util.cc
diff --git a/chrome/browser/chromeos/extensions/file_handler_util.cc b/chrome/browser/chromeos/extensions/file_handler_util.cc
index 3e30f9f3dfa1e2a80bb746c613605f8a1763feb8..9bc712a14d926feac1abea22430a517dcdf4342a 100644
--- a/chrome/browser/chromeos/extensions/file_handler_util.cc
+++ b/chrome/browser/chromeos/extensions/file_handler_util.cc
@@ -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());
« no previous file with comments | « chrome/browser/chromeos/extensions/file_browser_private_api.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698