Skip to content

Commit

Permalink
Auto-generate grd file for chrome://ukm.
Browse files Browse the repository at this point in the history
This is necessary to leverage build_webui() which is the canonical way
of building WebUI surfaces, and is also done in the same CL.

Bug: 1132403
Change-Id: I518b2289d5182d040140aa3733b9e0546bebd439
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4544862
Commit-Queue: Demetrios Papadopoulos <[email protected]>
Reviewed-by: Rohit Rao <[email protected]>
Reviewed-by: Robert Kaplow <[email protected]>
Auto-Submit: Demetrios Papadopoulos <[email protected]>
Reviewed-by: Rebekah Potter <[email protected]>
Reviewed-by: danakj <[email protected]>
Code-Coverage: [email protected] <[email protected]>
Reviewed-by: Nico Weber <[email protected]>
Reviewed-by: Avi Drissman <[email protected]>
Cr-Commit-Position: refs/heads/main@{#1219652}
  • Loading branch information
freshp86 authored and Chromium LUCI CQ committed Nov 3, 2023
1 parent 9ec5744 commit 87235c8
Show file tree
Hide file tree
Showing 12 changed files with 34 additions and 29 deletions.
2 changes: 2 additions & 0 deletions chrome/browser/resources/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,7 @@ group("dev_ui_resources") {
"//components/policy/resources/webui:resources",
"//components/resources:dev_ui_components_resources",
"//components/sync/service/resources",
"//components/ukm/debug:resources",
"//content/browser/resources/gpu:resources",
"//content/browser/resources/media:resources",
"//content/browser/resources/net:resources",
Expand Down Expand Up @@ -299,6 +300,7 @@ repack("dev_ui_paks") {
"$root_gen_dir/components/optimization_guide_internals_resources.pak",
"$root_gen_dir/components/policy_resources.pak",
"$root_gen_dir/components/sync_service_sync_internals_resources.pak",
"$root_gen_dir/components/ukm_resources.pak",
"$root_gen_dir/content/browser/resources/media/media_internals_resources.pak",
"$root_gen_dir/content/browser/webrtc/resources/webrtc_internals_resources.pak",
"$root_gen_dir/content/gpu_resources.pak",
Expand Down
1 change: 1 addition & 0 deletions components/ukm/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ static_library("ukm") {

public_deps = [
":ukm_recorder",
"//components/ukm/debug:resources",
"//services/metrics/public/cpp:metrics_cpp",
"//services/metrics/public/cpp:ukm_builders",
"//services/metrics/public/mojom",
Expand Down
26 changes: 13 additions & 13 deletions components/ukm/debug/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@
# Use of this source code is governed by a BSD-style license that can be
# found in the LICENSE file.

import("//tools/grit/preprocess_if_expr.gni")
import("//tools/typescript/ts_library.gni")
import("//ui/webui/resources/tools/build_webui.gni")

source_set("util") {
sources = [
Expand All @@ -17,16 +16,17 @@ source_set("util") {
]
}

preprocess_if_expr("preprocess") {
in_folder = "."
out_folder = target_gen_dir
in_files = [ "ukm_internals.ts" ]
}
build_webui("build") {
grd_prefix = "ukm"

static_files = [
"ukm_internals.css",
"ukm_internals.html",
]

non_web_component_files = [ "ukm_internals.ts" ]

ts_deps = [ "//ui/webui/resources/js:build_ts" ]

ts_library("build_ts") {
root_dir = target_gen_dir
out_dir = "$target_gen_dir/tsc"
in_files = [ "ukm_internals.ts" ]
deps = [ "//ui/webui/resources/js:build_ts" ]
extra_deps = [ ":preprocess" ]
grit_output_dir = "$root_gen_dir/components"
}
3 changes: 1 addition & 2 deletions content/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,9 @@ grit("content_resources") {
"grit/content_resources_map.h",
"content_resources.pak",
]
deps = [ "//components/ukm/debug:build_ts" ]

if (is_chromeos_ash) {
deps += [
deps = [
"//mojo/public/mojom/base:base_js__generator",
"//ui/base/mojom:mojom_js__generator",
"//url/mojom:url_mojom_gurl_js__generator",
Expand Down
1 change: 1 addition & 0 deletions content/browser/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ include_rules = [
"+components/download/public/common",
"+components/file_access",
"+components/filename_generation",
"+components/grit",
"+components/permissions/features.h",
"+components/power_monitor",
"+components/services/font",
Expand Down
8 changes: 4 additions & 4 deletions content/browser/ukm_internals_ui.cc
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@

#include "base/functional/bind.h"
#include "base/memory/raw_ptr.h"
#include "components/grit/ukm_resources.h"
#include "components/grit/ukm_resources_map.h"
#include "components/ukm/debug/ukm_debug_data_extractor.h"
#include "components/ukm/ukm_service.h"
#include "content/grit/content_resources.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/content_browser_client.h"
#include "content/public/browser/web_contents.h"
Expand All @@ -31,9 +32,8 @@ void CreateAndAddUkmHTMLSource(BrowserContext* browser_context) {
WebUIDataSource* source =
WebUIDataSource::CreateAndAdd(browser_context, kChromeUIUkmHost);

source->AddResourcePath("ukm_internals.js", IDR_UKM_INTERNALS_JS);
source->AddResourcePath("ukm_internals.css", IDR_UKM_INTERNALS_CSS);
source->SetDefaultResource(IDR_UKM_INTERNALS_HTML);
source->AddResourcePaths(base::make_span(kUkmResources, kUkmResourcesSize));
source->SetDefaultResource(IDR_UKM_UKM_INTERNALS_HTML);
}

// This class receives javascript messages from the renderer.
Expand Down
3 changes: 0 additions & 3 deletions content/content_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,6 @@ Other resources that belong in this file:
<include name="IDR_DEVTOOLS_PINCH_CURSOR_ICON_2X" file="browser/resources/devtools/devtools_pinch_cursor_2x.png" type="BINDATA" />
<include name="IDR_DEVTOOLS_TOUCH_CURSOR_ICON" file="browser/resources/devtools/devtools_touch_cursor.png" type="BINDATA" />
<include name="IDR_DEVTOOLS_TOUCH_CURSOR_ICON_2X" file="browser/resources/devtools/devtools_touch_cursor_2x.png" type="BINDATA" />
<include name="IDR_UKM_INTERNALS_HTML" file="../components/ukm/debug/ukm_internals.html" type="BINDATA" />
<include name="IDR_UKM_INTERNALS_JS" file="${root_gen_dir}/components/ukm/debug/tsc/ukm_internals.js" use_base_dir="false" resource_path="ukm_internals.js" type="BINDATA" />
<include name="IDR_UKM_INTERNALS_CSS" file="../components/ukm/debug/ukm_internals.css" type="BINDATA" />
<if expr="chromeos_ash">
<include name="IDR_UNGUESSABLE_TOKEN_MOJO_JS" file="${root_gen_dir}/mojo/public/mojom/base/unguessable_token.mojom-lite.js" resource_path="mojo/mojo/public/mojom/base/unguessable_token.mojom-lite.js" use_base_dir="false" type="BINDATA" />
<include name="IDR_URL_MOJO_JS" file="${root_gen_dir}/url/mojom/url.mojom-lite.js" resource_path="mojo/url/mojom/url.mojom-lite.js" use_base_dir="false" type="BINDATA" />
Expand Down
2 changes: 2 additions & 0 deletions content/shell/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -487,6 +487,7 @@ repack("pak") {

sources = [
"$root_gen_dir/base/tracing/protos/tracing_proto_resources.pak",
"$root_gen_dir/components/ukm_resources.pak",
"$root_gen_dir/content/attribution_internals_resources.pak",
"$root_gen_dir/content/browser/resources/media/media_internals_resources.pak",
"$root_gen_dir/content/browser/webrtc/resources/webrtc_internals_resources.pak",
Expand Down Expand Up @@ -517,6 +518,7 @@ repack("pak") {
deps = [
":resources",
"//base/tracing/protos:chrome_track_event_resources",
"//components/ukm/debug:resources",
"//content:content_resources",
"//content/browser/resources:resources",
"//content/browser/resources/media:resources",
Expand Down
4 changes: 2 additions & 2 deletions ios/chrome/app/resources/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,6 @@ grit("ios_resources") {
"grit/ios_resources.h",
"ios_resources.pak",
]

deps = [ "//components/ukm/debug:build_ts" ]
}

group("packed_resources") {
Expand Down Expand Up @@ -68,6 +66,7 @@ repack("repack_unscaled_resources") {
"$root_gen_dir/components/optimization_guide_internals_resources.pak",
"$root_gen_dir/components/policy_resources.pak",
"$root_gen_dir/components/sync_service_sync_internals_resources.pak",
"$root_gen_dir/components/ukm_resources.pak",
"$root_gen_dir/components/version_ui_resources.pak",
"$root_gen_dir/ios/chrome/ios_resources.pak",
"$root_gen_dir/ios/web/ios_web_resources.pak",
Expand All @@ -83,6 +82,7 @@ repack("repack_unscaled_resources") {
"//components/policy/resources/webui:resources",
"//components/resources",
"//components/sync/service/resources",
"//components/ukm/debug:resources",
"//ios/web:resources",
"//mojo/public/js:resources",
"//net:net_resources",
Expand Down
2 changes: 0 additions & 2 deletions ios/chrome/app/resources/ios_resources.grd
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
<include name="IDR_IOS_INSPECT_JS" file="inspect/inspect.js" type="BINDATA" />
<include name="IDR_IOS_OMAHA_HTML" file="omaha/omaha.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" />
<include name="IDR_IOS_OMAHA_JS" file="omaha/omaha.js" type="BINDATA" />
<include name="IDR_IOS_UKM_INTERNALS_HTML" file="../../../../components/ukm/debug/ukm_internals.html" flattenhtml="true" allowexternalscript="true" type="BINDATA" />
<include name="IDR_IOS_UKM_INTERNALS_JS" file="${root_gen_dir}/components/ukm/debug/tsc/ukm_internals.js" use_base_dir="false" type="BINDATA" />
<include name="IDR_IOS_TRANSLATE_INTERNALS_CSS" file="../../../../components/translate/translate_internals/translate_internals.css" type="BINDATA" />
<include name="IDR_IOS_TRANSLATE_INTERNALS_HTML" file="../../../../components/translate/translate_internals/translate_internals.html" type="BINDATA" />
<include name="IDR_IOS_TRANSLATE_INTERNALS_JS" file="../../../../components/translate/translate_internals/translate_internals.js" preprocess="true" type="BINDATA" />
Expand Down
7 changes: 4 additions & 3 deletions ios/chrome/browser/ui/webui/ukm_internals_ui.mm
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,14 @@

#import "base/functional/bind.h"
#import "base/memory/ref_counted_memory.h"
#import "components/grit/ukm_resources.h"
#import "components/grit/ukm_resources_map.h"
#import "components/metrics_services_manager/metrics_services_manager.h"
#import "components/ukm/debug/ukm_debug_data_extractor.h"
#import "components/ukm/ukm_service.h"
#import "ios/chrome/browser/shared/model/application_context/application_context.h"
#import "ios/chrome/browser/shared/model/browser_state/chrome_browser_state.h"
#import "ios/chrome/browser/shared/model/url/chrome_url_constants.h"
#import "ios/chrome/grit/ios_resources.h"
#import "ios/web/public/webui/url_data_source_ios.h"
#import "ios/web/public/webui/web_ui_ios.h"
#import "ios/web/public/webui/web_ui_ios_data_source.h"
Expand All @@ -24,8 +25,8 @@
web::WebUIIOSDataSource* source =
web::WebUIIOSDataSource::Create(kChromeUIURLKeyedMetricsHost);

source->AddResourcePath("ukm_internals.js", IDR_IOS_UKM_INTERNALS_JS);
source->SetDefaultResource(IDR_IOS_UKM_INTERNALS_HTML);
source->AddResourcePaths(base::make_span(kUkmResources, kUkmResourcesSize));
source->SetDefaultResource(IDR_UKM_UKM_INTERNALS_HTML);
return source;
}

Expand Down
4 changes: 4 additions & 0 deletions tools/gritsettings/resource_ids.spec
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,10 @@
"META": {"sizes": {"includes": [10]}},
"includes": [4500],
},
"<(SHARED_INTERMEDIATE_DIR)/components/ukm/debug/resources.grd": {
"META": {"sizes": {"includes": [5]}},
"includes": [4510],
},
"<(SHARED_INTERMEDIATE_DIR)/chrome/browser/resources/app_home/resources.grd": {
"META": {"sizes": {"includes": [20]}},
"includes": [4520],
Expand Down

0 comments on commit 87235c8

Please sign in to comment.