Commit 921f3569 authored by Joel Hockey's avatar Joel Hockey Committed by Chromium LUCI CQ

crosh: stick to chrome-untrusted://crosh

Only use the builtin chrome-untrusted://crosh for Ctrl+Alt+T shortcut
rather than allowing Secure Shell App to override.

Users can still manually use Secure Shell urls such as
chrome-extension://okddffdblfhhnmhodogpojmfkjmhinfp/html/crosh.html

Bug: None
Change-Id: I87743b662527ef8e42e27318dea47c407a951963
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2574639Reviewed-by: default avatarJason Lin <lxj@google.com>
Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Reviewed-by: default avatarMike Frysinger <vapier@chromium.org>
Reviewed-by: default avatarBen Wells <benwells@chromium.org>
Commit-Queue: Joel Hockey <joelhockey@chromium.org>
Cr-Commit-Position: refs/heads/master@{#834515}
parent 8d72e7d4
......@@ -13,7 +13,6 @@
#include "chrome/browser/apps/app_service/app_launch_params.h"
#include "chrome/browser/chromeos/crostini/crostini_pref_names.h"
#include "chrome/browser/chromeos/crostini/crostini_util.h"
#include "chrome/browser/extensions/api/terminal/terminal_extension_helper.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/ui/ash/window_properties.h"
#include "chrome/browser/ui/browser.h"
......
......@@ -997,8 +997,6 @@ static_library("extensions") {
"api/tabs/tabs_util_chromeos.cc",
"api/terminal/crostini_startup_status.cc",
"api/terminal/crostini_startup_status.h",
"api/terminal/terminal_extension_helper.cc",
"api/terminal/terminal_extension_helper.h",
"api/terminal/terminal_private_api.cc",
"api/terminal/terminal_private_api.h",
"api/virtual_keyboard_private/chrome_virtual_keyboard_delegate.cc",
......
// Copyright (c) 2012 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/extensions/api/terminal/terminal_extension_helper.h"
#include <stddef.h>
#include "base/stl_util.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/extension_constants.h"
#include "chrome/common/webui_url_constants.h"
#include "extensions/browser/extension_registry.h"
#include "extensions/common/extension.h"
namespace extensions {
namespace {
const char kCroshExtensionEntryPoint[] = "/html/crosh.html";
} // namespace
const Extension* TerminalExtensionHelper::GetTerminalExtension(
Profile* profile) {
// Search order for terminal extensions: nassh-dev, then nassh.
static const char* const kPossibleAppIds[] = {
extension_misc::kHTermDevAppId,
extension_misc::kHTermAppId,
};
// The nassh-dev should be first in the list.
DCHECK_EQ(kPossibleAppIds[0], extension_misc::kHTermDevAppId);
const ExtensionSet& extensions =
ExtensionRegistry::Get(profile)->enabled_extensions();
for (size_t i = 0; i < base::size(kPossibleAppIds); ++i) {
const extensions::Extension* extension =
extensions.GetByID(kPossibleAppIds[i]);
if (extension)
return extension;
}
return nullptr;
}
GURL TerminalExtensionHelper::GetCroshURL(Profile* profile) {
// chrome-untrusted://crosh by default.
GURL url(chrome::kChromeUIUntrustedCroshURL);
const extensions::Extension* extension = GetTerminalExtension(profile);
// Allow nassh-dev or nassh to override.
if (extension) {
url = extension->GetResourceURL(kCroshExtensionEntryPoint);
}
return url;
}
} // namespace extensions
// Copyright (c) 2012 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_EXTENSIONS_API_TERMINAL_TERMINAL_EXTENSION_HELPER_H_
#define CHROME_BROWSER_EXTENSIONS_API_TERMINAL_TERMINAL_EXTENSION_HELPER_H_
#include <string>
#include "url/gurl.h"
class Profile;
namespace extensions {
class Extension;
class TerminalExtensionHelper {
public:
// Returns the crosh extension. It is the first found out of:
// 1. nassh-dev : okddffdblfhhnmhodogpojmfkjmhinfp
// 2. nassh : pnhechapfaindjhompbnflcldabbghjo
static const Extension* GetTerminalExtension(Profile* profile);
// Returns crosh URL. chrome-untrusted://crosh is used by default, but it can
// be overridden by nassh-dev or nassh.
static GURL GetCroshURL(Profile* profile);
};
} // namespace extensions
#endif // CHROME_BROWSER_EXTENSIONS_API_TERMINAL_TERMINAL_EXTENSION_HELPER_H_
......@@ -28,7 +28,6 @@
#include "chrome/browser/chromeos/crostini/crostini_terminal.h"
#include "chrome/browser/chromeos/crostini/crostini_util.h"
#include "chrome/browser/extensions/api/terminal/crostini_startup_status.h"
#include "chrome/browser/extensions/api/terminal/terminal_extension_helper.h"
#include "chrome/browser/extensions/extension_service.h"
#include "chrome/browser/extensions/extension_tab_util.h"
#include "chrome/common/chrome_switches.h"
......
......@@ -27,7 +27,6 @@
#include "chrome/browser/chromeos/file_manager/path_util.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/chromeos/web_applications/chrome_camera_app_ui_delegate.h"
#include "chrome/browser/extensions/api/terminal/terminal_extension_helper.h"
#include "chrome/browser/extensions/extension_util.h"
#include "chrome/browser/prefs/incognito_mode_prefs.h"
#include "chrome/browser/profiles/profile_manager.h"
......@@ -416,14 +415,12 @@ void ChromeNewWindowClient::OpenDownloadsFolder() {
void ChromeNewWindowClient::OpenCrosh() {
Profile* profile = ProfileManager::GetActiveUserProfile();
GURL crosh_url = extensions::TerminalExtensionHelper::GetCroshURL(profile);
if (!crosh_url.is_valid())
return;
chrome::ScopedTabbedBrowserDisplayer displayer(profile);
Browser* browser = displayer.browser();
content::WebContents* page = browser->OpenURL(content::OpenURLParams(
crosh_url, content::Referrer(), WindowOpenDisposition::NEW_FOREGROUND_TAB,
ui::PAGE_TRANSITION_GENERATED, false));
GURL(chrome::kChromeUIUntrustedCroshURL), content::Referrer(),
WindowOpenDisposition::NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_GENERATED,
false));
browser->window()->Show();
browser->window()->Activate();
page->Focus();
......
......@@ -38,8 +38,6 @@ const char kGooglePlayMusicAppId[] = "icppfcnhkcmnfdhfhphakoifcfokfdhg";
const char kGooglePlusAppId[] = "dlppkpafhbajpcmmoheippocdidnckmm";
const char kGoogleSheetsAppId[] = "felcaaldnbdncclmgdcncolpebgiejap";
const char kGoogleSlidesAppId[] = "aapocclcgogkmnckokdopfmhonfmgoek";
const char kHTermAppId[] = "pnhechapfaindjhompbnflcldabbghjo";
const char kHTermDevAppId[] = "okddffdblfhhnmhodogpojmfkjmhinfp";
const char kIdentityApiUiAppId[] = "ahjaciijnoiaklcomgnblndopackapon";
const char kTextEditorAppId[] = "mmfbcljfglbokpmkimbfghdkjmjhdgbg";
const char kInAppPaymentsSupportAppId[] = "nmmhkkegccagdldgiimedpiccmgmieda";
......@@ -63,8 +61,6 @@ const char* const kBuiltInFirstPartyExtensionIds[] = {
kGooglePlusAppId,
kGoogleSheetsAppId,
kGoogleSlidesAppId,
kHTermAppId,
kHTermDevAppId,
kIdentityApiUiAppId,
kTextEditorAppId,
kInAppPaymentsSupportAppId,
......
......@@ -79,12 +79,6 @@ extern const char kGoogleSheetsAppId[];
// The extension id of the Google Slides application.
extern const char kGoogleSlidesAppId[];
// The extension id of the HTerm app for ChromeOS.
extern const char kHTermAppId[];
// The extension id of the HTerm dev app for ChromeOS.
extern const char kHTermDevAppId[];
// The extension id of the Identity API UI application.
extern const char kIdentityApiUiAppId[];
......
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