Skip to content

Commit

Permalink
[ChromeSigninIntercept] Create chrome-signin subpage
Browse files Browse the repository at this point in the history
New sub-URL: chrome://signin-dice-web-intercept/chrome-signin

The page currently shows a simple Cancel button in order to close the
bubble.
The content implementation will follow.

Bug: b:301431278
Change-Id: I0b9aa8a343e346c13f1094436b603ac517f55e6c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/4946450
Commit-Queue: Ryan Sultanem <rsult@google.com>
Reviewed-by: Gabriel Oliveira <gabolvr@google.com>
Reviewed-by: David Roger <droger@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1211639}
  • Loading branch information
Ryan Sultanem authored and Chromium LUCI CQ committed Oct 18, 2023
1 parent ad69e25 commit b0e2275
Show file tree
Hide file tree
Showing 10 changed files with 122 additions and 8 deletions.
7 changes: 5 additions & 2 deletions chrome/browser/resources/signin/BUILD.gn
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ build_webui("build") {
}
if (enable_dice_support) {
static_files += [
"dice_web_signin_intercept/chrome_signin/chrome_signin.html",
"dice_web_signin_intercept/dice_web_signin_intercept.html",
"dice_web_signin_intercept/images/split_header.svg",
]
Expand All @@ -60,8 +61,10 @@ build_webui("build") {
]
}
if (enable_dice_support) {
web_component_files +=
[ "dice_web_signin_intercept/dice_web_signin_intercept_app.ts" ]
web_component_files += [
"dice_web_signin_intercept/chrome_signin/chrome_signin_app.ts",
"dice_web_signin_intercept/dice_web_signin_intercept_app.ts",
]
}

non_web_component_files = [
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<!doctype html>
<html dir="$i18n{textdirection}" lang="$i18n{language}">
<head>
<meta charset="utf-8">
<link rel="stylesheet" href="chrome://resources/css/md_colors.css">
<link rel="stylesheet" href="chrome://resources/css/text_defaults_md.css">
<link rel="import" href="signin_vars_css.html">
<style>
body {
height: 100vh;
margin: 0;
width: 100vw;
}
@media (prefers-color-scheme: dark) {
body {
--md-background-color: var(--signin-dark-customized-background-color);
background-color: var(--md-background-color);
}
}
</style>
</head>
<body>
<chrome-signin-app></chrome-signin-app>
<script type="module" src="chrome_signin/chrome_signin_app.js"></script>
</body>
</html>
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<div id="interceptDialog">

<div>Chrome Signin Intercept!</div>
<div>(To be implemented)</div>
<cr-button id="cancelButton" on-click="onCancel_">
Cancel
</cr-button>

</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// Copyright 2023 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

import '../strings.m.js';
import 'chrome://resources/cr_elements/cr_button/cr_button.js';

import {PolymerElement} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';

import {DiceWebSigninInterceptBrowserProxy, DiceWebSigninInterceptBrowserProxyImpl} from '../dice_web_signin_intercept_browser_proxy.js';

import {getTemplate} from './chrome_signin_app.html.js';

export class ChromeSigninAppElement extends PolymerElement {
static get is() {
return 'chrome-signin-app';
}

static get template() {
return getTemplate();
}

private diceWebSigninInterceptBrowserProxy_:
DiceWebSigninInterceptBrowserProxy =
DiceWebSigninInterceptBrowserProxyImpl.getInstance();

override connectedCallback() {
super.connectedCallback();

const height =
this.shadowRoot!.querySelector<HTMLElement>(
'#interceptDialog')!.offsetHeight;
this.diceWebSigninInterceptBrowserProxy_.initializedWithHeight(height);
}

private onCancel_() {
this.diceWebSigninInterceptBrowserProxy_.cancel();
}
}

declare global {
interface HTMLElementTagNameMap {
'chrome-signin-app': ChromeSigninAppElement;
}
}

customElements.define(ChromeSigninAppElement.is, ChromeSigninAppElement);
14 changes: 12 additions & 2 deletions chrome/browser/signin/dice_web_signin_interceptor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -714,8 +714,8 @@ void DiceWebSigninInterceptor::OnInterceptionReadyToBeProcessed(
base::Unretained(this), info, profile_color);
break;
case WebSigninInterceptor::SigninInterceptionType::kChromeSignin:
// TODO(b/301431278): Attach the right callback here.
callback = base::DoNothing();
callback = base::BindOnce(&DiceWebSigninInterceptor::OnChromeSigninChoice,
base::Unretained(this));
break;
}
ShowSigninInterceptionBubble(bubble_parameters, std::move(callback));
Expand Down Expand Up @@ -768,6 +768,16 @@ void DiceWebSigninInterceptor::OnProfileCreationChoice(
base::Unretained(this), profile_color));
}

void DiceWebSigninInterceptor::OnChromeSigninChoice(
SigninInterceptionResult result) {
if (result == SigninInterceptionResult::kDeclined) {
Reset();
return;
}

// TODO(b/301431278): Implement the rest of the cases.
}

