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

Side by Side Diff: chrome/browser/ui/webui/extensions/install_extension_handler.cc

Issue 10270031: Add a first-class off-store install UI to chrome://extensions/. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: AppEngine, you suck 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 unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/webui/extensions/install_extension_handler.h"
6
7 #include "base/bind.h"
8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/extensions/crx_installer.h"
10 #include "chrome/browser/extensions/extension_install_ui.h"
11 #include "chrome/browser/extensions/extension_service.h"
12 #include "chrome/browser/extensions/extension_system.h"
13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/common/extensions/switch_utils.h"
15 #include "content/public/browser/web_contents.h"
16 #include "content/public/browser/web_contents_view.h"
17 #include "content/public/browser/web_ui.h"
18 #include "grit/generated_resources.h"
19 #include "ui/base/l10n/l10n_util.h"
20 #include "webkit/glue/webdropdata.h"
21
22 InstallExtensionHandler::InstallExtensionHandler() {
23 }
24
25 InstallExtensionHandler::~InstallExtensionHandler() {
26 }
27
28 void InstallExtensionHandler::GetLocalizedValues(
29 DictionaryValue* localized_strings) {
30 DCHECK(localized_strings);
31 localized_strings->SetString("extensionSettingsInstallDropTarget",
James Hawkins 2012/05/01 23:13:36 nit: The start of parameter rows must all begin on
Aaron Boodman 2012/05/02 00:41:36 Done.
32 l10n_util::GetStringUTF16(IDS_EXTENSIONS_INSTALL_DROP_TARGET));
33 localized_strings->SetBoolean(
34 "offstoreinstallenabled",
Evan Stade 2012/05/01 23:43:07 camel case
Aaron Boodman 2012/05/02 00:41:36 HTML attributes are forced to lowercase, so this d
35 extensions::switch_utils::IsOffStoreInstallEnabled());
36 }
37
38 void InstallExtensionHandler::RegisterMessages() {
39 web_ui()->RegisterMessageCallback(
40 "startDrag",
41 base::Bind(&InstallExtensionHandler::HandleStartDragMessage,
42 base::Unretained(this)));
43 web_ui()->RegisterMessageCallback(
44 "stopDrag",
45 base::Bind(&InstallExtensionHandler::HandleStopDragMessage,
46 base::Unretained(this)));
47 web_ui()->RegisterMessageCallback(
48 "installDroppedFile",
49 base::Bind(&InstallExtensionHandler::HandleInstallMessage,
50 base::Unretained(this)));
51 }
52
53 void InstallExtensionHandler::HandleStartDragMessage(const ListValue* args) {
Evan Stade 2012/05/01 23:43:07 is this necessary because by the time you get to h
Aaron Boodman 2012/05/02 00:41:36 Yep. Added comment.
54 WebDropData* drop_data = web_ui()->GetWebContents()->GetView()->GetDropData();
55 if (!drop_data) {
56 LOG(ERROR) << "No current drop data.";
James Hawkins 2012/05/01 23:13:36 Remove log spam?
Aaron Boodman 2012/05/02 00:41:36 Disagree that it is log spam. This will only occur
57 return;
58 }
59
60 if (drop_data->filenames.empty()) {
61 LOG(ERROR) << "Current drop data contains no files.";
62 return;
63 }
64
65 file_to_install_ = FilePath::FromWStringHack(
James Hawkins 2012/05/01 23:13:36 What is one supposed to do here to avoid using the
Aaron Boodman 2012/05/02 00:41:36 You're not supposed to have a string16 in the firs
66 UTF16ToWide(drop_data->filenames.front()));
67 }
68
69 void InstallExtensionHandler::HandleStopDragMessage(const ListValue* args) {
70 file_to_install_.clear();
71 }
72
73 void InstallExtensionHandler::HandleInstallMessage(const ListValue* args) {
74 if (file_to_install_.empty()) {
75 LOG(ERROR) << "No file captured to install.";
76 return;
77 }
78
79 Profile* profile = Profile::FromWebUI(web_ui());
80 scoped_refptr<CrxInstaller> crx_installer(
81 CrxInstaller::Create(
82 ExtensionSystem::Get(profile)->extension_service(),
83 new ExtensionInstallUI(profile)));
84 crx_installer->InstallCrx(file_to_install_);
85
86 file_to_install_.clear();
87 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698