Commit dccf70a9 authored by Joel Hockey's avatar Joel Hockey Committed by Commit Bot

Add crostini::GetTerminalId function

GetTerminalId returns old terminal, or Terminal System
App if feature is on.

Launches System App when LaunchCrostiniApp is called with
Terminal System App ID.

Bug: 1019021
Change-Id: I2420e2f3ca5bcc423ee5ea991f4301b86d1b965d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1925831Reviewed-by: default avatarTimothy Loh <timloh@chromium.org>
Commit-Queue: Joel Hockey <joelhockey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#716946}
parent 239ef678
...@@ -11,6 +11,7 @@ ...@@ -11,6 +11,7 @@
#include "base/feature_list.h" #include "base/feature_list.h"
#include "base/files/file_path.h" #include "base/files/file_path.h"
#include "base/metrics/histogram_functions.h" #include "base/metrics/histogram_functions.h"
#include "base/no_destructor.h"
#include "base/strings/strcat.h" #include "base/strings/strcat.h"
#include "base/task/post_task.h" #include "base/task/post_task.h"
#include "base/timer/timer.h" #include "base/timer/timer.h"
...@@ -34,6 +35,8 @@ ...@@ -34,6 +35,8 @@
#include "chrome/browser/ui/ash/launcher/shelf_spinner_item_controller.h" #include "chrome/browser/ui/ash/launcher/shelf_spinner_item_controller.h"
#include "chrome/browser/ui/browser.h" #include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_window.h" #include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/web_applications/system_web_app_ui_utils.h"
#include "chrome/browser/web_applications/system_web_app_manager.h"
#include "chrome/common/chrome_features.h" #include "chrome/common/chrome_features.h"
#include "chrome/grit/generated_resources.h" #include "chrome/grit/generated_resources.h"
#include "chromeos/constants/chromeos_features.h" #include "chromeos/constants/chromeos_features.h"
...@@ -288,7 +291,7 @@ std::ostream& operator<<(std::ostream& ostream, ...@@ -288,7 +291,7 @@ std::ostream& operator<<(std::ostream& ostream,
bool IsUninstallable(Profile* profile, const std::string& app_id) { bool IsUninstallable(Profile* profile, const std::string& app_id) {
if (!CrostiniFeatures::Get()->IsEnabled(profile) || if (!CrostiniFeatures::Get()->IsEnabled(profile) ||
app_id == kCrostiniTerminalId) { app_id == GetTerminalId()) {
return false; return false;
} }
CrostiniRegistryService* registry_service = CrostiniRegistryService* registry_service =
...@@ -360,7 +363,7 @@ void LaunchCrostiniApp(Profile* profile, ...@@ -360,7 +363,7 @@ void LaunchCrostiniApp(Profile* profile,
base::OnceClosure launch_closure; base::OnceClosure launch_closure;
Browser* browser = nullptr; Browser* browser = nullptr;
if (app_id == kCrostiniTerminalId) { if (app_id == GetTerminalId()) {
DCHECK(files.empty()); DCHECK(files.empty());
RecordAppLaunchHistogram(CrostiniAppLaunchAppType::kTerminal); RecordAppLaunchHistogram(CrostiniAppLaunchAppType::kTerminal);
...@@ -373,6 +376,13 @@ void LaunchCrostiniApp(Profile* profile, ...@@ -373,6 +376,13 @@ void LaunchCrostiniApp(Profile* profile,
GURL vsh_in_crosh_url = GenerateVshInCroshUrl( GURL vsh_in_crosh_url = GenerateVshInCroshUrl(
profile, vm_name, container_name, std::vector<std::string>()); profile, vm_name, container_name, std::vector<std::string>());
if (base::FeatureList::IsEnabled(features::kTerminalSystemApp)) {
web_app::LaunchSystemWebApp(profile, web_app::SystemAppType::TERMINAL,
vsh_in_crosh_url);
return;
}
apps::AppLaunchParams launch_params = GenerateTerminalAppLaunchParams(); apps::AppLaunchParams launch_params = GenerateTerminalAppLaunchParams();
// Create the terminal here so it's created in the right display. If the // Create the terminal here so it's created in the right display. If the
// browser creation is delayed into the callback the root window for new // browser creation is delayed into the callback the root window for new
...@@ -501,4 +511,13 @@ base::string16 GetTimeRemainingMessage(base::TimeTicks start, int percent) { ...@@ -501,4 +511,13 @@ base::string16 GetTimeRemainingMessage(base::TimeTicks start, int percent) {
} }
} }
const std::string& GetTerminalId() {
static const base::NoDestructor<std::string> app_id([] {
return base::FeatureList::IsEnabled(features::kTerminalSystemApp)
? kCrostiniTerminalSystemAppId
: kCrostiniTerminalId;
}());
return *app_id;
}
} // namespace crostini } // namespace crostini
...@@ -153,9 +153,14 @@ void CloseCrostiniUpdateFilesystemView(); ...@@ -153,9 +153,14 @@ void CloseCrostiniUpdateFilesystemView();
// applying an Ansible playbook in the container). // applying an Ansible playbook in the container).
void ShowCrostiniAnsibleSoftwareConfigView(Profile* profile); void ShowCrostiniAnsibleSoftwareConfigView(Profile* profile);
const std::string& GetTerminalId();
// We use an arbitrary well-formed extension id for the Terminal app, this // We use an arbitrary well-formed extension id for the Terminal app, this
// is equal to GenerateId("Terminal"). // is equal to GenerateId("Terminal").
constexpr char kCrostiniTerminalId[] = "oajcgpnkmhaalajejhlfpacbiokdnnfe"; constexpr char kCrostiniTerminalId[] = "oajcgpnkmhaalajejhlfpacbiokdnnfe";
// web_app::GenerateAppIdFromURL("chrome://terminal/html/terminal.html")
constexpr char kCrostiniTerminalSystemAppId[] =
"oapmgeobaaddjmlgbbjbdhapidbomlgg";
constexpr char kCrostiniDefaultVmName[] = "termina"; constexpr char kCrostiniDefaultVmName[] = "termina";
constexpr char kCrostiniDefaultContainerName[] = "penguin"; constexpr char kCrostiniDefaultContainerName[] = "penguin";
......
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