Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(223)

Side by Side Diff: chrome/browser/ui/webui/downloads_ui.cc

Issue 1710083005: Remove old downloads UI; Material Design version is now the default. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove testing/ Created 4 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "chrome/browser/ui/webui/downloads_ui.h"
6
7 #include "base/memory/ref_counted_memory.h"
8 #include "base/memory/singleton.h"
9 #include "base/strings/string_piece.h"
10 #include "base/threading/thread.h"
11 #include "base/values.h"
12 #include "chrome/browser/defaults.h"
13 #include "chrome/browser/download/download_service.h"
14 #include "chrome/browser/download/download_service_factory.h"
15 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ui/webui/downloads_dom_handler.h"
17 #include "chrome/browser/ui/webui/theme_source.h"
18 #include "chrome/common/chrome_switches.h"
19 #include "chrome/common/pref_names.h"
20 #include "chrome/common/url_constants.h"
21 #include "chrome/grit/chromium_strings.h"
22 #include "chrome/grit/generated_resources.h"
23 #include "components/prefs/pref_service.h"
24 #include "content/public/browser/download_manager.h"
25 #include "content/public/browser/url_data_source.h"
26 #include "content/public/browser/web_contents.h"
27 #include "content/public/browser/web_ui.h"
28 #include "content/public/browser/web_ui_data_source.h"
29 #include "grit/browser_resources.h"
30 #include "grit/theme_resources.h"
31 #include "ui/base/resource/resource_bundle.h"
32
33 using content::BrowserContext;
34 using content::DownloadManager;
35 using content::WebContents;
36
37 namespace {
38
39 content::WebUIDataSource* CreateDownloadsUIHTMLSource(Profile* profile) {
40 content::WebUIDataSource* source =
41 content::WebUIDataSource::Create(chrome::kChromeUIDownloadsHost);
42
43 source->AddLocalizedString("title", IDS_DOWNLOAD_TITLE);
44 source->AddLocalizedString("searchResultsFor", IDS_DOWNLOAD_SEARCHRESULTSFOR);
45 source->AddLocalizedString("downloads", IDS_DOWNLOAD_TITLE);
46 source->AddLocalizedString("clearAll", IDS_DOWNLOAD_LINK_CLEAR_ALL);
47 source->AddLocalizedString("openDownloadsFolder",
48 IDS_DOWNLOAD_LINK_OPEN_DOWNLOADS_FOLDER);
49 source->AddLocalizedString("searchButton", IDS_DOWNLOAD_SEARCH_BUTTON);
50
51 // No results message that shows instead of the downloads list.
52 source->AddLocalizedString("noDownloads", IDS_DOWNLOAD_NO_DOWNLOADS);
53 source->AddLocalizedString("noSearchResults",
54 IDS_DOWNLOAD_NO_SEARCH_RESULTS);
55
56 // Status.
57 source->AddLocalizedString("statusCancelled", IDS_DOWNLOAD_TAB_CANCELLED);
58 source->AddLocalizedString("statusRemoved", IDS_DOWNLOAD_FILE_REMOVED);
59
60 // Dangerous file.
61 source->AddLocalizedString("dangerFileDesc", IDS_PROMPT_DANGEROUS_DOWNLOAD);
62 source->AddLocalizedString("dangerUrlDesc",
63 IDS_PROMPT_MALICIOUS_DOWNLOAD_URL);
64 source->AddLocalizedString("dangerContentDesc",
65 IDS_PROMPT_MALICIOUS_DOWNLOAD_CONTENT);
66 source->AddLocalizedString("dangerUncommonDesc",
67 IDS_PROMPT_UNCOMMON_DOWNLOAD_CONTENT);
68 source->AddLocalizedString("dangerSettingsDesc",
69 IDS_PROMPT_DOWNLOAD_CHANGES_SETTINGS);
70 source->AddLocalizedString("dangerSave", IDS_CONFIRM_DOWNLOAD);
71 source->AddLocalizedString("dangerRestore", IDS_CONFIRM_DOWNLOAD_RESTORE);
72 source->AddLocalizedString("dangerDiscard", IDS_DISCARD_DOWNLOAD);
73
74 // Controls.
75 source->AddLocalizedString("controlPause", IDS_DOWNLOAD_LINK_PAUSE);
76 if (browser_defaults::kDownloadPageHasShowInFolder)
77 source->AddLocalizedString("controlShowInFolder", IDS_DOWNLOAD_LINK_SHOW);
78 source->AddLocalizedString("controlCancel", IDS_DOWNLOAD_LINK_CANCEL);
79 source->AddLocalizedString("controlResume", IDS_DOWNLOAD_LINK_RESUME);
80 source->AddLocalizedString("controlRemoveFromList",
81 IDS_DOWNLOAD_LINK_REMOVE);
82 source->AddLocalizedString("controlRetry", IDS_DOWNLOAD_LINK_RETRY);
83 source->AddLocalizedString("controlByExtension",
84 IDS_DOWNLOAD_BY_EXTENSION);
85
86 PrefService* prefs = profile->GetPrefs();
87 source->AddBoolean("allowDeletingHistory",
88 prefs->GetBoolean(prefs::kAllowDeletingBrowserHistory) &&
89 !profile->IsSupervised());
90
91 source->AddResourcePath("constants.html", IDR_DOWNLOADS_CONSTANTS_HTML);
92 source->AddResourcePath("constants.js", IDR_DOWNLOADS_CONSTANTS_JS);
93 source->AddResourcePath("item_view.js", IDR_DOWNLOADS_ITEM_VIEW_JS);
94 source->AddResourcePath("focus_row.js", IDR_DOWNLOADS_FOCUS_ROW_JS);
95 source->AddResourcePath("manager.js", IDR_DOWNLOADS_MANAGER_JS);
96 source->AddResourcePath("throttled_icon_loader.html",
97 IDR_DOWNLOADS_THROTTLED_ICON_LOADER_HTML);
98 source->AddResourcePath("throttled_icon_loader.js",
99 IDR_DOWNLOADS_THROTTLED_ICON_LOADER_JS);
100
101 source->SetDefaultResource(IDR_DOWNLOADS_DOWNLOADS_HTML);
102 source->SetJsonPath("strings.js");
103
104 return source;
105 }
106
107 } // namespace
108
109 ///////////////////////////////////////////////////////////////////////////////
110 //
111 // DownloadsUI
112 //
113 ///////////////////////////////////////////////////////////////////////////////
114
115 DownloadsUI::DownloadsUI(content::WebUI* web_ui) : WebUIController(web_ui) {
116 Profile* profile = Profile::FromWebUI(web_ui);
117 DownloadManager* dlm = BrowserContext::GetDownloadManager(profile);
118
119 DownloadsDOMHandler* handler = new DownloadsDOMHandler(dlm);
120 web_ui->AddMessageHandler(handler);
121
122 // Set up the chrome://downloads/ source.
123 content::WebUIDataSource* source = CreateDownloadsUIHTMLSource(profile);
124 content::WebUIDataSource::Add(profile, source);
125 #if defined(ENABLE_THEMES)
126 ThemeSource* theme = new ThemeSource(profile);
127 content::URLDataSource::Add(profile, theme);
128 #endif
129 }
130
131 // static
132 base::RefCountedMemory* DownloadsUI::GetFaviconResourceBytes(
133 ui::ScaleFactor scale_factor) {
134 return ResourceBundle::GetSharedInstance().
135 LoadDataResourceBytesForScale(IDR_DOWNLOADS_FAVICON, scale_factor);
136 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/webui/downloads_ui.h ('k') | chrome/browser/ui/webui/downloads_ui_browsertest.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698