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

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

Issue 18281002: Move WebDropData to content::DropData and split off conversion function. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix Mac build error. Created 7 years, 5 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
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/strings/string_util.h" 8 #include "base/strings/string_util.h"
9 #include "base/strings/utf_string_conversions.h" 9 #include "base/strings/utf_string_conversions.h"
10 #include "chrome/browser/extensions/crx_installer.h" 10 #include "chrome/browser/extensions/crx_installer.h"
11 #include "chrome/browser/extensions/extension_install_prompt.h" 11 #include "chrome/browser/extensions/extension_install_prompt.h"
12 #include "chrome/browser/extensions/extension_service.h" 12 #include "chrome/browser/extensions/extension_service.h"
13 #include "chrome/browser/extensions/extension_system.h" 13 #include "chrome/browser/extensions/extension_system.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/common/extensions/feature_switch.h" 15 #include "chrome/common/extensions/feature_switch.h"
16 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
17 #include "content/public/browser/web_contents_view.h" 17 #include "content/public/browser/web_contents_view.h"
18 #include "content/public/browser/web_ui.h" 18 #include "content/public/browser/web_ui.h"
19 #include "content/public/browser/web_ui_data_source.h" 19 #include "content/public/browser/web_ui_data_source.h"
20 #include "content/public/common/drop_data.h"
20 #include "grit/generated_resources.h" 21 #include "grit/generated_resources.h"
21 #include "net/base/net_util.h" 22 #include "net/base/net_util.h"
22 #include "ui/base/l10n/l10n_util.h" 23 #include "ui/base/l10n/l10n_util.h"
23 #include "webkit/common/webdropdata.h"
24 24
25 InstallExtensionHandler::InstallExtensionHandler() { 25 InstallExtensionHandler::InstallExtensionHandler() {
26 } 26 }
27 27
28 InstallExtensionHandler::~InstallExtensionHandler() { 28 InstallExtensionHandler::~InstallExtensionHandler() {
29 } 29 }
30 30
31 void InstallExtensionHandler::GetLocalizedValues( 31 void InstallExtensionHandler::GetLocalizedValues(
32 content::WebUIDataSource* source) { 32 content::WebUIDataSource* source) {
33 source->AddString( 33 source->AddString(
(...skipping 13 matching lines...) Expand all
47 "stopDrag", 47 "stopDrag",
48 base::Bind(&InstallExtensionHandler::HandleStopDragMessage, 48 base::Bind(&InstallExtensionHandler::HandleStopDragMessage,
49 base::Unretained(this))); 49 base::Unretained(this)));
50 web_ui()->RegisterMessageCallback( 50 web_ui()->RegisterMessageCallback(
51 "installDroppedFile", 51 "installDroppedFile",
52 base::Bind(&InstallExtensionHandler::HandleInstallMessage, 52 base::Bind(&InstallExtensionHandler::HandleInstallMessage,
53 base::Unretained(this))); 53 base::Unretained(this)));
54 } 54 }
55 55
56 void InstallExtensionHandler::HandleStartDragMessage(const ListValue* args) { 56 void InstallExtensionHandler::HandleStartDragMessage(const ListValue* args) {
57 WebDropData* drop_data = web_ui()->GetWebContents()->GetView()->GetDropData(); 57 content::DropData* drop_data =
58 web_ui()->GetWebContents()->GetView()->GetDropData();
58 if (!drop_data) { 59 if (!drop_data) {
59 DLOG(ERROR) << "No current drop data."; 60 DLOG(ERROR) << "No current drop data.";
60 return; 61 return;
61 } 62 }
62 63
63 if (drop_data->filenames.empty()) { 64 if (drop_data->filenames.empty()) {
64 DLOG(ERROR) << "Current drop data contains no files."; 65 DLOG(ERROR) << "Current drop data contains no files.";
65 return; 66 return;
66 } 67 }
67 68
68 const WebDropData::FileInfo& file_info = drop_data->filenames.front(); 69 const content::DropData::FileInfo& file_info = drop_data->filenames.front();
69 70
70 file_to_install_ = base::FilePath::FromWStringHack( 71 file_to_install_ = base::FilePath::FromWStringHack(
71 UTF16ToWide(file_info.path)); 72 UTF16ToWide(file_info.path));
72 // Use the display name if provided, for checking file names 73 // Use the display name if provided, for checking file names
73 // (.path is likely a random hash value in that case). 74 // (.path is likely a random hash value in that case).
74 file_display_name_ = 75 file_display_name_ =
75 file_info.display_name.empty() ? file_info.path : file_info.display_name; 76 file_info.display_name.empty() ? file_info.path : file_info.display_name;
76 } 77 }
77 78
78 void InstallExtensionHandler::HandleStopDragMessage(const ListValue* args) { 79 void InstallExtensionHandler::HandleStopDragMessage(const ListValue* args) {
(...skipping 28 matching lines...) Expand all
107 ASCIIToUTF16(".crx"), 108 ASCIIToUTF16(".crx"),
108 kCaseSensitive)) { 109 kCaseSensitive)) {
109 crx_installer->InstallCrx(file_to_install_); 110 crx_installer->InstallCrx(file_to_install_);
110 } else { 111 } else {
111 CHECK(false); 112 CHECK(false);
112 } 113 }
113 114
114 file_to_install_.clear(); 115 file_to_install_.clear();
115 file_display_name_.clear(); 116 file_display_name_.clear();
116 } 117 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698