Commit 5c669943 authored by Giovanni Ortuño Urquidi's avatar Giovanni Ortuño Urquidi Committed by Chromium LUCI CQ

terminal: Move the URLDataSource creation of Terminal to a WebUIController

Adds a WebUIConfig and a UntrustedWebUIController for Terminal.

Bug: 1080384
Change-Id: If43a0b9f778ad6bedf35f2e484627c8fa41ac321
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2592246
Commit-Queue: Giovanni Ortuño Urquidi <ortuno@chromium.org>
Reviewed-by: default avatarJoel Hockey <joelhockey@chromium.org>
Reviewed-by: default avatarcalamity <calamity@chromium.org>
Cr-Commit-Position: refs/heads/master@{#838600}
parent 5fe0ddee
...@@ -2929,6 +2929,8 @@ source_set("chromeos") { ...@@ -2929,6 +2929,8 @@ source_set("chromeos") {
"web_applications/terminal_source.h", "web_applications/terminal_source.h",
"web_applications/terminal_system_web_app_info.cc", "web_applications/terminal_system_web_app_info.cc",
"web_applications/terminal_system_web_app_info.h", "web_applications/terminal_system_web_app_info.h",
"web_applications/terminal_ui.cc",
"web_applications/terminal_ui.h",
"wilco_dtc_supportd/fake_wilco_dtc_supportd_client.cc", "wilco_dtc_supportd/fake_wilco_dtc_supportd_client.cc",
"wilco_dtc_supportd/fake_wilco_dtc_supportd_client.h", "wilco_dtc_supportd/fake_wilco_dtc_supportd_client.h",
"wilco_dtc_supportd/wilco_dtc_supportd_bridge.cc", "wilco_dtc_supportd/wilco_dtc_supportd_bridge.cc",
......
...@@ -8,6 +8,6 @@ per-file chrome_help_app*=carpenterr@chromium.org ...@@ -8,6 +8,6 @@ per-file chrome_help_app*=carpenterr@chromium.org
per-file chrome_file_manager*=file://chromeos/components/file_manager/OWNERS per-file chrome_file_manager*=file://chromeos/components/file_manager/OWNERS
per-file file_manager*=file://chromeos/components/file_manager/OWNERS per-file file_manager*=file://chromeos/components/file_manager/OWNERS
per-file *media_app*=file://chromeos/components/media_app_ui/OWNERS per-file *media_app*=file://chromeos/components/media_app_ui/OWNERS
per-file terminal_source*=calamity@chromium.org per-file terminal*=calamity@chromium.org
per-file terminal_source*=joelhockey@chromium.org per-file terminal*=joelhockey@chromium.org
per-file default_web_app_ids.h=jshikaram@chromium.org per-file default_web_app_ids.h=jshikaram@chromium.org
// Copyright 2020 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 "chrome/browser/chromeos/web_applications/terminal_ui.h"
#include "chrome/browser/chromeos/web_applications/terminal_source.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/webui_url_constants.h"
#include "content/public/common/url_constants.h"
#include "url/gurl.h"
TerminalUIConfig::TerminalUIConfig()
: WebUIConfig(content::kChromeUIUntrustedScheme,
chrome::kChromeUIUntrustedTerminalHost) {}
TerminalUIConfig::~TerminalUIConfig() = default;
std::unique_ptr<content::WebUIController>
TerminalUIConfig::CreateWebUIController(content::WebUI* web_ui) {
return std::make_unique<TerminalUI>(web_ui);
}
TerminalUI::TerminalUI(content::WebUI* web_ui)
: ui::UntrustedWebUIController(web_ui) {
auto* profile = Profile::FromWebUI(web_ui);
content::URLDataSource::Add(profile, TerminalSource::ForTerminal(profile));
}
TerminalUI::~TerminalUI() = default;
// Copyright 2020 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 CHROME_BROWSER_CHROMEOS_WEB_APPLICATIONS_TERMINAL_UI_H_
#define CHROME_BROWSER_CHROMEOS_WEB_APPLICATIONS_TERMINAL_UI_H_
#include "ui/webui/untrusted_web_ui_controller.h"
#include "ui/webui/webui_config.h"
namespace content {
class WebUI;
} // namespace content
class TerminalUIConfig : public ui::WebUIConfig {
public:
TerminalUIConfig();
~TerminalUIConfig() override;
std::unique_ptr<content::WebUIController> CreateWebUIController(
content::WebUI* web_ui) override;
};
class TerminalUI : public ui::UntrustedWebUIController {
public:
explicit TerminalUI(content::WebUI* web_ui);
TerminalUI(const TerminalUI&) = delete;
TerminalUI& operator=(const TerminalUI&) = delete;
~TerminalUI() override;
};
#endif // CHROME_BROWSER_CHROMEOS_WEB_APPLICATIONS_TERMINAL_UI_H_
...@@ -13,9 +13,12 @@ ...@@ -13,9 +13,12 @@
#include "ui/webui/webui_config.h" #include "ui/webui/webui_config.h"
#include "url/gurl.h" #include "url/gurl.h"
#if BUILDFLAG(IS_CHROMEOS_ASH) && !defined(OFFICIAL_BUILD) #if BUILDFLAG(IS_CHROMEOS_ASH)
#include "chrome/browser/chromeos/web_applications/terminal_ui.h"
#if !defined(OFFICIAL_BUILD)
#include "chromeos/components/sample_system_web_app_ui/untrusted_sample_system_web_app_ui.h" #include "chromeos/components/sample_system_web_app_ui/untrusted_sample_system_web_app_ui.h"
#endif #endif // !defined(OFFICIAL_BUILD)
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
using WebUIConfigList = using WebUIConfigList =
std::vector<std::pair<std::string, std::unique_ptr<ui::WebUIConfig>>>; std::vector<std::pair<std::string, std::unique_ptr<ui::WebUIConfig>>>;
...@@ -38,10 +41,13 @@ WebUIConfigList CreateConfigs() { ...@@ -38,10 +41,13 @@ WebUIConfigList CreateConfigs() {
ALLOW_UNUSED_LOCAL(register_config); ALLOW_UNUSED_LOCAL(register_config);
// Register WebUIConfigs below. // Register WebUIConfigs below.
#if BUILDFLAG(IS_CHROMEOS_ASH) && !defined(OFFICIAL_BUILD) #if BUILDFLAG(IS_CHROMEOS_ASH)
register_config(std::make_unique<TerminalUIConfig>());
#if !defined(OFFICIAL_BUILD)
register_config( register_config(
std::make_unique<chromeos::UntrustedSampleSystemWebAppUIConfig>()); std::make_unique<chromeos::UntrustedSampleSystemWebAppUIConfig>());
#endif #endif // !defined(OFFICIAL_BUILD)
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
return config_list; return config_list;
} }
......
...@@ -58,7 +58,6 @@ ...@@ -58,7 +58,6 @@
#include "chrome/browser/chromeos/web_applications/os_settings_web_app_info.h" #include "chrome/browser/chromeos/web_applications/os_settings_web_app_info.h"
#include "chrome/browser/chromeos/web_applications/print_management_web_app_info.h" #include "chrome/browser/chromeos/web_applications/print_management_web_app_info.h"
#include "chrome/browser/chromeos/web_applications/scanning_system_web_app_info.h" #include "chrome/browser/chromeos/web_applications/scanning_system_web_app_info.h"
#include "chrome/browser/chromeos/web_applications/terminal_source.h"
#include "chrome/browser/chromeos/web_applications/terminal_system_web_app_info.h" #include "chrome/browser/chromeos/web_applications/terminal_system_web_app_info.h"
#include "chrome/browser/web_applications/components/web_app_id_constants.h" #include "chrome/browser/web_applications/components/web_app_id_constants.h"
#include "chromeos/components/camera_app_ui/url_constants.h" #include "chromeos/components/camera_app_ui/url_constants.h"
...@@ -458,15 +457,6 @@ void SystemWebAppManager::Start() { ...@@ -458,15 +457,6 @@ void SystemWebAppManager::Start() {
// trial names. Ideally, construct them from some static const char*. // trial names. Ideally, construct them from some static const char*.
#endif // DCHECK_IS_ON() #endif // DCHECK_IS_ON()
#if BUILDFLAG(IS_CHROMEOS_ASH)
// Set up terminal data source. Terminal source is needed for install.
// TODO(crbug.com/1080384): Move once chrome-untrusted has WebUIControllers.
if (SystemWebAppManager::IsAppEnabled(SystemAppType::TERMINAL)) {
content::URLDataSource::Add(profile_,
TerminalSource::ForTerminal(profile_));
}
#endif // BUILDFLAG(IS_CHROMEOS_ASH)
std::vector<ExternalInstallOptions> install_options_list; std::vector<ExternalInstallOptions> install_options_list;
const bool should_force_install_apps = ShouldForceInstallApps(); const bool should_force_install_apps = ShouldForceInstallApps();
if (should_force_install_apps) { if (should_force_install_apps) {
......
...@@ -289,6 +289,7 @@ const char kChromeUISmbCredentialsHost[] = "smb-credentials-dialog"; ...@@ -289,6 +289,7 @@ const char kChromeUISmbCredentialsHost[] = "smb-credentials-dialog";
const char kChromeUISmbCredentialsURL[] = "chrome://smb-credentials-dialog/"; const char kChromeUISmbCredentialsURL[] = "chrome://smb-credentials-dialog/";
const char kChromeUISysInternalsHost[] = "sys-internals"; const char kChromeUISysInternalsHost[] = "sys-internals";
const char kChromeUIUntrustedCroshURL[] = "chrome-untrusted://crosh/"; const char kChromeUIUntrustedCroshURL[] = "chrome-untrusted://crosh/";
const char kChromeUIUntrustedTerminalHost[] = "terminal";
const char kChromeUIUntrustedTerminalURL[] = "chrome-untrusted://terminal/"; const char kChromeUIUntrustedTerminalURL[] = "chrome-untrusted://terminal/";
const char kChromeUIUserImageHost[] = "userimage"; const char kChromeUIUserImageHost[] = "userimage";
const char kChromeUIUserImageURL[] = "chrome://userimage/"; const char kChromeUIUserImageURL[] = "chrome://userimage/";
......
...@@ -281,6 +281,7 @@ extern const char kChromeUISmbShareHost[]; ...@@ -281,6 +281,7 @@ extern const char kChromeUISmbShareHost[];
extern const char kChromeUISmbShareURL[]; extern const char kChromeUISmbShareURL[];
extern const char kChromeUISysInternalsHost[]; extern const char kChromeUISysInternalsHost[];
extern const char kChromeUIUntrustedCroshURL[]; extern const char kChromeUIUntrustedCroshURL[];
extern const char kChromeUIUntrustedTerminalHost[];
extern const char kChromeUIUntrustedTerminalURL[]; extern const char kChromeUIUntrustedTerminalURL[];
extern const char kChromeUIUrgentPasswordExpiryNotificationHost[]; extern const char kChromeUIUrgentPasswordExpiryNotificationHost[];
extern const char kChromeUIUrgentPasswordExpiryNotificationUrl[]; extern const char kChromeUIUrgentPasswordExpiryNotificationUrl[];
......
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