From c77e3e1e82d9e3802e70671e60f0690beed8a7ba Mon Sep 17 00:00:00 2001 From: Jay Harris Date: Thu, 5 Dec 2024 20:08:21 +1300 Subject: [PATCH] [Web UI]: Convert History to new overrides (#26879) --- browser/resources/history/BUILD.gn | 17 ------------ .../resources/history/brave_history_item.html | 5 ---- .../resources/history/brave_history_item.ts | 14 ---------- .../history/brave_overrides/index.ts | 8 ------ browser/resources/history/sources.gni | 26 ------------------- build/config/brave_build.gni | 1 - .../chrome/browser/resources/history}/app.ts | 6 ++--- .../resources/history}/history_item.ts | 10 +++++-- .../browser/resources/history}/side_bar.ts | 6 ++--- ...e-browser-resources-history-BUILD.gn.patch | 10 ------- ...browser-resources-history-history.ts.patch | 12 --------- ...-resources-history-history_item.html.patch | 10 ------- ...er-resources-history-history_item.ts.patch | 12 --------- 13 files changed, 14 insertions(+), 123 deletions(-) delete mode 100644 browser/resources/history/BUILD.gn delete mode 100644 browser/resources/history/brave_history_item.html delete mode 100644 browser/resources/history/brave_history_item.ts delete mode 100644 browser/resources/history/brave_overrides/index.ts delete mode 100644 browser/resources/history/sources.gni rename {browser/resources/history/brave_overrides => chromium_src/chrome/browser/resources/history}/app.ts (85%) rename {browser/resources/history/brave_overrides => chromium_src/chrome/browser/resources/history}/history_item.ts (59%) rename {browser/resources/history/brave_overrides => chromium_src/chrome/browser/resources/history}/side_bar.ts (90%) delete mode 100644 patches/chrome-browser-resources-history-BUILD.gn.patch delete mode 100644 patches/chrome-browser-resources-history-history.ts.patch delete mode 100644 patches/chrome-browser-resources-history-history_item.html.patch delete mode 100644 patches/chrome-browser-resources-history-history_item.ts.patch diff --git a/browser/resources/history/BUILD.gn b/browser/resources/history/BUILD.gn deleted file mode 100644 index 36deadc350f7..000000000000 --- a/browser/resources/history/BUILD.gn +++ /dev/null @@ -1,17 +0,0 @@ -# Copyright (c) 2022 The Brave Authors. All rights reserved. -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this file, -# you can obtain one at http://mozilla.org/MPL/2.0/. - -import("//tools/grit/preprocess_if_expr.gni") -import("sources.gni") - -# Move brave files to the place where chromium history page is compiled from. -# It should be the same directory that build_webui.gni uses after it performs -# its own preprocess_if_expr. Once chromium and brave frontend files are all in -# the same place, build_webui.gni will continue its typescript and rollup -# compile (etc.) from that directory. -preprocess_if_expr("preprocess") { - out_folder = "$root_gen_dir/chrome/browser/resources/history/preprocessed" - in_files = brave_history_local_html_files + brave_history_local_ts_files -} diff --git a/browser/resources/history/brave_history_item.html b/browser/resources/history/brave_history_item.html deleted file mode 100644 index a87cc1c7b4b8..000000000000 --- a/browser/resources/history/brave_history_item.html +++ /dev/null @@ -1,5 +0,0 @@ - \ No newline at end of file diff --git a/browser/resources/history/brave_history_item.ts b/browser/resources/history/brave_history_item.ts deleted file mode 100644 index e574b92a3bbf..000000000000 --- a/browser/resources/history/brave_history_item.ts +++ /dev/null @@ -1,14 +0,0 @@ -// Copyright 2020 The Brave Authors. All rights reserved. -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this file, -// you can obtain one at https://mozilla.org/MPL/2.0/. - -// @ts-nocheck TODO(petemill): Convert to Polymer class and remove ts-nocheck - -import {Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; -import {getTemplate} from './brave_history_item.html.js' - -Polymer({ - is: 'brave-history-item', - _template: getTemplate() -}) diff --git a/browser/resources/history/brave_overrides/index.ts b/browser/resources/history/brave_overrides/index.ts deleted file mode 100644 index 6275fa7ef3f7..000000000000 --- a/browser/resources/history/brave_overrides/index.ts +++ /dev/null @@ -1,8 +0,0 @@ -// Copyright (c) 2022 The Brave Authors. All rights reserved. -// This Source Code Form is subject to the terms of the Mozilla Public -// License, v. 2.0. If a copy of the MPL was not distributed with this file, -// you can obtain one at https://mozilla.org/MPL/2.0/. - -import './app.js' -import './history_item.js' -import './side_bar.js' diff --git a/browser/resources/history/sources.gni b/browser/resources/history/sources.gni deleted file mode 100644 index f2412868f9c6..000000000000 --- a/browser/resources/history/sources.gni +++ /dev/null @@ -1,26 +0,0 @@ -# Copyright (c) 2020 The Brave Authors. All rights reserved. -# This Source Code Form is subject to the terms of the Mozilla Public -# License, v. 2.0. If a copy of the MPL was not distributed with this file, -# you can obtain one at http://mozilla.org/MPL/2.0/. - -brave_history_web_component_files = [ "brave_history_item.ts" ] - -brave_history_non_web_component_files = [ - "brave_overrides/app.ts", - "brave_overrides/history_item.ts", - "brave_overrides/side_bar.ts", - "brave_overrides/index.ts", -] - -# Also include the .html sibling files -brave_history_local_ts_files = - brave_history_web_component_files + brave_history_non_web_component_files - -brave_history_local_html_files = [] -foreach(component_file, brave_history_web_component_files) { - brave_history_local_html_files += - [ string_replace(component_file, ".ts", ".html") ] -} - -brave_history_preprocess_extra_deps = - [ "//brave/browser/resources/history:preprocess" ] diff --git a/build/config/brave_build.gni b/build/config/brave_build.gni index 92c1836765fa..0cb0b41b23ce 100644 --- a/build/config/brave_build.gni +++ b/build/config/brave_build.gni @@ -11,7 +11,6 @@ import("//brave/brave_repack_locales.gni") import("//brave/browser/extensions/resources.gni") import("//brave/browser/resources/bookmarks/sources.gni") import("//brave/browser/resources/extensions/sources.gni") -import("//brave/browser/resources/history/sources.gni") import("//brave/browser/resources/settings/sources.gni") import("//brave/browser/ui/color/sources.gni") import("//brave/build/mac/config.gni") diff --git a/browser/resources/history/brave_overrides/app.ts b/chromium_src/chrome/browser/resources/history/app.ts similarity index 85% rename from browser/resources/history/brave_overrides/app.ts rename to chromium_src/chrome/browser/resources/history/app.ts index 91faa3a17c6b..1b971f3e0a3e 100644 --- a/browser/resources/history/brave_overrides/app.ts +++ b/chromium_src/chrome/browser/resources/history/app.ts @@ -3,8 +3,6 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // You can obtain one at https://mozilla.org/MPL/2.0/. -// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck - import {RegisterStyleOverride} from 'chrome://resources/brave/polymer_overriding.js' import {html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js' @@ -13,8 +11,10 @@ RegisterStyleOverride( html` ` ) + +export * from './app-chromium.js' diff --git a/browser/resources/history/brave_overrides/history_item.ts b/chromium_src/chrome/browser/resources/history/history_item.ts similarity index 59% rename from browser/resources/history/brave_overrides/history_item.ts rename to chromium_src/chrome/browser/resources/history/history_item.ts index ecdfb86003eb..2658983fcd76 100644 --- a/browser/resources/history/brave_overrides/history_item.ts +++ b/chromium_src/chrome/browser/resources/history/history_item.ts @@ -3,8 +3,8 @@ // License, v. 2.0. If a copy of the MPL was not distributed with this file, // You can obtain one at https://mozilla.org/MPL/2.0/. -import {RegisterStyleOverride} from 'chrome://resources/brave/polymer_overriding.js' -import {html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js' +import { RegisterStyleOverride } from 'chrome://resources/brave/polymer_overriding.js' +import { html } from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js' RegisterStyleOverride( 'history-item', @@ -14,6 +14,12 @@ RegisterStyleOverride( font-size: 13px; font-weight: 400; } + + #menu-button { + transform: rotate(90deg) !important; + } ` ) + +export * from './history_item-chromium.js' diff --git a/browser/resources/history/brave_overrides/side_bar.ts b/chromium_src/chrome/browser/resources/history/side_bar.ts similarity index 90% rename from browser/resources/history/brave_overrides/side_bar.ts rename to chromium_src/chrome/browser/resources/history/side_bar.ts index 70a9b76c9139..2b78be8e36ab 100644 --- a/browser/resources/history/brave_overrides/side_bar.ts +++ b/chromium_src/chrome/browser/resources/history/side_bar.ts @@ -1,9 +1,7 @@ // Copyright (c) 2022 The Brave Authors. All rights reserved. // This Source Code Form is subject to the terms of the Mozilla Public // License, v. 2.0. If a copy of the MPL was not distributed with this file, -// you can obtain one at https://mozilla.org/MPL/2.0/. - -// @ts-nocheck TODO(petemill): Define types and remove ts-nocheck +// You can obtain one at https://mozilla.org/MPL/2.0/. import {RegisterStyleOverride} from 'chrome://resources/brave/polymer_overriding.js' import {html} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js' @@ -39,3 +37,5 @@ RegisterStyleOverride( ` ) + +export * from './side_bar-chromium.js' diff --git a/patches/chrome-browser-resources-history-BUILD.gn.patch b/patches/chrome-browser-resources-history-BUILD.gn.patch deleted file mode 100644 index 008ace2a488d..000000000000 --- a/patches/chrome-browser-resources-history-BUILD.gn.patch +++ /dev/null @@ -1,10 +0,0 @@ -diff --git a/chrome/browser/resources/history/BUILD.gn b/chrome/browser/resources/history/BUILD.gn -index 7b7b44c0ba80fb83a0e705650537ab4505977ebe..41ad31824164428df023cdd2ca82df224dd11494 100644 ---- a/chrome/browser/resources/history/BUILD.gn -+++ b/chrome/browser/resources/history/BUILD.gn -@@ -89,4 +89,5 @@ build_webui("build") { - "lazy_load.js", - ] - } -+ import("//brave/browser/resources/history/sources.gni") web_component_files += brave_history_web_component_files non_web_component_files += brave_history_non_web_component_files exclude_ts_preprocess_files = brave_history_local_ts_files exclude_html_css_preprocess_files = brave_history_local_html_files preprocess_deps = brave_history_preprocess_extra_deps - } diff --git a/patches/chrome-browser-resources-history-history.ts.patch b/patches/chrome-browser-resources-history-history.ts.patch deleted file mode 100644 index cf95c53537cb..000000000000 --- a/patches/chrome-browser-resources-history-history.ts.patch +++ /dev/null @@ -1,12 +0,0 @@ -diff --git a/chrome/browser/resources/history/history.ts b/chrome/browser/resources/history/history.ts -index 5aa8bff2a95f6016605a70b785af0865a9a5f168..32abc81e135a543388e0fc48be4e7a39edc3e799 100644 ---- a/chrome/browser/resources/history/history.ts -+++ b/chrome/browser/resources/history/history.ts -@@ -2,6 +2,7 @@ - // Use of this source code is governed by a BSD-style license that can be - // found in the LICENSE file. - -+import './brave_overrides/index.js'; - import './app.js'; - - export {PageCallbackRouter as ProductSpecificationsCallbackRouter} from 'chrome://resources/cr_components/commerce/product_specifications.mojom-webui.js'; diff --git a/patches/chrome-browser-resources-history-history_item.html.patch b/patches/chrome-browser-resources-history-history_item.html.patch deleted file mode 100644 index ab9fc8bd732d..000000000000 --- a/patches/chrome-browser-resources-history-history_item.html.patch +++ /dev/null @@ -1,10 +0,0 @@ -diff --git a/chrome/browser/resources/history/history_item.html b/chrome/browser/resources/history/history_item.html -index 7964c83ad5250258f29ecdd8c4fb572e01e2ae68..33a8b6efd9b91757bb80dab3ec163a6894d1fb69 100644 ---- a/chrome/browser/resources/history/history_item.html -+++ b/chrome/browser/resources/history/history_item.html -@@ -1,4 +1,4 @@ --