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

Side by Side Diff: chrome/browser/dom_ui/downloads_dom_handler.cc

Issue 164459: Implement drag and drop of downloads for the Mac downloads page (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 4 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) 2006-2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2006-2009 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/dom_ui/downloads_dom_handler.h" 5 #include "chrome/browser/dom_ui/downloads_dom_handler.h"
6 6
7 #include "app/l10n_util.h" 7 #include "app/l10n_util.h"
8 #include "base/basictypes.h" 8 #include "base/basictypes.h"
9 #include "base/gfx/png_encoder.h" 9 #include "base/gfx/png_encoder.h"
10 #include "base/string_piece.h" 10 #include "base/string_piece.h"
11 #include "base/thread.h" 11 #include "base/thread.h"
12 #include "base/time_format.h" 12 #include "base/time_format.h"
13 #include "base/values.h" 13 #include "base/values.h"
14 #include "chrome/browser/browser_process.h" 14 #include "chrome/browser/browser_process.h"
15 #include "chrome/browser/dom_ui/chrome_url_data_manager.h" 15 #include "chrome/browser/dom_ui/chrome_url_data_manager.h"
16 #include "chrome/browser/dom_ui/fileicon_source.h" 16 #include "chrome/browser/dom_ui/fileicon_source.h"
17 #include "chrome/browser/metrics/user_metrics.h" 17 #include "chrome/browser/metrics/user_metrics.h"
18 #include "chrome/browser/profile.h" 18 #include "chrome/browser/profile.h"
19 #include "chrome/browser/tab_contents/tab_contents.h"
19 #include "chrome/common/jstemplate_builder.h" 20 #include "chrome/common/jstemplate_builder.h"
20 #include "chrome/common/time_format.h" 21 #include "chrome/common/time_format.h"
21 #include "chrome/common/url_constants.h" 22 #include "chrome/common/url_constants.h"
22 #include "grit/browser_resources.h" 23 #include "grit/browser_resources.h"
23 #include "grit/generated_resources.h" 24 #include "grit/generated_resources.h"
24 25
25 #if defined(TOOLKIT_VIEWS) 26 #if defined(TOOLKIT_VIEWS) || defined(OS_MACOSX)
26 // TODO(port): re-enable when download_util is ported 27 // TODO(port): re-enable when download_util is ported
27 #include "chrome/browser/download/download_util.h" 28 #include "chrome/browser/download/download_util.h"
28 #else 29 #else
29 #include "chrome/common/temp_scaffolding_stubs.h" 30 #include "chrome/common/temp_scaffolding_stubs.h"
30 #endif 31 #endif
31 32
32 namespace { 33 namespace {
33 34
34 // Maximum number of downloads to show. TODO(glen): Remove this and instead 35 // Maximum number of downloads to show. TODO(glen): Remove this and instead
35 // stuff the downloads down the pipe slowly. 36 // stuff the downloads down the pipe slowly.
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
162 DownloadItem* file = GetDownloadByValue(value); 163 DownloadItem* file = GetDownloadByValue(value);
163 if (file) 164 if (file)
164 download_manager_->OpenDownload(file, NULL); 165 download_manager_->OpenDownload(file, NULL);
165 } 166 }
166 167
167 void DownloadsDOMHandler::HandleDrag(const Value* value) { 168 void DownloadsDOMHandler::HandleDrag(const Value* value) {
168 DownloadItem* file = GetDownloadByValue(value); 169 DownloadItem* file = GetDownloadByValue(value);
169 if (file) { 170 if (file) {
170 IconManager* im = g_browser_process->icon_manager(); 171 IconManager* im = g_browser_process->icon_manager();
171 SkBitmap* icon = im->LookupIcon(file->full_path(), IconLoader::NORMAL); 172 SkBitmap* icon = im->LookupIcon(file->full_path(), IconLoader::NORMAL);
172 download_util::DragDownload(file, icon); 173 gfx::NativeView view = dom_ui_->tab_contents()->GetNativeView();
174 download_util::DragDownload(file, icon, view);
173 } 175 }
174 } 176 }
175 177
176 void DownloadsDOMHandler::HandleSaveDangerous(const Value* value) { 178 void DownloadsDOMHandler::HandleSaveDangerous(const Value* value) {
177 DownloadItem* file = GetDownloadByValue(value); 179 DownloadItem* file = GetDownloadByValue(value);
178 if (file) 180 if (file)
179 download_manager_->DangerousDownloadValidated(file); 181 download_manager_->DangerousDownloadValidated(file);
180 } 182 }
181 183
182 void DownloadsDOMHandler::HandleDiscardDangerous(const Value* value) { 184 void DownloadsDOMHandler::HandleDiscardDangerous(const Value* value) {
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
352 else if (download->TimeRemaining(&remaining)) 354 else if (download->TimeRemaining(&remaining))
353 time_remaining = TimeFormat::TimeRemaining(remaining); 355 time_remaining = TimeFormat::TimeRemaining(remaining);
354 356
355 if (time_remaining.empty()) { 357 if (time_remaining.empty()) {
356 return l10n_util::GetStringF(IDS_DOWNLOAD_TAB_PROGRESS_STATUS_TIME_UNKNOWN, 358 return l10n_util::GetStringF(IDS_DOWNLOAD_TAB_PROGRESS_STATUS_TIME_UNKNOWN,
357 speed_text, amount); 359 speed_text, amount);
358 } 360 }
359 return l10n_util::GetStringF(IDS_DOWNLOAD_TAB_PROGRESS_STATUS, speed_text, 361 return l10n_util::GetStringF(IDS_DOWNLOAD_TAB_PROGRESS_STATUS, speed_text,
360 amount, time_remaining); 362 amount, time_remaining);
361 } 363 }
OLDNEW
« no previous file with comments | « chrome/browser/cocoa/download_util_mac_unittest.mm ('k') | chrome/browser/download/download_util.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698