Commit 233c01f8 authored by Rachel Carpenter's avatar Rachel Carpenter Committed by Commit Bot

Move the new Help App untrusted context to untrusted scheme.

Previously we served the sandboxed iframe at
chrome://help-app-guest. Now the untrusted scheme is ready, using
chrome-untrusted://help-app.

Bug: b/149713277
Change-Id: If474995c39dbcce85d868535fa33effd9592d5c7
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2066373Reviewed-by: default avatarGiovanni Ortuño Urquidi <ortuno@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Reviewed-by: default avatarTrent Apted <tapted@chromium.org>
Commit-Queue: Rachel Carpenter <carpenterr@google.com>
Cr-Commit-Position: refs/heads/master@{#744077}
parent 06ce127a
...@@ -10,13 +10,13 @@ assert(is_chromeos, "Help App is Chrome OS only") ...@@ -10,13 +10,13 @@ assert(is_chromeos, "Help App is Chrome OS only")
static_library("help_app_ui") { static_library("help_app_ui") {
sources = [ sources = [
"help_app_guest_ui.cc",
"help_app_guest_ui.h",
"help_app_page_handler.cc", "help_app_page_handler.cc",
"help_app_page_handler.h", "help_app_page_handler.h",
"help_app_ui.cc", "help_app_ui.cc",
"help_app_ui.h", "help_app_ui.h",
"help_app_ui_delegate.h", "help_app_ui_delegate.h",
"help_app_untrusted_ui.cc",
"help_app_untrusted_ui.h",
"url_constants.cc", "url_constants.cc",
"url_constants.h", "url_constants.h",
] ]
...@@ -29,6 +29,7 @@ static_library("help_app_ui") { ...@@ -29,6 +29,7 @@ static_library("help_app_ui") {
"//chromeos/resources:help_app_resources", "//chromeos/resources:help_app_resources",
"//chromeos/system", "//chromeos/system",
"//content/public/browser", "//content/public/browser",
"//content/public/common",
"//mojo/public/cpp/bindings", "//mojo/public/cpp/bindings",
"//mojo/public/cpp/platform", "//mojo/public/cpp/platform",
"//ui/resources:webui_resources_grd_grit", "//ui/resources:webui_resources_grd_grit",
......
...@@ -2,6 +2,7 @@ include_rules = [ ...@@ -2,6 +2,7 @@ include_rules = [
# Do not add chrome here (use a delegate instead). # Do not add chrome here (use a delegate instead).
"+chromeos/grit/chromeos_help_app_resources.h", "+chromeos/grit/chromeos_help_app_resources.h",
"+content/public/browser", "+content/public/browser",
"+content/public/common",
"+ui/resources/grit/webui_resources.h", "+ui/resources/grit/webui_resources.h",
"+ui/webui", "+ui/webui",
] ]
...@@ -6,13 +6,14 @@ ...@@ -6,13 +6,14 @@
#include <utility> #include <utility>
#include "chromeos/components/help_app_ui/help_app_guest_ui.h"
#include "chromeos/components/help_app_ui/help_app_page_handler.h" #include "chromeos/components/help_app_ui/help_app_page_handler.h"
#include "chromeos/components/help_app_ui/help_app_untrusted_ui.h"
#include "chromeos/components/help_app_ui/url_constants.h" #include "chromeos/components/help_app_ui/url_constants.h"
#include "chromeos/grit/chromeos_help_app_resources.h" #include "chromeos/grit/chromeos_help_app_resources.h"
#include "content/public/browser/web_contents.h" #include "content/public/browser/web_contents.h"
#include "content/public/browser/web_ui.h" #include "content/public/browser/web_ui.h"
#include "content/public/browser/web_ui_data_source.h" #include "content/public/browser/web_ui_data_source.h"
#include "content/public/common/url_constants.h"
namespace chromeos { namespace chromeos {
...@@ -41,12 +42,17 @@ HelpAppUI::HelpAppUI(content::WebUI* web_ui, ...@@ -41,12 +42,17 @@ HelpAppUI::HelpAppUI(content::WebUI* web_ui,
web_ui->GetWebContents()->GetBrowserContext(); web_ui->GetWebContents()->GetBrowserContext();
content::WebUIDataSource* host_source = CreateHostDataSource(); content::WebUIDataSource* host_source = CreateHostDataSource();
content::WebUIDataSource::Add(browser_context, host_source); content::WebUIDataSource::Add(browser_context, host_source);
// We need a CSP override to use the guest origin in the host. // We need a CSP override to use the chrome-untrusted:// scheme in the host.
std::string csp = std::string("frame-src ") + kChromeUIHelpAppGuestURL + ";"; std::string csp =
std::string("frame-src ") + kChromeUIHelpAppUntrustedURL + ";";
host_source->OverrideContentSecurityPolicyChildSrc(csp); host_source->OverrideContentSecurityPolicyChildSrc(csp);
content::WebUIDataSource* guest_source = CreateHelpAppGuestDataSource(); content::WebUIDataSource* untrusted_source =
content::WebUIDataSource::Add(browser_context, guest_source); CreateHelpAppUntrustedDataSource();
content::WebUIDataSource::Add(browser_context, untrusted_source);
// Add ability to request chrome-untrusted: URLs.
web_ui->AddRequestableScheme(content::kChromeUIUntrustedScheme);
} }
HelpAppUI::~HelpAppUI() = default; HelpAppUI::~HelpAppUI() = default;
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#include "chromeos/components/help_app_ui/help_app_guest_ui.h" #include "chromeos/components/help_app_ui/help_app_untrusted_ui.h"
#include "base/system/sys_info.h" #include "base/system/sys_info.h"
#include "chromeos/components/help_app_ui/url_constants.h" #include "chromeos/components/help_app_ui/url_constants.h"
...@@ -16,9 +16,9 @@ ...@@ -16,9 +16,9 @@
namespace chromeos { namespace chromeos {
// static // static
content::WebUIDataSource* CreateHelpAppGuestDataSource() { content::WebUIDataSource* CreateHelpAppUntrustedDataSource() {
content::WebUIDataSource* source = content::WebUIDataSource* source =
content::WebUIDataSource::Create(kChromeUIHelpAppGuestHost); content::WebUIDataSource::Create(kChromeUIHelpAppUntrustedURL);
source->AddResourcePath("app.html", IDR_HELP_APP_APP_HTML); source->AddResourcePath("app.html", IDR_HELP_APP_APP_HTML);
source->AddResourcePath("app_bin.js", IDR_HELP_APP_APP_BIN_JS); source->AddResourcePath("app_bin.js", IDR_HELP_APP_APP_BIN_JS);
source->AddResourcePath("load_time_data.js", IDR_WEBUI_JS_LOAD_TIME_DATA); source->AddResourcePath("load_time_data.js", IDR_WEBUI_JS_LOAD_TIME_DATA);
...@@ -40,8 +40,7 @@ content::WebUIDataSource* CreateHelpAppGuestDataSource() { ...@@ -40,8 +40,7 @@ content::WebUIDataSource* CreateHelpAppGuestDataSource() {
source->AddString("customizationId", customization_id); source->AddString("customizationId", customization_id);
source->UseStringsJs(); source->UseStringsJs();
// TODO(crbug.com/1023700): Better solution before launch. source->AddFrameAncestor(GURL(kChromeUIHelpAppURL));
source->DisableDenyXFrameOptions();
return source; return source;
} }
......
// Copyright 2019 The Chromium Authors. All rights reserved. // Copyright 2020 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be // Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file. // found in the LICENSE file.
#ifndef CHROMEOS_COMPONENTS_HELP_APP_UI_HELP_APP_GUEST_UI_H_ #ifndef CHROMEOS_COMPONENTS_HELP_APP_UI_HELP_APP_UNTRUSTED_UI_H_
#define CHROMEOS_COMPONENTS_HELP_APP_UI_HELP_APP_GUEST_UI_H_ #define CHROMEOS_COMPONENTS_HELP_APP_UI_HELP_APP_UNTRUSTED_UI_H_
namespace content { namespace content {
class WebUIDataSource; class WebUIDataSource;
} }
namespace chromeos { namespace chromeos {
// The data source creation for chrome://help-app-guest. // The data source creation for chrome-untrusted://help-app.
content::WebUIDataSource* CreateHelpAppGuestDataSource(); content::WebUIDataSource* CreateHelpAppUntrustedDataSource();
} // namespace chromeos } // namespace chromeos
#endif // CHROMEOS_COMPONENTS_HELP_APP_UI_HELP_APP_GUEST_UI_H_ #endif // CHROMEOS_COMPONENTS_HELP_APP_UI_HELP_APP_UNTRUSTED_UI_H_
...@@ -23,4 +23,4 @@ ...@@ -23,4 +23,4 @@
<script src="chrome://resources/mojo/mojo/public/js/mojo_bindings_lite.js"></script> <script src="chrome://resources/mojo/mojo/public/js/mojo_bindings_lite.js"></script>
<script src="/help_app.mojom-lite.js"></script> <script src="/help_app.mojom-lite.js"></script>
<script src="/browser_proxy.js"></script> <script src="/browser_proxy.js"></script>
<iframe src="chrome://help-app-guest/app.html"></iframe> <iframe src="chrome-untrusted://help-app/app.html"></iframe>
...@@ -9,7 +9,7 @@ ...@@ -9,7 +9,7 @@
GEN('#include "chromeos/constants/chromeos_features.h"'); GEN('#include "chromeos/constants/chromeos_features.h"');
const HOST_ORIGIN = 'chrome://help-app'; const HOST_ORIGIN = 'chrome://help-app';
const GUEST_ORIGIN = 'chrome://help-app-guest'; const GUEST_ORIGIN = 'chrome-untrusted://help-app';
var HelpAppUIBrowserTest = class extends testing.Test { var HelpAppUIBrowserTest = class extends testing.Test {
/** @override */ /** @override */
......
...@@ -8,7 +8,6 @@ namespace chromeos { ...@@ -8,7 +8,6 @@ namespace chromeos {
const char kChromeUIHelpAppHost[] = "help-app"; const char kChromeUIHelpAppHost[] = "help-app";
const char kChromeUIHelpAppURL[] = "chrome://help-app/"; const char kChromeUIHelpAppURL[] = "chrome://help-app/";
const char kChromeUIHelpAppGuestHost[] = "help-app-guest"; const char kChromeUIHelpAppUntrustedURL[] = "chrome-untrusted://help-app/";
const char kChromeUIHelpAppGuestURL[] = "chrome://help-app-guest/";
} // namespace chromeos } // namespace chromeos
...@@ -9,8 +9,7 @@ namespace chromeos { ...@@ -9,8 +9,7 @@ namespace chromeos {
extern const char kChromeUIHelpAppHost[]; extern const char kChromeUIHelpAppHost[];
extern const char kChromeUIHelpAppURL[]; extern const char kChromeUIHelpAppURL[];
extern const char kChromeUIHelpAppGuestHost[]; extern const char kChromeUIHelpAppUntrustedURL[];
extern const char kChromeUIHelpAppGuestURL[];
} // namespace chromeos } // namespace chromeos
......
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