void DiceWebSigninInterceptor::OnProfileSwitchChoice(
const std::string& email,
const base::FilePath& profile_path,
Expand Down
3 changes: 3 additions & 0 deletions chrome/browser/signin/dice_web_signin_interceptor.h
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,9 @@ class DiceWebSigninInterceptor : public KeyedService,
void OnProfileSwitchChoice(const std::string& email,
const base::FilePath& profile_path,
SigninInterceptionResult switch_profile);
// Called after the user chose whether they want to sign in to chrome or not
// via the Chrome Signin Bubble.
void OnChromeSigninChoice(SigninInterceptionResult result);

// Called when the new profile is created or loaded from disk.
// `profile_color` is set as theme color for the profile ; it should be
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,13 @@ DiceWebSigninInterceptionBubbleView::DiceWebSigninInterceptionBubbleView(
// Create the web view in the native bubble.
std::unique_ptr<views::WebView> web_view =
std::make_unique<views::WebView>(browser->profile());
// TODO(b/301431278): Use the new URL for the Chrome Signin intercept.
web_view->LoadInitialURL(GURL(chrome::kChromeUIDiceWebSigninInterceptURL));
GURL intercept_url =
bubble_parameters_.interception_type ==
WebSigninInterceptor::SigninInterceptionType::kChromeSignin
? GURL(chrome::kChromeUIDiceWebSigninInterceptChromeSigninURL)
: GURL(chrome::kChromeUIDiceWebSigninInterceptURL);
web_view->LoadInitialURL(intercept_url);

web_view->GetWebContents()->SetDelegate(this);
web_view->SetPreferredSize(
gfx::Size(kInterceptionBubbleWidth, kInterceptionBubbleBaseHeight));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ DiceWebSigninInterceptUI::DiceWebSigninInterceptUI(content::WebUI* web_ui)
{"test_loader.js", IDR_WEBUI_JS_TEST_LOADER_JS},
{"test_loader_util.js", IDR_WEBUI_JS_TEST_LOADER_UTIL_JS},
{"test_loader.html", IDR_WEBUI_TEST_LOADER_HTML},
// Resources for the Chrome signin sub page: chrome_signin/.
{chrome::kChromeUIDiceWebSigninInterceptChromeSigninSubPage,
IDR_SIGNIN_DICE_WEB_SIGNIN_INTERCEPT_CHROME_SIGNIN_CHROME_SIGNIN_HTML},
{"chrome_signin/chrome_signin_app.js",
IDR_SIGNIN_DICE_WEB_SIGNIN_INTERCEPT_CHROME_SIGNIN_CHROME_SIGNIN_APP_JS},
{"chrome_signin/chrome_signin_app.html.js",
IDR_SIGNIN_DICE_WEB_SIGNIN_INTERCEPT_CHROME_SIGNIN_CHROME_SIGNIN_APP_HTML_JS},
};
source->AddResourcePaths(kResources);

Expand Down Expand Up @@ -109,8 +116,6 @@ void DiceWebSigninInterceptUI::Initialize(
base::OnceCallback<void(int)> show_widget_with_height_callback,
base::OnceCallback<void(SigninInterceptionUserChoice)>
completion_callback) {
// TODO(b/301431278): Create a different handler for the Chrome Signin
// intercept UI.
web_ui()->AddMessageHandler(std::make_unique<DiceWebSigninInterceptHandler>(
bubble_parameters, std::move(show_widget_with_height_callback),
std::move(completion_callback)));
Expand Down
4 changes: 4 additions & 0 deletions chrome/common/webui_url_constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,10 @@ const char kChromeUIDevUiLoaderURL[] = "chrome://dev-ui-loader/";
const char kChromeUIDiceWebSigninInterceptHost[] = "signin-dice-web-intercept";
const char kChromeUIDiceWebSigninInterceptURL[] =
"chrome://signin-dice-web-intercept/";
const char kChromeUIDiceWebSigninInterceptChromeSigninURL[] =
"chrome://signin-dice-web-intercept/chrome-signin";
const char kChromeUIDiceWebSigninInterceptChromeSigninSubPage[] =
"chrome-signin";
const char kChromeUIDownloadInternalsHost[] = "download-internals";
const char kChromeUIDownloadsHost[] = "downloads";
const char kChromeUIDownloadsURL[] = "chrome://downloads/";
Expand Down
2 changes: 2 additions & 0 deletions chrome/common/webui_url_constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,8 @@ extern const char kChromeUIDeviceLogUrl[];
extern const char kChromeUIDevUiLoaderURL[];
extern const char kChromeUIDiceWebSigninInterceptHost[];
extern const char kChromeUIDiceWebSigninInterceptURL[];
extern const char kChromeUIDiceWebSigninInterceptChromeSigninURL[];
extern const char kChromeUIDiceWebSigninInterceptChromeSigninSubPage[];
extern const char kChromeUIDownloadInternalsHost[];
extern const char kChromeUIDownloadsHost[];
extern const char kChromeUIDownloadsURL[];
Expand Down

0 comments on commit b0e2275

Please sign in to comment.