| 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/active_downloads_ui.h" | 5 #include "chrome/browser/ui/webui/active_downloads_ui.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <string> | 8 #include <string> |
| 9 #include <vector> | 9 #include <vector> |
| 10 | 10 |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 #include "chrome/browser/ui/browser_list.h" | 37 #include "chrome/browser/ui/browser_list.h" |
| 38 #include "chrome/browser/ui/browser_window.h" | 38 #include "chrome/browser/ui/browser_window.h" |
| 39 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 39 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
| 40 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" | 40 #include "chrome/browser/ui/webui/chrome_web_ui_data_source.h" |
| 41 #include "chrome/browser/ui/webui/fileicon_source_chromeos.h" | 41 #include "chrome/browser/ui/webui/fileicon_source_chromeos.h" |
| 42 #include "chrome/common/chrome_paths.h" | 42 #include "chrome/common/chrome_paths.h" |
| 43 #include "chrome/common/chrome_switches.h" | 43 #include "chrome/common/chrome_switches.h" |
| 44 #include "chrome/common/url_constants.h" | 44 #include "chrome/common/url_constants.h" |
| 45 #include "content/browser/renderer_host/render_view_host.h" | 45 #include "content/browser/renderer_host/render_view_host.h" |
| 46 #include "content/browser/renderer_host/render_view_host_delegate.h" | 46 #include "content/browser/renderer_host/render_view_host_delegate.h" |
| 47 #include "content/browser/webui/web_ui.h" |
| 47 #include "content/public/browser/download_item.h" | 48 #include "content/public/browser/download_item.h" |
| 48 #include "content/public/browser/download_manager.h" | 49 #include "content/public/browser/download_manager.h" |
| 49 #include "content/public/browser/navigation_controller.h" | 50 #include "content/public/browser/navigation_controller.h" |
| 50 #include "content/public/browser/web_contents.h" | 51 #include "content/public/browser/web_contents.h" |
| 51 #include "content/public/browser/web_ui_message_handler.h" | 52 #include "content/public/browser/web_ui_message_handler.h" |
| 52 #include "grit/browser_resources.h" | 53 #include "grit/browser_resources.h" |
| 53 #include "grit/chromium_strings.h" | 54 #include "grit/chromium_strings.h" |
| 54 #include "grit/generated_resources.h" | 55 #include "grit/generated_resources.h" |
| 55 #include "grit/locale_settings.h" | 56 #include "grit/locale_settings.h" |
| 56 #include "net/base/escape.h" | 57 #include "net/base/escape.h" |
| (...skipping 257 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 314 } | 315 } |
| 315 } | 316 } |
| 316 | 317 |
| 317 //////////////////////////////////////////////////////////////////////////////// | 318 //////////////////////////////////////////////////////////////////////////////// |
| 318 // | 319 // |
| 319 // ActiveDownloadsUI | 320 // ActiveDownloadsUI |
| 320 // | 321 // |
| 321 //////////////////////////////////////////////////////////////////////////////// | 322 //////////////////////////////////////////////////////////////////////////////// |
| 322 | 323 |
| 323 | 324 |
| 324 ActiveDownloadsUI::ActiveDownloadsUI(WebContents* contents) | 325 ActiveDownloadsUI::ActiveDownloadsUI(WebUI* web_ui) |
| 325 : HtmlDialogUI(contents), | 326 : HtmlDialogUI(web_ui), |
| 326 handler_(new ActiveDownloadsHandler()) { | 327 handler_(new ActiveDownloadsHandler()) { |
| 327 AddMessageHandler(handler_); | 328 web_ui->AddMessageHandler(handler_); |
| 328 | 329 |
| 329 // Set up the chrome://active-downloads/ source. | 330 // Set up the chrome://active-downloads/ source. |
| 330 Profile* profile = Profile::FromBrowserContext(contents->GetBrowserContext()); | 331 Profile* profile = Profile::FromBrowserContext( |
| 332 web_ui->web_contents()->GetBrowserContext()); |
| 331 profile->GetChromeURLDataManager()->AddDataSource( | 333 profile->GetChromeURLDataManager()->AddDataSource( |
| 332 CreateActiveDownloadsUIHTMLSource()); | 334 CreateActiveDownloadsUIHTMLSource()); |
| 333 } | 335 } |
| 334 | 336 |
| 335 // static | 337 // static |
| 336 bool ActiveDownloadsUI::ShouldShowPopup(Profile* profile, | 338 bool ActiveDownloadsUI::ShouldShowPopup(Profile* profile, |
| 337 DownloadItem* download) { | 339 DownloadItem* download) { |
| 338 // Don't show downloads panel for extension/theme downloads from gallery, | 340 // Don't show downloads panel for extension/theme downloads from gallery, |
| 339 // or temporary downloads. | 341 // or temporary downloads. |
| 340 ExtensionService* service = profile->GetExtensionService(); | 342 ExtensionService* service = profile->GetExtensionService(); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 390 return (*it); | 392 return (*it); |
| 391 } | 393 } |
| 392 } | 394 } |
| 393 } | 395 } |
| 394 return NULL; | 396 return NULL; |
| 395 } | 397 } |
| 396 | 398 |
| 397 const ActiveDownloadsUI::DownloadList& ActiveDownloadsUI::GetDownloads() const { | 399 const ActiveDownloadsUI::DownloadList& ActiveDownloadsUI::GetDownloads() const { |
| 398 return handler_->downloads(); | 400 return handler_->downloads(); |
| 399 } | 401 } |
| OLD | NEW |