Commit 44a495d7 authored by Jason Lin's avatar Jason Lin Committed by Commit Bot

crostini: migrate terminal SWA to chrome-untrusted://

Bug: 1055647
Change-Id: I4840e626bcb2882ada6524416849bc7c1c6a8657
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2077318Reviewed-by: default avatarBen Wells <benwells@chromium.org>
Reviewed-by: default avatarcalamity <calamity@chromium.org>
Reviewed-by: default avatarGiovanni Ortuño Urquidi <ortuno@chromium.org>
Reviewed-by: default avatarJoel Hockey <joelhockey@chromium.org>
Commit-Queue: Jason Lin <lxj@google.com>
Cr-Commit-Position: refs/heads/master@{#747048}
parent 02c231f7
......@@ -2346,6 +2346,8 @@ source_set("chromeos") {
"web_applications/chrome_help_app_ui_delegate.h",
"web_applications/chrome_media_app_ui_delegate.cc",
"web_applications/chrome_media_app_ui_delegate.h",
"web_applications/terminal_source.cc",
"web_applications/terminal_source.h",
"wilco_dtc_supportd/fake_wilco_dtc_supportd_client.cc",
"wilco_dtc_supportd/fake_wilco_dtc_supportd_client.h",
"wilco_dtc_supportd/mojo_utils.cc",
......
......@@ -7,6 +7,7 @@
#include "base/containers/flat_map.h"
#include "base/metrics/histogram_functions.h"
#include "base/no_destructor.h"
#include "base/strings/strcat.h"
#include "base/strings/string_util.h"
#include "base/values.h"
#include "chrome/browser/apps/app_service/app_launch_params.h"
......@@ -42,7 +43,8 @@ GURL GenerateVshInCroshUrl(Profile* profile,
const std::string& container_name,
const std::vector<std::string>& terminal_args) {
std::string vsh_crosh =
std::string(chrome::kChromeUITerminalURL) + "html/terminal.html";
base::StrCat({std::string(chrome::kChromeUIUntrustedTerminalURL),
"html/terminal.html"});
if (!base::FeatureList::IsEnabled(features::kTerminalSystemApp)) {
vsh_crosh =
extensions::TerminalExtensionHelper::GetCroshURL(profile).spec();
......@@ -135,7 +137,9 @@ void LaunchTerminalSettings(Profile* profile, gfx::Point window_origin) {
web_app::LaunchSystemWebApp(
profile, web_app::SystemAppType::TERMINAL,
GURL(std::string(chrome::kChromeUITerminalURL) + path), *params);
GURL(base::StrCat(
{std::string(chrome::kChromeUIUntrustedTerminalURL), path})),
*params);
}
void RecordTerminalSettingsChangesUMAs(Profile* profile) {
......
......@@ -181,9 +181,10 @@ const std::string& GetDeletedTerminalId();
// We use an arbitrary well-formed extension id for the Terminal app, this
// is equal to GenerateId("Terminal").
constexpr char kCrostiniTerminalId[] = "oajcgpnkmhaalajejhlfpacbiokdnnfe";
// web_app::GenerateAppIdFromURL("chrome://terminal/html/terminal.html")
// web_app::GenerateAppIdFromURL(
// GURL("chrome-untrusted://terminal/html/terminal.html"))
constexpr char kCrostiniTerminalSystemAppId[] =
"oapmgeobaaddjmlgbbjbdhapidbomlgg";
"fhicihalidkgcimdmhpohldehjmcabcf";
constexpr char kCrostiniDefaultVmName[] = "termina";
constexpr char kCrostiniDefaultContainerName[] = "penguin";
......
......@@ -2,7 +2,7 @@
// 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/chromeos/terminal/terminal_source.h"
#include "chrome/browser/chromeos/web_applications/terminal_source.h"
#include "base/containers/flat_map.h"
#include "base/files/file_path.h"
......@@ -87,7 +87,7 @@ TerminalSource::TerminalSource(Profile* profile) : profile_(profile) {}
TerminalSource::~TerminalSource() = default;
std::string TerminalSource::GetSource() {
return chrome::kChromeUITerminalHost;
return chrome::kChromeUIUntrustedTerminalURL;
}
#if !BUILDFLAG(OPTIMIZE_WEBUI)
......
......@@ -2,8 +2,10 @@
// 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_CHROMEOS_TERMINAL_TERMINAL_SOURCE_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_TERMINAL_TERMINAL_SOURCE_H_
// TODO(crbug.com/1057510): Move TerminalSource to chromeos/components
#ifndef CHROME_BROWSER_CHROMEOS_WEB_APPLICATIONS_TERMINAL_SOURCE_H_
#define CHROME_BROWSER_CHROMEOS_WEB_APPLICATIONS_TERMINAL_SOURCE_H_
#include <string>
......@@ -45,4 +47,4 @@ class TerminalSource : public content::URLDataSource {
DISALLOW_COPY_AND_ASSIGN(TerminalSource);
};
#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_TERMINAL_TERMINAL_SOURCE_H_
#endif // CHROME_BROWSER_CHROMEOS_WEB_APPLICATIONS_TERMINAL_SOURCE_H_
......@@ -1939,10 +1939,6 @@ jumbo_static_library("ui") {
"webui/chromeos/sys_internals/sys_internals_ui.h",
"webui/chromeos/system_web_dialog_delegate.cc",
"webui/chromeos/system_web_dialog_delegate.h",
"webui/chromeos/terminal/terminal_source.cc",
"webui/chromeos/terminal/terminal_source.h",
"webui/chromeos/terminal/terminal_ui.cc",
"webui/chromeos/terminal/terminal_ui.h",
"webui/chromeos/user_image_source.cc",
"webui/chromeos/user_image_source.h",
"webui/chromeos/video_source.cc",
......
......@@ -186,7 +186,6 @@
#include "chrome/browser/ui/webui/chromeos/smb_shares/smb_credentials_dialog.h"
#include "chrome/browser/ui/webui/chromeos/smb_shares/smb_share_dialog.h"
#include "chrome/browser/ui/webui/chromeos/sys_internals/sys_internals_ui.h"
#include "chrome/browser/ui/webui/chromeos/terminal/terminal_ui.h"
#include "chrome/browser/ui/webui/settings/chromeos/os_settings_ui.h"
#include "chrome/browser/ui/webui/signin/inline_login_ui.h"
#include "chromeos/components/help_app_ui/help_app_ui.h"
......@@ -606,8 +605,6 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
return &NewWebUI<chromeos::smb_dialog::SmbShareDialogUI>;
if (url.host_piece() == chrome::kChromeUISysInternalsHost)
return &NewWebUI<SysInternalsUI>;
if (url.host_piece() == chrome::kChromeUITerminalHost)
return &NewWebUI<TerminalUI>;
if (url.host_piece() == chrome::kChromeUIAssistantOptInHost)
return &NewWebUI<chromeos::AssistantOptInUI>;
if (url.host_piece() == chrome::kChromeUICameraHost &&
......
// Copyright 2019 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/ui/webui/chromeos/terminal/terminal_ui.h"
#include <memory>
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/webui/chromeos/terminal/terminal_source.h"
#include "content/public/browser/url_data_source.h"
TerminalUI::TerminalUI(content::WebUI* web_ui) : WebUIController(web_ui) {
Profile* profile = Profile::FromWebUI(web_ui);
content::URLDataSource::Add(profile,
std::make_unique<TerminalSource>(profile));
}
// Copyright 2019 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_UI_WEBUI_CHROMEOS_TERMINAL_TERMINAL_UI_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_TERMINAL_TERMINAL_UI_H_
#include "base/macros.h"
#include "content/public/browser/web_ui_controller.h"
class TerminalUI : public content::WebUIController {
public:
explicit TerminalUI(content::WebUI* web_ui);
private:
DISALLOW_COPY_AND_ASSIGN(TerminalUI);
};
#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_TERMINAL_TERMINAL_UI_H_
......@@ -29,12 +29,14 @@
#include "components/pref_registry/pref_registry_syncable.h"
#include "components/prefs/pref_service.h"
#include "components/version_info/version_info.h"
#include "content/public/browser/url_data_source.h"
#include "content/public/common/content_switches.h"
#include "ui/base/l10n/l10n_util.h"
#if defined(OS_CHROMEOS)
#include "ash/public/cpp/app_list/internal_app_id_constants.h"
#include "chrome/browser/chromeos/extensions/default_web_app_ids.h"
#include "chrome/browser/chromeos/web_applications/terminal_source.h"
#include "chromeos/components/help_app_ui/url_constants.h"
#include "chromeos/components/media_app_ui/url_constants.h"
#include "chromeos/constants/chromeos_features.h"
......@@ -78,7 +80,8 @@ base::flat_map<SystemAppType, SystemAppInfo> CreateSystemWebApps() {
if (SystemWebAppManager::IsAppEnabled(SystemAppType::TERMINAL)) {
infos.emplace(
SystemAppType::TERMINAL,
SystemAppInfo("Terminal", GURL("chrome://terminal/html/pwa.html")));
SystemAppInfo("Terminal",
GURL("chrome-untrusted://terminal/html/pwa.html")));
infos.at(SystemAppType::TERMINAL).single_window = false;
}
......@@ -166,11 +169,12 @@ bool SystemWebAppManager::IsAppEnabled(SystemAppType type) {
#endif // OS_CHROMEOS
}
SystemWebAppManager::SystemWebAppManager(Profile* profile)
: on_apps_synchronized_(new base::OneShotEvent()),
: profile_(profile),
on_apps_synchronized_(new base::OneShotEvent()),
install_result_per_profile_histogram_name_(
std::string(kInstallResultHistogramName) + ".Profiles." +
GetProfileCategoryForLogging(profile)),
pref_service_(profile->GetPrefs()) {
pref_service_(profile_->GetPrefs()) {
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
::switches::kTestType)) {
// Always update in tests, and return early to avoid populating with real
......@@ -206,6 +210,14 @@ void SystemWebAppManager::SetSubsystems(PendingAppManager* pending_app_manager,
void SystemWebAppManager::Start() {
const base::TimeTicks install_start_time = base::TimeTicks::Now();
#if defined(OS_CHROMEOS)
if (SystemWebAppManager::IsAppEnabled(SystemAppType::TERMINAL)) {
// We need to set up the terminal data source before installing it.
content::URLDataSource::Add(profile_,
std::make_unique<TerminalSource>(profile_));
}
#endif // defined(OS_CHROMEOS)
std::vector<ExternalInstallOptions> install_options_list;
if (IsEnabled()) {
// Skipping this will uninstall all System Apps currently installed.
......
......@@ -183,6 +183,8 @@ class SystemWebAppManager {
const std::map<GURL, InstallResultCode>& install_results,
const base::TimeDelta& install_duration) const;
Profile* profile_;
std::unique_ptr<base::OneShotEvent> on_apps_synchronized_;
bool shutting_down_ = false;
......
......@@ -748,19 +748,25 @@
"contexts": ["webui"],
"matches": [
"chrome://bookmarks/*",
"chrome://tab-strip/*",
"chrome://terminal/*"
"chrome://tab-strip/*"
]
}, {
"channel": "stable",
"contexts": ["webui_untrusted"],
"matches": [
"chrome-untrusted://terminal/*"
],
"platforms": ["chromeos"]
}],
"terminalPrivate": [{
"dependencies": ["permission:terminalPrivate"],
"contexts": ["blessed_extension"],
"platforms": ["chromeos"]
}, {
"channel": "dev",
"contexts": ["webui"],
"channel": "stable",
"contexts": ["webui_untrusted"],
"matches": [
"chrome://terminal/*"
"chrome-untrusted://terminal/*"
],
"platforms": ["chromeos"]
}],
......@@ -847,8 +853,14 @@
"contexts": ["webui"],
"matches": [
"chrome://bookmarks/*",
"chrome://tab-strip/*",
"chrome://terminal/*"
"chrome://tab-strip/*"
]
}, {
"channel": "stable",
"contexts": ["webui_untrusted"],
"matches": [
"chrome-untrusted://terminal/*"
],
"platforms": ["chromeos"]
}]
}
......@@ -266,8 +266,7 @@ const char kChromeUISmbShareURL[] = "chrome://smb-share-dialog/";
const char kChromeUISmbCredentialsHost[] = "smb-credentials-dialog";
const char kChromeUISmbCredentialsURL[] = "chrome://smb-credentials-dialog/";
const char kChromeUISysInternalsHost[] = "sys-internals";
const char kChromeUITerminalHost[] = "terminal";
const char kChromeUITerminalURL[] = "chrome://terminal/";
const char kChromeUIUntrustedTerminalURL[] = "chrome-untrusted://terminal/";
const char kChromeUIUserImageHost[] = "userimage";
const char kChromeUIUserImageURL[] = "chrome://userimage/";
const char kChromeUIUrgentPasswordExpiryNotificationHost[] =
......
......@@ -260,8 +260,7 @@ extern const char kChromeUISmbCredentialsURL[];
extern const char kChromeUISmbShareHost[];
extern const char kChromeUISmbShareURL[];
extern const char kChromeUISysInternalsHost[];
extern const char kChromeUITerminalHost[];
extern const char kChromeUITerminalURL[];
extern const char kChromeUIUntrustedTerminalURL[];
extern const char kChromeUIUrgentPasswordExpiryNotificationHost[];
extern const char kChromeUIUrgentPasswordExpiryNotificationUrl[];
extern const char kChromeUIUserImageHost[];
......
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