Skip to content

Commit

Permalink
Enterprise Reporting webUI boilerplate
Browse files Browse the repository at this point in the history
This change create the boilerplate code for a webUI which will describe
the health of enterprise reporting systems.

Bug: b:214041435
Change-Id: I6b7b4d6b634c35471e3f590cf13d084dfd60de17
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3753554
Reviewed-by: Chad Duffin <chadduffin@chromium.org>
Commit-Queue: Tyler Garrett <tylergarrett@chromium.org>
Reviewed-by: Kyle Horimoto <khorimoto@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1101045}
  • Loading branch information
Tyler Garrett authored and Chromium LUCI CQ committed Feb 3, 2023
1 parent 82b5ce9 commit a39d07a
Show file tree
Hide file tree
Showing 13 changed files with 118 additions and 0 deletions.
1 change: 1 addition & 0 deletions chrome/browser/resources/chromeos/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ group("resources") {
"audio:resources",
"desk_api:resources",
"emoji_picker:resources",
"enterprise_reporting:resources",
"gaia_action_buttons:resources",
"launcher_internals:resources",
"lock_screen_reauth:resources",
Expand Down
16 changes: 16 additions & 0 deletions chrome/browser/resources/chromeos/enterprise_reporting/BUILD.gn
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Copyright 2023 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.

import("//chrome/browser/resources/tools/build_webui.gni")

assert(is_chromeos_ash)

build_webui("build") {
grd_prefix = "enterprise_reporting"
static_files = [ "enterprise_reporting.html" ]
non_web_component_files = [ "enterprise_reporting.ts" ]

ts_use_local_config = true
ts_deps = [ "//ui/webui/resources/js:build_ts" ]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Enterprise Reporting</title>
<script type="module" src="enterprise_reporting.js"></script>
</head>
<body>
<h1>Enterprise Reporting</h1>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

function initialize() {}

document.addEventListener('DOMContentLoaded', initialize);
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"extends": "../../../../../tools/typescript/tsconfig_base.json",
"compilerOptions": {
"allowJs": true
}
}
2 changes: 2 additions & 0 deletions chrome/browser/ui/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -2683,6 +2683,8 @@ static_library("ui") {
"webui/ash/emoji/emoji_ui.h",
"webui/ash/emoji/gif_tenor_api_fetcher.cc",
"webui/ash/emoji/gif_tenor_api_fetcher.h",
"webui/ash/enterprise_reporting/enterprise_reporting_ui.cc",
"webui/ash/enterprise_reporting/enterprise_reporting_ui.h",
"webui/ash/guest_os_installer/guest_os_installer_dialog.cc",
"webui/ash/guest_os_installer/guest_os_installer_dialog.h",
"webui/ash/human_presence_internals_ui.cc",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
// Copyright 2023 The Chromium Authors
// 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/ash/enterprise_reporting/enterprise_reporting_ui.h"

#include "ash/constants/ash_features.h"
#include "base/containers/span.h"
#include "chrome/browser/ui/webui/webui_util.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/enterprise_reporting_resources.h"
#include "chrome/grit/enterprise_reporting_resources_map.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h"

namespace ash::reporting {

EnterpriseReportingUI::EnterpriseReportingUI(content::WebUI* web_ui)
: content::WebUIController(web_ui) {
DCHECK(base::FeatureList::IsEnabled(ash::features::kEnterpriseReportingUI));
// Set up the chrome://enterprise-reporting source.
content::WebUIDataSource* html_source =
content::WebUIDataSource::CreateAndAdd(
web_ui->GetWebContents()->GetBrowserContext(),
chrome::kChromeUIEnterpriseReportingHost);

// Add required resources.
webui::SetupWebUIDataSource(
html_source,
base::make_span(kEnterpriseReportingResources,
kEnterpriseReportingResourcesSize),
IDR_ENTERPRISE_REPORTING_ENTERPRISE_REPORTING_HTML);
}

EnterpriseReportingUI::~EnterpriseReportingUI() = default;

} // namespace ash::reporting
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
// Copyright 2023 The Chromium Authors
// 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_ASH_ENTERPRISE_REPORTING_ENTERPRISE_REPORTING_UI_H_
#define CHROME_BROWSER_UI_WEBUI_ASH_ENTERPRISE_REPORTING_ENTERPRISE_REPORTING_UI_H_

#include "content/public/browser/web_ui_controller.h"

namespace ash::reporting {

// The WebUI for chrome://enterprise-reporting
class EnterpriseReportingUI : public content::WebUIController {
public:
explicit EnterpriseReportingUI(content::WebUI* web_ui);
~EnterpriseReportingUI() override;
};

} // namespace ash::reporting

#endif // CHROME_BROWSER_UI_WEBUI_ASH_ENTERPRISE_REPORTING_ENTERPRISE_REPORTING_UI_H_
5 changes: 5 additions & 0 deletions chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@
#include "chrome/browser/ui/webui/ash/cryptohome_ui.h"
#include "chrome/browser/ui/webui/ash/drive_internals_ui.h"
#include "chrome/browser/ui/webui/ash/emoji/emoji_ui.h"
#include "chrome/browser/ui/webui/ash/enterprise_reporting/enterprise_reporting_ui.h"
#include "chrome/browser/ui/webui/ash/human_presence_internals_ui.h"
#include "chrome/browser/ui/webui/ash/in_session_password_change/password_change_ui.h"
#include "chrome/browser/ui/webui/ash/internet_config_dialog.h"
Expand Down Expand Up @@ -967,6 +968,10 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
}
return &NewComponentUI<ash::FaceMLAppUI, ash::ChromeFaceMLUserProvider>;
}
if (url.host_piece() == chrome::kChromeUIEnterpriseReportingHost &&
base::FeatureList::IsEnabled(ash::features::kEnterpriseReportingUI)) {
return &NewWebUI<ash::reporting::EnterpriseReportingUI>;
}
if (url.host_piece() == ash::file_manager::kChromeUIFileManagerHost) {
return &NewComponentUI<ash::file_manager::FileManagerUI,
ChromeFileManagerUIDelegate>;
Expand Down
2 changes: 2 additions & 0 deletions chrome/chrome_paks.gni
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,7 @@ template("chrome_extra_paks") {
"$root_gen_dir/chrome/cloud_upload_resources.pak",
"$root_gen_dir/chrome/desk_api_resources.pak",
"$root_gen_dir/chrome/emoji_picker_resources.pak",
"$root_gen_dir/chrome/enterprise_reporting_resources.pak",
"$root_gen_dir/chrome/gaia_action_buttons_resources.pak",
"$root_gen_dir/chrome/internet_config_dialog_resources.pak",
"$root_gen_dir/chrome/internet_detail_dialog_resources.pak",
Expand Down Expand Up @@ -369,6 +370,7 @@ template("chrome_extra_paks") {
"//chrome/browser/resources/chromeos/cloud_upload:resources",
"//chrome/browser/resources/chromeos/desk_api:resources",
"//chrome/browser/resources/chromeos/emoji_picker:resources",
"//chrome/browser/resources/chromeos/enterprise_reporting:resources",
"//chrome/browser/resources/chromeos/gaia_action_buttons:resources",
"//chrome/browser/resources/chromeos/launcher_internals:resources",
"//chrome/browser/resources/chromeos/lock_screen_reauth:resources",
Expand Down
2 changes: 2 additions & 0 deletions chrome/common/webui_url_constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,8 @@ const char kChromeUICryptohomeHost[] = "cryptohome";
const char kChromeUICryptohomeURL[] = "chrome://cryptohome";
const char kChromeUIDeviceEmulatorHost[] = "device-emulator";
const char kChromeUIDiagnosticsAppURL[] = "chrome://diagnostics";
const char kChromeUIEnterpriseReportingHost[] = "enterprise-reporting";
const char kChromeUIEnterpriseReportingURL[] = "chrome://enterprise-reporting";
const char kChromeUIInternetConfigDialogURL[] =
"chrome://internet-config-dialog/";
const char kChromeUIInternetDetailDialogURL[] =
Expand Down
2 changes: 2 additions & 0 deletions chrome/common/webui_url_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -309,6 +309,8 @@ extern const char kChromeUIDeviceEmulatorHost[];
extern const char kChromeUIDiagnosticsAppURL[];
extern const char kChromeUIEmojiPickerURL[];
extern const char kChromeUIEmojiPickerHost[];
extern const char kChromeUIEnterpriseReportingHost[];
extern const char kChromeUIEnterpriseReportingURL[];
extern const char kChromeUIInternetConfigDialogURL[];
extern const char kChromeUIInternetDetailDialogURL[];
extern const char kChromeUIInternetConfigDialogHost[];
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 @@ -543,6 +543,10 @@
"META": {"sizes": {"includes": [10]}},
"includes": [2685],
},
"<(SHARED_INTERMEDIATE_DIR)/chrome/browser/resources/chromeos/enterprise_reporting/resources.grd": {
"META": {"sizes": {"includes": [20]}},
"includes": [2695],
},
# END chrome/ WebUI resources section

# START chrome/ miscellaneous section.
Expand Down

0 comments on commit a39d07a

Please sign in to comment.