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