Skip to content

Commit

Permalink
[feedback] initial skeleton WebUI for feedback tool new UX
Browse files Browse the repository at this point in the history
With this CL, a non-functional new Feedback Tool UX for ChromeOS is
served under chrome://os-feedback as a WebUI. This is the starting
point to implement the UX change (go/cros-feedback-tool).

A follow up CL will convert this into an SWA.

Bug: b/185624798
Change-Id: Ibd410ee2fbb9c71e281e0edc314a79d53d2ef67d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2851539
Reviewed-by: Jochen Eisinger <jochen@chromium.org>
Reviewed-by: Jimmy Gong <jimmyxgong@chromium.org>
Reviewed-by: Lei Zhang <thestig@chromium.org>
Reviewed-by: Kyle Horimoto <khorimoto@chromium.org>
Commit-Queue: Xiangdong Kong <xiangdongkong@google.com>
Cr-Commit-Position: refs/heads/master@{#879887}
  • Loading branch information
Xiangdong Kong authored and Chromium LUCI CQ committed May 6, 2021
1 parent 2d0d0f5 commit cf4df37
Show file tree
Hide file tree
Showing 17 changed files with 189 additions and 0 deletions.
23 changes: 23 additions & 0 deletions ash/components/os_feedback_ui/BUILD.gn
@@ -0,0 +1,23 @@
# Copyright 2021 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("//build/config/chromeos/ui_mode.gni")
import("//ui/webui/resources/tools/generate_grd.gni")

assert(is_chromeos_ash, "Non-ChromeOS builds cannot depend on //ash")

static_library("os_feedback_ui") {
sources = [
"os_feedback_ui.cc",
"os_feedback_ui.h",
"url_constants.cc",
"url_constants.h",
]

deps = [
"//ash/components/resources:os_feedback_resources",
"//content/public/browser",
"//ui/webui",
]
}
4 changes: 4 additions & 0 deletions ash/components/os_feedback_ui/DEPS
@@ -0,0 +1,4 @@
include_rules = [
"+content/public/browser",
"+ui/webui",
]
3 changes: 3 additions & 0 deletions ash/components/os_feedback_ui/DIR_METADATA
@@ -0,0 +1,3 @@
monorail {
component: "OS>Apps>Feedback"
}
1 change: 1 addition & 0 deletions ash/components/os_feedback_ui/OWNERS
@@ -0,0 +1 @@
file://components/feedback/OWNERS
44 changes: 44 additions & 0 deletions ash/components/os_feedback_ui/os_feedback_ui.cc
@@ -0,0 +1,44 @@
// Copyright 2021 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 "ash/components/os_feedback_ui/os_feedback_ui.h"

#include "ash/components/os_feedback_ui/url_constants.h"
#include "ash/grit/ash_os_feedback_resources.h"
#include "ash/grit/ash_os_feedback_resources_map.h"
#include "base/memory/ptr_util.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 "ui/webui/mojo_web_ui_controller.h"

namespace ash {

namespace {

void SetUpWebUIDataSource(content::WebUIDataSource* source,
base::span<const webui::ResourcePath> resources,
int default_resource) {
source->AddResourcePaths(resources);
source->SetDefaultResource(default_resource);
}

} // namespace

OSFeedbackUI::OSFeedbackUI(content::WebUI* web_ui)
: MojoWebUIController(web_ui) {
auto source = base::WrapUnique(
content::WebUIDataSource::Create(kChromeUIOSFeedbackHost));

const auto resources =
base::make_span(kAshOsFeedbackResources, kAshOsFeedbackResourcesSize);
SetUpWebUIDataSource(source.get(), resources, IDR_ASH_OS_FEEDBACK_INDEX_HTML);

auto* browser_context = web_ui->GetWebContents()->GetBrowserContext();
content::WebUIDataSource::Add(browser_context, source.release());
}

OSFeedbackUI::~OSFeedbackUI() = default;

} // namespace ash
26 changes: 26 additions & 0 deletions ash/components/os_feedback_ui/os_feedback_ui.h
@@ -0,0 +1,26 @@
// Copyright 2021 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 ASH_COMPONENTS_OS_FEEDBACK_UI_OS_FEEDBACK_UI_H_
#define ASH_COMPONENTS_OS_FEEDBACK_UI_OS_FEEDBACK_UI_H_

#include "ui/webui/mojo_web_ui_controller.h"

namespace content {
class WebUI;
} // namespace content

namespace ash {

class OSFeedbackUI : public ui::MojoWebUIController {
public:
explicit OSFeedbackUI(content::WebUI* web_ui);
OSFeedbackUI(const OSFeedbackUI&) = delete;
OSFeedbackUI& operator=(const OSFeedbackUI&) = delete;
~OSFeedbackUI() override;
};

} // namespace ash

#endif // ASH_COMPONENTS_OS_FEEDBACK_UI_OS_FEEDBACK_UI_H_
16 changes: 16 additions & 0 deletions ash/components/os_feedback_ui/resources/BUILD.gn
@@ -0,0 +1,16 @@
# Copyright 2021 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("//build/config/chromeos/ui_mode.gni")
import("//ui/webui/resources/tools/generate_grd.gni")

assert(is_chromeos_ash, "Non-ChromeOS builds cannot depend on //ash")

generate_grd("build_grd") {
input_files_base_dir = rebase_path(".", "//")
input_files = [ "index.html" ]
manifest_files = []
grd_prefix = "ash_os_feedback"
out_grd = "$target_gen_dir/${grd_prefix}_resources.grd"
}
15 changes: 15 additions & 0 deletions ash/components/os_feedback_ui/resources/index.html
@@ -0,0 +1,15 @@
<!-- Copyright 2021 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. -->
<!doctype html>
<html dir="$i18n{textdirection}" lang="$i18n{language}">

<head>
<meta charset="utf-8">
</head>

<body>
<div>Hello, World!</div>
</body>

</html>
11 changes: 11 additions & 0 deletions ash/components/os_feedback_ui/url_constants.cc
@@ -0,0 +1,11 @@
// Copyright 2021 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 "ash/components/os_feedback_ui/url_constants.h"

namespace ash {

const char kChromeUIOSFeedbackHost[] = "os-feedback";

} // namespace ash
14 changes: 14 additions & 0 deletions ash/components/os_feedback_ui/url_constants.h
@@ -0,0 +1,14 @@
// Copyright 2021 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 ASH_COMPONENTS_OS_FEEDBACK_UI_URL_CONSTANTS_H_
#define ASH_COMPONENTS_OS_FEEDBACK_UI_URL_CONSTANTS_H_

namespace ash {

extern const char kChromeUIOSFeedbackHost[];

} // namespace ash

#endif // ASH_COMPONENTS_OS_FEEDBACK_UI_URL_CONSTANTS_H_
17 changes: 17 additions & 0 deletions ash/components/resources/BUILD.gn
Expand Up @@ -6,6 +6,23 @@ import("//tools/grit/grit_rule.gni")

assert(is_chromeos_ash, "Non-ChromeOS builds cannot depend on //ash")

# Resources used by chrome://os-feedback
grit("os_feedback_resources") {
# These arguments are needed since the grd is generated at build time.
enable_input_discovery_for_gn_analyze = false
os_feedback_gen_dir = "$root_gen_dir/ash/components/os_feedback_ui/resources"
source = "$os_feedback_gen_dir/ash_os_feedback_resources.grd"
deps = [ "//ash/components/os_feedback_ui/resources:build_grd" ]

outputs = [
"grit/ash_os_feedback_resources.h",
"grit/ash_os_feedback_resources_map.cc",
"grit/ash_os_feedback_resources_map.h",
"ash_os_feedback_resources.pak",
]
output_dir = "$root_gen_dir/ash"
}

grit("scanning_app_resources") {
source = "../../content/scanning/resources/scanning_app_resources.grd"

Expand Down
1 change: 1 addition & 0 deletions chrome/browser/ui/BUILD.gn
Expand Up @@ -2646,6 +2646,7 @@ static_library("ui") {
"//ash/assistant/util",
"//ash/components/account_manager",
"//ash/components/audio",
"//ash/components/os_feedback_ui",
"//ash/components/pcie_peripheral",
"//ash/constants",
"//ash/content/scanning",
Expand Down
1 change: 1 addition & 0 deletions chrome/browser/ui/webui/DEPS
@@ -1,6 +1,7 @@
include_rules = [
"+ash/components/account_manager",
"+ash/components/audio",
"+ash/components/os_feedback_ui",
"+components/services/app_service/public",
"+device/bluetooth",
"+extensions/strings/grit/extensions_strings.h",
Expand Down
6 changes: 6 additions & 0 deletions chrome/browser/ui/webui/chrome_web_ui_controller_factory.cc
Expand Up @@ -148,6 +148,8 @@
#endif // defined(OS_ANDROID)

#if BUILDFLAG(IS_CHROMEOS_ASH)
#include "ash/components/os_feedback_ui/os_feedback_ui.h"
#include "ash/components/os_feedback_ui/url_constants.h"
#include "ash/constants/ash_features.h"
#include "ash/constants/ash_switches.h"
#include "ash/content/scanning/scanning_ui.h"
Expand Down Expand Up @@ -710,6 +712,10 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<ConflictsUI>;
#endif
#if BUILDFLAG(IS_CHROMEOS_ASH)
if (base::FeatureList::IsEnabled(ash::features::kOsFeedback)) {
if (url.host_piece() == ash::kChromeUIOSFeedbackHost)
return &NewWebUI<ash::OSFeedbackUI>;
}
if (url.host_piece() == chrome::kChromeUIPasswordChangeHost) {
if (!profile->GetPrefs()->GetBoolean(
chromeos::prefs::kSamlInSessionPasswordChangeEnabled)) {
Expand Down
1 change: 1 addition & 0 deletions chrome/browser/web_applications/BUILD.gn
Expand Up @@ -109,6 +109,7 @@ source_set("web_applications") {

if (is_chromeos_ash) {
deps += [
"//ash/components/os_feedback_ui",
"//ash/constants",
"//ash/content/shimless_rma",
"//ash/content/shortcut_customization_ui",
Expand Down
2 changes: 2 additions & 0 deletions chrome/chrome_paks.gni
Expand Up @@ -183,6 +183,7 @@ template("chrome_extra_paks") {
}
if (is_chromeos_ash) {
sources += [
"$root_gen_dir/ash/ash_os_feedback_resources.pak",
"$root_gen_dir/ash/ash_scanning_app_resources.pak",
"$root_gen_dir/ash/ash_shimless_rma_resources.pak",
"$root_gen_dir/ash/ash_shortcut_customization_app_resources.pak",
Expand Down Expand Up @@ -216,6 +217,7 @@ template("chrome_extra_paks") {
"$root_gen_dir/ui/file_manager/file_manager_resources.pak",
]
deps += [
"//ash/components/resources:os_feedback_resources",
"//ash/components/resources:scanning_app_resources",
"//ash/components/resources:shimless_rma_resources",
"//ash/components/resources:shortcut_customization_app_resources",
Expand Down
4 changes: 4 additions & 0 deletions tools/gritsettings/resource_ids.spec
Expand Up @@ -604,6 +604,10 @@
"ash/ash_strings.grd": {
"messages": [3060],
},
"<(SHARED_INTERMEDIATE_DIR)/ash/components/os_feedback_ui/resources/ash_os_feedback_resources.grd": {
"META": {"sizes": {"includes": [50],}},
"includes": [3064],
},
"<(SHARED_INTERMEDIATE_DIR)/ash/content/shortcut_customization_ui/resources/ash_shortcut_customization_app_resources.grd": {
"META": {"sizes": {"includes": [200],}},
"includes": [3070],
Expand Down

0 comments on commit cf4df37

Please sign in to comment.