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

Unified Diff: chrome/browser/ui/webui/extensions/install_extension_handler.cc

Issue 10449008: Allow user script install by dragging onto chrome://extensions/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: use correct base Created 8 years, 7 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/resources/extensions/extensions.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/webui/extensions/install_extension_handler.cc
diff --git a/chrome/browser/ui/webui/extensions/install_extension_handler.cc b/chrome/browser/ui/webui/extensions/install_extension_handler.cc
index b0aa4f94a006cacc495c311a877484c613a87423..e00980fcc7482c0e57f2aa488b8e971a5bbc2a14 100644
--- a/chrome/browser/ui/webui/extensions/install_extension_handler.cc
+++ b/chrome/browser/ui/webui/extensions/install_extension_handler.cc
@@ -5,6 +5,7 @@
#include "chrome/browser/ui/webui/extensions/install_extension_handler.h"
#include "base/bind.h"
+#include "base/string_util.h"
#include "base/utf_string_conversions.h"
#include "chrome/browser/extensions/crx_installer.h"
#include "chrome/browser/extensions/extension_install_ui.h"
@@ -16,6 +17,7 @@
#include "content/public/browser/web_contents_view.h"
#include "content/public/browser/web_ui.h"
#include "grit/generated_resources.h"
+#include "net/base/net_util.h"
#include "ui/base/l10n/l10n_util.h"
#include "webkit/glue/webdropdata.h"
@@ -83,7 +85,24 @@ void InstallExtensionHandler::HandleInstallMessage(const ListValue* args) {
ExtensionSystem::Get(profile)->extension_service(),
new ExtensionInstallUI(profile)));
crx_installer->set_allow_off_store_install(true);
- crx_installer->InstallCrx(file_to_install_);
+
+ const bool kCaseSensitive = false;
+
+ // Have to use EndsWith() because FilePath::Extension() would return ".js" for
+ // "foo.user.js".
+ if (EndsWith(file_to_install_.BaseName().value(),
+ FILE_PATH_LITERAL(".user.js"),
+ kCaseSensitive)) {
+ crx_installer->InstallUserScript(
+ file_to_install_,
+ net::FilePathToFileURL(file_to_install_));
+ } else if (EndsWith(file_to_install_.BaseName().value(),
+ FILE_PATH_LITERAL(".crx"),
+ kCaseSensitive)) {
+ crx_installer->InstallCrx(file_to_install_);
+ } else {
+ CHECK(false);
+ }
file_to_install_.clear();
}
« no previous file with comments | « chrome/browser/resources/extensions/extensions.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698