| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/downloads_dom_handler.h" | 5 #include "chrome/browser/ui/webui/downloads_dom_handler.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <functional> | 8 #include <functional> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "chrome/browser/download/download_prefs.h" | 22 #include "chrome/browser/download/download_prefs.h" |
| 23 #include "chrome/browser/download/download_service.h" | 23 #include "chrome/browser/download/download_service.h" |
| 24 #include "chrome/browser/download/download_service_factory.h" | 24 #include "chrome/browser/download/download_service_factory.h" |
| 25 #include "chrome/browser/download/download_util.h" | 25 #include "chrome/browser/download/download_util.h" |
| 26 #include "chrome/browser/platform_util.h" | 26 #include "chrome/browser/platform_util.h" |
| 27 #include "chrome/browser/profiles/profile.h" | 27 #include "chrome/browser/profiles/profile.h" |
| 28 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" | 28 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" |
| 29 #include "chrome/browser/ui/webui/fileicon_source.h" | 29 #include "chrome/browser/ui/webui/fileicon_source.h" |
| 30 #include "chrome/browser/ui/webui/fileicon_source_chromeos.h" | 30 #include "chrome/browser/ui/webui/fileicon_source_chromeos.h" |
| 31 #include "chrome/common/url_constants.h" | 31 #include "chrome/common/url_constants.h" |
| 32 #include "content/browser/tab_contents/tab_contents.h" | |
| 33 #include "content/public/browser/download_item.h" | 32 #include "content/public/browser/download_item.h" |
| 34 #include "content/public/browser/user_metrics.h" | 33 #include "content/public/browser/user_metrics.h" |
| 34 #include "content/public/browser/web_contents.h" |
| 35 #include "grit/generated_resources.h" | 35 #include "grit/generated_resources.h" |
| 36 #include "ui/gfx/image/image.h" | 36 #include "ui/gfx/image/image.h" |
| 37 | 37 |
| 38 #if !defined(OS_MACOSX) | 38 #if !defined(OS_MACOSX) |
| 39 #include "content/public/browser/browser_thread.h" | 39 #include "content/public/browser/browser_thread.h" |
| 40 #endif | 40 #endif |
| 41 | 41 |
| 42 #if defined(OS_CHROMEOS) | 42 #if defined(OS_CHROMEOS) |
| 43 #include "chrome/browser/extensions/file_manager_util.h" | 43 #include "chrome/browser/extensions/file_manager_util.h" |
| 44 #endif | 44 #endif |
| (...skipping 237 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 282 file->OpenDownload(); | 282 file->OpenDownload(); |
| 283 } | 283 } |
| 284 | 284 |
| 285 void DownloadsDOMHandler::HandleDrag(const ListValue* args) { | 285 void DownloadsDOMHandler::HandleDrag(const ListValue* args) { |
| 286 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_DRAG); | 286 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_DRAG); |
| 287 DownloadItem* file = GetDownloadByValue(args); | 287 DownloadItem* file = GetDownloadByValue(args); |
| 288 if (file) { | 288 if (file) { |
| 289 IconManager* im = g_browser_process->icon_manager(); | 289 IconManager* im = g_browser_process->icon_manager(); |
| 290 gfx::Image* icon = im->LookupIcon(file->GetUserVerifiedFilePath(), | 290 gfx::Image* icon = im->LookupIcon(file->GetUserVerifiedFilePath(), |
| 291 IconLoader::NORMAL); | 291 IconLoader::NORMAL); |
| 292 gfx::NativeView view = web_ui()->tab_contents()->GetNativeView(); | 292 gfx::NativeView view = web_ui()->web_contents()->GetNativeView(); |
| 293 { | 293 { |
| 294 // Enable nested tasks during DnD, while |DragDownload()| blocks. | 294 // Enable nested tasks during DnD, while |DragDownload()| blocks. |
| 295 MessageLoop::ScopedNestableTaskAllower allower(MessageLoop::current()); | 295 MessageLoop::ScopedNestableTaskAllower allower(MessageLoop::current()); |
| 296 download_util::DragDownload(file, icon, view); | 296 download_util::DragDownload(file, icon, view); |
| 297 } | 297 } |
| 298 } | 298 } |
| 299 } | 299 } |
| 300 | 300 |
| 301 void DownloadsDOMHandler::HandleSaveDangerous(const ListValue* args) { | 301 void DownloadsDOMHandler::HandleSaveDangerous(const ListValue* args) { |
| 302 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_SAVE_DANGEROUS); | 302 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_SAVE_DANGEROUS); |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 402 return NULL; | 402 return NULL; |
| 403 } | 403 } |
| 404 | 404 |
| 405 DownloadItem* DownloadsDOMHandler::GetDownloadByValue(const ListValue* args) { | 405 DownloadItem* DownloadsDOMHandler::GetDownloadByValue(const ListValue* args) { |
| 406 int id; | 406 int id; |
| 407 if (ExtractIntegerValue(args, &id)) { | 407 if (ExtractIntegerValue(args, &id)) { |
| 408 return GetDownloadById(id); | 408 return GetDownloadById(id); |
| 409 } | 409 } |
| 410 return NULL; | 410 return NULL; |
| 411 } | 411 } |
| OLD | NEW |