summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authordbeam <dbeam@chromium.org>2016-02-22 17:43:27 -0800
committerCommit bot <commit-bot@chromium.org>2016-02-23 01:44:22 +0000
commit2b4fc356ff151e0c104596bffea377d6fad40281 (patch)
treea416356a9fb99b4b00a55564c7924878d673beb2
parente4fec04138c05a31edf8942afef26914e8b38e52 (diff)
downloadchromium_src-2b4fc356ff151e0c104596bffea377d6fad40281.zip
chromium_src-2b4fc356ff151e0c104596bffea377d6fad40281.tar.gz
chromium_src-2b4fc356ff151e0c104596bffea377d6fad40281.tar.bz2
Remove old downloads UI; Material Design version is now the default.
This step removes the code and resources. Next step drops all the "Md" prefixes. R=asanka@chromium.org,asvitkine@chromium.org BUG=528484 Review URL: https://codereview.chromium.org/1710083005 Cr-Commit-Position: refs/heads/master@{#376895}
-rw-r--r--chrome/app/generated_resources.grd15
-rw-r--r--chrome/app/theme/theme_resources.grd2
-rw-r--r--chrome/browser/about_flags.cc6
-rw-r--r--chrome/browser/browser_resources.grd8
-rw-r--r--chrome/browser/lifetime/browser_close_manager_browsertest.cc7
-rw-r--r--chrome/browser/resources/downloads/OWNERS2
-rw-r--r--chrome/browser/resources/downloads/compiled_resources.gyp33
-rw-r--r--chrome/browser/resources/downloads/compiled_resources2.gyp63
-rw-r--r--chrome/browser/resources/downloads/constants.html2
-rw-r--r--chrome/browser/resources/downloads/constants.js38
-rw-r--r--chrome/browser/resources/downloads/downloads.css163
-rw-r--r--chrome/browser/resources/downloads/downloads.html104
-rw-r--r--chrome/browser/resources/downloads/externs.js36
-rw-r--r--chrome/browser/resources/downloads/focus_row.js32
-rw-r--r--chrome/browser/resources/downloads/item_view.js395
-rw-r--r--chrome/browser/resources/downloads/manager.js256
-rw-r--r--chrome/browser/resources/downloads/throttled_icon_loader.html3
-rw-r--r--chrome/browser/resources/downloads/throttled_icon_loader.js61
-rw-r--r--chrome/browser/resources/md_downloads/compiled_resources2.gyp2
-rw-r--r--chrome/browser/resources/md_downloads/externs.js2
-rw-r--r--chrome/browser/ui/browser_navigator_browsertest.cc10
-rw-r--r--chrome/browser/ui/find_bar/find_bar_host_browsertest.cc7
-rw-r--r--chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc11
-rw-r--r--chrome/browser/ui/webui/downloads_dom_handler.cc722
-rw-r--r--chrome/browser/ui/webui/downloads_dom_handler.h178
-rw-r--r--chrome/browser/ui/webui/downloads_dom_handler_browsertest.cc330
-rw-r--r--chrome/browser/ui/webui/downloads_ui.cc136
-rw-r--r--chrome/browser/ui/webui/downloads_ui.h27
-rw-r--r--chrome/browser/ui/webui/downloads_ui_browsertest.cc30
-rw-r--r--chrome/browser/ui/webui/downloads_ui_browsertest.h28
-rw-r--r--chrome/browser/ui/webui/downloads_ui_browsertest.js170
-rw-r--r--chrome/browser/ui/webui/downloads_ui_browsertest_base.js177
-rw-r--r--chrome/browser/ui/webui/downloads_ui_supervised_browsertest.cc16
-rw-r--r--chrome/browser/ui/webui/downloads_ui_supervised_browsertest.h16
-rw-r--r--chrome/browser/ui/webui/downloads_ui_supervised_browsertest.js27
-rw-r--r--chrome/browser/ui/webui/downloads_util.cc30
-rw-r--r--chrome/browser/ui/webui/downloads_util.h13
-rw-r--r--chrome/browser/ui/webui/downloads_util_unittest.cc69
-rw-r--r--chrome/chrome_browser_ui.gypi6
-rw-r--r--chrome/chrome_tests.gypi12
-rw-r--r--chrome/chrome_tests_unit.gypi1
-rw-r--r--chrome/common/chrome_switches.cc9
-rw-r--r--chrome/common/chrome_switches.h3
-rw-r--r--chrome/test/BUILD.gn4
-rw-r--r--chrome/test/base/web_ui_browser_test_browsertest.cc7
-rw-r--r--third_party/closure_compiler/compiled_resources.gyp1
-rw-r--r--third_party/closure_compiler/compiled_resources2.gyp1
-rw-r--r--ui/webui/resources/images/2x/otr_icon_standalone.pngbin2739 -> 0 bytes
-rw-r--r--ui/webui/resources/images/otr_icon_standalone.pngbin1392 -> 0 bytes
49 files changed, 14 insertions, 3257 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 0433cc0..171306c 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -1834,10 +1834,6 @@ Even if you have downloaded files from this website before, the website might ha
desc="In the download view, 'Pause' link text">
Pause
</message>
- <message name="IDS_DOWNLOAD_SEARCH_BUTTON"
- desc="Title of the button in the download page that triggers a search">
- Search downloads
- </message>
<message name="IDS_MD_DOWNLOAD_SEARCH"
desc="Placeholder text/label for the search input in the download page">
Search
@@ -1852,9 +1848,6 @@ Even if you have downloaded files from this website before, the website might ha
<message name="IDS_DOWNLOAD_NO_SEARCH_RESULTS" desc="A message shown for when a search yield no results (no matching downloads).">
No search results found.
</message>
- <message name="IDS_DOWNLOAD_NO_DOWNLOADS" desc="A message shown when the user has no downloads to show on chrome://downloads.">
- No downloads found.
- </message>
<message name="IDS_MD_DOWNLOAD_NO_DOWNLOADS" desc="A message shown when the user has no downloads to show on chrome://downloads.">
Nothing to see here...
</message>
@@ -1870,10 +1863,6 @@ Even if you have downloaded files from this website before, the website might ha
desc="In the download view, 'Cancel' link text">
Cancel
</message>
- <message name="IDS_DOWNLOAD_LINK_RETRY"
- desc="In the download view, 'Retry download' link text">
- Retry download
- </message>
<message name="IDS_MD_DOWNLOAD_LINK_RETRY"
desc="In the download view, 'Retry' button text to retry downloading a file.">
Retry
@@ -1936,10 +1925,6 @@ Even if you have downloaded files from this website before, the website might ha
desc="Tooltip of a button on the downloads page that shows a menu with actions like 'Open downloads folder' or 'Clear all'">
More actions...
</message>
- <message name="IDS_DOWNLOAD_BY_EXTENSION"
- desc="Indicates which extension downloaded this file.">
- Downloaded by &lt;a&gt;<ph name="EXTENSION">$1<ex>The Best Chrome Extension Ever</ex></ph>&lt;/a&gt;
- </message>
<message name="IDS_DOWNLOAD_BY_EXTENSION_URL"
desc="Indicates which extension downloaded this file by name and URL.">
Downloaded by &lt;a href=&quot;<ph name="URL">$1<ex>adblock.com</ex></ph>&quot;&gt;<ph name="EXTENSION">$2<ex>The Best Chrome Extension Ever</ex></ph>&lt;/a&gt;
diff --git a/chrome/app/theme/theme_resources.grd b/chrome/app/theme/theme_resources.grd
index 07dcba0d..e29d0e1 100644
--- a/chrome/app/theme/theme_resources.grd
+++ b/chrome/app/theme/theme_resources.grd
@@ -235,8 +235,6 @@
<structure type="chrome_scaled_image" name="IDR_DOWNLOAD_BUTTON_RIGHT_TOP_H" file="common/download_button_right_top_hover.png" />
<structure type="chrome_scaled_image" name="IDR_DOWNLOAD_BUTTON_RIGHT_TOP_NO_DD" file="common/download_button_right_top_no_dd.png" />
<structure type="chrome_scaled_image" name="IDR_DOWNLOAD_BUTTON_RIGHT_TOP_P" file="common/download_button_right_top_pressed.png" />
- <structure type="chrome_scaled_image" name="IDR_DOWNLOAD_PROGRESS_BACKGROUND_32" file="common/download_progress_background32.png" />
- <structure type="chrome_scaled_image" name="IDR_DOWNLOAD_PROGRESS_FOREGROUND_32" file="common/download_progress_foreground32.png" />
<if expr="chromeos">
<structure type="chrome_scaled_image" name="IDR_DOWNLOAD_NOTIFICATION_MENU_CANCEL" file="cros/downloads/cancel.png" />
<structure type="chrome_scaled_image" name="IDR_DOWNLOAD_NOTIFICATION_MENU_DELETE" file="cros/downloads/delete.png" />
diff --git a/chrome/browser/about_flags.cc b/chrome/browser/about_flags.cc
index fc6bdb5..8cb91ea 100644
--- a/chrome/browser/about_flags.cc
+++ b/chrome/browser/about_flags.cc
@@ -1604,12 +1604,6 @@ const FeatureEntry kFeatureEntries[] = {
{"v8-cache-options", IDS_FLAGS_V8_CACHE_OPTIONS_NAME,
IDS_FLAGS_V8_CACHE_OPTIONS_DESCRIPTION, kOsAll,
MULTI_VALUE_TYPE(kV8CacheOptionsChoices)},
-#if !defined(OS_ANDROID) && !defined(OS_IOS)
- {"enable-md-downloads", IDS_FLAGS_ENABLE_MATERIAL_DESIGN_DOWNLOADS_NAME,
- IDS_FLAGS_ENABLE_MATERIAL_DESIGN_DOWNLOADS_DESCRIPTION, kOsDesktop,
- ENABLE_DISABLE_VALUE_TYPE(switches::kEnableMaterialDesignDownloads,
- switches::kDisableMaterialDesignDownloads)},
-#endif
{"enable-clear-browsing-data-counters",
IDS_FLAGS_ENABLE_CLEAR_BROWSING_DATA_COUNTERS_NAME,
IDS_FLAGS_ENABLE_CLEAR_BROWSING_DATA_COUNTERS_DESCRIPTION, kOsAll,
diff --git a/chrome/browser/browser_resources.grd b/chrome/browser/browser_resources.grd
index 6d8b551..182d976 100644
--- a/chrome/browser/browser_resources.grd
+++ b/chrome/browser/browser_resources.grd
@@ -24,7 +24,6 @@
<structure name="IDR_APP_LIST_START_PAGE_JS" file="resources\app_list\start_page.js" flattenhtml="true" type="chrome_html" />
</if>
<if expr="not is_android">
- <structure name="IDR_DOWNLOADS_DOWNLOADS_HTML" file="resources\downloads\downloads.html" flattenhtml="true" allowexternalscript="true" type="chrome_html" />
<if expr="use_vulcanize">
<then>
<structure name="IDR_MD_DOWNLOADS_VULCANIZED_HTML" file="resources\md_downloads\vulcanized.html" flattenhtml="true" allowexternalscript="true" type="chrome_html" />
@@ -119,13 +118,6 @@
<include name="IDR_DOMAIN_RELIABILITY_INTERNALS_CSS" file="resources\domain_reliability_internals.css" type="BINDATA" />
<include name="IDR_DOMAIN_RELIABILITY_INTERNALS_JS" file="resources\domain_reliability_internals.js" type="BINDATA" />
<if expr="not is_android">
- <include name="IDR_DOWNLOADS_CONSTANTS_HTML" file="resources\downloads\constants.html" type="BINDATA" />
- <include name="IDR_DOWNLOADS_CONSTANTS_JS" file="resources\downloads\constants.js" type="BINDATA" />
- <include name="IDR_DOWNLOADS_FOCUS_ROW_JS" file="resources\downloads\focus_row.js" type="BINDATA" />
- <include name="IDR_DOWNLOADS_ITEM_VIEW_JS" file="resources\downloads\item_view.js" type="BINDATA" />
- <include name="IDR_DOWNLOADS_MANAGER_JS" file="resources\downloads\manager.js" type="BINDATA" />
- <include name="IDR_DOWNLOADS_THROTTLED_ICON_LOADER_HTML" file="resources\downloads\throttled_icon_loader.html" type="BINDATA" />
- <include name="IDR_DOWNLOADS_THROTTLED_ICON_LOADER_JS" file="resources\downloads\throttled_icon_loader.js" type="BINDATA" />
<include name="IDR_MD_DOWNLOADS_1X_INCOGNITO_MARKER_PNG" file="resources\md_downloads\1x\incognito_marker.png" type="BINDATA" />
<include name="IDR_MD_DOWNLOADS_2X_INCOGNITO_MARKER_PNG" file="resources\md_downloads\2x\incognito_marker.png" type="BINDATA" />
<include name="IDR_MD_DOWNLOADS_1X_NO_DOWNLOADS_PNG" file="resources\md_downloads\1x\no_downloads.png" type="BINDATA" />
diff --git a/chrome/browser/lifetime/browser_close_manager_browsertest.cc b/chrome/browser/lifetime/browser_close_manager_browsertest.cc
index 626f244..4a185b3 100644
--- a/chrome/browser/lifetime/browser_close_manager_browsertest.cc
+++ b/chrome/browser/lifetime/browser_close_manager_browsertest.cc
@@ -708,13 +708,6 @@ class BrowserCloseManagerWithDownloadsBrowserTest :
ASSERT_TRUE(scoped_download_directory_.CreateUniqueTempDir());
}
- // Disable new downloads UI as it is very very slow. https://crbug.com/526577
- // TODO(dbeam): remove this once the downloads UI is not slow.
- void SetUpCommandLine(base::CommandLine* command_line) override {
- BrowserCloseManagerBrowserTest::SetUpCommandLine(command_line);
- command_line->AppendSwitch(switches::kDisableMaterialDesignDownloads);
- }
-
void SetDownloadPathForProfile(Profile* profile) {
DownloadPrefs* download_prefs = DownloadPrefs::FromBrowserContext(profile);
download_prefs->SetDownloadPath(download_path());
diff --git a/chrome/browser/resources/downloads/OWNERS b/chrome/browser/resources/downloads/OWNERS
deleted file mode 100644
index cd46f8d..0000000
--- a/chrome/browser/resources/downloads/OWNERS
+++ /dev/null
@@ -1,2 +0,0 @@
-asanka@chromium.org
-dbeam@chromium.org
diff --git a/chrome/browser/resources/downloads/compiled_resources.gyp b/chrome/browser/resources/downloads/compiled_resources.gyp
deleted file mode 100644
index 25184bd..0000000
--- a/chrome/browser/resources/downloads/compiled_resources.gyp
+++ /dev/null
@@ -1,33 +0,0 @@
-# Copyright 2014 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'manager',
- 'variables': {
- 'depends': [
- '../../../../ui/webui/resources/js/action_link.js',
- '../../../../ui/webui/resources/js/assert.js',
- '../../../../ui/webui/resources/js/compiled_resources.gyp:load_time_data',
- '../../../../ui/webui/resources/js/cr.js',
- '../../../../ui/webui/resources/js/cr/ui.js',
- '../../../../ui/webui/resources/js/cr/ui/command.js',
- '../../../../ui/webui/resources/js/cr/ui/focus_grid.js',
- '../../../../ui/webui/resources/js/cr/ui/focus_row.js',
- '../../../../ui/webui/resources/js/event_tracker.js',
- '../../../../ui/webui/resources/js/util.js',
- 'constants.js',
- 'throttled_icon_loader.js',
- 'item_view.js',
- 'focus_row.js',
- ],
- 'externs': [
- '<(EXTERNS_DIR)/chrome_send.js',
- 'externs.js',
- ],
- },
- 'includes': ['../../../../third_party/closure_compiler/compile_js.gypi'],
- }
- ],
-}
diff --git a/chrome/browser/resources/downloads/compiled_resources2.gyp b/chrome/browser/resources/downloads/compiled_resources2.gyp
deleted file mode 100644
index 4777352..0000000
--- a/chrome/browser/resources/downloads/compiled_resources2.gyp
+++ /dev/null
@@ -1,63 +0,0 @@
-# Copyright 2014 The Chromium Authors. All rights reserved.
-# Use of this source code is governed by a BSD-style license that can be
-# found in the LICENSE file.
-{
- 'targets': [
- {
- 'target_name': 'constants',
- 'dependencies': ['<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr'],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'externs',
- 'includes': ['../../../../third_party/closure_compiler/externs_js.gypi'],
- },
- {
- 'target_name': 'item_view',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:util',
- 'constants',
- 'throttled_icon_loader',
- 'externs',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'focus_row',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:focus_row',
- 'item_view',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'manager',
- 'dependencies': [
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:assert',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:load_time_data',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:event_tracker',
- '<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:util',
- '<(DEPTH)/ui/webui/resources/js/cr/compiled_resources2.gyp:ui',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:command',
- '<(DEPTH)/ui/webui/resources/js/cr/ui/compiled_resources2.gyp:focus_grid',
- 'constants',
- 'throttled_icon_loader',
- 'item_view',
- 'focus_row',
- '<(EXTERNS_GYP):chrome_send',
- 'externs',
- ],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- {
- 'target_name': 'throttled_icon_loader',
- 'dependencies': ['<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:cr'],
- 'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
- },
- ],
-}
diff --git a/chrome/browser/resources/downloads/constants.html b/chrome/browser/resources/downloads/constants.html
deleted file mode 100644
index 0ac6c26..0000000
--- a/chrome/browser/resources/downloads/constants.html
+++ /dev/null
@@ -1,2 +0,0 @@
-<link rel="import" href="chrome://resources/html/cr.html">
-<script src="chrome://downloads/constants.js"></script>
diff --git a/chrome/browser/resources/downloads/constants.js b/chrome/browser/resources/downloads/constants.js
deleted file mode 100644
index b123be0..0000000
--- a/chrome/browser/resources/downloads/constants.js
+++ /dev/null
@@ -1,38 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-cr.define('downloads', function() {
- /**
- * Explains why a download is in DANGEROUS state.
- * @enum {string}
- */
- var DangerType = {
- NOT_DANGEROUS: 'NOT_DANGEROUS',
- DANGEROUS_FILE: 'DANGEROUS_FILE',
- DANGEROUS_URL: 'DANGEROUS_URL',
- DANGEROUS_CONTENT: 'DANGEROUS_CONTENT',
- UNCOMMON_CONTENT: 'UNCOMMON_CONTENT',
- DANGEROUS_HOST: 'DANGEROUS_HOST',
- POTENTIALLY_UNWANTED: 'POTENTIALLY_UNWANTED',
- };
-
- /**
- * The states a download can be in. These correspond to states defined in
- * DownloadsDOMHandler::CreateDownloadItemValue
- * @enum {string}
- */
- var States = {
- IN_PROGRESS: 'IN_PROGRESS',
- CANCELLED: 'CANCELLED',
- COMPLETE: 'COMPLETE',
- PAUSED: 'PAUSED',
- DANGEROUS: 'DANGEROUS',
- INTERRUPTED: 'INTERRUPTED',
- };
-
- return {
- DangerType: DangerType,
- States: States,
- };
-});
diff --git a/chrome/browser/resources/downloads/downloads.css b/chrome/browser/resources/downloads/downloads.css
deleted file mode 100644
index dd6bb7d..0000000
--- a/chrome/browser/resources/downloads/downloads.css
+++ /dev/null
@@ -1,163 +0,0 @@
-/* Copyright (c) 2012 The Chromium Authors. All rights reserved.
- * Use of this source code is governed by a BSD-style license that can be
- * found in the LICENSE file. */
-
-<include src="../search_header.css">
-
-#downloads-summary-text {
- font-weight: bold;
-}
-
-#download-actions {
- -webkit-margin-start: 16px;
-}
-
-#downloads-actions > * ~ * {
- -webkit-margin-start: 10px;
-}
-
-#downloads-display,
-#no-downloads-or-results {
- max-width: 740px;
- padding: 0 10px 34px;
-}
-
-.download {
- -webkit-margin-start: 114px;
- -webkit-padding-start: 52px;
- margin-bottom: 15px;
- position: relative;
-}
-
-.download,
-#no-downloads-or-results {
- margin-top: 6px;
-}
-
-.date-container {
- left: -110px;
- position: absolute;
- width: 110px;
-}
-
-html[dir=rtl] .date-container {
- left: auto;
- right: -110px;
-}
-
-.date-container .since {
- color: black;
-}
-
-.date-container .date {
- color: #666;
-}
-
-.download .icon {
- height: 32px;
- left: 9px;
- position: absolute;
- top: 2px;
- width: 32px;
-}
-
-html[dir=rtl] .icon {
- left: auto;
- right: 9px;
-}
-
-.download.otr > :-webkit-any(.safe, .dangerous) {
- -webkit-transition: opacity 150ms;
- background: url(../../../../ui/webui/resources/images/otr_icon_standalone.png)
- no-repeat right bottom;
- opacity: .66;
-}
-
-html[dir=rtl] .download.otr > :-webkit-any(.safe, .dangerous) {
- background-position: left bottom;
-}
-
-.download.otr > :-webkit-any(.safe, .dangerous):hover {
- opacity: 1;
-}
-
-.description.malware {
- color: rgb(196, 42, 23);
-}
-
-.progress {
- height: 48px;
- left: 0;
- position: absolute;
- top: -6px;
- width: 48px;
-}
-
-html[dir=rtl] .progress {
- left: auto;
- right: 0;
-}
-
-.progress.background {
- background: url(chrome://theme/IDR_DOWNLOAD_PROGRESS_BACKGROUND_32);
- background-size: 48px;
-}
-
-.title-area {
- align-items: baseline;
- display: flex;
-}
-
-.title-area > * {
- flex-shrink: 0;
-}
-
-.name,
-.src-url,
-.controls a,
-.description {
- -webkit-padding-end: 4px;
- -webkit-padding-start: 4px;
-}
-
-.name {
- -webkit-padding-end: 16px;
- display: inline-block;
- max-width: 450px;
- word-break: break-all;
-}
-
-.interrupted {
- color: red;
-}
-
-.download .status {
- color: #999;
- white-space: nowrap;
-}
-
-.download .src-url {
- color: rgb(85, 102, 221);
- display: inline-block;
- max-width: 500px;
- overflow: hidden;
- padding-bottom: 1px;
- padding-top: 4px;
- text-decoration: none;
- text-overflow: ellipsis;
- white-space: nowrap;
-}
-
-.controls a {
- -webkit-margin-end: 12px;
- color: #777;
-}
-
-.safe .controls a {
- display: inline;
-}
-
-#downloads-pagination {
- -webkit-margin-start: 18px;
- padding-top: 24px;
-}
diff --git a/chrome/browser/resources/downloads/downloads.html b/chrome/browser/resources/downloads/downloads.html
deleted file mode 100644
index 4349816..0000000
--- a/chrome/browser/resources/downloads/downloads.html
+++ /dev/null
@@ -1,104 +0,0 @@
-<!doctype html>
-<html i18n-values="dir:textdirection;lang:language">
-<head>
- <meta charset="utf-8">
- <title i18n-content="title"></title>
- <link rel="stylesheet" href="chrome://resources/css/chrome_shared.css">
- <!-- This has to come after chrome_shared.css -->
- <link rel="stylesheet" href="downloads.css">
- <script src="chrome://resources/js/action_link.js"></script>
- <link rel="import" href="chrome://resources/html/assert.html">
- <link rel="import" href="chrome://resources/html/cr.html">
- <script src="chrome://resources/js/cr/ui.js"></script>
- <script src="chrome://resources/js/cr/ui/command.js"></script>
- <script src="chrome://resources/js/load_time_data.js"></script>
- <script src="chrome://resources/js/util.js"></script>
- <script src="chrome://resources/js/event_tracker.js"></script>
- <script src="chrome://resources/js/cr/ui/focus_row.js"></script>
- <script src="chrome://resources/js/cr/ui/focus_grid.js"></script>
- <link rel="import" href="chrome://downloads/constants.html">
- <link rel="import" href="chrome://downloads/throttled_icon_loader.html">
- <script src="chrome://downloads/item_view.js"></script>
- <script src="chrome://downloads/focus_row.js"></script>
- <script src="chrome://downloads/manager.js"></script>
-</head>
-<body>
- <header>
- <h1 i18n-content="downloads"></h1>
- <input id="term" type="search" tabindex=1
- i18n-values="placeholder:searchButton" autofocus incremental>
- </header>
- <div class="main">
- <div class="summary" id="downloads-summary">
- <span id="downloads-summary-text"></span>
- <span id="downloads-actions">
- <a is="action-link" id="open-downloads-folder"
- i18n-content="openDownloadsFolder"></a>
- <a is="action-link" id="clear-all" i18n-content="clearAll" hidden></a>
- </span>
- </div>
- <div id="downloads-display"></div>
- <div id="no-downloads-or-results"></div>
- </div>
- <command id="clear-all-command" shortcut="Alt-U+0043"><!-- Alt+C -->
-<if expr="is_macosx">
- <command id="undo-command" shortcut="Meta-U+005A"><!-- Command+Z -->
-</if>
-<if expr="not is_macosx">
- <command id="undo-command" shortcut="Ctrl-U+005A"><!-- Ctrl+Z -->
-</if>
- <div id="templates" hidden>
- <div class="download">
- <div class="date-container">
- <div class="since"></div>
- <div class="date"></div>
- </div>
- <div class="safe">
- <div class="progress background"></div>
- <canvas class="progress"></canvas>
- <img class="icon" alt="">
- <div class="title-area">
- <a is="action-link" class="name" focus-type="name"></a>
- <span class="name"></span>
- <span class="status"></span>
- </div>
- <div class="url-container">
- <a class="src-url" target="_blank" focus-type="url"></a>
- </div>
- <div class="controls">
- <a is="action-link" class="show" focus-type="show"
- i18n-content="controlShowInFolder"></a>
- <a class="retry" focus-type="retry" i18n-content="controlRetry"
- download></a>
- <a is="action-link" class="pause" focus-type="pause"
- i18n-content="controlPause"></a>
- <a is="action-link" class="resume" focus-type="resume"
- i18n-content="controlResume"></a>
- <a is="action-link" class="remove" focus-type="remove"
- i18n-content="controlRemoveFromList"></a>
- <a is="action-link" class="cancel" focus-type="cancel"
- i18n-content="controlCancel"></a>
- <span class="controlled-by"
- i18n-values=".innerHTML:controlByExtension"></span>
- </div>
- </div>
- <div class="dangerous">
- <img class="icon" alt="">
- <div class="description"></div>
- <div class="controls">
- <a is="action-link" class="restore" focus-type="save"
- i18n-content="dangerRestore"></a>
- <a is="action-link" class="remove" focus-type="discard"
- i18n-content="controlRemoveFromList"></a>
- </div>
- <button class="save" focus-type="save"
- i18n-content="dangerSave"></button>
- <button class="discard" focus-type="discard"
- i18n-content="dangerDiscard"></button>
- </div>
- </div>
- </div>
- <script src="chrome://downloads/strings.js"></script>
- <script src="chrome://resources/js/i18n_template.js"></script>
-</body>
-</html>
diff --git a/chrome/browser/resources/downloads/externs.js b/chrome/browser/resources/downloads/externs.js
deleted file mode 100644
index 65efb05..0000000
--- a/chrome/browser/resources/downloads/externs.js
+++ /dev/null
@@ -1,36 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-/**
- * @fileoverview Externs for objects sent from C++ to JS for chrome://downloads.
- * @externs
- */
-
-var downloads = {};
-
-/**
- * The type of the download object. The definition is based on
- * chrome/browser/ui/webui/downloads_dom_handler.cc:CreateDownloadItemValue()
- * @typedef {{by_ext_id: string,
- * by_ext_name: string,
- * danger_type: string,
- * date_string: string,
- * file_externally_removed: boolean,
- * file_name: string,
- * file_path: string,
- * file_url: string,
- * id: string,
- * last_reason_text: string,
- * otr: boolean,
- * percent: number,
- * progress_status_text: string,
- * resume: boolean,
- * retry: boolean,
- * since_string: string,
- * started: number,
- * state: string,
- * total: number,
- * url: string}}
- */
-downloads.Data;
diff --git a/chrome/browser/resources/downloads/focus_row.js b/chrome/browser/resources/downloads/focus_row.js
deleted file mode 100644
index b5f389f..0000000
--- a/chrome/browser/resources/downloads/focus_row.js
+++ /dev/null
@@ -1,32 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-cr.define('downloads', function() {
- /**
- * @param {!Element} root
- * @param {?Element} boundary
- * @constructor
- * @extends {cr.ui.FocusRow}
- */
- function FocusRow(root, boundary) {
- cr.ui.FocusRow.call(this, root, boundary);
-
- assert(this.addItem('name', '[is="action-link"].name'));
- assert(this.addItem('url', '.src-url'));
- assert(this.addItem('show-retry', '.safe .controls .show'));
- assert(this.addItem('show-retry', '.retry'));
- assert(this.addItem('pause-resume', '.pause'));
- assert(this.addItem('pause-resume', '.resume'));
- assert(this.addItem('remove', '.remove'));
- assert(this.addItem('cancel', '.cancel'));
- assert(this.addItem('restore-save', '.restore'));
- assert(this.addItem('restore-save', '.save'));
- assert(this.addItem('remove-discard', '.remove'));
- assert(this.addItem('remove-discard', '.discard'));
- }
-
- FocusRow.prototype = {__proto__: cr.ui.FocusRow.prototype};
-
- return {FocusRow: FocusRow};
-});
diff --git a/chrome/browser/resources/downloads/item_view.js b/chrome/browser/resources/downloads/item_view.js
deleted file mode 100644
index f91d3fb..0000000
--- a/chrome/browser/resources/downloads/item_view.js
+++ /dev/null
@@ -1,395 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-cr.define('downloads', function() {
- /**
- * Creates and updates the DOM representation for a download.
- * @param {!downloads.ThrottledIconLoader} iconLoader
- * @constructor
- */
- function ItemView(iconLoader) {
- /** @private {!downloads.ThrottledIconLoader} */
- this.iconLoader_ = iconLoader;
-
- this.node = $('templates').querySelector('.download').cloneNode(true);
-
- this.safe_ = this.queryRequired_('.safe');
- this.since_ = this.queryRequired_('.since');
- this.dateContainer = this.queryRequired_('.date-container');
- this.date_ = this.queryRequired_('.date');
- this.save_ = this.queryRequired_('.save');
- this.backgroundProgress_ = this.queryRequired_('.progress.background');
- this.foregroundProgress_ = /** @type !HTMLCanvasElement */(
- this.queryRequired_('canvas.progress'));
- this.safeImg_ = /** @type !HTMLImageElement */(
- this.queryRequired_('.safe img'));
- this.fileName_ = this.queryRequired_('span.name');
- this.fileLink_ = this.queryRequired_('[is="action-link"].name');
- this.status_ = this.queryRequired_('.status');
- this.srcUrl_ = this.queryRequired_('.src-url');
- this.show_ = this.queryRequired_('.show');
- this.retry_ = this.queryRequired_('.retry');
- this.pause_ = this.queryRequired_('.pause');
- this.resume_ = this.queryRequired_('.resume');
- this.safeRemove_ = this.queryRequired_('.safe .remove');
- this.cancel_ = this.queryRequired_('.cancel');
- this.controlledBy_ = this.queryRequired_('.controlled-by');
-
- this.dangerous_ = this.queryRequired_('.dangerous');
- this.dangerImg_ = /** @type {!HTMLImageElement} */(
- this.queryRequired_('.dangerous img'));
- this.description_ = this.queryRequired_('.description');
- this.malwareControls_ = this.queryRequired_('.dangerous .controls');
- this.restore_ = this.queryRequired_('.restore');
- this.dangerRemove_ = this.queryRequired_('.dangerous .remove');
- this.save_ = this.queryRequired_('.save');
- this.discard_ = this.queryRequired_('.discard');
-
- // Event handlers (bound once on creation).
- this.safe_.ondragstart = this.onSafeDragstart_.bind(this);
- this.fileLink_.onclick = this.onFileLinkClick_.bind(this);
- this.show_.onclick = this.onShowClick_.bind(this);
- this.pause_.onclick = this.onPauseClick_.bind(this);
- this.resume_.onclick = this.onResumeClick_.bind(this);
- this.safeRemove_.onclick = this.onSafeRemoveClick_.bind(this);
- this.cancel_.onclick = this.onCancelClick_.bind(this);
- this.restore_.onclick = this.onRestoreClick_.bind(this);
- this.save_.onclick = this.onSaveClick_.bind(this);
- this.dangerRemove_.onclick = this.onDangerRemoveClick_.bind(this);
- this.discard_.onclick = this.onDiscardClick_.bind(this);
- }
-
- /** Progress meter constants. */
- ItemView.Progress = {
- /** @const {number} */
- START_ANGLE: -0.5 * Math.PI,
- /** @const {number} */
- SIDE: 48,
- };
-
- /** @const {number} */
- ItemView.Progress.HALF = ItemView.Progress.SIDE / 2;
-
- ItemView.computeDownloadProgress = function() {
- /**
- * @param {number} a Some float.
- * @param {number} b Some float.
- * @param {number=} opt_pct Percent of min(a,b).
- * @return {boolean} true if a is within opt_pct percent of b.
- */
- function floatEq(a, b, opt_pct) {
- return Math.abs(a - b) < (Math.min(a, b) * (opt_pct || 1.0) / 100.0);
- }
-
- if (floatEq(ItemView.Progress.scale, window.devicePixelRatio)) {
- // Zooming in or out multiple times then typing Ctrl+0 resets the zoom
- // level directly to 1x, which fires the matchMedia event multiple times.
- return;
- }
- var Progress = ItemView.Progress;
- Progress.scale = window.devicePixelRatio;
- Progress.width = Progress.SIDE * Progress.scale;
- Progress.height = Progress.SIDE * Progress.scale;
- Progress.radius = Progress.HALF * Progress.scale;
- Progress.centerX = Progress.HALF * Progress.scale;
- Progress.centerY = Progress.HALF * Progress.scale;
- };
- ItemView.computeDownloadProgress();
-
- // Listens for when device-pixel-ratio changes between any zoom level.
- [0.3, 0.4, 0.6, 0.7, 0.8, 0.95, 1.05, 1.2, 1.4, 1.6, 1.9, 2.2, 2.7, 3.5, 4.5].
- forEach(function(scale) {
- var media = '(-webkit-min-device-pixel-ratio:' + scale + ')';
- window.matchMedia(media).addListener(ItemView.computeDownloadProgress);
- });
-
- /**
- * @return {!HTMLImageElement} The correct <img> to show when an item is
- * progressing in the foreground.
- */
- ItemView.getForegroundProgressImage = function() {
- var x = window.devicePixelRatio >= 2 ? '2x' : '1x';
- ItemView.foregroundImages_ = ItemView.foregroundImages_ || {};
- if (!ItemView.foregroundImages_[x]) {
- ItemView.foregroundImages_[x] = new Image;
- var IMAGE_URL = 'chrome://theme/IDR_DOWNLOAD_PROGRESS_FOREGROUND_32';
- ItemView.foregroundImages_[x].src = IMAGE_URL + '@' + x;
- }
- return ItemView.foregroundImages_[x];
- };
-
- ItemView.prototype = {
- /** @param {!downloads.Data} data */
- update: function(data) {
- assert(!this.id_ || data.id == this.id_);
- this.id_ = data.id; // This is the only thing saved from |data|.
-
- this.node.classList.toggle('otr', data.otr);
-
- var dangerText = this.getDangerText_(data);
- this.dangerous_.hidden = !dangerText;
- this.safe_.hidden = !!dangerText;
-
- this.ensureTextIs_(this.since_, data.since_string);
- this.ensureTextIs_(this.date_, data.date_string);
-
- if (dangerText) {
- this.ensureTextIs_(this.description_, dangerText);
-
- var dangerType = data.danger_type;
- var dangerousFile = dangerType == downloads.DangerType.DANGEROUS_FILE;
- this.description_.classList.toggle('malware', !dangerousFile);
-
- var idr = dangerousFile ? 'IDR_WARNING' : 'IDR_SAFEBROWSING_WARNING';
- var iconUrl = 'chrome://theme/' + idr;
- this.iconLoader_.loadScaledIcon(this.dangerImg_, iconUrl);
-
- var showMalwareControls =
- dangerType == downloads.DangerType.DANGEROUS_CONTENT ||
- dangerType == downloads.DangerType.DANGEROUS_HOST ||
- dangerType == downloads.DangerType.DANGEROUS_URL ||
- dangerType == downloads.DangerType.POTENTIALLY_UNWANTED;
-
- this.malwareControls_.hidden = !showMalwareControls;
- this.discard_.hidden = showMalwareControls;
- this.save_.hidden = showMalwareControls;
- } else {
- var iconUrl = 'chrome://fileicon/' + encodeURIComponent(data.file_path);
- this.iconLoader_.loadScaledIcon(this.safeImg_, iconUrl);
-
- /** @const */ var isInProgress =
- data.state == downloads.States.IN_PROGRESS;
- this.node.classList.toggle('in-progress', isInProgress);
-
- /** @const */ var completelyOnDisk =
- data.state == downloads.States.COMPLETE &&
- !data.file_externally_removed;
-
- this.fileLink_.href = data.url;
- this.ensureTextIs_(this.fileLink_, data.file_name);
- this.fileLink_.hidden = !completelyOnDisk;
-
- /** @const */ var isInterrupted =
- data.state == downloads.States.INTERRUPTED;
- this.fileName_.classList.toggle('interrupted', isInterrupted);
- this.ensureTextIs_(this.fileName_, data.file_name);
- this.fileName_.hidden = completelyOnDisk;
-
- this.show_.hidden = !completelyOnDisk;
-
- this.retry_.href = data.url;
- this.retry_.hidden = !data.retry;
-
- this.pause_.hidden = !isInProgress;
-
- this.resume_.hidden = !data.resume;
-
- /** @const */ var isPaused = data.state == downloads.States.PAUSED;
- /** @const */ var showCancel = isPaused || isInProgress;
- this.cancel_.hidden = !showCancel;
-
- this.safeRemove_.hidden = showCancel ||
- !loadTimeData.getBoolean('allowDeletingHistory');
-
- /** @const */ var controlledByExtension = data.by_ext_id &&
- data.by_ext_name;
- this.controlledBy_.hidden = !controlledByExtension;
- if (controlledByExtension) {
- var link = this.controlledBy_.querySelector('a');
- link.href = 'chrome://extensions#' + data.by_ext_id;
- link.setAttribute('focus-type', 'controlled-by');
- link.textContent = data.by_ext_name;
- }
-
- this.ensureTextIs_(this.srcUrl_, data.url);
- this.srcUrl_.href = data.url;
- this.ensureTextIs_(this.status_, this.getStatusText_(data));
-
- this.foregroundProgress_.hidden = !isInProgress;
- this.backgroundProgress_.hidden = !isInProgress;
-
- if (isInProgress) {
- this.foregroundProgress_.width = ItemView.Progress.width;
- this.foregroundProgress_.height = ItemView.Progress.height;
-
- if (!this.progressContext_) {
- /** @private */
- this.progressContext_ = /** @type !CanvasRenderingContext2D */(
- this.foregroundProgress_.getContext('2d'));
- }
-
- var foregroundImage = ItemView.getForegroundProgressImage();
-
- // Draw a pie-slice for the progress.
- this.progressContext_.globalCompositeOperation = 'copy';
- this.progressContext_.drawImage(
- foregroundImage,
- 0, 0, // sx, sy
- foregroundImage.width,
- foregroundImage.height,
- 0, 0, // x, y
- ItemView.Progress.width, ItemView.Progress.height);
-
- this.progressContext_.globalCompositeOperation = 'destination-in';
- this.progressContext_.beginPath();
- this.progressContext_.moveTo(ItemView.Progress.centerX,
- ItemView.Progress.centerY);
-
- // Draw an arc CW for both RTL and LTR. http://crbug.com/13215
- this.progressContext_.arc(
- ItemView.Progress.centerX,
- ItemView.Progress.centerY,
- ItemView.Progress.radius,
- ItemView.Progress.START_ANGLE,
- ItemView.Progress.START_ANGLE + Math.PI * 0.02 * data.percent,
- false);
-
- this.progressContext_.lineTo(ItemView.Progress.centerX,
- ItemView.Progress.centerY);
- this.progressContext_.fill();
- this.progressContext_.closePath();
- }
- }
- },
-
- destroy: function() {
- if (this.node.parentNode)
- this.node.parentNode.removeChild(this.node);
- },
-
- /**
- * @param {string} selector A CSS selector (e.g. '.class-name').
- * @return {!Element} The element found by querying for |selector|.
- * @private
- */
- queryRequired_: function(selector) {
- return assert(this.node.querySelector(selector));
- },
-
- /**
- * Overwrite |el|'s textContent if it differs from |text|.
- * @param {!Element} el
- * @param {string} text
- * @private
- */
- ensureTextIs_: function(el, text) {
- if (el.textContent != text)
- el.textContent = text;
- },
-
- /**
- * @param {!downloads.Data} data
- * @return {string} Text describing the danger of a download. Empty if not
- * dangerous.
- */
- getDangerText_: function(data) {
- switch (data.danger_type) {
- case downloads.DangerType.DANGEROUS_FILE:
- return loadTimeData.getStringF('dangerFileDesc', data.file_name);
- case downloads.DangerType.DANGEROUS_URL:
- return loadTimeData.getString('dangerUrlDesc');
- case downloads.DangerType.DANGEROUS_CONTENT: // Fall through.
- case downloads.DangerType.DANGEROUS_HOST:
- return loadTimeData.getStringF('dangerContentDesc', data.file_name);
- case downloads.DangerType.UNCOMMON_CONTENT:
- return loadTimeData.getStringF('dangerUncommonDesc', data.file_name);
- case downloads.DangerType.POTENTIALLY_UNWANTED:
- return loadTimeData.getStringF('dangerSettingsDesc', data.file_name);
- default:
- return '';
- }
- },
-
- /**
- * @param {!downloads.Data} data
- * @return {string} User-visible status update text.
- * @private
- */
- getStatusText_: function(data) {
- switch (data.state) {
- case downloads.States.IN_PROGRESS:
- case downloads.States.PAUSED: // Fallthrough.
- assert(typeof data.progress_status_text == 'string');
- return data.progress_status_text;
- case downloads.States.CANCELLED:
- return loadTimeData.getString('statusCancelled');
- case downloads.States.DANGEROUS:
- break; // Intentionally hit assertNotReached(); at bottom.
- case downloads.States.INTERRUPTED:
- assert(typeof data.last_reason_text == 'string');
- return data.last_reason_text;
- case downloads.States.COMPLETE:
- return data.file_externally_removed ?
- loadTimeData.getString('statusRemoved') : '';
- }
- assertNotReached();
- return '';
- },
-
- /**
- * @private
- * @param {Event} e
- */
- onSafeDragstart_: function(e) {
- e.preventDefault();
- chrome.send('drag', [this.id_]);
- },
-
- /**
- * @param {Event} e
- * @private
- */
- onFileLinkClick_: function(e) {
- e.preventDefault();
- chrome.send('openFile', [this.id_]);
- },
-
- /** @private */
- onShowClick_: function() {
- chrome.send('show', [this.id_]);
- },
-
- /** @private */
- onPauseClick_: function() {
- chrome.send('pause', [this.id_]);
- },
-
- /** @private */
- onResumeClick_: function() {
- chrome.send('resume', [this.id_]);
- },
-
- /** @private */
- onSafeRemoveClick_: function() {
- chrome.send('remove', [this.id_]);
- },
-
- /** @private */
- onCancelClick_: function() {
- chrome.send('cancel', [this.id_]);
- },
-
- /** @private */
- onRestoreClick_: function() {
- this.onSaveClick_();
- },
-
- /** @private */
- onSaveClick_: function() {
- chrome.send('saveDangerous', [this.id_]);
- },
-
- /** @private */
- onDangerRemoveClick_: function() {
- this.onDiscardClick_();
- },
-
- /** @private */
- onDiscardClick_: function() {
- chrome.send('discardDangerous', [this.id_]);
- },
- };
-
- return {ItemView: ItemView};
-});
diff --git a/chrome/browser/resources/downloads/manager.js b/chrome/browser/resources/downloads/manager.js
deleted file mode 100644
index 7f91b61..0000000
--- a/chrome/browser/resources/downloads/manager.js
+++ /dev/null
@@ -1,256 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-cr.define('downloads', function() {
- /**
- * Class to own and manage download items.
- * @constructor
- */
- function Manager() {}
-
- cr.addSingletonGetter(Manager);
-
- Manager.prototype = {
- /** @private {string} */
- searchText_: '',
-
- /**
- * Sets the search text, updates related UIs, and tells the browser.
- * @param {string} searchText Text we're searching for.
- * @private
- */
- setSearchText_: function(searchText) {
- this.searchText_ = searchText;
-
- $('downloads-summary-text').textContent = this.searchText_ ?
- loadTimeData.getStringF('searchResultsFor', this.searchText_) : '';
-
- // Split quoted terms (e.g., 'The "lazy" dog' => ['The', 'lazy', 'dog']).
- function trim(s) { return s.trim(); }
- chrome.send('getDownloads', searchText.split(/"([^"]*)"/).map(trim));
- },
-
- /**
- * @return {number} A guess at how many items could be visible at once.
- * @private
- */
- guesstimateNumberOfVisibleItems_: function() {
- var headerHeight = document.querySelector('header').offsetHeight;
- var summaryHeight = $('downloads-summary').offsetHeight;
- var nonItemSpace = headerHeight + summaryHeight;
- return Math.floor((window.innerHeight - nonItemSpace) / 46) + 1;
- },
-
- /**
- * Called when all items need to be updated.
- * @param {!Array<!downloads.Data>} list A list of new download data.
- * @private
- */
- updateAll_: function(list) {
- var oldIdMap = this.idMap_ || {};
-
- /** @private {!Object<!downloads.ItemView>} */
- this.idMap_ = {};
-
- /** @private {!Array<!downloads.ItemView>} */
- this.items_ = [];
-
- if (!this.iconLoader_) {
- var guesstimate = Math.max(this.guesstimateNumberOfVisibleItems_(), 1);
- /** @private {downloads.ThrottledIconLoader} */
- this.iconLoader_ = new downloads.ThrottledIconLoader(guesstimate);
- }
-
- for (var i = 0; i < list.length; ++i) {
- var data = list[i];
- var id = data.id;
-
- // Re-use old items when possible (saves work, preserves focus).
- var item = oldIdMap[id] || new downloads.ItemView(this.iconLoader_);
-
- this.idMap_[id] = item; // Associated by ID for fast lookup.
- this.items_.push(item); // Add to sorted list for order.
-
- // Render |item| but don't actually add to the DOM yet. |this.items_|
- // must be fully created to be able to find the right spot to insert.
- item.update(data);
-
- // Collapse redundant dates.
- var prev = list[i - 1];
- item.dateContainer.hidden =
- prev && prev.date_string == data.date_string;
-
- delete oldIdMap[id];
- }
-
- // Remove stale, previously rendered items from the DOM.
- for (var id in oldIdMap) {
- var oldNode = oldIdMap[id].node;
- if (oldNode.parentNode)
- oldNode.parentNode.removeChild(oldNode);
- delete oldIdMap[id];
- }
-
- for (var i = 0; i < this.items_.length; ++i) {
- var item = this.items_[i];
- if (item.node.parentNode) // Already in the DOM; skip.
- continue;
-
- var before = null;
- // Find the next rendered item after this one, and insert before it.
- for (var j = i + 1; !before && j < this.items_.length; ++j) {
- if (this.items_[j].node.parentNode)
- before = this.items_[j].node;
- }
- // If |before| is null, |item| will just get added at the end.
- this.node_.insertBefore(item.node, before);
- }
-
- var noDownloadsOrResults = $('no-downloads-or-results');
- noDownloadsOrResults.textContent = loadTimeData.getString(
- this.searchText_ ? 'noSearchResults' : 'noDownloads');
-
- var hasDownloads = this.size_() > 0;
- this.node_.hidden = !hasDownloads;
- noDownloadsOrResults.hidden = hasDownloads;
-
- if (loadTimeData.getBoolean('allowDeletingHistory'))
- $('clear-all').hidden = !hasDownloads || this.searchText_.length > 0;
-
- this.rebuildFocusGrid_();
- },
-
- /**
- * @param {!downloads.Data} data Info about the item to update.
- * @private
- */
- updateItem_: function(data) {
- var activeElement = document.activeElement;
-
- var item = this.idMap_[data.id];
- item.update(data);
-
- if (item.node.contains(activeElement) &&
- !cr.ui.FocusRow.isFocusable(activeElement)) {
- var focusRow = this.focusGrid_.getRowForRoot(item.node);
- focusRow.getEquivalentElement(activeElement).focus();
- }
- },
-
- /**
- * Rebuild the focusGrid_ using the elements that each download will have.
- * @private
- */
- rebuildFocusGrid_: function() {
- var activeElement = document.activeElement;
-
- /** @private {!cr.ui.FocusGrid} */
- this.focusGrid_ = this.focusGrid_ || new cr.ui.FocusGrid();
- this.focusGrid_.destroy();
-
- this.items_.forEach(function(item) {
- var focusRow = new downloads.FocusRow(item.node, this.node_);
-
- this.focusGrid_.addRow(focusRow);
-
- if (item.node.contains(activeElement) &&
- !cr.ui.FocusRow.isFocusable(activeElement)) {
- focusRow.getEquivalentElement(activeElement).focus();
- }
- }, this);
-
- this.focusGrid_.ensureRowActive();
- },
-
- /**
- * @return {number} The number of downloads shown on the page.
- * @private
- */
- size_: function() {
- return this.items_.length;
- },
-
- /** @private */
- clearAll_: function() {
- if (loadTimeData.getBoolean('allowDeletingHistory')) {
- chrome.send('clearAll');
- this.setSearchText_('');
- }
- },
-
- /** @private */
- onLoad_: function() {
- this.node_ = $('downloads-display');
-
- $('clear-all').onclick = function() {
- this.clearAll_();
- }.bind(this);
-
- $('open-downloads-folder').onclick = function() {
- chrome.send('openDownloadsFolder');
- };
-
- $('term').onsearch = function(e) {
- this.setSearchText_($('term').value);
- }.bind(this);
-
- cr.ui.decorate('command', cr.ui.Command);
- document.addEventListener('canExecute', this.onCanExecute_.bind(this));
- document.addEventListener('command', this.onCommand_.bind(this));
-
- this.setSearchText_('');
- },
-
- /**
- * @param {Event} e
- * @private
- */
- onCanExecute_: function(e) {
- e = /** @type {cr.ui.CanExecuteEvent} */(e);
- switch (e.command.id) {
- case 'undo-command':
- e.canExecute = document.activeElement != $('term');
- break;
- case 'clear-all-command':
- e.canExecute = true;
- break;
- }
- },
-
- /**
- * @param {Event} e
- * @private
- */
- onCommand_: function(e) {
- if (e.command.id == 'undo-command')
- chrome.send('undo');
- else if (e.command.id == 'clear-all-command')
- this.clearAll_();
- },
- };
-
- Manager.updateAll = function(list) {
- Manager.getInstance().updateAll_(list);
- };
-
- Manager.updateItem = function(item) {
- Manager.getInstance().updateItem_(item);
- };
-
- Manager.setSearchText = function(searchText) {
- Manager.getInstance().setSearchText_(searchText);
- };
-
- Manager.onLoad = function() {
- Manager.getInstance().onLoad_();
- };
-
- Manager.size = function() {
- return Manager.getInstance().size_();
- };
-
- return {Manager: Manager};
-});
-
-window.addEventListener('DOMContentLoaded', downloads.Manager.onLoad);
diff --git a/chrome/browser/resources/downloads/throttled_icon_loader.html b/chrome/browser/resources/downloads/throttled_icon_loader.html
deleted file mode 100644
index 4cbd4eb..0000000
--- a/chrome/browser/resources/downloads/throttled_icon_loader.html
+++ /dev/null
@@ -1,3 +0,0 @@
-<link rel="import" href="chrome://resources/html/assert.html">
-<link rel="import" href="chrome://resources/html/cr.html">
-<script src="throttled_icon_loader.js"></script>
diff --git a/chrome/browser/resources/downloads/throttled_icon_loader.js b/chrome/browser/resources/downloads/throttled_icon_loader.js
deleted file mode 100644
index 5a10024..0000000
--- a/chrome/browser/resources/downloads/throttled_icon_loader.js
+++ /dev/null
@@ -1,61 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-/** @typedef {{img: HTMLImageElement, url: string}} */
-var LoadIconRequest;
-
-cr.define('downloads', function() {
- /**
- * @param {number} maxAllowed The maximum number of simultaneous downloads
- * allowed.
- * @constructor
- */
- function ThrottledIconLoader(maxAllowed) {
- assert(maxAllowed > 0);
-
- /** @private {number} */
- this.maxAllowed_ = maxAllowed;
-
- /** @private {!Array<!LoadIconRequest>} */
- this.requests_ = [];
- }
-
- ThrottledIconLoader.prototype = {
- /** @private {number} */
- loading_: 0,
-
- /**
- * Load the provided |url| into |img.src| after appending ?scale=.
- * @param {!HTMLImageElement} img An <img> to show the loaded image in.
- * @param {string} url A remote image URL to load.
- */
- loadScaledIcon: function(img, url) {
- var scaledUrl = url + '?scale=' + window.devicePixelRatio + 'x';
- if (img.src == scaledUrl)
- return;
-
- this.requests_.push({img: img, url: scaledUrl});
- this.loadNextIcon_();
- },
-
- /** @private */
- loadNextIcon_: function() {
- if (this.loading_ > this.maxAllowed_ || !this.requests_.length)
- return;
-
- var request = this.requests_.shift();
- var img = request.img;
-
- img.onabort = img.onerror = img.onload = function() {
- this.loading_--;
- this.loadNextIcon_();
- }.bind(this);
-
- this.loading_++;
- img.src = request.url;
- },
- };
-
- return {ThrottledIconLoader: ThrottledIconLoader};
-});
diff --git a/chrome/browser/resources/md_downloads/compiled_resources2.gyp b/chrome/browser/resources/md_downloads/compiled_resources2.gyp
index 7fc69be..7b492d1 100644
--- a/chrome/browser/resources/md_downloads/compiled_resources2.gyp
+++ b/chrome/browser/resources/md_downloads/compiled_resources2.gyp
@@ -46,7 +46,7 @@
'item',
'toolbar',
'<(EXTERNS_GYP):chrome_send',
- '../downloads/compiled_resources2.gyp:externs',
+ 'externs',
],
'includes': ['../../../../third_party/closure_compiler/compile_js2.gypi'],
},
diff --git a/chrome/browser/resources/md_downloads/externs.js b/chrome/browser/resources/md_downloads/externs.js
index 65efb05..51830ff 100644
--- a/chrome/browser/resources/md_downloads/externs.js
+++ b/chrome/browser/resources/md_downloads/externs.js
@@ -11,7 +11,7 @@ var downloads = {};
/**
* The type of the download object. The definition is based on
- * chrome/browser/ui/webui/downloads_dom_handler.cc:CreateDownloadItemValue()
+ * MdDownloadsDOMHandler::CreateDownloadItemValue()
* @typedef {{by_ext_id: string,
* by_ext_name: string,
* danger_type: string,
diff --git a/chrome/browser/ui/browser_navigator_browsertest.cc b/chrome/browser/ui/browser_navigator_browsertest.cc
index e5442d4..429519a 100644
--- a/chrome/browser/ui/browser_navigator_browsertest.cc
+++ b/chrome/browser/ui/browser_navigator_browsertest.cc
@@ -202,10 +202,6 @@ void BrowserNavigatorTest::SetUpCommandLine(base::CommandLine* command_line) {
// Disable settings-in-a-window so that we can use the settings page and
// sub-pages to test browser navigation.
command_line->AppendSwitch(::switches::kDisableSettingsWindow);
-
- // Disable new downloads UI as it is very very slow. https://crbug.com/526577
- // TODO(dbeam): remove this once the downloads UI is not slow.
- command_line->AppendSwitch(switches::kDisableMaterialDesignDownloads);
}
void BrowserNavigatorTest::Observe(
@@ -1281,9 +1277,11 @@ IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
// TODO(linux_aura) http://crbug.com/163931
#if defined(OS_LINUX) && !defined(OS_CHROMEOS) && defined(USE_AURA)
-#define MAYBE_NavigateFromDefaultToBookmarksInSameTab DISABLED_NavigateFromDefaultToBookmarksInSameTab
+#define MAYBE_NavigateFromDefaultToBookmarksInSameTab \
+ DISABLED_NavigateFromDefaultToBookmarksInSameTab
#else
-#define MAYBE_NavigateFromDefaultToBookmarksInSameTab NavigateFromDefaultToBookmarksInSameTab
+#define MAYBE_NavigateFromDefaultToBookmarksInSameTab \
+ NavigateFromDefaultToBookmarksInSameTab
#endif
IN_PROC_BROWSER_TEST_F(BrowserNavigatorTest,
MAYBE_NavigateFromDefaultToBookmarksInSameTab) {
diff --git a/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc b/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc
index 3616e43..b33892ee 100644
--- a/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc
+++ b/chrome/browser/ui/find_bar/find_bar_host_browsertest.cc
@@ -87,13 +87,6 @@ class FindInPageControllerTest : public InProcessBrowserTest {
chrome::DisableFindBarAnimationsDuringTesting(true);
}
- // Disable new downloads UI as it is very very slow. https://crbug.com/526577
- // TODO(dbeam): remove this once the downloads UI is not slow.
- void SetUpCommandLine(base::CommandLine* command_line) override {
- InProcessBrowserTest::SetUpCommandLine(command_line);
- command_line->AppendSwitch(switches::kDisableMaterialDesignDownloads);
- }
-
protected:
bool GetFindBarWindowInfoForBrowser(
Browser* browser, gfx::Point* position, bool* fully_visible) {
diff --git a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
index 6ebbae1..7b6d615 100644
--- a/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
+++ b/chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
@@ -25,8 +25,6 @@
#include "chrome/browser/ui/webui/crashes_ui.h"
#include "chrome/browser/ui/webui/device_log_ui.h"
#include "chrome/browser/ui/webui/domain_reliability_internals_ui.h"
-#include "chrome/browser/ui/webui/downloads_ui.h"
-#include "chrome/browser/ui/webui/downloads_util.h"
#include "chrome/browser/ui/webui/flags_ui.h"
#include "chrome/browser/ui/webui/flash_ui.h"
#include "chrome/browser/ui/webui/gcm_internals_ui.h"
@@ -396,11 +394,8 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
if (url.host() == chrome::kChromeUIBookmarksHost)
return &NewWebUI<BookmarksUI>;
// Downloads list on Android uses the built-in download manager.
- if (url.host() == chrome::kChromeUIDownloadsHost) {
- if (MdDownloadsEnabled())
- return &NewWebUI<MdDownloadsUI>;
- return &NewWebUI<DownloadsUI>;
- }
+ if (url.host() == chrome::kChromeUIDownloadsHost)
+ return &NewWebUI<MdDownloadsUI>;
// Help is implemented with native UI elements on Android.
if (url.host() == chrome::kChromeUIHelpFrameHost)
return &NewWebUI<HelpUI>;
@@ -780,7 +775,7 @@ base::RefCountedMemory* ChromeWebUIControllerFactory::GetFaviconResourceBytes(
// Android uses the native download manager.
if (page_url.host() == chrome::kChromeUIDownloadsHost)
- return DownloadsUI::GetFaviconResourceBytes(scale_factor);
+ return MdDownloadsUI::GetFaviconResourceBytes(scale_factor);
// Android doesn't use the Options pages.
if (page_url.host() == chrome::kChromeUISettingsHost ||
diff --git a/chrome/browser/ui/webui/downloads_dom_handler.cc b/chrome/browser/ui/webui/downloads_dom_handler.cc
deleted file mode 100644
index e04a706..0000000
--- a/chrome/browser/ui/webui/downloads_dom_handler.cc
+++ /dev/null
@@ -1,722 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/downloads_dom_handler.h"
-
-#include <stddef.h>
-
-#include <algorithm>
-#include <functional>
-
-#include "base/bind.h"
-#include "base/bind_helpers.h"
-#include "base/i18n/rtl.h"
-#include "base/i18n/time_formatting.h"
-#include "base/logging.h"
-#include "base/memory/singleton.h"
-#include "base/metrics/field_trial.h"
-#include "base/metrics/histogram.h"
-#include "base/strings/string_number_conversions.h"
-#include "base/strings/string_piece.h"
-#include "base/strings/utf_string_conversions.h"
-#include "base/supports_user_data.h"
-#include "base/threading/thread.h"
-#include "base/value_conversions.h"
-#include "base/values.h"
-#include "chrome/browser/browser_process.h"
-#include "chrome/browser/download/download_crx_util.h"
-#include "chrome/browser/download/download_danger_prompt.h"
-#include "chrome/browser/download/download_history.h"
-#include "chrome/browser/download/download_item_model.h"
-#include "chrome/browser/download/download_prefs.h"
-#include "chrome/browser/download/download_query.h"
-#include "chrome/browser/download/download_service.h"
-#include "chrome/browser/download/download_service_factory.h"
-#include "chrome/browser/download/drag_download_item.h"
-#include "chrome/browser/extensions/api/downloads/downloads_api.h"
-#include "chrome/browser/extensions/extension_service.h"
-#include "chrome/browser/platform_util.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/webui/fileicon_source.h"
-#include "chrome/common/chrome_switches.h"
-#include "chrome/common/pref_names.h"
-#include "chrome/common/url_constants.h"
-#include "components/prefs/pref_service.h"
-#include "content/public/browser/browser_thread.h"
-#include "content/public/browser/download_item.h"
-#include "content/public/browser/url_data_source.h"
-#include "content/public/browser/user_metrics.h"
-#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_ui.h"
-#include "extensions/browser/extension_system.h"
-#include "net/base/filename_util.h"
-#include "third_party/icu/source/i18n/unicode/datefmt.h"
-#include "ui/base/l10n/time_format.h"
-#include "ui/gfx/image/image.h"
-
-using base::UserMetricsAction;
-using content::BrowserContext;
-using content::BrowserThread;
-
-namespace {
-
-// Maximum number of downloads to show. TODO(glen): Remove this and instead
-// stuff the downloads down the pipe slowly.
-size_t kMaxNumberOfDownloads = 150;
-
-enum DownloadsDOMEvent {
- DOWNLOADS_DOM_EVENT_GET_DOWNLOADS = 0,
- DOWNLOADS_DOM_EVENT_OPEN_FILE = 1,
- DOWNLOADS_DOM_EVENT_DRAG = 2,
- DOWNLOADS_DOM_EVENT_SAVE_DANGEROUS = 3,
- DOWNLOADS_DOM_EVENT_DISCARD_DANGEROUS = 4,
- DOWNLOADS_DOM_EVENT_SHOW = 5,
- DOWNLOADS_DOM_EVENT_PAUSE = 6,
- DOWNLOADS_DOM_EVENT_REMOVE = 7,
- DOWNLOADS_DOM_EVENT_CANCEL = 8,
- DOWNLOADS_DOM_EVENT_CLEAR_ALL = 9,
- DOWNLOADS_DOM_EVENT_OPEN_FOLDER = 10,
- DOWNLOADS_DOM_EVENT_RESUME = 11,
- DOWNLOADS_DOM_EVENT_MAX
-};
-
-void CountDownloadsDOMEvents(DownloadsDOMEvent event) {
- UMA_HISTOGRAM_ENUMERATION("Download.DOMEvent",
- event,
- DOWNLOADS_DOM_EVENT_MAX);
-}
-
-// Returns a string constant to be used as the |danger_type| value in
-// CreateDownloadItemValue(). Only return strings for DANGEROUS_FILE,
-// DANGEROUS_URL, DANGEROUS_CONTENT, and UNCOMMON_CONTENT because the
-// |danger_type| value is only defined if the value of |state| is |DANGEROUS|.
-const char* GetDangerTypeString(content::DownloadDangerType danger_type) {
- switch (danger_type) {
- case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE:
- return "DANGEROUS_FILE";
- case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL:
- return "DANGEROUS_URL";
- case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT:
- return "DANGEROUS_CONTENT";
- case content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT:
- return "UNCOMMON_CONTENT";
- case content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST:
- return "DANGEROUS_HOST";
- case content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED:
- return "POTENTIALLY_UNWANTED";
- default:
- // Don't return a danger type string if it is NOT_DANGEROUS or
- // MAYBE_DANGEROUS_CONTENT.
- NOTREACHED();
- return "";
- }
-}
-
-// Returns a JSON dictionary containing some of the attributes of |download|.
-// The JSON dictionary will also have a field "id" set to |id|, and a field
-// "otr" set to |incognito|.
-base::DictionaryValue* CreateDownloadItemValue(
- content::DownloadItem* download_item,
- bool incognito) {
- // TODO(asanka): Move towards using download_model here for getting status and
- // progress. The difference currently only matters to Drive downloads and
- // those don't show up on the downloads page, but should.
- DownloadItemModel download_model(download_item);
-
- // The items which are to be written into file_value are also described in
- // chrome/browser/resources/downloads/downloads.js in @typedef for
- // BackendDownloadObject. Please update it whenever you add or remove
- // any keys in file_value.
- base::DictionaryValue* file_value = new base::DictionaryValue();
-
- file_value->SetInteger(
- "started", static_cast<int>(download_item->GetStartTime().ToTimeT()));
- file_value->SetString(
- "since_string", ui::TimeFormat::RelativeDate(
- download_item->GetStartTime(), NULL));
-
- base::Time start_time = download_item->GetStartTime();
- base::string16 date_string = base::TimeFormatShortDate(start_time);
- file_value->SetString("date_string", date_string);
-
- file_value->SetString("id", base::Uint64ToString(download_item->GetId()));
-
- base::FilePath download_path(download_item->GetTargetFilePath());
- file_value->Set("file_path", base::CreateFilePathValue(download_path));
- file_value->SetString("file_url",
- net::FilePathToFileURL(download_path).spec());
-
- extensions::DownloadedByExtension* by_ext =
- extensions::DownloadedByExtension::Get(download_item);
- std::string by_ext_id;
- std::string by_ext_name;
- if (by_ext) {
- by_ext_id = by_ext->id();
- // TODO(dbeam): why doesn't DownloadsByExtension::name() return a string16?
- by_ext_name = by_ext->name();
-
- // Lookup the extension's current name() in case the user changed their
- // language. This won't work if the extension was uninstalled, so the name
- // might be the wrong language.
- bool include_disabled = true;
- const extensions::Extension* extension = extensions::ExtensionSystem::Get(
- Profile::FromBrowserContext(download_item->GetBrowserContext()))->
- extension_service()->GetExtensionById(by_ext->id(), include_disabled);
- if (extension)
- file_value->SetString("by_ext_name", extension->name());
- }
- file_value->SetString("by_ext_id", by_ext_id);
- file_value->SetString("by_ext_name", by_ext_name);
-
- // Keep file names as LTR.
- base::string16 file_name =
- download_item->GetFileNameToReportUser().LossyDisplayName();
- file_name = base::i18n::GetDisplayStringInLTRDirectionality(file_name);
- file_value->SetString("file_name", file_name);
- file_value->SetString("url", download_item->GetURL().spec());
- file_value->SetBoolean("otr", incognito);
- file_value->SetInteger("total", static_cast<int>(
- download_item->GetTotalBytes()));
- file_value->SetBoolean("file_externally_removed",
- download_item->GetFileExternallyRemoved());
- file_value->SetBoolean("resume", download_item->CanResume());
-
- const char* danger_type = "";
- base::string16 last_reason_text;
- // -2 is invalid, -1 means indeterminate, and 0-100 are in-progress.
- int percent = -2;
- base::string16 progress_status_text;
- bool retry = false;
- const char* state = nullptr;
-
- switch (download_item->GetState()) {
- case content::DownloadItem::IN_PROGRESS: {
- if (download_item->IsDangerous()) {
- state = "DANGEROUS";
- // These are the only danger states that the UI is equipped to handle.
- DCHECK(download_item->GetDangerType() ==
- content::DOWNLOAD_DANGER_TYPE_DANGEROUS_FILE ||
- download_item->GetDangerType() ==
- content::DOWNLOAD_DANGER_TYPE_DANGEROUS_URL ||
- download_item->GetDangerType() ==
- content::DOWNLOAD_DANGER_TYPE_DANGEROUS_CONTENT ||
- download_item->GetDangerType() ==
- content::DOWNLOAD_DANGER_TYPE_UNCOMMON_CONTENT ||
- download_item->GetDangerType() ==
- content::DOWNLOAD_DANGER_TYPE_DANGEROUS_HOST ||
- download_item->GetDangerType() ==
- content::DOWNLOAD_DANGER_TYPE_POTENTIALLY_UNWANTED);
- danger_type = GetDangerTypeString(download_item->GetDangerType());
- } else if (download_item->IsPaused()) {
- state = "PAUSED";
- } else {
- state = "IN_PROGRESS";
- }
- progress_status_text = download_model.GetTabProgressStatusText();
- percent = std::max(0, download_item->PercentComplete());
- break;
- }
-
- case content::DownloadItem::INTERRUPTED:
- state = "INTERRUPTED";
- progress_status_text = download_model.GetTabProgressStatusText();
-
- if (download_item->CanResume())
- percent = download_item->PercentComplete();
-
- last_reason_text = download_model.GetInterruptReasonText();
- if (content::DOWNLOAD_INTERRUPT_REASON_CRASH ==
- download_item->GetLastReason() && !download_item->CanResume()) {
- retry = true;
- }
- break;
-
- case content::DownloadItem::CANCELLED:
- state = "CANCELLED";
- retry = true;
- break;
-
- case content::DownloadItem::COMPLETE:
- DCHECK(!download_item->IsDangerous());
- state = "COMPLETE";
- break;
-
- case content::DownloadItem::MAX_DOWNLOAD_STATE:
- NOTREACHED();
- }
-
- DCHECK(state);
-
- file_value->SetString("danger_type", danger_type);
- file_value->SetString("last_reason_text", last_reason_text);
- file_value->SetInteger("percent", percent);
- file_value->SetString("progress_status_text", progress_status_text);
- file_value->SetBoolean("retry", retry);
- file_value->SetString("state", state);
-
- return file_value;
-}
-
-// Filters out extension downloads and downloads that don't have a filename yet.
-bool IsDownloadDisplayable(const content::DownloadItem& item) {
- return !download_crx_util::IsExtensionDownload(item) &&
- !item.IsTemporary() &&
- !item.GetFileNameToReportUser().empty() &&
- !item.GetTargetFilePath().empty() &&
- DownloadItemModel(
- const_cast<content::DownloadItem*>(&item)).ShouldShowInShelf();
-}
-
-} // namespace
-
-DownloadsDOMHandler::DownloadsDOMHandler(
- content::DownloadManager* download_manager)
- : download_manager_(download_manager),
- update_scheduled_(false),
- weak_ptr_factory_(this) {
- // Create our fileicon data source.
- Profile* profile = Profile::FromBrowserContext(
- download_manager->GetBrowserContext());
- content::URLDataSource::Add(profile, new FileIconSource());
-}
-
-DownloadsDOMHandler::~DownloadsDOMHandler() {
- FinalizeRemovals();
-}
-
-// DownloadsDOMHandler, public: -----------------------------------------------
-
-void DownloadsDOMHandler::RegisterMessages() {
- web_ui()->RegisterMessageCallback("getDownloads",
- base::Bind(&DownloadsDOMHandler::HandleGetDownloads,
- weak_ptr_factory_.GetWeakPtr()));
- web_ui()->RegisterMessageCallback("openFile",
- base::Bind(&DownloadsDOMHandler::HandleOpenFile,
- weak_ptr_factory_.GetWeakPtr()));
- web_ui()->RegisterMessageCallback("drag",
- base::Bind(&DownloadsDOMHandler::HandleDrag,
- weak_ptr_factory_.GetWeakPtr()));
- web_ui()->RegisterMessageCallback("saveDangerous",
- base::Bind(&DownloadsDOMHandler::HandleSaveDangerous,
- weak_ptr_factory_.GetWeakPtr()));
- web_ui()->RegisterMessageCallback("discardDangerous",
- base::Bind(&DownloadsDOMHandler::HandleDiscardDangerous,
- weak_ptr_factory_.GetWeakPtr()));
- web_ui()->RegisterMessageCallback("show",
- base::Bind(&DownloadsDOMHandler::HandleShow,
- weak_ptr_factory_.GetWeakPtr()));
- web_ui()->RegisterMessageCallback("pause",
- base::Bind(&DownloadsDOMHandler::HandlePause,
- weak_ptr_factory_.GetWeakPtr()));
- web_ui()->RegisterMessageCallback("resume",
- base::Bind(&DownloadsDOMHandler::HandleResume,
- weak_ptr_factory_.GetWeakPtr()));
- web_ui()->RegisterMessageCallback("remove",
- base::Bind(&DownloadsDOMHandler::HandleRemove,
- weak_ptr_factory_.GetWeakPtr()));
- web_ui()->RegisterMessageCallback("undo",
- base::Bind(&DownloadsDOMHandler::HandleUndo,
- weak_ptr_factory_.GetWeakPtr()));
- web_ui()->RegisterMessageCallback("cancel",
- base::Bind(&DownloadsDOMHandler::HandleCancel,
- weak_ptr_factory_.GetWeakPtr()));
- web_ui()->RegisterMessageCallback("clearAll",
- base::Bind(&DownloadsDOMHandler::HandleClearAll,
- weak_ptr_factory_.GetWeakPtr()));
- web_ui()->RegisterMessageCallback("openDownloadsFolder",
- base::Bind(&DownloadsDOMHandler::HandleOpenDownloadsFolder,
- weak_ptr_factory_.GetWeakPtr()));
-}
-
-void DownloadsDOMHandler::OnDownloadCreated(
- content::DownloadManager* manager, content::DownloadItem* download_item) {
- if (IsDownloadDisplayable(*download_item))
- ScheduleSendCurrentDownloads();
- else
- new_downloads_.insert(download_item->GetId());
-}
-
-void DownloadsDOMHandler::OnDownloadUpdated(
- content::DownloadManager* manager,
- content::DownloadItem* download_item) {
- if (update_scheduled_)
- return;
-
- bool showing_new_item = false;
-
- if (new_downloads_.count(download_item->GetId())) {
- // A new download (that the page doesn't know about yet) has been updated.
- if (!IsDownloadDisplayable(*download_item)) {
- // Item isn't ready to be displayed yet. Wait until it is.
- return;
- }
-
- new_downloads_.erase(download_item->GetId());
- showing_new_item = true;
- }
-
- if (showing_new_item || DownloadItemModel(download_item).IsBeingRevived() ||
- !IsDownloadDisplayable(*download_item)) {
- // A download will be shown or hidden by this update. Resend the list.
- ScheduleSendCurrentDownloads();
- return;
- }
-
- if (search_terms_ && !search_terms_->empty()) {
- // Don't CallUpdateItem() if download_item doesn't match
- // search_terms_.
- // TODO(benjhayden): Consider splitting MatchesQuery() out to a function.
- content::DownloadManager::DownloadVector all_items, filtered_items;
- all_items.push_back(download_item);
- DownloadQuery query;
- query.AddFilter(DownloadQuery::FILTER_QUERY, *search_terms_);
- query.Search(all_items.begin(), all_items.end(), &filtered_items);
- if (filtered_items.empty())
- return;
- }
-
- DCHECK(manager);
- scoped_ptr<base::DictionaryValue> item(CreateDownloadItemValue(
- download_item,
- original_notifier_ && manager == GetMainNotifierManager()));
- CallUpdateItem(*item);
-}
-
-void DownloadsDOMHandler::OnDownloadRemoved(
- content::DownloadManager* manager,
- content::DownloadItem* download_item) {
- if (!DownloadItemModel(download_item).ShouldShowInShelf())
- return;
-
- // This relies on |download_item| being removed from DownloadManager in this
- // MessageLoop iteration. |download_item| may not have been removed from
- // DownloadManager when OnDownloadRemoved() is fired, so bounce off the
- // MessageLoop to give it a chance to be removed. SendCurrentDownloads() looks
- // at all downloads, and we do not tell it that |download_item| is being
- // removed. If DownloadManager is ever changed to not immediately remove
- // |download_item| from its map when OnDownloadRemoved is sent, then
- // DownloadsDOMHandler::OnDownloadRemoved() will need to explicitly tell
- // SendCurrentDownloads() that |download_item| was removed. A
- // SupportsUserData::Data would be the correct way to do this.
- ScheduleSendCurrentDownloads();
-}
-
-void DownloadsDOMHandler::HandleGetDownloads(const base::ListValue* args) {
- CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_GET_DOWNLOADS);
- search_terms_.reset(args && !args->empty() ? args->DeepCopy() : NULL);
- ScheduleSendCurrentDownloads();
-
- if (!main_notifier_) {
- main_notifier_.reset(new AllDownloadItemNotifier(download_manager_, this));
-
- Profile* profile = Profile::FromBrowserContext(
- download_manager_->GetBrowserContext());
- if (profile->IsOffTheRecord()) {
- original_notifier_.reset(new AllDownloadItemNotifier(
- BrowserContext::GetDownloadManager(profile->GetOriginalProfile()),
- this));
- }
- }
-}
-
-void DownloadsDOMHandler::HandleOpenFile(const base::ListValue* args) {
- CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_OPEN_FILE);
- content::DownloadItem* file = GetDownloadByValue(args);
- if (file)
- file->OpenDownload();
-}
-
-void DownloadsDOMHandler::HandleDrag(const base::ListValue* args) {
- CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_DRAG);
- content::DownloadItem* file = GetDownloadByValue(args);
- if (!file)
- return;
-
- content::WebContents* web_contents = GetWebUIWebContents();
- // |web_contents| is only NULL in the test.
- if (!web_contents)
- return;
-
- if (file->GetState() != content::DownloadItem::COMPLETE)
- return;
-
- gfx::Image* icon = g_browser_process->icon_manager()->LookupIconFromFilepath(
- file->GetTargetFilePath(), IconLoader::NORMAL);
- gfx::NativeView view = web_contents->GetNativeView();
- {
- // Enable nested tasks during DnD, while |DragDownload()| blocks.
- base::MessageLoop::ScopedNestableTaskAllower allow(
- base::MessageLoop::current());
- DragDownloadItem(file, icon, view);
- }
-}
-
-void DownloadsDOMHandler::HandleSaveDangerous(const base::ListValue* args) {
- CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_SAVE_DANGEROUS);
- content::DownloadItem* file = GetDownloadByValue(args);
- if (file)
- ShowDangerPrompt(file);
-}
-
-void DownloadsDOMHandler::HandleDiscardDangerous(const base::ListValue* args) {
- CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_DISCARD_DANGEROUS);
- content::DownloadItem* file = GetDownloadByValue(args);
- if (file)
- file->Remove();
-}
-
-void DownloadsDOMHandler::HandleShow(const base::ListValue* args) {
- CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_SHOW);
- content::DownloadItem* file = GetDownloadByValue(args);
- if (file)
- file->ShowDownloadInShell();
-}
-
-void DownloadsDOMHandler::HandlePause(const base::ListValue* args) {
- CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_PAUSE);
- content::DownloadItem* file = GetDownloadByValue(args);
- if (file)
- file->Pause();
-}
-
-void DownloadsDOMHandler::HandleResume(const base::ListValue* args) {
- CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_RESUME);
- content::DownloadItem* file = GetDownloadByValue(args);
- if (file)
- file->Resume();
-}
-
-void DownloadsDOMHandler::HandleRemove(const base::ListValue* args) {
- if (!IsDeletingHistoryAllowed())
- return;
-
- CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_REMOVE);
- content::DownloadItem* file = GetDownloadByValue(args);
- if (!file)
- return;
-
- std::vector<content::DownloadItem*> downloads;
- downloads.push_back(file);
- RemoveDownloads(downloads);
-}
-
-void DownloadsDOMHandler::HandleUndo(const base::ListValue* args) {
- // TODO(dbeam): handle more than removed downloads someday?
- if (removals_.empty())
- return;
-
- const std::set<uint32_t> last_removed_ids = removals_.back();
- removals_.pop_back();
-
- for (auto id : last_removed_ids) {
- content::DownloadItem* download = GetDownloadById(id);
- if (!download)
- continue;
-
- DownloadItemModel model(download);
- model.SetShouldShowInShelf(true);
- model.SetIsBeingRevived(true);
-
- download->UpdateObservers();
-
- model.SetIsBeingRevived(false);
- }
-}
-
-void DownloadsDOMHandler::HandleCancel(const base::ListValue* args) {
- CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_CANCEL);
- content::DownloadItem* file = GetDownloadByValue(args);
- if (file)
- file->Cancel(true);
-}
-
-void DownloadsDOMHandler::HandleClearAll(const base::ListValue* args) {
- if (!IsDeletingHistoryAllowed()) {
- // This should only be reached during tests.
- return;
- }
-
- CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_CLEAR_ALL);
-
- std::vector<content::DownloadItem*> downloads;
- if (GetMainNotifierManager())
- GetMainNotifierManager()->GetAllDownloads(&downloads);
- if (GetOriginalNotifierManager())
- GetOriginalNotifierManager()->GetAllDownloads(&downloads);
- RemoveDownloads(downloads);
-}
-
-void DownloadsDOMHandler::RemoveDownloads(
- const std::vector<content::DownloadItem*>& to_remove) {
- std::set<uint32_t> ids;
-
- for (auto* download : to_remove) {
- DownloadItemModel item_model(download);
- if (!item_model.ShouldShowInShelf() ||
- download->GetState() == content::DownloadItem::IN_PROGRESS) {
- continue;
- }
-
- item_model.SetShouldShowInShelf(false);
- ids.insert(download->GetId());
- download->UpdateObservers();
- }
-
- if (!ids.empty())
- removals_.push_back(ids);
-}
-
-void DownloadsDOMHandler::HandleOpenDownloadsFolder(
- const base::ListValue* args) {
- CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_OPEN_FOLDER);
- content::DownloadManager* manager = GetMainNotifierManager();
- if (manager) {
- platform_util::OpenItem(
- Profile::FromBrowserContext(manager->GetBrowserContext()),
- DownloadPrefs::FromDownloadManager(manager)->DownloadPath(),
- platform_util::OPEN_FOLDER, platform_util::OpenOperationCallback());
- }
-}
-
-// DownloadsDOMHandler, private: ----------------------------------------------
-
-void DownloadsDOMHandler::ScheduleSendCurrentDownloads() {
- // Don't call SendCurrentDownloads() every time anything changes. Batch them
- // together instead. This may handle hundreds of OnDownloadDestroyed() calls
- // in a single UI message loop iteration when the user Clears All downloads.
- if (update_scheduled_)
- return;
-
- update_scheduled_ = true;
-
- BrowserThread::PostTask(
- BrowserThread::UI, FROM_HERE,
- base::Bind(&DownloadsDOMHandler::SendCurrentDownloads,
- weak_ptr_factory_.GetWeakPtr()));
-}
-
-content::DownloadManager* DownloadsDOMHandler::GetMainNotifierManager() const {
- return main_notifier_ ? main_notifier_->GetManager() : nullptr;
-}
-
-content::DownloadManager* DownloadsDOMHandler::GetOriginalNotifierManager()
- const {
- return original_notifier_ ? original_notifier_->GetManager() : nullptr;
-}
-
-void DownloadsDOMHandler::FinalizeRemovals() {
- while (!removals_.empty()) {
- const std::set<uint32_t> remove = removals_.back();
- removals_.pop_back();
-
- for (const auto id : remove) {
- content::DownloadItem* download = GetDownloadById(id);
- if (download)
- download->Remove();
- }
- }
-}
-
-void DownloadsDOMHandler::SendCurrentDownloads() {
- update_scheduled_ = false;
-
- content::DownloadManager::DownloadVector all_items, filtered_items;
- if (GetMainNotifierManager()) {
- GetMainNotifierManager()->GetAllDownloads(&all_items);
- GetMainNotifierManager()->CheckForHistoryFilesRemoval();
- }
- if (GetOriginalNotifierManager()) {
- GetOriginalNotifierManager()->GetAllDownloads(&all_items);
- GetOriginalNotifierManager()->CheckForHistoryFilesRemoval();
- }
-
- DownloadQuery query;
- if (search_terms_ && !search_terms_->empty())
- query.AddFilter(DownloadQuery::FILTER_QUERY, *search_terms_);
- query.AddFilter(base::Bind(&IsDownloadDisplayable));
- query.AddSorter(DownloadQuery::SORT_START_TIME, DownloadQuery::DESCENDING);
- query.Limit(kMaxNumberOfDownloads);
- query.Search(all_items.begin(), all_items.end(), &filtered_items);
-
- base::ListValue results_value;
- for (auto* item : filtered_items) {
- results_value.Append(CreateDownloadItemValue(
- item,
- original_notifier_ && GetMainNotifierManager() &&
- GetMainNotifierManager()->GetDownload(item->GetId()) == item));
- }
- CallUpdateAll(results_value);
-}
-
-void DownloadsDOMHandler::ShowDangerPrompt(
- content::DownloadItem* dangerous_item) {
- DownloadDangerPrompt* danger_prompt = DownloadDangerPrompt::Create(
- dangerous_item,
- GetWebUIWebContents(),
- false,
- base::Bind(&DownloadsDOMHandler::DangerPromptDone,
- weak_ptr_factory_.GetWeakPtr(), dangerous_item->GetId()));
- // danger_prompt will delete itself.
- DCHECK(danger_prompt);
-}
-
-void DownloadsDOMHandler::DangerPromptDone(
- int download_id, DownloadDangerPrompt::Action action) {
- if (action != DownloadDangerPrompt::ACCEPT)
- return;
- content::DownloadItem* item = NULL;
- if (GetMainNotifierManager())
- item = GetMainNotifierManager()->GetDownload(download_id);
- if (!item && GetOriginalNotifierManager())
- item = GetOriginalNotifierManager()->GetDownload(download_id);
- if (!item || item->IsDone())
- return;
- CountDownloadsDOMEvents(DOWNLOADS_DOM_EVENT_SAVE_DANGEROUS);
- item->ValidateDangerousDownload();
-}
-
-bool DownloadsDOMHandler::IsDeletingHistoryAllowed() {
- content::DownloadManager* manager = GetMainNotifierManager();
- return manager &&
- Profile::FromBrowserContext(manager->GetBrowserContext())->
- GetPrefs()->GetBoolean(prefs::kAllowDeletingBrowserHistory);
-}
-
-content::DownloadItem* DownloadsDOMHandler::GetDownloadByValue(
- const base::ListValue* args) {
- std::string download_id;
- if (!args->GetString(0, &download_id)) {
- NOTREACHED();
- return nullptr;
- }
-
- uint64_t id;
- if (!base::StringToUint64(download_id, &id)) {
- NOTREACHED();
- return nullptr;
- }
-
- return GetDownloadById(static_cast<uint32_t>(id));
-}
-
-content::DownloadItem* DownloadsDOMHandler::GetDownloadById(uint32_t id) {
- content::DownloadItem* item = NULL;
- if (GetMainNotifierManager())
- item = GetMainNotifierManager()->GetDownload(id);
- if (!item && GetOriginalNotifierManager())
- item = GetOriginalNotifierManager()->GetDownload(id);
- return item;
-}
-
-content::WebContents* DownloadsDOMHandler::GetWebUIWebContents() {
- return web_ui()->GetWebContents();
-}
-
-void DownloadsDOMHandler::CallUpdateAll(const base::ListValue& list) {
- web_ui()->CallJavascriptFunction("downloads.Manager.updateAll", list);
-}
-
-void DownloadsDOMHandler::CallUpdateItem(const base::DictionaryValue& item) {
- web_ui()->CallJavascriptFunction("downloads.Manager.updateItem", item);
-}
diff --git a/chrome/browser/ui/webui/downloads_dom_handler.h b/chrome/browser/ui/webui/downloads_dom_handler.h
deleted file mode 100644
index 1324642..0000000
--- a/chrome/browser/ui/webui/downloads_dom_handler.h
+++ /dev/null
@@ -1,178 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_DOWNLOADS_DOM_HANDLER_H_
-#define CHROME_BROWSER_UI_WEBUI_DOWNLOADS_DOM_HANDLER_H_
-
-#include <stdint.h>
-
-#include <set>
-#include <vector>
-
-#include "base/compiler_specific.h"
-#include "base/macros.h"
-#include "base/memory/weak_ptr.h"
-#include "chrome/browser/download/all_download_item_notifier.h"
-#include "chrome/browser/download/download_danger_prompt.h"
-#include "content/public/browser/download_item.h"
-#include "content/public/browser/download_manager.h"
-#include "content/public/browser/web_ui_message_handler.h"
-
-namespace base {
-class ListValue;
-}
-
-namespace content {
-class WebContents;
-}
-
-// The handler for Javascript messages related to the "downloads" view,
-// also observes changes to the download manager.
-class DownloadsDOMHandler : public content::WebUIMessageHandler,
- public AllDownloadItemNotifier::Observer {
- public:
- explicit DownloadsDOMHandler(content::DownloadManager* download_manager);
- ~DownloadsDOMHandler() override;
-
- void Init();
-
- // WebUIMessageHandler implementation.
- void RegisterMessages() override;
-
- // AllDownloadItemNotifier::Observer interface
- void OnDownloadCreated(content::DownloadManager* manager,
- content::DownloadItem* download_item) override;
- void OnDownloadUpdated(content::DownloadManager* manager,
- content::DownloadItem* download_item) override;
- void OnDownloadRemoved(content::DownloadManager* manager,
- content::DownloadItem* download_item) override;
-
- // Callback for the "getDownloads" message.
- void HandleGetDownloads(const base::ListValue* args);
-
- // Callback for the "openFile" message - opens the file in the shell.
- void HandleOpenFile(const base::ListValue* args);
-
- // Callback for the "drag" message - initiates a file object drag.
- void HandleDrag(const base::ListValue* args);
-
- // Callback for the "saveDangerous" message - specifies that the user
- // wishes to save a dangerous file.
- void HandleSaveDangerous(const base::ListValue* args);
-
- // Callback for the "discardDangerous" message - specifies that the user
- // wishes to discard (remove) a dangerous file.
- void HandleDiscardDangerous(const base::ListValue* args);
-
- // Callback for the "show" message - shows the file in explorer.
- void HandleShow(const base::ListValue* args);
-
- // Callback for the "pause" message - pauses the file download.
- void HandlePause(const base::ListValue* args);
-
- // Callback for the "resume" message - resumes the file download.
- void HandleResume(const base::ListValue* args);
-
- // Callback for the "remove" message - removes the file download from shelf
- // and list.
- void HandleRemove(const base::ListValue* args);
-
- // Callback for the "undo" message. Currently only undoes removals.
- void HandleUndo(const base::ListValue* args);
-
- // Callback for the "cancel" message - cancels the download.
- void HandleCancel(const base::ListValue* args);
-
- // Callback for the "clearAll" message - clears all the downloads.
- void HandleClearAll(const base::ListValue* args);
-
- // Callback for the "openDownloadsFolder" message - opens the downloads
- // folder.
- void HandleOpenDownloadsFolder(const base::ListValue* args);
-
- protected:
- // These methods are for mocking so that most of this class does not actually
- // depend on WebUI. The other methods that depend on WebUI are
- // RegisterMessages() and HandleDrag().
- virtual content::WebContents* GetWebUIWebContents();
- virtual void CallUpdateAll(const base::ListValue& list);
- virtual void CallUpdateItem(const base::DictionaryValue& item);
-
- // Schedules a call to SendCurrentDownloads() in the next message loop
- // iteration. Protected rather than private for use in tests.
- void ScheduleSendCurrentDownloads();
-
- // Actually remove downloads with an ID in |removals_|. This cannot be undone.
- void FinalizeRemovals();
-
- private:
- // Shorthand for |observing_items_|, which tracks all items that this is
- // observing so that RemoveObserver will be called for all of them.
- typedef std::set<content::DownloadItem*> DownloadSet;
-
- // Convenience method to call |main_notifier_->GetManager()| while
- // null-checking |main_notifier_|.
- content::DownloadManager* GetMainNotifierManager() const;
-
- // Convenience method to call |original_notifier_->GetManager()| while
- // null-checking |original_notifier_|.
- content::DownloadManager* GetOriginalNotifierManager() const;
-
- // Sends the current list of downloads to the page.
- void SendCurrentDownloads();
-
- // Displays a native prompt asking the user for confirmation after accepting
- // the dangerous download specified by |dangerous|. The function returns
- // immediately, and will invoke DangerPromptAccepted() asynchronously if the
- // user accepts the dangerous download. The native prompt will observe
- // |dangerous| until either the dialog is dismissed or |dangerous| is no
- // longer an in-progress dangerous download.
- void ShowDangerPrompt(content::DownloadItem* dangerous);
-
- // Conveys danger acceptance from the DownloadDangerPrompt to the
- // DownloadItem.
- void DangerPromptDone(int download_id, DownloadDangerPrompt::Action action);
-
- // Returns true if the records of any downloaded items are allowed (and able)
- // to be deleted.
- bool IsDeletingHistoryAllowed();
-
- // Returns the download that is referred to in a given value.
- content::DownloadItem* GetDownloadByValue(const base::ListValue* args);
-
- // Returns the download with |id| or NULL if it doesn't exist.
- content::DownloadItem* GetDownloadById(uint32_t id);
-
- // Remove all downloads in |to_remove| with the ability to undo removal later.
- void RemoveDownloads(const std::vector<content::DownloadItem*>& to_remove);
-
- // Weak reference to the DownloadManager this class was constructed with. You
- // should probably be using use Get{Main,Original}NotifierManager() instead.
- content::DownloadManager* download_manager_;
-
- // Current search terms.
- scoped_ptr<base::ListValue> search_terms_;
-
- // Notifies OnDownload*() and provides safe access to the DownloadManager.
- scoped_ptr<AllDownloadItemNotifier> main_notifier_;
-
- // If |main_notifier_| observes an incognito profile, then this observes the
- // DownloadManager for the original profile; otherwise, this is NULL.
- scoped_ptr<AllDownloadItemNotifier> original_notifier_;
-
- // IDs of downloads to remove when this handler gets deleted.
- std::vector<std::set<uint32_t>> removals_;
-
- // Whether a call to SendCurrentDownloads() is currently scheduled.
- bool update_scheduled_;
-
- // IDs of new downloads that the page doesn't know about yet.
- std::set<uint32_t> new_downloads_;
-
- base::WeakPtrFactory<DownloadsDOMHandler> weak_ptr_factory_;
-
- DISALLOW_COPY_AND_ASSIGN(DownloadsDOMHandler);
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_DOWNLOADS_DOM_HANDLER_H_
diff --git a/chrome/browser/ui/webui/downloads_dom_handler_browsertest.cc b/chrome/browser/ui/webui/downloads_dom_handler_browsertest.cc
deleted file mode 100644
index adf13bc..0000000
--- a/chrome/browser/ui/webui/downloads_dom_handler_browsertest.cc
+++ /dev/null
@@ -1,330 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include <stddef.h>
-
-#include "base/auto_reset.h"
-#include "base/files/scoped_temp_dir.h"
-#include "base/json/json_reader.h"
-#include "base/macros.h"
-#include "base/values.h"
-#include "chrome/browser/download/download_item_model.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/webui/downloads_dom_handler.h"
-#include "chrome/common/pref_names.h"
-#include "chrome/test/base/in_process_browser_test.h"
-#include "components/prefs/pref_service.h"
-#include "content/public/browser/web_contents.h"
-#include "content/public/test/mock_download_item.h"
-#include "content/public/test/mock_download_manager.h"
-#include "content/public/test/test_utils.h"
-#include "net/test/embedded_test_server/embedded_test_server.h"
-
-namespace {
-
-// Reads |right_json| into a ListValue |left_list|; returns true if all
-// key-value pairs in in all dictionaries in |right_list| are also in the
-// corresponding dictionary in |left_list|. Ignores keys in dictionaries in
-// |left_list| that are not in the corresponding dictionary in |right_list|.
-bool ListMatches(base::ListValue* left_list, const std::string& right_json) {
- scoped_ptr<base::Value> right_value = base::JSONReader::Read(right_json);
- base::ListValue* right_list = NULL;
- CHECK(right_value->GetAsList(&right_list));
- for (size_t i = 0; i < left_list->GetSize(); ++i) {
- base::DictionaryValue* left_dict = NULL;
- base::DictionaryValue* right_dict = NULL;
- CHECK(left_list->GetDictionary(i, &left_dict));
- CHECK(right_list->GetDictionary(i, &right_dict));
- for (base::DictionaryValue::Iterator iter(*right_dict);
- !iter.IsAtEnd(); iter.Advance()) {
- base::Value* left_value = NULL;
- if (left_dict->HasKey(iter.key()) &&
- left_dict->Get(iter.key(), &left_value) &&
- !iter.value().Equals(left_value)) {
- LOG(WARNING) << "key \"" << iter.key() << "\" doesn't match ("
- << iter.value() << " vs. " << *left_value << ")";
- return false;
- }
- }
- }
- return true;
-}
-
-// A |DownloadsDOMHandler| that doesn't use a real WebUI object, but is real in
-// all other respects.
-class MockDownloadsDOMHandler : public DownloadsDOMHandler {
- public:
- explicit MockDownloadsDOMHandler(content::DownloadManager* download_manager)
- : DownloadsDOMHandler(download_manager),
- waiting_list_(false),
- waiting_updated_(false) {
- }
- ~MockDownloadsDOMHandler() override {}
-
- base::ListValue* downloads_list() { return downloads_list_.get(); }
- base::DictionaryValue* download_updated() { return download_updated_.get(); }
-
- void WaitForDownloadsList() {
- if (downloads_list_)
- return;
- base::AutoReset<bool> reset_waiting(&waiting_list_, true);
- content::RunMessageLoop();
- }
-
- void WaitForDownloadUpdated() {
- if (download_updated_)
- return;
- base::AutoReset<bool> reset_waiting(&waiting_updated_, true);
- content::RunMessageLoop();
- }
-
- void ForceSendCurrentDownloads() {
- ScheduleSendCurrentDownloads();
- }
-
- void reset_downloads_list() { downloads_list_.reset(); }
- void reset_download_updated() { download_updated_.reset(); }
-
- using DownloadsDOMHandler::FinalizeRemovals;
-
- protected:
- content::WebContents* GetWebUIWebContents() override { return NULL; }
-
- void CallUpdateAll(const base::ListValue& list) override {
- downloads_list_.reset(list.DeepCopy());
- if (waiting_list_) {
- content::BrowserThread::PostTask(
- content::BrowserThread::UI, FROM_HERE,
- base::MessageLoop::QuitWhenIdleClosure());
- }
- }
-
- void CallUpdateItem(const base::DictionaryValue& item) override {
- download_updated_.reset(item.DeepCopy());
- if (waiting_updated_) {
- content::BrowserThread::PostTask(
- content::BrowserThread::UI, FROM_HERE,
- base::MessageLoop::QuitWhenIdleClosure());
- }
- }
-
- private:
- scoped_ptr<base::ListValue> downloads_list_;
- scoped_ptr<base::DictionaryValue> download_updated_;
- bool waiting_list_;
- bool waiting_updated_;
-
- DISALLOW_COPY_AND_ASSIGN(MockDownloadsDOMHandler);
-};
-
-} // namespace
-
-class DownloadsDOMHandlerTest : public InProcessBrowserTest {
- public:
- DownloadsDOMHandlerTest() {}
-
- ~DownloadsDOMHandlerTest() override {}
-
- void SetUpOnMainThread() override {
- mock_handler_.reset(new MockDownloadsDOMHandler(download_manager()));
- CHECK(downloads_directory_.CreateUniqueTempDir());
- browser()->profile()->GetPrefs()->SetFilePath(
- prefs::kDownloadDefaultDirectory,
- downloads_directory_.path());
- CHECK(embedded_test_server()->Start());
- mock_handler_->HandleGetDownloads(nullptr);
- }
-
- content::DownloadManager* download_manager() {
- return content::BrowserContext::GetDownloadManager(browser()->profile());
- }
-
- void DownloadAnItem() {
- GURL url = embedded_test_server()->GetURL("/downloads/image.jpg");
- std::vector<GURL> url_chain;
- url_chain.push_back(url);
- base::Time current(base::Time::Now());
- download_manager()->CreateDownloadItem(
- 1, // id
- base::FilePath(FILE_PATH_LITERAL("/path/to/file")),
- base::FilePath(FILE_PATH_LITERAL("/path/to/file")),
- url_chain,
- GURL(std::string()),
- "application/octet-stream",
- "application/octet-stream",
- current,
- current,
- std::string(),
- std::string(),
- 128,
- 128,
- content::DownloadItem::COMPLETE,
- content::DOWNLOAD_DANGER_TYPE_NOT_DANGEROUS,
- content::DOWNLOAD_INTERRUPT_REASON_NONE,
- false);
-
- mock_handler_->ForceSendCurrentDownloads();
- mock_handler_->WaitForDownloadsList();
- ASSERT_EQ(1, static_cast<int>(mock_handler_->downloads_list()->GetSize()));
- EXPECT_TRUE(ListMatches(
- mock_handler_->downloads_list(),
- "[{\"file_externally_removed\": false,"
- " \"file_name\": \"file\","
- " \"id\": \"1\","
- " \"otr\": false,"
- " \"since_string\": \"Today\","
- " \"state\": \"COMPLETE\","
- " \"total\": 128}]"));
- }
-
- protected:
- scoped_ptr<MockDownloadsDOMHandler> mock_handler_;
-
- private:
- base::ScopedTempDir downloads_directory_;
-
- DISALLOW_COPY_AND_ASSIGN(DownloadsDOMHandlerTest);
-};
-
-// Tests removing all items, both when prohibited and when allowed.
-IN_PROC_BROWSER_TEST_F(DownloadsDOMHandlerTest, RemoveAll) {
- DownloadAnItem();
-
- mock_handler_->reset_downloads_list();
- browser()->profile()->GetPrefs()->SetBoolean(
- prefs::kAllowDeletingBrowserHistory, false);
- mock_handler_->HandleClearAll(NULL);
- // Attempting to clear all shouldn't do anything when deletion is disabled.
- mock_handler_->ForceSendCurrentDownloads();
- mock_handler_->WaitForDownloadsList();
- ASSERT_EQ(1, static_cast<int>(mock_handler_->downloads_list()->GetSize()));
-
- mock_handler_->reset_downloads_list();
- browser()->profile()->GetPrefs()->SetBoolean(
- prefs::kAllowDeletingBrowserHistory, true);
- mock_handler_->HandleClearAll(NULL);
- mock_handler_->WaitForDownloadsList();
- EXPECT_EQ(0, static_cast<int>(mock_handler_->downloads_list()->GetSize()));
-}
-
-// Tests removing one item, both when prohibited and when allowed.
-IN_PROC_BROWSER_TEST_F(DownloadsDOMHandlerTest, RemoveOneItem) {
- DownloadAnItem();
- base::ListValue item;
- item.AppendString("1");
-
- mock_handler_->reset_downloads_list();
- browser()->profile()->GetPrefs()->SetBoolean(
- prefs::kAllowDeletingBrowserHistory, false);
- mock_handler_->HandleRemove(&item);
- // Removing an item only sends the new download list if anything was actually
- // removed, so force it.
- mock_handler_->ForceSendCurrentDownloads();
- mock_handler_->WaitForDownloadsList();
- ASSERT_EQ(1, static_cast<int>(mock_handler_->downloads_list()->GetSize()));
-
- mock_handler_->reset_downloads_list();
- browser()->profile()->GetPrefs()->SetBoolean(
- prefs::kAllowDeletingBrowserHistory, true);
- mock_handler_->HandleRemove(&item);
- mock_handler_->WaitForDownloadsList();
- EXPECT_EQ(0, static_cast<int>(mock_handler_->downloads_list()->GetSize()));
-}
-
-IN_PROC_BROWSER_TEST_F(DownloadsDOMHandlerTest, ClearAllSkipsInProgress) {
- testing::NiceMock<content::MockDownloadManager> manager;
- EXPECT_CALL(manager, GetBrowserContext()).WillRepeatedly(
- testing::Return(browser()->profile()));
- mock_handler_.reset(new MockDownloadsDOMHandler(&manager));
- mock_handler_->HandleGetDownloads(nullptr);
-
- content::MockDownloadItem item;
- EXPECT_CALL(item, GetState()).WillRepeatedly(
- testing::Return(content::DownloadItem::IN_PROGRESS));
- EXPECT_CALL(item, UpdateObservers()).Times(0);
-
- std::vector<content::DownloadItem*> items;
- items.push_back(&item);
- EXPECT_CALL(manager, GetAllDownloads(testing::_)).WillOnce(
- testing::SetArgPointee<0>(items));
-
- mock_handler_->HandleClearAll(NULL);
- EXPECT_TRUE(DownloadItemModel(&item).ShouldShowInShelf());
-
- mock_handler_.reset();
-}
-
-// Tests that DownloadsDOMHandler detects new downloads and relays them to the
-// renderer.
-// crbug.com/159390: This test fails when daylight savings time ends.
-IN_PROC_BROWSER_TEST_F(DownloadsDOMHandlerTest, DownloadsRelayed) {
- DownloadAnItem();
-
- mock_handler_->WaitForDownloadUpdated();
- const base::DictionaryValue* update = mock_handler_->download_updated();
- ASSERT_TRUE(update);
-
- bool removed;
- ASSERT_TRUE(update->GetBoolean("file_externally_removed", &removed));
- EXPECT_TRUE(removed);
-
- std::string id;
- ASSERT_TRUE(update->GetString("id", &id));
- EXPECT_EQ("1", id);
-
- mock_handler_->reset_downloads_list();
- browser()->profile()->GetPrefs()->SetBoolean(
- prefs::kAllowDeletingBrowserHistory, true);
- mock_handler_->HandleClearAll(NULL);
- mock_handler_->WaitForDownloadsList();
- EXPECT_EQ(0, static_cast<int>(mock_handler_->downloads_list()->GetSize()));
-}
-
-// Tests that DownloadsDOMHandler actually calls DownloadItem::Remove() when
-// it's closed (and removals can no longer be undone).
-IN_PROC_BROWSER_TEST_F(DownloadsDOMHandlerTest, RemoveCalledOnPageClose) {
- testing::NiceMock<content::MockDownloadManager> manager;
- EXPECT_CALL(manager, GetBrowserContext()).WillRepeatedly(
- testing::Return(browser()->profile()));
- mock_handler_.reset(new MockDownloadsDOMHandler(&manager));
- mock_handler_->HandleGetDownloads(nullptr);
-
- content::MockDownloadItem item;
- EXPECT_CALL(item, GetId()).WillRepeatedly(testing::Return(1));
- EXPECT_CALL(item, GetState()).WillRepeatedly(
- testing::Return(content::DownloadItem::COMPLETE));
-
- DownloadItemModel model(&item);
- EXPECT_TRUE(model.ShouldShowInShelf());
-
- EXPECT_CALL(manager, GetDownload(1)).WillRepeatedly(testing::Return(&item));
-
- base::ListValue remove;
- remove.AppendString("1");
- EXPECT_CALL(item, UpdateObservers()).Times(1);
- mock_handler_->HandleRemove(&remove);
- EXPECT_FALSE(model.ShouldShowInShelf());
-
- EXPECT_CALL(item, Remove()).Times(1);
- // Call |mock_handler_->FinalizeRemovals()| instead of |mock_handler_.reset()|
- // because the vtable is affected during destruction and the fake manager
- // rigging doesn't work.
- mock_handler_->FinalizeRemovals();
- mock_handler_.reset();
-}
-
-// TODO(benjhayden): Test the extension downloads filter for both
-// mock_handler_.downloads_list() and mock_handler_.download_updated().
-
-// TODO(benjhayden): Test incognito, both downloads_list() and that on-record
-// calls can't access off-record items.
-
-// TODO(benjhayden): Test that bad download ids incoming from the javascript are
-// dropped on the floor.
-
-// TODO(benjhayden): Test that IsTemporary() downloads are not shown.
-
-// TODO(benjhayden): Test that RemoveObserver is called on all download items,
-// including items that crossed IsTemporary() and back.
diff --git a/chrome/browser/ui/webui/downloads_ui.cc b/chrome/browser/ui/webui/downloads_ui.cc
deleted file mode 100644
index 37c2feb..0000000
--- a/chrome/browser/ui/webui/downloads_ui.cc
+++ /dev/null
@@ -1,136 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/downloads_ui.h"
-
-#include "base/memory/ref_counted_memory.h"
-#include "base/memory/singleton.h"
-#include "base/strings/string_piece.h"
-#include "base/threading/thread.h"
-#include "base/values.h"
-#include "chrome/browser/defaults.h"
-#include "chrome/browser/download/download_service.h"
-#include "chrome/browser/download/download_service_factory.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/webui/downloads_dom_handler.h"
-#include "chrome/browser/ui/webui/theme_source.h"
-#include "chrome/common/chrome_switches.h"
-#include "chrome/common/pref_names.h"
-#include "chrome/common/url_constants.h"
-#include "chrome/grit/chromium_strings.h"
-#include "chrome/grit/generated_resources.h"
-#include "components/prefs/pref_service.h"
-#include "content/public/browser/download_manager.h"
-#include "content/public/browser/url_data_source.h"
-#include "content/public/browser/web_contents.h"
-#include "content/public/browser/web_ui.h"
-#include "content/public/browser/web_ui_data_source.h"
-#include "grit/browser_resources.h"
-#include "grit/theme_resources.h"
-#include "ui/base/resource/resource_bundle.h"
-
-using content::BrowserContext;
-using content::DownloadManager;
-using content::WebContents;
-
-namespace {
-
-content::WebUIDataSource* CreateDownloadsUIHTMLSource(Profile* profile) {
- content::WebUIDataSource* source =
- content::WebUIDataSource::Create(chrome::kChromeUIDownloadsHost);
-
- source->AddLocalizedString("title", IDS_DOWNLOAD_TITLE);
- source->AddLocalizedString("searchResultsFor", IDS_DOWNLOAD_SEARCHRESULTSFOR);
- source->AddLocalizedString("downloads", IDS_DOWNLOAD_TITLE);
- source->AddLocalizedString("clearAll", IDS_DOWNLOAD_LINK_CLEAR_ALL);
- source->AddLocalizedString("openDownloadsFolder",
- IDS_DOWNLOAD_LINK_OPEN_DOWNLOADS_FOLDER);
- source->AddLocalizedString("searchButton", IDS_DOWNLOAD_SEARCH_BUTTON);
-
- // No results message that shows instead of the downloads list.
- source->AddLocalizedString("noDownloads", IDS_DOWNLOAD_NO_DOWNLOADS);
- source->AddLocalizedString("noSearchResults",
- IDS_DOWNLOAD_NO_SEARCH_RESULTS);
-
- // Status.
- source->AddLocalizedString("statusCancelled", IDS_DOWNLOAD_TAB_CANCELLED);
- source->AddLocalizedString("statusRemoved", IDS_DOWNLOAD_FILE_REMOVED);
-
- // Dangerous file.
- source->AddLocalizedString("dangerFileDesc", IDS_PROMPT_DANGEROUS_DOWNLOAD);
- source->AddLocalizedString("dangerUrlDesc",
- IDS_PROMPT_MALICIOUS_DOWNLOAD_URL);
- source->AddLocalizedString("dangerContentDesc",
- IDS_PROMPT_MALICIOUS_DOWNLOAD_CONTENT);
- source->AddLocalizedString("dangerUncommonDesc",
- IDS_PROMPT_UNCOMMON_DOWNLOAD_CONTENT);
- source->AddLocalizedString("dangerSettingsDesc",
- IDS_PROMPT_DOWNLOAD_CHANGES_SETTINGS);
- source->AddLocalizedString("dangerSave", IDS_CONFIRM_DOWNLOAD);
- source->AddLocalizedString("dangerRestore", IDS_CONFIRM_DOWNLOAD_RESTORE);
- source->AddLocalizedString("dangerDiscard", IDS_DISCARD_DOWNLOAD);
-
- // Controls.
- source->AddLocalizedString("controlPause", IDS_DOWNLOAD_LINK_PAUSE);
- if (browser_defaults::kDownloadPageHasShowInFolder)
- source->AddLocalizedString("controlShowInFolder", IDS_DOWNLOAD_LINK_SHOW);
- source->AddLocalizedString("controlCancel", IDS_DOWNLOAD_LINK_CANCEL);
- source->AddLocalizedString("controlResume", IDS_DOWNLOAD_LINK_RESUME);
- source->AddLocalizedString("controlRemoveFromList",
- IDS_DOWNLOAD_LINK_REMOVE);
- source->AddLocalizedString("controlRetry", IDS_DOWNLOAD_LINK_RETRY);
- source->AddLocalizedString("controlByExtension",
- IDS_DOWNLOAD_BY_EXTENSION);
-
- PrefService* prefs = profile->GetPrefs();
- source->AddBoolean("allowDeletingHistory",
- prefs->GetBoolean(prefs::kAllowDeletingBrowserHistory) &&
- !profile->IsSupervised());
-
- source->AddResourcePath("constants.html", IDR_DOWNLOADS_CONSTANTS_HTML);
- source->AddResourcePath("constants.js", IDR_DOWNLOADS_CONSTANTS_JS);
- source->AddResourcePath("item_view.js", IDR_DOWNLOADS_ITEM_VIEW_JS);
- source->AddResourcePath("focus_row.js", IDR_DOWNLOADS_FOCUS_ROW_JS);
- source->AddResourcePath("manager.js", IDR_DOWNLOADS_MANAGER_JS);
- source->AddResourcePath("throttled_icon_loader.html",
- IDR_DOWNLOADS_THROTTLED_ICON_LOADER_HTML);
- source->AddResourcePath("throttled_icon_loader.js",
- IDR_DOWNLOADS_THROTTLED_ICON_LOADER_JS);
-
- source->SetDefaultResource(IDR_DOWNLOADS_DOWNLOADS_HTML);
- source->SetJsonPath("strings.js");
-
- return source;
-}
-
-} // namespace
-
-///////////////////////////////////////////////////////////////////////////////
-//
-// DownloadsUI
-//
-///////////////////////////////////////////////////////////////////////////////
-
-DownloadsUI::DownloadsUI(content::WebUI* web_ui) : WebUIController(web_ui) {
- Profile* profile = Profile::FromWebUI(web_ui);
- DownloadManager* dlm = BrowserContext::GetDownloadManager(profile);
-
- DownloadsDOMHandler* handler = new DownloadsDOMHandler(dlm);
- web_ui->AddMessageHandler(handler);
-
- // Set up the chrome://downloads/ source.
- content::WebUIDataSource* source = CreateDownloadsUIHTMLSource(profile);
- content::WebUIDataSource::Add(profile, source);
-#if defined(ENABLE_THEMES)
- ThemeSource* theme = new ThemeSource(profile);
- content::URLDataSource::Add(profile, theme);
-#endif
-}
-
-// static
-base::RefCountedMemory* DownloadsUI::GetFaviconResourceBytes(
- ui::ScaleFactor scale_factor) {
- return ResourceBundle::GetSharedInstance().
- LoadDataResourceBytesForScale(IDR_DOWNLOADS_FAVICON, scale_factor);
-}
diff --git a/chrome/browser/ui/webui/downloads_ui.h b/chrome/browser/ui/webui/downloads_ui.h
deleted file mode 100644
index 7ac8707..0000000
--- a/chrome/browser/ui/webui/downloads_ui.h
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright (c) 2012 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_DOWNLOADS_UI_H_
-#define CHROME_BROWSER_UI_WEBUI_DOWNLOADS_UI_H_
-
-#include "base/macros.h"
-#include "content/public/browser/web_ui_controller.h"
-#include "ui/base/layout.h"
-
-namespace base {
-class RefCountedMemory;
-}
-
-class DownloadsUI : public content::WebUIController {
- public:
- explicit DownloadsUI(content::WebUI* web_ui);
-
- static base::RefCountedMemory* GetFaviconResourceBytes(
- ui::ScaleFactor scale_factor);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(DownloadsUI);
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_DOWNLOADS_UI_H_
diff --git a/chrome/browser/ui/webui/downloads_ui_browsertest.cc b/chrome/browser/ui/webui/downloads_ui_browsertest.cc
deleted file mode 100644
index 0caa51d..0000000
--- a/chrome/browser/ui/webui/downloads_ui_browsertest.cc
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/downloads_ui_browsertest.h"
-
-#include "base/command_line.h"
-#include "chrome/browser/profiles/profile.h"
-#include "chrome/browser/ui/browser.h"
-#include "chrome/browser/ui/webui/downloads_util.h"
-#include "chrome/common/chrome_switches.h"
-#include "chrome/common/pref_names.h"
-#include "components/prefs/pref_service.h"
-#include "content/public/test/test_utils.h"
-
-DownloadsUIBrowserTest::DownloadsUIBrowserTest() {}
-
-DownloadsUIBrowserTest::~DownloadsUIBrowserTest() {}
-
-void DownloadsUIBrowserTest::SetUpCommandLine(
- base::CommandLine* command_line) {
- WebUIBrowserTest::SetUpCommandLine(command_line);
- command_line->AppendSwitch(switches::kDisableMaterialDesignDownloads);
- ASSERT_FALSE(MdDownloadsEnabled());
-}
-
-void DownloadsUIBrowserTest::SetDeleteAllowed(bool allowed) {
- browser()->profile()->GetPrefs()->
- SetBoolean(prefs::kAllowDeletingBrowserHistory, allowed);
-}
diff --git a/chrome/browser/ui/webui/downloads_ui_browsertest.h b/chrome/browser/ui/webui/downloads_ui_browsertest.h
deleted file mode 100644
index 38e718a..0000000
--- a/chrome/browser/ui/webui/downloads_ui_browsertest.h
+++ /dev/null
@@ -1,28 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_DOWNLOADS_UI_BROWSERTEST_H_
-#define CHROME_BROWSER_UI_WEBUI_DOWNLOADS_UI_BROWSERTEST_H_
-
-#include "base/macros.h"
-#include "chrome/test/base/web_ui_browser_test.h"
-
-// This is a helper class used by downloads_ui_browsertest.js.
-class DownloadsUIBrowserTest : public WebUIBrowserTest {
- public:
- DownloadsUIBrowserTest();
- ~DownloadsUIBrowserTest() override;
-
- // WebUIBrowserTest:
- void SetUpCommandLine(base::CommandLine* command_line) override;
-
- protected:
- // Sets the pref to allow or prohibit deleting history entries.
- void SetDeleteAllowed(bool allowed);
-
- private:
- DISALLOW_COPY_AND_ASSIGN(DownloadsUIBrowserTest);
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_DOWNLOADS_UI_BROWSERTEST_H_
diff --git a/chrome/browser/ui/webui/downloads_ui_browsertest.js b/chrome/browser/ui/webui/downloads_ui_browsertest.js
deleted file mode 100644
index 8ffba04..0000000
--- a/chrome/browser/ui/webui/downloads_ui_browsertest.js
+++ /dev/null
@@ -1,170 +0,0 @@
-// Copyright 2013 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-GEN_INCLUDE(['downloads_ui_browsertest_base.js']);
-GEN('#include "chrome/browser/ui/webui/downloads_ui_browsertest.h"');
-
-// Test UI when removing entries is allowed.
-TEST_F('BaseDownloadsWebUITest', 'DeleteAllowed', function() {
- this.expectDeleteControlsVisible(true);
- // TODO(pamg): Mock out the back-end calls, so we can also test removing a
- // single item.
-});
-
-TEST_F('BaseDownloadsWebUITest', 'NoResultsHiddenWhenDownloads', function() {
- assertNotEquals(0, downloads.Manager.size());
- expectFalse($('downloads-display').hidden);
- expectTrue($('no-downloads-or-results').hidden);
-});
-
-TEST_F('BaseDownloadsWebUITest', 'NoSearchResultsShown', function() {
- expectFalse($('downloads-display').hidden);
- var noResults = $('no-downloads-or-results');
- expectTrue(noResults.hidden);
-
- downloads.Manager.setSearchText('just try to search for me!');
- this.sendEmptyList();
-
- expectTrue($('downloads-display').hidden);
- this.checkShowing(noResults, loadTimeData.getString('noSearchResults'));
-});
-
-TEST_F('BaseDownloadsWebUITest', 'NoDownloadsAfterClearAll', function() {
- expectFalse($('downloads-display').hidden);
- var noResults = $('no-downloads-or-results');
- expectTrue(noResults.hidden);
-
- $('clear-all').click();
- this.sendEmptyList();
-
- expectTrue($('downloads-display').hidden);
- this.checkShowing(noResults, loadTimeData.getString('noDownloads'));
-});
-
-TEST_F('BaseDownloadsWebUITest', 'PauseResumeFocus', function() {
- assertGE(downloads.Manager.size(), 0);
-
- var freshestDownload = this.createdDownloads[0];
- freshestDownload.state = downloads.States.IN_PROGRESS;
- freshestDownload.resume = false;
- downloads.Manager.updateItem(freshestDownload);
-
- var manager = downloads.Manager.getInstance();
- var node = manager.idMap_[freshestDownload.id].node;
- var pause = node.querySelector('.pause');
- var resume = node.querySelector('.resume');
-
- expectFalse(pause.hidden);
- expectTrue(resume.hidden);
- // Move the focus to "Pause" then pretend the download was resumed. The focus
- // should move to the equivalent button ("Resume" in this case).
- pause.focus();
- assertEquals(document.activeElement, pause);
-
- freshestDownload.state = downloads.States.PAUSED;
- freshestDownload.resume = true;
- downloads.Manager.updateItem(freshestDownload);
-
- expectTrue(pause.hidden);
- expectFalse(resume.hidden);
- expectEquals(document.activeElement, resume);
-});
-
-TEST_F('BaseDownloadsWebUITest', 'DatesCollapse', function() {
- function datesShowing() {
- var displayDiv = $('downloads-display');
- return displayDiv.querySelectorAll('.date-container:not([hidden])').length;
- }
-
- var numDownloads = downloads.Manager.size();
- assertGE(numDownloads, 2);
-
- expectEquals(1, datesShowing());
-
- var freshestId = this.createdDownloads[0].id;
- this.createDangerousDownload(freshestId + 1, Date.now());
- downloads.Manager.updateAll(this.createdDownloads);
-
- expectEquals(numDownloads + 1, downloads.Manager.size());
- expectEquals(1, datesShowing());
-
- var firstContainer = document.querySelector('.date-container');
- assertFalse(firstContainer.hidden);
- expectGT(firstContainer.querySelector('.since').textContent.trim().length, 0);
- expectGT(firstContainer.querySelector('.date').textContent.trim().length, 0);
-});
-
-TEST_F('BaseDownloadsWebUITest', 'EmptyProgressStatusText', function() {
- this.createdDownloads[0].state = downloads.States.PAUSED;
- this.createdDownloads[0].progress_status_text = '';
- downloads.Manager.updateItem(this.createdDownloads[0]); // Might assert().
-});
-
-TEST_F('BaseDownloadsWebUITest', 'EmptyLastStatusText', function() {
- this.createdDownloads[0].state = downloads.States.INTERRUPTED;
- this.createdDownloads[0].last_reason_text = '';
- downloads.Manager.updateItem(this.createdDownloads[0]); // Might assert().
-});
-
-/**
- * @constructor
- * @extends {BaseDownloadsWebUITest}
- */
-function EmptyDownloadsWebUITest() {}
-
-EmptyDownloadsWebUITest.prototype = {
- __proto__: BaseDownloadsWebUITest.prototype,
-
- /** @override */
- setUp: function() {
- // Doesn't create any fake downloads.
- assertEquals(0, downloads.Manager.size());
-
- this.updateAccessibilityAuditConfig();
- },
-};
-
-TEST_F('EmptyDownloadsWebUITest', 'NoDownloadsMessageShowing', function() {
- expectTrue($('downloads-display').hidden);
- var noResults = $('no-downloads-or-results');
- this.checkShowing(noResults, loadTimeData.getString('noDownloads'));
-});
-
-TEST_F('EmptyDownloadsWebUITest', 'NoSearchResultsWithNoDownloads', function() {
- downloads.Manager.setSearchText('bananas');
- this.sendEmptyList();
-
- expectTrue($('downloads-display').hidden);
- var noResults = $('no-downloads-or-results');
- this.checkShowing(noResults, loadTimeData.getString('noSearchResults'));
-});
-
-/**
- * Fixture for Downloads WebUI testing when deletions are prohibited.
- * @extends {BaseDownloadsWebUITest}
- * @constructor
- */
-function DownloadsWebUIDeleteProhibitedTest() {}
-
-DownloadsWebUIDeleteProhibitedTest.prototype = {
- __proto__: BaseDownloadsWebUITest.prototype,
-
- /** @override */
- testGenPreamble: function() {
- GEN(' SetDeleteAllowed(false);');
- },
-};
-
-// Test UI when removing entries is prohibited.
-TEST_F('DownloadsWebUIDeleteProhibitedTest', 'DeleteProhibited', function() {
- this.expectDeleteControlsVisible(false);
- // TODO(pamg): Mock out the back-end calls, so we can also test removing a
- // single item.
-});
-
-TEST_F('DownloadsWebUIDeleteProhibitedTest', 'ClearLeavesSearch', function() {
- downloads.Manager.setSearchText('muhahaha');
- $('clear-all').click();
- expectGE(downloads.Manager.getInstance().searchText_.length, 0);
-});
diff --git a/chrome/browser/ui/webui/downloads_ui_browsertest_base.js b/chrome/browser/ui/webui/downloads_ui_browsertest_base.js
deleted file mode 100644
index 24ec279..0000000
--- a/chrome/browser/ui/webui/downloads_ui_browsertest_base.js
+++ /dev/null
@@ -1,177 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-/** @const */ var TOTAL_RESULT_COUNT = 25;
-
-/**
- * Test C++ fixture for downloads WebUI testing.
- * @constructor
- * @extends {testing.Test}
- */
-function DownloadsUIBrowserTest() {}
-
-/**
- * Base fixture for Downloads WebUI testing.
- * @extends {testing.Test}
- * @constructor
- */
-function BaseDownloadsWebUITest() {}
-
-BaseDownloadsWebUITest.prototype = {
- __proto__: testing.Test.prototype,
-
- /**
- * Browse to the downloads page & call our preLoad().
- */
- browsePreload: 'chrome://downloads/',
-
- /** @override */
- typedefCppFixture: 'DownloadsUIBrowserTest',
-
- /** @override */
- testGenPreamble: function() {
- GEN(' SetDeleteAllowed(true);');
- },
-
- /** @override */
- runAccessibilityChecks: true,
-
- /** @override */
- accessibilityIssuesAreErrors: true,
-
- /**
- * Sends TOTAL_RESULT_COUNT fake downloads to the page. This can't be called
- * in the preLoad, because it requires the global Download object to have
- * been created by the page.
- * @override
- */
- setUp: function() {
- testing.Test.prototype.setUp.call(this);
-
- this.createdDownloads = [];
-
- // The entries will begin at 1:00 AM on Sept 2, 2008, and will be spaced
- // two minutes apart.
- var timestamp = new Date(2008, 9, 2, 1, 0).getTime();
- for (var i = 0; i < TOTAL_RESULT_COUNT; ++i) {
- this.createDownload(i, timestamp);
- timestamp += 2 * 60 * 1000; // Next visit is two minutes later.
- }
- downloads.Manager.updateAll(this.createdDownloads);
- expectEquals(downloads.Manager.size(), TOTAL_RESULT_COUNT);
-
- this.updateAccessibilityAuditConfig();
- },
-
- /**
- * Disables failing accessibility audits. This should be removed when all
- * audit issues have been resolved.
- */
- updateAccessibilityAuditConfig: function() {
- // Enable when failure is resolved.
- // AX_TEXT_01: http://crbug.com/559217
- this.accessibilityAuditConfig.ignoreSelectors(
- 'controlsWithoutLabel',
- '#term');
-
- // Enable when failure is resolved.
- // AX_FOCUS_03: http://crbug.com/559219
- this.accessibilityAuditConfig.ignoreSelectors(
- 'tabIndexGreaterThanZero',
- '#term');
- },
-
- /**
- * Creates a download object to be passed to the page, following the expected
- * backend format (see downloads_dom_handler.cc).
- * @param {number} id A unique ID for the download.
- * @param {number} timestamp The time the download purportedly started.
- * @return {!Object} A fake download object.
- */
- createDownload: function(id, timestamp) {
- this.createdDownloads.unshift({
- id: id,
- started: timestamp,
- otr: false,
- state: downloads.States.COMPLETE,
- retry: false,
- file_path: '/path/to/file',
- file_url: 'http://google.com/' + timestamp,
- file_name: 'download_' + timestamp,
- url: 'http://google.com/' + timestamp,
- file_externally_removed: false,
- danger_type: downloads.DangerType.NOT_DANGEROUS,
- last_reason_text: '',
- since_string: 'today',
- date_string: 'today',
- percent: 100,
- progress_status_text: 'done',
- received: 128,
- });
- return this.createdDownloads[0];
- },
-
- /**
- * Creates a dangerous download object. See downloads_dom_handler.cc.
- * @param {number} id The ID of the download.
- * @param {number} timestamp The time this download started.
- * @return {!Object} A fake, dangerous download object.
- */
- createDangerousDownload: function(id, timestamp) {
- this.createdDownloads.unshift({
- id: id,
- started: timestamp,
- otr: false,
- state: downloads.States.DANGEROUS,
- retry: false,
- file_path: '/oh/noes.jpg.exe',
- file_url: 'http://evil.com/cute/kittens' + timestamp,
- file_name: 'evil.' + timestamp + '.jar',
- file_url: 'http://evil.com/cute/kittens' + timestamp,
- file_externally_removed: false,
- danger_type: downloads.DangerType.DANGEROUS_FILE,
- last_reason_text: '',
- since_string: 'today',
- date_string: 'today',
- percent: 0,
- progress_status_text: '',
- received: 128,
- });
- return this.createdDownloads[0];
- },
-
- /**
- * Simulates getting no results from C++.
- */
- sendEmptyList: function() {
- downloads.Manager.updateAll([]);
- assertEquals(0, downloads.Manager.size());
- },
-
- /**
- * Check that |element| is showing and contains |text|.
- * @param {Element} element
- * @param {string} text
- */
- checkShowing: function(element, text) {
- expectFalse(element.hidden);
- expectNotEquals(-1, element.textContent.indexOf(text));
- },
-
- /**
- * Asserts the correctness of the state of the UI elements that delete the
- * download history.
- * @param {boolean} visible True if download deletion UI should be visible.
- */
- expectDeleteControlsVisible: function(visible) {
- // "Clear all" should only be showing when deletions are allowed.
- expectEquals(!visible, $('clear-all').hidden);
-
- // "Remove from list" links should only exist when deletions are allowed.
- var query = '#downloads-display .safe .remove';
- if (!visible)
- query += '[hidden]';
- expectEquals(TOTAL_RESULT_COUNT, document.querySelectorAll(query).length);
- },
-};
diff --git a/chrome/browser/ui/webui/downloads_ui_supervised_browsertest.cc b/chrome/browser/ui/webui/downloads_ui_supervised_browsertest.cc
deleted file mode 100644
index 04c44a5..0000000
--- a/chrome/browser/ui/webui/downloads_ui_supervised_browsertest.cc
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/downloads_ui_supervised_browsertest.h"
-
-#include "base/command_line.h"
-#include "chrome/browser/ui/browser.h"
-#include "chrome/common/chrome_switches.h"
-#include "content/public/test/test_utils.h"
-
-void DownloadsWebUIForSupervisedUsersTest::SetUpCommandLine(
- base::CommandLine* command_line) {
- DownloadsUIBrowserTest::SetUpCommandLine(command_line);
- command_line->AppendSwitchASCII(switches::kSupervisedUserId, "asdf");
-}
diff --git a/chrome/browser/ui/webui/downloads_ui_supervised_browsertest.h b/chrome/browser/ui/webui/downloads_ui_supervised_browsertest.h
deleted file mode 100644
index ee60fc6..0000000
--- a/chrome/browser/ui/webui/downloads_ui_supervised_browsertest.h
+++ /dev/null
@@ -1,16 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_DOWNLOADS_UI_SUPERVISED_BROWSERTEST_H_
-#define CHROME_BROWSER_UI_WEBUI_DOWNLOADS_UI_SUPERVISED_BROWSERTEST_H_
-
-#include "chrome/browser/ui/webui/downloads_ui_browsertest.h"
-
-class DownloadsWebUIForSupervisedUsersTest : public DownloadsUIBrowserTest {
- public:
- // InProcessBrowserTest implementation.
- void SetUpCommandLine(base::CommandLine* command_line) override;
-};
-
-#endif // CHROME_BROWSER_UI_WEBUI_DOWNLOADS_UI_SUPERVISED_BROWSERTEST_H_
diff --git a/chrome/browser/ui/webui/downloads_ui_supervised_browsertest.js b/chrome/browser/ui/webui/downloads_ui_supervised_browsertest.js
deleted file mode 100644
index 84870a8..0000000
--- a/chrome/browser/ui/webui/downloads_ui_supervised_browsertest.js
+++ /dev/null
@@ -1,27 +0,0 @@
-// Copyright 2014 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-GEN_INCLUDE(['downloads_ui_browsertest_base.js']);
-GEN('#include "chrome/browser/ui/webui/downloads_ui_supervised_browsertest.h"');
-
-/**
- * Fixture for Downloads WebUI testing for a supervised user.
- * @extends {BaseDownloadsWebUITest}
- * @constructor
- */
-function DownloadsWebUIForSupervisedUsersTest() {}
-
-DownloadsWebUIForSupervisedUsersTest.prototype = {
- __proto__: BaseDownloadsWebUITest.prototype,
-
- /** @override */
- typedefCppFixture: 'DownloadsWebUIForSupervisedUsersTest',
-};
-
-// Test UI for supervised users, removing entries should be disabled
-// and removal controls should be hidden.
-TEST_F('DownloadsWebUIForSupervisedUsersTest', 'SupervisedUsers', function() {
- this.expectDeleteControlsVisible(false);
- testDone();
-});
diff --git a/chrome/browser/ui/webui/downloads_util.cc b/chrome/browser/ui/webui/downloads_util.cc
deleted file mode 100644
index 404cc80..0000000
--- a/chrome/browser/ui/webui/downloads_util.cc
+++ /dev/null
@@ -1,30 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/downloads_util.h"
-
-#include "base/command_line.h"
-#include "base/metrics/field_trial.h"
-#include "base/strings/string_util.h"
-#include "chrome/common/channel_info.h"
-#include "chrome/common/chrome_switches.h"
-#include "components/version_info/version_info.h"
-
-const char kMaterialDesignDownloadsFinchTrialName[] = "MaterialDesignDownloads";
-
-bool MdDownloadsEnabled() {
- // Intentionally call this before checking command line to assign a group.
- std::string group = base::FieldTrialList::FindFullName(
- kMaterialDesignDownloadsFinchTrialName);
-
- base::CommandLine* cl = base::CommandLine::ForCurrentProcess();
- if (cl->HasSwitch(switches::kEnableMaterialDesignDownloads))
- return true;
-
- if (cl->HasSwitch(switches::kDisableMaterialDesignDownloads))
- return false;
-
- return base::StartsWith(group, "Enabled",
- base::CompareCase::INSENSITIVE_ASCII);
-}
diff --git a/chrome/browser/ui/webui/downloads_util.h b/chrome/browser/ui/webui/downloads_util.h
deleted file mode 100644
index 69774605..0000000
--- a/chrome/browser/ui/webui/downloads_util.h
+++ /dev/null
@@ -1,13 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#ifndef CHROME_BROWSER_UI_WEBUI_DOWNLOADS_UTIL_H_
-#define CHROME_BROWSER_UI_WEBUI_DOWNLOADS_UTIL_H_
-
-extern const char kMaterialDesignDownloadsFinchTrialName[];
-
-// Whether the Material Design version of chrome://downloads should be enabled.
-bool MdDownloadsEnabled();
-
-#endif // CHROME_BROWSER_UI_WEBUI_DOWNLOADS_UTIL_H_
diff --git a/chrome/browser/ui/webui/downloads_util_unittest.cc b/chrome/browser/ui/webui/downloads_util_unittest.cc
deleted file mode 100644
index 378ded5..0000000
--- a/chrome/browser/ui/webui/downloads_util_unittest.cc
+++ /dev/null
@@ -1,69 +0,0 @@
-// Copyright 2015 The Chromium Authors. All rights reserved.
-// Use of this source code is governed by a BSD-style license that can be
-// found in the LICENSE file.
-
-#include "chrome/browser/ui/webui/downloads_util.h"
-
-#include "base/command_line.h"
-#include "base/macros.h"
-#include "base/metrics/field_trial.h"
-#include "base/test/mock_entropy_provider.h"
-#include "chrome/common/chrome_switches.h"
-#include "testing/gtest/include/gtest/gtest.h"
-
-using base::FieldTrialList;
-
-const char* kFieldTrialName = kMaterialDesignDownloadsFinchTrialName;
-
-class MdDownloadsEnabledTest : public testing::Test {
- public:
- MdDownloadsEnabledTest() : field_trial_list_(new base::MockEntropyProvider) {}
- ~MdDownloadsEnabledTest() override {}
-
- private:
- base::FieldTrialList field_trial_list_;
-};
-
-TEST_F(MdDownloadsEnabledTest, DisabledByDefault) {
- base::CommandLine* cl = base::CommandLine::ForCurrentProcess();
- ASSERT_FALSE(cl->HasSwitch(switches::kDisableMaterialDesignDownloads));
- ASSERT_FALSE(cl->HasSwitch(switches::kEnableMaterialDesignDownloads));
- ASSERT_FALSE(base::FieldTrialList::TrialExists(kFieldTrialName));
- EXPECT_FALSE(MdDownloadsEnabled());
-}
-
-TEST_F(MdDownloadsEnabledTest, EnabledByFieldTrial) {
- ASSERT_TRUE(FieldTrialList::CreateFieldTrial(kFieldTrialName, "Enabled2"));
- EXPECT_TRUE(MdDownloadsEnabled());
-}
-
-TEST_F(MdDownloadsEnabledTest, DisabledByFieldTrial) {
- ASSERT_TRUE(FieldTrialList::CreateFieldTrial(kFieldTrialName, "Disabled2"));
- EXPECT_FALSE(MdDownloadsEnabled());
-}
-
-TEST_F(MdDownloadsEnabledTest, EnabledBySwitch) {
- base::CommandLine* cl = base::CommandLine::ForCurrentProcess();
- cl->AppendSwitch(switches::kEnableMaterialDesignDownloads);
- EXPECT_TRUE(MdDownloadsEnabled());
-}
-
-TEST_F(MdDownloadsEnabledTest, DisabledBySwitch) {
- base::CommandLine* cl = base::CommandLine::ForCurrentProcess();
- cl->AppendSwitch(switches::kDisableMaterialDesignDownloads);
- EXPECT_FALSE(MdDownloadsEnabled());
-}
-
-TEST_F(MdDownloadsEnabledTest, SwitchOverridesFieldTrial1) {
- ASSERT_TRUE(FieldTrialList::CreateFieldTrial(kFieldTrialName, "Disabled2"));
- base::CommandLine* cl = base::CommandLine::ForCurrentProcess();
- cl->AppendSwitch(switches::kEnableMaterialDesignDownloads);
- EXPECT_TRUE(MdDownloadsEnabled());
-}
-
-TEST_F(MdDownloadsEnabledTest, SwitchOverridesFieldTrial2) {
- ASSERT_TRUE(FieldTrialList::CreateFieldTrial(kFieldTrialName, "Enabled2"));
- base::CommandLine* cl = base::CommandLine::ForCurrentProcess();
- cl->AppendSwitch(switches::kDisableMaterialDesignDownloads);
- EXPECT_FALSE(MdDownloadsEnabled());
-}
diff --git a/chrome/chrome_browser_ui.gypi b/chrome/chrome_browser_ui.gypi
index 17f2785..4cef868 100644
--- a/chrome/chrome_browser_ui.gypi
+++ b/chrome/chrome_browser_ui.gypi
@@ -1816,12 +1816,6 @@
'browser/ui/webui/copresence_ui_handler.h',
'browser/ui/webui/devtools_ui.cc',
'browser/ui/webui/devtools_ui.h',
- 'browser/ui/webui/downloads_dom_handler.cc',
- 'browser/ui/webui/downloads_dom_handler.h',
- 'browser/ui/webui/downloads_ui.cc',
- 'browser/ui/webui/downloads_ui.h',
- 'browser/ui/webui/downloads_util.cc',
- 'browser/ui/webui/downloads_util.h',
'browser/ui/webui/engagement/site_engagement_ui.cc',
'browser/ui/webui/engagement/site_engagement_ui.h',
'browser/ui/webui/extensions/extension_loader_handler.cc',
diff --git a/chrome/chrome_tests.gypi b/chrome/chrome_tests.gypi
index 8b20c08..eb8c8f6 100644
--- a/chrome/chrome_tests.gypi
+++ b/chrome/chrome_tests.gypi
@@ -505,9 +505,6 @@
'browser/ui/webui/chrome_url_data_manager_browsertest.cc',
'browser/ui/webui/chromeos/bluetooth_pairing_ui_browsertest-inl.h',
'browser/ui/webui/constrained_web_dialog_ui_browsertest.cc',
- 'browser/ui/webui/downloads_dom_handler_browsertest.cc',
- 'browser/ui/webui/downloads_ui_browsertest.cc',
- 'browser/ui/webui/downloads_ui_browsertest.h',
'browser/ui/webui/extensions/extension_settings_browsertest.cc',
'browser/ui/webui/extensions/extension_settings_browsertest.h',
'browser/ui/webui/identity_internals_ui_browsertest.cc',
@@ -901,8 +898,6 @@
'browser/supervised_user/supervised_user_browsertest.cc',
'browser/supervised_user/supervised_user_resource_throttle_browsertest.cc',
'browser/supervised_user/supervised_user_service_browsertest.cc',
- 'browser/ui/webui/downloads_ui_supervised_browsertest.cc',
- 'browser/ui/webui/downloads_ui_supervised_browsertest.h',
],
'chrome_browser_tests_app_list_sources': [
'browser/apps/drive/drive_app_converter_browsertest.cc',
@@ -938,9 +933,6 @@
'browser/ui/webui/chromeos/bluetooth_pairing_ui_browsertest.js',
'browser/ui/webui/chromeos/certificate_manager_dialog_browsertest.js',
'browser/ui/webui/chromeos/set_time_ui_browsertest.js',
- 'browser/ui/webui/downloads_ui_browsertest.js',
- 'browser/ui/webui/downloads_ui_browsertest_base.js',
- 'browser/ui/webui/downloads_ui_supervised_browsertest.js',
'browser/ui/webui/extensions/chromeos/kiosk_apps_browsertest.js',
'browser/ui/webui/extensions/extension_settings_browsertest.js',
'browser/ui/webui/help/help_browsertest.js',
@@ -2601,10 +2593,6 @@
}],
['enable_supervised_users==1', {
'sources': [ '<@(chrome_browser_tests_supervised_user_sources)' ],
- }, {
- 'sources!': [
- 'browser/ui/webui/downloads_ui_supervised_browsertest.js',
- ],
}],
['enable_pepper_cdms==1', {
'dependencies': [
diff --git a/chrome/chrome_tests_unit.gypi b/chrome/chrome_tests_unit.gypi
index 581e5f1..50b7bab 100644
--- a/chrome/chrome_tests_unit.gypi
+++ b/chrome/chrome_tests_unit.gypi
@@ -1558,7 +1558,6 @@
'browser/ui/toolbar/toolbar_model_unittest.cc',
'browser/ui/website_settings/permission_bubble_manager_unittest.cc',
'browser/ui/website_settings/permission_menu_model_unittest.cc',
- 'browser/ui/webui/downloads_util_unittest.cc',
'browser/ui/webui/help/version_updater_chromeos_unittest.cc',
'browser/ui/webui/md_downloads/downloads_list_tracker_unittest.cc',
'browser/ui/webui/md_downloads/md_downloads_dom_handler_unittest.cc',
diff --git a/chrome/common/chrome_switches.cc b/chrome/common/chrome_switches.cc
index 259b0a9..6384301 100644
--- a/chrome/common/chrome_switches.cc
+++ b/chrome/common/chrome_switches.cc
@@ -274,8 +274,10 @@ const char kDisableFieldTrialTestingConfig[] = "disable-field-trial-config";
// Disable HTTP/2 and SPDY/3.1 protocols.
const char kDisableHttp2[] = "disable-http2";
-// Disables the Material Design version of chrome://downloads.
-const char kDisableMaterialDesignDownloads[] = "disable-md-downloads";
+// Disable the behavior that the second click on a launcher item (the click when
+// the item is already active) minimizes the item.
+const char kDisableMinimizeOnSecondLauncherItemClick[] =
+ "disable-minimize-on-second-launcher-item-click";
// Disables the new bookmark app system.
const char kDisableNewBookmarkApps[] = "disable-new-bookmark-apps";
@@ -415,9 +417,6 @@ const char kEnableExtensionActivityLogTesting[] =
// crbug.com/142458 .
const char kEnableFastUnload[] = "enable-fast-unload";
-// Enables the Material Design version of chrome://downloads.
-const char kEnableMaterialDesignDownloads[] = "enable-md-downloads";
-
// Enables the Material Design version of chrome://extensions.
const char kEnableMaterialDesignExtensions[] = "enable-md-extensions";
diff --git a/chrome/common/chrome_switches.h b/chrome/common/chrome_switches.h
index 9aa3b6d..f2d4866 100644
--- a/chrome/common/chrome_switches.h
+++ b/chrome/common/chrome_switches.h
@@ -80,7 +80,7 @@ extern const char kDisableExtensions[];
extern const char kDisableFieldTrialTestingConfig[];
extern const char kDisableHttp2[];
extern const char kDisableJavaScriptHarmonyShipping[];
-extern const char kDisableMaterialDesignDownloads[];
+extern const char kDisableMinimizeOnSecondLauncherItemClick[];
extern const char kDisableNewBookmarkApps[];
extern const char kDisableNTPPopularSites[];
extern const char kDisableOfflineAutoReload[];
@@ -120,7 +120,6 @@ extern const char kEnableExperimentalHotwordHardware[];
extern const char kEnableExtensionActivityLogging[];
extern const char kEnableExtensionActivityLogTesting[];
extern const char kEnableFastUnload[];
-extern const char kEnableMaterialDesignDownloads[];
extern const char kEnableMaterialDesignExtensions[];
extern const char kEnableMaterialDesignHistory[];
extern const char kEnableMaterialDesignPolicyPage[];
diff --git a/chrome/test/BUILD.gn b/chrome/test/BUILD.gn
index ff183c6..3cfe1f7 100644
--- a/chrome/test/BUILD.gn
+++ b/chrome/test/BUILD.gn
@@ -652,10 +652,6 @@ if (!is_android) {
if (!enable_app_list) {
sources -= [ "../browser/ui/webui/app_list/start_page_browsertest.js" ]
}
- if (!enable_supervised_users) {
- sources -=
- [ "../browser/ui/webui/downloads_ui_supervised_browsertest.js" ]
- }
if (!enable_print_preview) {
sources -= [ "data/webui/print_preview.js" ]
}
diff --git a/chrome/test/base/web_ui_browser_test_browsertest.cc b/chrome/test/base/web_ui_browser_test_browsertest.cc
index 165b4d0..8c65956 100644
--- a/chrome/test/base/web_ui_browser_test_browsertest.cc
+++ b/chrome/test/base/web_ui_browser_test_browsertest.cc
@@ -32,13 +32,6 @@ class WebUIBrowserExpectFailTest : public WebUIBrowserTest {
s_test_ = this;
}
- // Disable new downloads UI as it is very very slow. https://crbug.com/526577
- // TODO(dbeam): remove this once the downloads UI is not slow.
- void SetUpCommandLine(base::CommandLine* command_line) override {
- WebUIBrowserTest::SetUpCommandLine(command_line);
- command_line->AppendSwitch(switches::kDisableMaterialDesignDownloads);
- }
-
protected:
~WebUIBrowserExpectFailTest() override {
EXPECT_TRUE(s_test_);
diff --git a/third_party/closure_compiler/compiled_resources.gyp b/third_party/closure_compiler/compiled_resources.gyp
index 9da4e16..9903f4a 100644
--- a/third_party/closure_compiler/compiled_resources.gyp
+++ b/third_party/closure_compiler/compiled_resources.gyp
@@ -24,7 +24,6 @@
'../../chrome/browser/resources/chromeos/braille_ime/compiled_resources.gyp:*',
'../../chrome/browser/resources/chromeos/compiled_resources.gyp:*',
'../../chrome/browser/resources/chromeos/network_ui/compiled_resources.gyp:*',
- '../../chrome/browser/resources/downloads/compiled_resources.gyp:*',
'../../chrome/browser/resources/extensions/compiled_resources.gyp:*',
'../../chrome/browser/resources/help/compiled_resources.gyp:*',
'../../chrome/browser/resources/history/compiled_resources.gyp:*',
diff --git a/third_party/closure_compiler/compiled_resources2.gyp b/third_party/closure_compiler/compiled_resources2.gyp
index e8bc2ca..bba863d 100644
--- a/third_party/closure_compiler/compiled_resources2.gyp
+++ b/third_party/closure_compiler/compiled_resources2.gyp
@@ -14,7 +14,6 @@
'target_name': 'compile_all_resources',
'type': 'none',
'dependencies': [
- '<(DEPTH)/chrome/browser/resources/downloads/compiled_resources2.gyp:*',
'<(DEPTH)/chrome/browser/resources/md_downloads/compiled_resources2.gyp:*',
'<(DEPTH)/chrome/browser/resources/settings/compiled_resources2.gyp:*',
'<(DEPTH)/ui/webui/resources/js/compiled_resources2.gyp:*',
diff --git a/ui/webui/resources/images/2x/otr_icon_standalone.png b/ui/webui/resources/images/2x/otr_icon_standalone.png
deleted file mode 100644
index af06732..0000000
--- a/ui/webui/resources/images/2x/otr_icon_standalone.png
+++ /dev/null
Binary files differ
diff --git a/ui/webui/resources/images/otr_icon_standalone.png b/ui/webui/resources/images/otr_icon_standalone.png
deleted file mode 100644
index 27d3dc4..0000000
--- a/ui/webui/resources/images/otr_icon_standalone.png
+++ /dev/null
Binary files differ