| 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 21 matching lines...) Expand all Loading... |
| 32 #include "chrome/browser/platform_util.h" | 32 #include "chrome/browser/platform_util.h" |
| 33 #include "chrome/browser/profiles/profile.h" | 33 #include "chrome/browser/profiles/profile.h" |
| 34 #include "chrome/browser/ui/webui/fileicon_source.h" | 34 #include "chrome/browser/ui/webui/fileicon_source.h" |
| 35 #include "chrome/common/time_format.h" | 35 #include "chrome/common/time_format.h" |
| 36 #include "chrome/common/url_constants.h" | 36 #include "chrome/common/url_constants.h" |
| 37 #include "content/public/browser/browser_thread.h" | 37 #include "content/public/browser/browser_thread.h" |
| 38 #include "content/public/browser/download_item.h" | 38 #include "content/public/browser/download_item.h" |
| 39 #include "content/public/browser/user_metrics.h" | 39 #include "content/public/browser/user_metrics.h" |
| 40 #include "content/public/browser/url_data_source.h" | 40 #include "content/public/browser/url_data_source.h" |
| 41 #include "content/public/browser/web_contents.h" | 41 #include "content/public/browser/web_contents.h" |
| 42 #include "content/public/browser/web_contents_view.h" |
| 42 #include "content/public/browser/web_ui.h" | 43 #include "content/public/browser/web_ui.h" |
| 43 #include "grit/generated_resources.h" | 44 #include "grit/generated_resources.h" |
| 44 #include "net/base/net_util.h" | 45 #include "net/base/net_util.h" |
| 45 #include "ui/gfx/image/image.h" | 46 #include "ui/gfx/image/image.h" |
| 46 | 47 |
| 47 #if defined(OS_CHROMEOS) | 48 #if defined(OS_CHROMEOS) |
| 48 #include "chrome/browser/chromeos/extensions/file_manager_util.h" | 49 #include "chrome/browser/chromeos/extensions/file_manager_util.h" |
| 49 #endif | 50 #endif |
| 50 | 51 |
| 51 using content::BrowserContext; | 52 using content::BrowserContext; |
| (...skipping 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 337 | 338 |
| 338 void DownloadsDOMHandler::HandleDrag(const base::ListValue* args) { | 339 void DownloadsDOMHandler::HandleDrag(const base::ListValue* args) { |
| 339 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_DRAG); | 340 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_DRAG); |
| 340 content::DownloadItem* file = GetDownloadByValue(args); | 341 content::DownloadItem* file = GetDownloadByValue(args); |
| 341 content::WebContents* web_contents = GetWebUIWebContents(); | 342 content::WebContents* web_contents = GetWebUIWebContents(); |
| 342 // |web_contents| is only NULL in the test. | 343 // |web_contents| is only NULL in the test. |
| 343 if (!file || !web_contents || !file->IsComplete()) | 344 if (!file || !web_contents || !file->IsComplete()) |
| 344 return; | 345 return; |
| 345 gfx::Image* icon = g_browser_process->icon_manager()->LookupIcon( | 346 gfx::Image* icon = g_browser_process->icon_manager()->LookupIcon( |
| 346 file->GetTargetFilePath(), IconLoader::NORMAL); | 347 file->GetTargetFilePath(), IconLoader::NORMAL); |
| 347 gfx::NativeView view = web_contents->GetNativeView(); | 348 gfx::NativeView view = web_contents->GetView()->GetNativeView(); |
| 348 { | 349 { |
| 349 // Enable nested tasks during DnD, while |DragDownload()| blocks. | 350 // Enable nested tasks during DnD, while |DragDownload()| blocks. |
| 350 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); | 351 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); |
| 351 download_util::DragDownload(file, icon, view); | 352 download_util::DragDownload(file, icon, view); |
| 352 } | 353 } |
| 353 } | 354 } |
| 354 | 355 |
| 355 void DownloadsDOMHandler::HandleSaveDangerous(const base::ListValue* args) { | 356 void DownloadsDOMHandler::HandleSaveDangerous(const base::ListValue* args) { |
| 356 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_SAVE_DANGEROUS); | 357 CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_SAVE_DANGEROUS); |
| 357 content::DownloadItem* file = GetDownloadByValue(args); | 358 content::DownloadItem* file = GetDownloadByValue(args); |
| (...skipping 155 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 513 } | 514 } |
| 514 | 515 |
| 515 void DownloadsDOMHandler::CallDownloadsList(const base::ListValue& downloads) { | 516 void DownloadsDOMHandler::CallDownloadsList(const base::ListValue& downloads) { |
| 516 web_ui()->CallJavascriptFunction("downloadsList", downloads); | 517 web_ui()->CallJavascriptFunction("downloadsList", downloads); |
| 517 } | 518 } |
| 518 | 519 |
| 519 void DownloadsDOMHandler::CallDownloadUpdated( | 520 void DownloadsDOMHandler::CallDownloadUpdated( |
| 520 const base::ListValue& download_item) { | 521 const base::ListValue& download_item) { |
| 521 web_ui()->CallJavascriptFunction("downloadUpdated", download_item); | 522 web_ui()->CallJavascriptFunction("downloadUpdated", download_item); |
| 522 } | 523 } |
| OLD | NEW |