Commit 5c61d15d authored by Anatoliy Potapchuk's avatar Anatoliy Potapchuk Committed by Commit Bot

[Kiosk] Do not use launch_url if it has different origin

To avoid potential risks, do not update launch url if its origin does
not much the one provided by policy.

Bug: 1046260
Change-Id: Ifa82de2eb45ada3bd9a68351ffbbf88324d9f9fb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2027849
Commit-Queue: Anatoliy Potapchuk <apotapchuk@chromium.org>
Reviewed-by: default avatarSergey Poromov <poromov@chromium.org>
Cr-Commit-Position: refs/heads/master@{#737295}
parent cffcbc6f
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include "ash/public/cpp/window_pin_type.h" #include "ash/public/cpp/window_pin_type.h"
#include "ash/public/cpp/window_properties.h" #include "ash/public/cpp/window_properties.h"
#include "base/bind.h" #include "base/bind.h"
#include "base/logging.h"
#include "chrome/browser/chromeos/app_mode/web_app/web_kiosk_app_data.h" #include "chrome/browser/chromeos/app_mode/web_app/web_kiosk_app_data.h"
#include "chrome/browser/chromeos/app_mode/web_app/web_kiosk_app_manager.h" #include "chrome/browser/chromeos/app_mode/web_app/web_kiosk_app_manager.h"
#include "chrome/browser/extensions/api/tabs/tabs_util.h" #include "chrome/browser/extensions/api/tabs/tabs_util.h"
...@@ -20,6 +21,7 @@ ...@@ -20,6 +21,7 @@
#include "components/account_id/account_id.h" #include "components/account_id/account_id.h"
#include "ui/aura/window.h" #include "ui/aura/window.h"
#include "ui/base/page_transition_types.h" #include "ui/base/page_transition_types.h"
#include "url/origin.h"
namespace chromeos { namespace chromeos {
...@@ -60,6 +62,13 @@ void WebKioskAppLauncher::ContinueWithNetworkReady() { ...@@ -60,6 +62,13 @@ void WebKioskAppLauncher::ContinueWithNetworkReady() {
weak_ptr_factory_.GetWeakPtr())); weak_ptr_factory_.GetWeakPtr()));
} }
const WebKioskAppData* WebKioskAppLauncher::GetCurrentApp() const {
const WebKioskAppData* app =
WebKioskAppManager::Get()->GetAppByAccountId(account_id_);
DCHECK(app);
return app;
}
void WebKioskAppLauncher::OnAppDataObtained( void WebKioskAppLauncher::OnAppDataObtained(
std::unique_ptr<WebApplicationInfo> app_info) { std::unique_ptr<WebApplicationInfo> app_info) {
if (!app_info) { if (!app_info) {
...@@ -68,6 +77,15 @@ void WebKioskAppLauncher::OnAppDataObtained( ...@@ -68,6 +77,15 @@ void WebKioskAppLauncher::OnAppDataObtained(
return; return;
} }
// When received |app_info->app_url| origin does not match the origin of
// |install_url|, fail.
if (url::Origin::Create(GetCurrentApp()->install_url()) !=
url::Origin::Create(app_info->app_url)) {
VLOG(1) << "Origin of the app does not match the origin of install url";
delegate_->OnAppLaunchFailed();
return;
}
WebKioskAppManager::Get()->UpdateAppByAccountId(account_id_, WebKioskAppManager::Get()->UpdateAppByAccountId(account_id_,
std::move(app_info)); std::move(app_info));
delegate_->OnAppPrepared(); delegate_->OnAppPrepared();
...@@ -75,9 +93,7 @@ void WebKioskAppLauncher::OnAppDataObtained( ...@@ -75,9 +93,7 @@ void WebKioskAppLauncher::OnAppDataObtained(
void WebKioskAppLauncher::LaunchApp() { void WebKioskAppLauncher::LaunchApp() {
DCHECK(!browser_); DCHECK(!browser_);
const WebKioskAppData* app = const WebKioskAppData* app = GetCurrentApp();
WebKioskAppManager::Get()->GetAppByAccountId(account_id_);
DCHECK(app);
GURL url = app->status() == WebKioskAppData::STATUS_INSTALLED GURL url = app->status() == WebKioskAppData::STATUS_INSTALLED
? app->launch_url() ? app->launch_url()
......
...@@ -27,6 +27,8 @@ class WebAppUrlLoader; ...@@ -27,6 +27,8 @@ class WebAppUrlLoader;
namespace chromeos { namespace chromeos {
class WebKioskAppData;
// Object responsible for preparing and launching web kiosk app. Is destroyed // Object responsible for preparing and launching web kiosk app. Is destroyed
// upon app launch. // upon app launch.
class WebKioskAppLauncher { class WebKioskAppLauncher {
...@@ -59,6 +61,8 @@ class WebKioskAppLauncher { ...@@ -59,6 +61,8 @@ class WebKioskAppLauncher {
private: private:
void OnAppDataObtained(std::unique_ptr<WebApplicationInfo> app_info); void OnAppDataObtained(std::unique_ptr<WebApplicationInfo> app_info);
const WebKioskAppData* GetCurrentApp() const;
bool is_installed_ = false; // Whether the installation was completed. bool is_installed_ = false; // Whether the installation was completed.
AccountId account_id_; AccountId account_id_;
Profile* const profile_; Profile* const profile_;
......
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