| OLD | NEW |
| 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/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 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 331 content::DownloadItem* file = GetDownloadByValue(args); | 331 content::DownloadItem* file = GetDownloadByValue(args); |
| 332 if (file) | 332 if (file) |
| 333 file->OpenDownload(); | 333 file->OpenDownload(); |
| 334 } | 334 } |
| 335 | 335 |
| 336 void DownloadsDOMHandler::HandleDrag(const base::ListValue* args) { | 336 void DownloadsDOMHandler::HandleDrag(const base::ListValue* args) { |
| 337 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_DRAG); | 337 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_DRAG); |
| 338 content::DownloadItem* file = GetDownloadByValue(args); | 338 content::DownloadItem* file = GetDownloadByValue(args); |
| 339 content::WebContents* web_contents = GetWebUIWebContents(); | 339 content::WebContents* web_contents = GetWebUIWebContents(); |
| 340 // |web_contents| is only NULL in the test. | 340 // |web_contents| is only NULL in the test. |
| 341 if (!file || !web_contents) | 341 if (!file || !web_contents || !file->IsComplete()) |
| 342 return; | 342 return; |
| 343 gfx::Image* icon = g_browser_process->icon_manager()->LookupIcon( | 343 gfx::Image* icon = g_browser_process->icon_manager()->LookupIcon( |
| 344 file->GetUserVerifiedFilePath(), IconLoader::NORMAL); | 344 file->GetTargetFilePath(), IconLoader::NORMAL); |
| 345 gfx::NativeView view = web_contents->GetNativeView(); | 345 gfx::NativeView view = web_contents->GetNativeView(); |
| 346 { | 346 { |
| 347 // Enable nested tasks during DnD, while |DragDownload()| blocks. | 347 // Enable nested tasks during DnD, while |DragDownload()| blocks. |
| 348 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); | 348 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); |
| 349 download_util::DragDownload(file, icon, view); | 349 download_util::DragDownload(file, icon, view); |
| 350 } | 350 } |
| 351 } | 351 } |
| 352 | 352 |
| 353 void DownloadsDOMHandler::HandleSaveDangerous(const base::ListValue* args) { | 353 void DownloadsDOMHandler::HandleSaveDangerous(const base::ListValue* args) { |
| 354 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_SAVE_DANGEROUS); | 354 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_SAVE_DANGEROUS); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 510 } | 510 } |
| 511 | 511 |
| 512 void DownloadsDOMHandler::CallDownloadsList(const base::ListValue& downloads) { | 512 void DownloadsDOMHandler::CallDownloadsList(const base::ListValue& downloads) { |
| 513 web_ui()->CallJavascriptFunction("downloadsList", downloads); | 513 web_ui()->CallJavascriptFunction("downloadsList", downloads); |
| 514 } | 514 } |
| 515 | 515 |
| 516 void DownloadsDOMHandler::CallDownloadUpdated( | 516 void DownloadsDOMHandler::CallDownloadUpdated( |
| 517 const base::ListValue& download_item) { | 517 const base::ListValue& download_item) { |
| 518 web_ui()->CallJavascriptFunction("downloadUpdated", download_item); | 518 web_ui()->CallJavascriptFunction("downloadUpdated", download_item); |
| 519 } | 519 } |
| OLD | NEW |