Commit 7816271c authored by Anastasiia Nikolaienko's avatar Anastasiia Nikolaienko Committed by Commit Bot

Display an error page instead of Gaia sign-in screen

If addition of secondary accounts is disabled, an error page should be
displayed instead of Gaia sign-in screen.

Bug: 987218
Change-Id: I2954adddf8ece06ca9a0cf355539781e23817d42
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1731891Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarKush Sinha <sinhak@chromium.org>
Commit-Queue: Anastasiia Nikolaienko <anastasiian@chromium.org>
Cr-Commit-Position: refs/heads/master@{#697637}
parent 0a7773f1
......@@ -3933,6 +3933,14 @@
Contact the device admin for your organization
</message>
<!-- Strings for Account Manager error screen -->
<message name="IDS_ACCOUNT_MANAGER_SECONDARY_ACCOUNTS_DISABLED_TITLE" desc="Title for the Chrome OS Account Manager error screen when addition of secondary Google Accounts is disabled.">
Addition of more Google Accounts is disabled
</message>
<message name="IDS_ACCOUNT_MANAGER_SECONDARY_ACCOUNTS_DISABLED_TEXT" desc="Text body for the Chrome OS Account Manager error screen when addition of secondary Google Accounts is disabled.">
Your administrator has disabled the addition of more Google Accounts
</message>
<!-- Strings for Account Manager welcome screen -->
<message name="IDS_ACCOUNT_MANAGER_WELCOME_TITLE" desc="Title for the Chrome OS Account Manager Welcome screen.">
Sign-in has changed
......
119040b68c7fe1caddd650a4c166a1d319f9996b
\ No newline at end of file
119040b68c7fe1caddd650a4c166a1d319f9996b
\ No newline at end of file
......@@ -381,6 +381,8 @@
<include name="IDR_ACCOUNT_MIGRATION_WELCOME_JS" file="resources\chromeos\account_migration_welcome.js" flattenhtml="true" type="BINDATA" compress="gzip" />
<include name="IDR_ACCOUNT_MIGRATION_BROWSER_PROXY_HTML" file="resources\chromeos\account_migration_browser_proxy.html" type="BINDATA" />
<include name="IDR_ACCOUNT_MIGRATION_BROWSER_PROXY_JS" file="resources\chromeos\account_migration_browser_proxy.js" type="BINDATA" />
<include name="IDR_ACCOUNT_MANAGER_ERROR_HTML" file="resources\chromeos\account_manager_error.html" allowexternalscript="true" type="BINDATA" compress="gzip" preprocess="true"/>
<include name="IDR_ACCOUNT_MANAGER_ERROR_JS" file="resources\chromeos\account_manager_error.js" type="BINDATA" compress="gzip" />
<if expr="_google_chrome">
<include name="IDR_ACCOUNT_MANAGER_WELCOME_1X_PNG" file="resources\chromeos\account_manager_welcome_1x.png" type="BINDATA" compress="gzip" />
<include name="IDR_ACCOUNT_MANAGER_WELCOME_2X_PNG" file="resources\chromeos\account_manager_welcome_2x.png" type="BINDATA" compress="gzip" />
......
<!doctype html>
<html>
<head>
<title>$i18n{errorTitle}</title>
<meta charset="utf-8">
<link rel="import" href="chrome://resources/html/polymer.html">
<link rel="import" href="chrome://resources/cr_elements/cr_button/cr_button.html">
<link rel="import" href="chrome://resources/cr_elements/shared_style_css.html">
<link rel="stylesheet" href="chrome://resources/css/chrome_shared.css">
<link rel="stylesheet" href="chrome://resources/css/text_defaults_md.css">
<link rel="stylesheet" href="account_manager_shared.css">
<custom-style>
<style is="custom-style" include="cr-shared-style">
</style>
</custom-style>
<script src="chrome://resources/js/cr.js"></script>
<script src="chrome://resources/js/load_time_data.js"></script>
<script src="chrome://resources/js/util.js"></script>
<script src="strings.js"></script>
<script src="account_manager_error.js"></script>
</head>
<body>
<div id="content">
<if expr="_google_chrome">
<img id="google-logo" src="googleg.svg" alt="">
</if>
<h1>$i18n{errorTitle}</h1>
<p>$i18n{errorMessage}</p>
<div class="button-container">
<cr-button id="ok-button" class="action-button">
$i18n{okButton}
</cr-button>
</div>
</div>
</body>
</html>
// Copyright (c) 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.
cr.define('account_manager_error', function() {
'use strict';
function initialize() {
$('ok-button').addEventListener('click', closeDialog);
}
function closeDialog() {
chrome.send('closeDialog');
}
return {
initialize: initialize,
closeDialog: closeDialog,
};
});
document.addEventListener('DOMContentLoaded', account_manager_error.initialize);
......@@ -1597,6 +1597,8 @@ jumbo_split_static_library("ui") {
"views/touch_selection_menu_chromeos.h",
"views/touch_selection_menu_runner_chromeos.cc",
"views/touch_selection_menu_runner_chromeos.h",
"webui/chromeos/account_manager_error_ui.cc",
"webui/chromeos/account_manager_error_ui.h",
"webui/chromeos/account_manager_welcome_dialog.cc",
"webui/chromeos/account_manager_welcome_dialog.h",
"webui/chromeos/account_manager_welcome_ui.cc",
......
......@@ -26,6 +26,7 @@
#include "chrome/browser/ui/webui/autofill_and_password_manager_internals/autofill_internals_ui.h"
#include "chrome/browser/ui/webui/autofill_and_password_manager_internals/password_manager_internals_ui.h"
#include "chrome/browser/ui/webui/bluetooth_internals/bluetooth_internals_ui.h"
#include "chrome/browser/ui/webui/chromeos/account_manager_error_ui.h"
#include "chrome/browser/ui/webui/chromeos/account_manager_welcome_ui.h"
#include "chrome/browser/ui/webui/chromeos/account_migration_welcome_ui.h"
#include "chrome/browser/ui/webui/chromeos/camera/camera_ui.h"
......@@ -519,6 +520,8 @@ WebUIFactoryFunction GetWebUIFactoryFunction(WebUI* web_ui,
}
return &NewWebUI<chromeos::UrgentPasswordExpiryNotificationUI>;
}
if (url.host_piece() == chrome::kChromeUIAccountManagerErrorHost)
return &NewWebUI<chromeos::AccountManagerErrorUI>;
if (url.host_piece() == chrome::kChromeUIAccountManagerWelcomeHost)
return &NewWebUI<chromeos::AccountManagerWelcomeUI>;
if (url.host_piece() == chrome::kChromeUIAccountMigrationWelcomeHost)
......
// 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/account_manager_error_ui.h"
#include "base/bind.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/url_constants.h"
#include "chrome/common/webui_url_constants.h"
#include "chrome/grit/browser_resources.h"
#include "chrome/grit/generated_resources.h"
#include "content/public/browser/web_ui_data_source.h"
#include "ui/strings/grit/ui_strings.h"
namespace chromeos {
AccountManagerErrorUI::AccountManagerErrorUI(content::WebUI* web_ui)
: ui::WebDialogUI(web_ui), weak_factory_(this) {
content::WebUIDataSource* html_source = content::WebUIDataSource::Create(
chrome::kChromeUIAccountManagerErrorHost);
web_ui->RegisterMessageCallback(
"closeDialog", base::BindRepeating(&WebDialogUI::CloseDialog,
weak_factory_.GetWeakPtr()));
html_source->UseStringsJs();
html_source->AddLocalizedString(
"errorTitle", IDS_ACCOUNT_MANAGER_SECONDARY_ACCOUNTS_DISABLED_TITLE);
html_source->AddLocalizedString(
"errorMessage", IDS_ACCOUNT_MANAGER_SECONDARY_ACCOUNTS_DISABLED_TEXT);
html_source->AddLocalizedString("okButton", IDS_APP_OK);
#if defined(GOOGLE_CHROME_BUILD)
html_source->AddResourcePath("googleg.svg",
IDR_ACCOUNT_MANAGER_WELCOME_GOOGLE_LOGO_SVG);
#endif
// Add required resources.
html_source->AddResourcePath("account_manager_shared.css",
IDR_ACCOUNT_MANAGER_SHARED_CSS);
html_source->AddResourcePath("account_manager_error.js",
IDR_ACCOUNT_MANAGER_ERROR_JS);
html_source->SetDefaultResource(IDR_ACCOUNT_MANAGER_ERROR_HTML);
Profile* profile = Profile::FromWebUI(web_ui);
content::WebUIDataSource::Add(profile, html_source);
}
AccountManagerErrorUI::~AccountManagerErrorUI() = default;
} // namespace chromeos
// 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_ACCOUNT_MANAGER_ERROR_UI_H_
#define CHROME_BROWSER_UI_WEBUI_CHROMEOS_ACCOUNT_MANAGER_ERROR_UI_H_
#include "base/macros.h"
#include "base/memory/weak_ptr.h"
#include "ui/web_dialogs/web_dialog_ui.h"
namespace chromeos {
// For chrome:://account-manager-error
class AccountManagerErrorUI : public ui::WebDialogUI {
public:
explicit AccountManagerErrorUI(content::WebUI* web_ui);
~AccountManagerErrorUI() override;
private:
base::WeakPtrFactory<AccountManagerErrorUI> weak_factory_;
DISALLOW_COPY_AND_ASSIGN(AccountManagerErrorUI);
};
} // namespace chromeos
#endif // CHROME_BROWSER_UI_WEBUI_CHROMEOS_ACCOUNT_MANAGER_ERROR_UI_H_
......@@ -9,9 +9,14 @@
#include "base/logging.h"
#include "base/macros.h"
#include "chrome/browser/chromeos/profiles/profile_helper.h"
#include "chrome/browser/profiles/profile_manager.h"
#include "chrome/browser/ui/webui/chromeos/system_web_dialog_delegate.h"
#include "chrome/common/webui_url_constants.h"
#include "chromeos/constants/chromeos_pref_names.h"
#include "components/prefs/pref_service.h"
#include "components/web_modal/web_contents_modal_dialog_manager.h"
#include "google_apis/gaia/gaia_auth_util.h"
#include "net/base/url_util.h"
#include "ui/aura/window.h"
#include "ui/display/display.h"
......@@ -27,6 +32,12 @@ InlineLoginHandlerDialogChromeOS* dialog = nullptr;
constexpr int kSigninDialogWidth = 768;
constexpr int kSigninDialogHeight = 640;
bool IsDeviceAccountEmail(const std::string& email) {
auto* active_user = user_manager::UserManager::Get()->GetActiveUser();
return active_user &&
gaia::AreEmailsSame(active_user->GetDisplayEmail(), email);
}
} // namespace
// static
......@@ -36,10 +47,20 @@ void InlineLoginHandlerDialogChromeOS::Show(const std::string& email) {
return;
}
GURL url(chrome::kChromeUIChromeSigninURL);
if (!email.empty()) {
url = net::AppendQueryParameter(url, "email", email);
url = net::AppendQueryParameter(url, "readOnlyEmail", "true");
GURL url;
if (ProfileManager::GetActiveUserProfile()->GetPrefs()->GetBoolean(
chromeos::prefs::kSecondaryGoogleAccountSigninAllowed) ||
IsDeviceAccountEmail(email)) {
// Addition of secondary Google Accounts is allowed OR it's a primary
// account re-auth.
url = GURL(chrome::kChromeUIChromeSigninURL);
if (!email.empty()) {
url = net::AppendQueryParameter(url, "email", email);
url = net::AppendQueryParameter(url, "readOnlyEmail", "true");
}
} else {
// Addition of secondary Google Accounts is not allowed.
url = GURL(chrome::kChromeUIAccountManagerErrorURL);
}
// Will be deleted by |SystemWebDialogDelegate::OnDialogClosed|.
......
......@@ -189,6 +189,8 @@ const char kChromeUIWebApksHost[] = "webapks";
#if defined(OS_CHROMEOS)
// Keep alphabetized.
const char kChromeUIAccountManagerErrorHost[] = "account-manager-error";
const char kChromeUIAccountManagerErrorURL[] = "chrome://account-manager-error";
const char kChromeUIAccountManagerWelcomeHost[] = "account-manager-welcome";
const char kChromeUIAccountManagerWelcomeURL[] =
"chrome://account-manager-welcome";
......@@ -269,6 +271,7 @@ bool IsSystemWebUIHost(base::StringPiece host) {
// Compares host instead of full URL for performance (the strings are
// shorter).
static const char* const kHosts[] = {
kChromeUIAccountManagerErrorHost,
kChromeUIAccountManagerWelcomeHost,
kChromeUIAccountMigrationWelcomeHost,
kChromeUIActivationMessageHost,
......
......@@ -190,6 +190,8 @@ extern const char kChromeUIWebApksHost[];
#if defined(OS_CHROMEOS)
// NOTE: If you add a URL/host please check if it should be added to
// IsSystemWebUIHost().
extern const char kChromeUIAccountManagerErrorHost[];
extern const char kChromeUIAccountManagerErrorURL[];
extern const char kChromeUIAccountManagerWelcomeHost[];
extern const char kChromeUIAccountManagerWelcomeURL[];
extern const char kChromeUIAccountMigrationWelcomeHost[];
......
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