| 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_ui.h" | 5 #include "chrome/browser/ui/webui/downloads_ui.h" |
| 6 | 6 |
| 7 #include "base/memory/ref_counted_memory.h" | 7 #include "base/memory/ref_counted_memory.h" |
| 8 #include "base/memory/singleton.h" | 8 #include "base/memory/singleton.h" |
| 9 #include "base/string_piece.h" | 9 #include "base/string_piece.h" |
| 10 #include "base/threading/thread.h" | 10 #include "base/threading/thread.h" |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 source->AddLocalizedString("control_retry", IDS_DOWNLOAD_LINK_RETRY); | 68 source->AddLocalizedString("control_retry", IDS_DOWNLOAD_LINK_RETRY); |
| 69 source->AddLocalizedString("control_cancel", IDS_DOWNLOAD_LINK_CANCEL); | 69 source->AddLocalizedString("control_cancel", IDS_DOWNLOAD_LINK_CANCEL); |
| 70 source->AddLocalizedString("control_resume", IDS_DOWNLOAD_LINK_RESUME); | 70 source->AddLocalizedString("control_resume", IDS_DOWNLOAD_LINK_RESUME); |
| 71 source->AddLocalizedString("control_removefromlist", | 71 source->AddLocalizedString("control_removefromlist", |
| 72 IDS_DOWNLOAD_LINK_REMOVE); | 72 IDS_DOWNLOAD_LINK_REMOVE); |
| 73 | 73 |
| 74 source->set_json_path("strings.js"); | 74 source->set_json_path("strings.js"); |
| 75 source->add_resource_path("downloads.css", IDR_DOWNLOADS_CSS); | 75 source->add_resource_path("downloads.css", IDR_DOWNLOADS_CSS); |
| 76 source->add_resource_path("downloads.js", IDR_DOWNLOADS_JS); | 76 source->add_resource_path("downloads.js", IDR_DOWNLOADS_JS); |
| 77 source->set_default_resource(IDR_DOWNLOADS_HTML); | 77 source->set_default_resource(IDR_DOWNLOADS_HTML); |
| 78 source->set_use_json_js_format_v2(); |
| 78 | 79 |
| 79 return source; | 80 return source; |
| 80 } | 81 } |
| 81 | 82 |
| 82 } // namespace | 83 } // namespace |
| 83 | 84 |
| 84 /////////////////////////////////////////////////////////////////////////////// | 85 /////////////////////////////////////////////////////////////////////////////// |
| 85 // | 86 // |
| 86 // DownloadsUI | 87 // DownloadsUI |
| 87 // | 88 // |
| 88 /////////////////////////////////////////////////////////////////////////////// | 89 /////////////////////////////////////////////////////////////////////////////// |
| 89 | 90 |
| 90 DownloadsUI::DownloadsUI(content::WebUI* web_ui) : WebUIController(web_ui) { | 91 DownloadsUI::DownloadsUI(content::WebUI* web_ui) : WebUIController(web_ui) { |
| 91 Profile* profile = Profile::FromWebUI(web_ui); | 92 Profile* profile = Profile::FromWebUI(web_ui); |
| 92 DownloadManager* dlm = BrowserContext::GetDownloadManager(profile); | 93 DownloadManager* dlm = BrowserContext::GetDownloadManager(profile); |
| 93 | 94 |
| 94 DownloadsDOMHandler* handler = new DownloadsDOMHandler(dlm); | 95 DownloadsDOMHandler* handler = new DownloadsDOMHandler(dlm); |
| 95 web_ui->AddMessageHandler(handler); | 96 web_ui->AddMessageHandler(handler); |
| 96 | 97 |
| 97 // Set up the chrome://downloads/ source. | 98 // Set up the chrome://downloads/ source. |
| 98 ChromeWebUIDataSource* source = CreateDownloadsUIHTMLSource(); | 99 ChromeWebUIDataSource* source = CreateDownloadsUIHTMLSource(); |
| 99 source->set_use_json_js_format_v2(); | 100 ChromeURLDataManager::AddDataSourceImpl(profile, source); |
| 100 ChromeURLDataManager::AddDataSource(profile, source); | |
| 101 #if defined(ENABLE_THEMES) | 101 #if defined(ENABLE_THEMES) |
| 102 ThemeSource* theme = new ThemeSource(profile); | 102 ThemeSource* theme = new ThemeSource(profile); |
| 103 ChromeURLDataManager::AddDataSource(profile, theme); | 103 ChromeURLDataManager::AddDataSource(profile, theme); |
| 104 #endif | 104 #endif |
| 105 } | 105 } |
| 106 | 106 |
| 107 // static | 107 // static |
| 108 base::RefCountedMemory* DownloadsUI::GetFaviconResourceBytes( | 108 base::RefCountedMemory* DownloadsUI::GetFaviconResourceBytes( |
| 109 ui::ScaleFactor scale_factor) { | 109 ui::ScaleFactor scale_factor) { |
| 110 return ResourceBundle::GetSharedInstance(). | 110 return ResourceBundle::GetSharedInstance(). |
| 111 LoadDataResourceBytesForScale(IDR_DOWNLOADS_FAVICON, scale_factor); | 111 LoadDataResourceBytesForScale(IDR_DOWNLOADS_FAVICON, scale_factor); |
| 112 } | 112 } |
| OLD | NEW |