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

Side by Side 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, 6 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/resources/extensions/extensions.js ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/webui/extensions/install_extension_handler.h" 5 #include "chrome/browser/ui/webui/extensions/install_extension_handler.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/string_util.h"
8 #include "base/utf_string_conversions.h" 9 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/extensions/crx_installer.h" 10 #include "chrome/browser/extensions/crx_installer.h"
10 #include "chrome/browser/extensions/extension_install_ui.h" 11 #include "chrome/browser/extensions/extension_install_ui.h"
11 #include "chrome/browser/extensions/extension_service.h" 12 #include "chrome/browser/extensions/extension_service.h"
12 #include "chrome/browser/extensions/extension_system.h" 13 #include "chrome/browser/extensions/extension_system.h"
13 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/common/extensions/extension_switch_utils.h" 15 #include "chrome/common/extensions/extension_switch_utils.h"
15 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
16 #include "content/public/browser/web_contents_view.h" 17 #include "content/public/browser/web_contents_view.h"
17 #include "content/public/browser/web_ui.h" 18 #include "content/public/browser/web_ui.h"
18 #include "grit/generated_resources.h" 19 #include "grit/generated_resources.h"
20 #include "net/base/net_util.h"
19 #include "ui/base/l10n/l10n_util.h" 21 #include "ui/base/l10n/l10n_util.h"
20 #include "webkit/glue/webdropdata.h" 22 #include "webkit/glue/webdropdata.h"
21 23
22 InstallExtensionHandler::InstallExtensionHandler() { 24 InstallExtensionHandler::InstallExtensionHandler() {
23 } 25 }
24 26
25 InstallExtensionHandler::~InstallExtensionHandler() { 27 InstallExtensionHandler::~InstallExtensionHandler() {
26 } 28 }
27 29
28 void InstallExtensionHandler::GetLocalizedValues( 30 void InstallExtensionHandler::GetLocalizedValues(
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 LOG(ERROR) << "No file captured to install."; 78 LOG(ERROR) << "No file captured to install.";
77 return; 79 return;
78 } 80 }
79 81
80 Profile* profile = Profile::FromWebUI(web_ui()); 82 Profile* profile = Profile::FromWebUI(web_ui());
81 scoped_refptr<CrxInstaller> crx_installer( 83 scoped_refptr<CrxInstaller> crx_installer(
82 CrxInstaller::Create( 84 CrxInstaller::Create(
83 ExtensionSystem::Get(profile)->extension_service(), 85 ExtensionSystem::Get(profile)->extension_service(),
84 new ExtensionInstallUI(profile))); 86 new ExtensionInstallUI(profile)));
85 crx_installer->set_allow_off_store_install(true); 87 crx_installer->set_allow_off_store_install(true);
86 crx_installer->InstallCrx(file_to_install_); 88
89 const bool kCaseSensitive = false;
90
91 // Have to use EndsWith() because FilePath::Extension() would return ".js" for
92 // "foo.user.js".
93 if (EndsWith(file_to_install_.BaseName().value(),
94 FILE_PATH_LITERAL(".user.js"),
95 kCaseSensitive)) {
96 crx_installer->InstallUserScript(
97 file_to_install_,
98 net::FilePathToFileURL(file_to_install_));
99 } else if (EndsWith(file_to_install_.BaseName().value(),
100 FILE_PATH_LITERAL(".crx"),
101 kCaseSensitive)) {
102 crx_installer->InstallCrx(file_to_install_);
103 } else {
104 CHECK(false);
105 }
87 106
88 file_to_install_.clear(); 107 file_to_install_.clear();
89 } 108 }
OLDNEW
« 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