Commit 89292a4a authored by dpapad's avatar dpapad Committed by Chromium LUCI CQ

Migrate chrome://predictors to JS modules.

Bug: None
Change-Id: Idf627b30a15a069a44c4d6faf6a63316d6ec38b5
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2574394
Commit-Queue: dpapad <dpapad@chromium.org>
Reviewed-by: default avatarAlex Ilin <alexilin@chromium.org>
Cr-Commit-Position: refs/heads/master@{#834176}
parent 82bce459
...@@ -52,8 +52,10 @@ This file specifies browser resources for developer-facing chrome:// pages ...@@ -52,8 +52,10 @@ This file specifies browser resources for developer-facing chrome:// pages
<include name="IDR_MEDIA_HISTORY_STORE_MOJOM_LITE_JS" file="${root_gen_dir}\chrome\browser\media\history\media_history_store.mojom-lite.js" use_base_dir="false" type="BINDATA" /> <include name="IDR_MEDIA_HISTORY_STORE_MOJOM_LITE_JS" file="${root_gen_dir}\chrome\browser\media\history\media_history_store.mojom-lite.js" use_base_dir="false" type="BINDATA" />
<include name="IDR_MEMORY_INTERNALS_HTML" file="resources\memory_internals\memory_internals.html" type="BINDATA" /> <include name="IDR_MEMORY_INTERNALS_HTML" file="resources\memory_internals\memory_internals.html" type="BINDATA" />
<include name="IDR_MEMORY_INTERNALS_JS" file="resources\memory_internals\memory_internals.js" type="BINDATA" /> <include name="IDR_MEMORY_INTERNALS_JS" file="resources\memory_internals\memory_internals.js" type="BINDATA" />
<include name="IDR_PREDICTORS_AUTOCOMPLETE_ACTION_PREDICTOR_JS" file="resources\predictors\autocomplete_action_predictor.js" type="BINDATA" />
<include name="IDR_PREDICTORS_HTML" file="resources\predictors\predictors.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" /> <include name="IDR_PREDICTORS_HTML" file="resources\predictors\predictors.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" />
<include name="IDR_PREDICTORS_JS" file="resources\predictors\predictors.js" flattenhtml="true" type="BINDATA" /> <include name="IDR_PREDICTORS_JS" file="resources\predictors\predictors.js" type="BINDATA" />
<include name="IDR_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_JS" file="resources\predictors\resource_prefetch_predictor.js" type="BINDATA" />
<include name="IDR_MEDIA_SESSION_MOJOM_LITE_JS" file="${root_gen_dir}\services\media_session\public\mojom\media_session.mojom-lite.js" use_base_dir="false" type="BINDATA" /> <include name="IDR_MEDIA_SESSION_MOJOM_LITE_JS" file="${root_gen_dir}\services\media_session\public\mojom\media_session.mojom-lite.js" use_base_dir="false" type="BINDATA" />
<include name="IDR_UI_GEOMETRY_MOJOM_LITE_JS" file="${root_gen_dir}\ui\gfx\geometry\mojom\geometry.mojom-lite.js" use_base_dir="false" type="BINDATA" /> <include name="IDR_UI_GEOMETRY_MOJOM_LITE_JS" file="${root_gen_dir}\ui\gfx\geometry\mojom\geometry.mojom-lite.js" use_base_dir="false" type="BINDATA" />
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
import("//third_party/closure_compiler/compile_js.gni") import("//third_party/closure_compiler/compile_js.gni")
js_type_check("closure_compile") { js_type_check("closure_compile") {
uses_js_modules = true
deps = [ deps = [
":autocomplete_action_predictor", ":autocomplete_action_predictor",
":predictors", ":predictors",
...@@ -14,22 +15,22 @@ js_type_check("closure_compile") { ...@@ -14,22 +15,22 @@ js_type_check("closure_compile") {
js_library("autocomplete_action_predictor") { js_library("autocomplete_action_predictor") {
deps = [ deps = [
"//ui/webui/resources/js:cr", "//ui/webui/resources/js:cr.m",
"//ui/webui/resources/js:util", "//ui/webui/resources/js:util.m",
] ]
} }
js_library("predictors") { js_library("predictors") {
deps = [ deps = [
"//ui/webui/resources/js:cr", "//ui/webui/resources/js:cr.m",
"//ui/webui/resources/js/cr:ui", "//ui/webui/resources/js/cr:ui.m",
"//ui/webui/resources/js/cr/ui:tabs", "//ui/webui/resources/js/cr/ui:tabs.m",
] ]
} }
js_library("resource_prefetch_predictor") { js_library("resource_prefetch_predictor") {
deps = [ deps = [
"//ui/webui/resources/js:cr", "//ui/webui/resources/js:cr.m",
"//ui/webui/resources/js:util", "//ui/webui/resources/js:util.m",
] ]
} }
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import {sendWithPromise} from 'chrome://resources/js/cr.m.js';
import {$} from 'chrome://resources/js/util.m.js';
/** /**
* @typedef {{ * @typedef {{
* enabled: boolean, * enabled: boolean,
...@@ -20,7 +23,7 @@ let AutocompleteActionPredictorDb; ...@@ -20,7 +23,7 @@ let AutocompleteActionPredictorDb;
* Requests the database from the backend. * Requests the database from the backend.
*/ */
function requestAutocompleteActionPredictorDb() { function requestAutocompleteActionPredictorDb() {
cr.sendWithPromise('requestAutocompleteActionPredictorDb') sendWithPromise('requestAutocompleteActionPredictorDb')
.then(updateAutocompleteActionPredictorDb); .then(updateAutocompleteActionPredictorDb);
} }
......
...@@ -3,23 +3,13 @@ ...@@ -3,23 +3,13 @@
<head> <head>
<meta charset="utf-8"> <meta charset="utf-8">
<title>Predictors</title> <title>Predictors</title>
<link rel="stylesheet" href="chrome://resources/css/list.css">
<link rel="stylesheet" href="chrome://resources/css/tabs.css"> <link rel="stylesheet" href="chrome://resources/css/tabs.css">
<link rel="stylesheet" href="chrome://resources/css/text_defaults.css"> <link rel="stylesheet" href="chrome://resources/css/text_defaults.css">
<link rel="stylesheet" href="chrome://resources/css/tree.css">
<style> <style>
<include src="predictors.css"> <include src="predictors.css">
</style> </style>
<!-- List stuff. -->
<script src="chrome://resources/js/assert.js"></script>
<script src="chrome://resources/js/promise_resolver.js"></script>
<script src="chrome://resources/js/cr.js"></script>
<script src="chrome://resources/js/cr/ui.js"></script>
<script src="chrome://resources/js/cr/ui/focus_outline_manager.js"></script>
<script src="chrome://resources/js/cr/ui/tabs.js"></script>
<script src="chrome://resources/js/util.js"></script>
</head> </head>
<body> <body>
...@@ -37,6 +27,6 @@ ...@@ -37,6 +27,6 @@
</tabpanel> </tabpanel>
</tabpanels> </tabpanels>
</tabbox> </tabbox>
<script src="predictors.js"></script> <script type="module" src="predictors.js"></script>
</body> </body>
</html> </html>
...@@ -2,11 +2,15 @@ ...@@ -2,11 +2,15 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
// <include src="autocomplete_action_predictor.js"> import './autocomplete_action_predictor.js';
// <include src="resource_prefetch_predictor.js"> import './resource_prefetch_predictor.js';
if (cr.isWindows) { import {isWindows} from 'chrome://resources/js/cr.m.js';
import {decorate} from 'chrome://resources/js/cr/ui.m.js';
import {TabBox} from 'chrome://resources/js/cr/ui/tabs.m.js';
if (isWindows) {
document.documentElement.setAttribute('os', 'win'); document.documentElement.setAttribute('os', 'win');
} }
cr.ui.decorate('tabbox', cr.ui.TabBox); decorate('tabbox', TabBox);
...@@ -2,6 +2,9 @@ ...@@ -2,6 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
import {sendWithPromise} from 'chrome://resources/js/cr.m.js';
import {$} from 'chrome://resources/js/util.m.js';
/** /**
* @typedef {{ * @typedef {{
* enabled: boolean, * enabled: boolean,
...@@ -31,7 +34,7 @@ let OriginData; ...@@ -31,7 +34,7 @@ let OriginData;
* Requests the database from the backend. * Requests the database from the backend.
*/ */
function requestResourcePrefetchPredictorDb() { function requestResourcePrefetchPredictorDb() {
cr.sendWithPromise('requestResourcePrefetchPredictorDb') sendWithPromise('requestResourcePrefetchPredictorDb')
.then(updateResourcePrefetchPredictorDb); .then(updateResourcePrefetchPredictorDb);
} }
......
...@@ -19,7 +19,11 @@ namespace { ...@@ -19,7 +19,11 @@ namespace {
content::WebUIDataSource* CreatePredictorsUIHTMLSource() { content::WebUIDataSource* CreatePredictorsUIHTMLSource() {
content::WebUIDataSource* source = content::WebUIDataSource* source =
content::WebUIDataSource::Create(chrome::kChromeUIPredictorsHost); content::WebUIDataSource::Create(chrome::kChromeUIPredictorsHost);
source->AddResourcePath("autocomplete_action_predictor.js",
IDR_PREDICTORS_AUTOCOMPLETE_ACTION_PREDICTOR_JS);
source->AddResourcePath("predictors.js", IDR_PREDICTORS_JS); source->AddResourcePath("predictors.js", IDR_PREDICTORS_JS);
source->AddResourcePath("resource_prefetch_predictor.js",
IDR_PREDICTORS_RESOURCE_PREFETCH_PREDICTOR_JS);
source->SetDefaultResource(IDR_PREDICTORS_HTML); source->SetDefaultResource(IDR_PREDICTORS_HTML);
return source; return source;
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment