Chromium Code Reviews| 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 340 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 351 content::DownloadItem* file = GetDownloadByValue(args); | 351 content::DownloadItem* file = GetDownloadByValue(args); |
| 352 if (file) | 352 if (file) |
| 353 file->OpenDownload(); | 353 file->OpenDownload(); |
| 354 } | 354 } |
| 355 | 355 |
| 356 void DownloadsDOMHandler::HandleDrag(const base::ListValue* args) { | 356 void DownloadsDOMHandler::HandleDrag(const base::ListValue* args) { |
| 357 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_DRAG); | 357 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_DRAG); |
| 358 content::DownloadItem* file = GetDownloadByValue(args); | 358 content::DownloadItem* file = GetDownloadByValue(args); |
| 359 content::WebContents* web_contents = GetWebUIWebContents(); | 359 content::WebContents* web_contents = GetWebUIWebContents(); |
| 360 // |web_contents| is only NULL in the test. | 360 // |web_contents| is only NULL in the test. |
| 361 if (!file || !web_contents || !file->IsComplete()) | 361 if (!file || !web_contents || |
|
Bernhard Bauer
2013/06/13 19:07:23
It might be slightly more readable if you break th
| |
| 362 (file->GetState() != content::DownloadItem::COMPLETE)) | |
| 362 return; | 363 return; |
| 363 gfx::Image* icon = g_browser_process->icon_manager()->LookupIconFromFilepath( | 364 gfx::Image* icon = g_browser_process->icon_manager()->LookupIconFromFilepath( |
| 364 file->GetTargetFilePath(), IconLoader::NORMAL); | 365 file->GetTargetFilePath(), IconLoader::NORMAL); |
| 365 gfx::NativeView view = web_contents->GetView()->GetNativeView(); | 366 gfx::NativeView view = web_contents->GetView()->GetNativeView(); |
| 366 { | 367 { |
| 367 // Enable nested tasks during DnD, while |DragDownload()| blocks. | 368 // Enable nested tasks during DnD, while |DragDownload()| blocks. |
| 368 base::MessageLoop::ScopedNestableTaskAllower allow( | 369 base::MessageLoop::ScopedNestableTaskAllower allow( |
| 369 base::MessageLoop::current()); | 370 base::MessageLoop::current()); |
| 370 download_util::DragDownload(file, icon, view); | 371 download_util::DragDownload(file, icon, view); |
| 371 } | 372 } |
| (...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 551 } | 552 } |
| 552 | 553 |
| 553 void DownloadsDOMHandler::CallDownloadsList(const base::ListValue& downloads) { | 554 void DownloadsDOMHandler::CallDownloadsList(const base::ListValue& downloads) { |
| 554 web_ui()->CallJavascriptFunction("downloadsList", downloads); | 555 web_ui()->CallJavascriptFunction("downloadsList", downloads); |
| 555 } | 556 } |
| 556 | 557 |
| 557 void DownloadsDOMHandler::CallDownloadUpdated( | 558 void DownloadsDOMHandler::CallDownloadUpdated( |
| 558 const base::ListValue& download_item) { | 559 const base::ListValue& download_item) { |
| 559 web_ui()->CallJavascriptFunction("downloadUpdated", download_item); | 560 web_ui()->CallJavascriptFunction("downloadUpdated", download_item); |
| 560 } | 561 } |
| OLD | NEW |