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 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
348 content::DownloadItem* file = GetDownloadByValue(args); | 348 content::DownloadItem* file = GetDownloadByValue(args); |
349 content::WebContents* web_contents = GetWebUIWebContents(); | 349 content::WebContents* web_contents = GetWebUIWebContents(); |
350 // |web_contents| is only NULL in the test. | 350 // |web_contents| is only NULL in the test. |
351 if (!file || !web_contents || !file->IsComplete()) | 351 if (!file || !web_contents || !file->IsComplete()) |
352 return; | 352 return; |
353 gfx::Image* icon = g_browser_process->icon_manager()->LookupIconFromFilepath( | 353 gfx::Image* icon = g_browser_process->icon_manager()->LookupIconFromFilepath( |
354 file->GetTargetFilePath(), IconLoader::NORMAL); | 354 file->GetTargetFilePath(), IconLoader::NORMAL); |
355 gfx::NativeView view = web_contents->GetView()->GetNativeView(); | 355 gfx::NativeView view = web_contents->GetView()->GetNativeView(); |
356 { | 356 { |
357 // Enable nested tasks during DnD, while |DragDownload()| blocks. | 357 // Enable nested tasks during DnD, while |DragDownload()| blocks. |
358 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); | 358 base::MessageLoop::ScopedNestableTaskAllower allow( |
| 359 base::MessageLoop::current()); |
359 download_util::DragDownload(file, icon, view); | 360 download_util::DragDownload(file, icon, view); |
360 } | 361 } |
361 } | 362 } |
362 | 363 |
363 void DownloadsDOMHandler::HandleSaveDangerous(const base::ListValue* args) { | 364 void DownloadsDOMHandler::HandleSaveDangerous(const base::ListValue* args) { |
364 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_SAVE_DANGEROUS); | 365 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_SAVE_DANGEROUS); |
365 content::DownloadItem* file = GetDownloadByValue(args); | 366 content::DownloadItem* file = GetDownloadByValue(args); |
366 if (file) | 367 if (file) |
367 ShowDangerPrompt(file); | 368 ShowDangerPrompt(file); |
368 } | 369 } |
(...skipping 171 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
540 } | 541 } |
541 | 542 |
542 void DownloadsDOMHandler::CallDownloadsList(const base::ListValue& downloads) { | 543 void DownloadsDOMHandler::CallDownloadsList(const base::ListValue& downloads) { |
543 web_ui()->CallJavascriptFunction("downloadsList", downloads); | 544 web_ui()->CallJavascriptFunction("downloadsList", downloads); |
544 } | 545 } |
545 | 546 |
546 void DownloadsDOMHandler::CallDownloadUpdated( | 547 void DownloadsDOMHandler::CallDownloadUpdated( |
547 const base::ListValue& download_item) { | 548 const base::ListValue& download_item) { |
548 web_ui()->CallJavascriptFunction("downloadUpdated", download_item); | 549 web_ui()->CallJavascriptFunction("downloadUpdated", download_item); |
549 } | 550 } |
OLD | NEW |