Commit 7e03a934 authored by Mariam Ali's avatar Mariam Ali Committed by Commit Bot

Update Ephemeral Guest Profile NTP strings

This CL updates NTP strings for ephemeral guest profile by adding
educational bullet points about items that will not be saved
on the device vs. items that will be saved.

Screenshot:
https://screenshot.googleplex.com/7Gf3vSb5iAWBHxt.png

Bug: 1134111
Change-Id: I7096631987dcc143552c2c721ed1ca4868265987
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2442690
Commit-Queue: Mariam Ali <alimariam@google.com>
Reviewed-by: default avatarEvan Stade <estade@chromium.org>
Reviewed-by: default avatarDavid Roger <droger@chromium.org>
Reviewed-by: default avatarEsmael Elmoslimany <aee@chromium.org>
Reviewed-by: default avatarRohit Agarwal <roagarwal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#822576}
parent 75438b2a
......@@ -17,6 +17,8 @@
<structure name="IDR_INCOGNITO_TAB_HTML" file="resources\ntp4\incognito_tab.html" flattenhtml="true" type="chrome_html" />
<structure name="IDR_INCOGNITO_TAB_THEME_CSS" file="resources\ntp4\incognito_tab_theme.css" flattenhtml="true" type="chrome_html" />
<structure name="IDR_GUEST_TAB_HTML" file="resources\ntp4\guest_tab.html" flattenhtml="true" type="chrome_html" />
<structure name="IDR_EPHEMERAL_GUEST_TAB_HTML" file="resources\ntp4\ephemeral_guest_tab.html" flattenhtml="true" type="chrome_html" />
<structure name="IDR_EPHEMERAL_GUEST_TAB_CSS" file="resources\ntp4\ephemeral_guest_tab.css" flattenhtml="true" type="chrome_html" />
<structure name="IDR_NEW_TAB_4_HTML" file="resources\ntp4\new_tab.html" flattenhtml="true" type="chrome_html" />
<structure name="IDR_NEW_TAB_4_THEME_CSS" file="resources\ntp4\new_tab_theme.css" flattenhtml="true" type="chrome_html" />
......
/* Copyright 2020 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.
*
* Ephemeral Guest Profile CSS.
* TODO(crbug.com/1125474): move styling to guest tab.css and remove this file
* once all instances of non-ephemeral Guest profiles are deprecated.
*/
a {
color: rgb(51, 103, 214);
}
@media (prefers-color-scheme: dark) {
html {
background: rgb(53, 54, 58);
color: rgb(232, 234, 237); /* --google-grey-200 */
}
:-webkit-any(a, .learn-more-button) {
color: rgb(138, 180, 248); /* --google-blue-refresh-300 */
}
}
\ No newline at end of file
<!-- Copyright 2020 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.
-->
<!-- TODO(crbug.com/1125474): Rename file to guest_tab.html once all audit is
-- done and all instances of non-ephemeral Guest profiles are deprecated.
-->
<!doctype html>
<html dir="$i18n{textdirection}" lang="$i18n{language}">
<head>
<meta charset="utf-16">
<title>$i18n{title}</title>
<script src="chrome://resources/js/util.js"></script>
<link rel="stylesheet" href="chrome://resources/css/text_defaults_md.css">
<link rel="stylesheet" href="incognito_and_guest_tab.css">
<link rel="stylesheet" href="ephemeral_guest_tab.css">
</head>
<body>
<div class="content">
<h1>$i18nRaw{guestTabHeading}</h1>
<p id="subtitle">
<span>$i18nRaw{guestTabDescription}</span>
<a class="learn-more-button"
href="$i18n{learnMoreLink}">$i18n{learnMore}</a>
</p>
<div id="bulletpoints-wrapper">
<div class="bulletpoints first">$i18nRaw{guestTabFeatures}</div>
<div class="bulletpoints">$i18nRaw{guestTabWarning}</div>
</div>
<a class="learn-more-button" href="$i18n{learnMoreLink}">$i18n{learnMore}</a>
</div>
<script type="module" src="ephemeral_guest_tab.js"></script>
</body>
</html>
// Copyright 2020 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.
// TODO(crbug.com/1125474): Rename file to guest_tab.js once all audit is done
// and all instances of non-ephemeral Guest profiles are deprecated.
// clang-format off
import {addSingletonGetter} from 'chrome://resources/js/cr.m.js';
// clang-format on
/** @interface */
class GuestSignIn {
/**
* Handles sign in and sign out based on user's sign in status.
*/
onChangeSignInStatusClicked() {}
}
/** @implements {GuestSignIn} */
class GuestSignInImpl {
onChangeSignInStatusClicked() {
chrome.send('onChangeSignInStatusClicked');
}
}
addSingletonGetter(GuestSignInImpl);
window.addEventListener('load', function() {
$('change-sign-in-status').onclick = () =>
GuestSignInImpl.getInstance().onChangeSignInStatusClicked();
});
/* Copyright 2020 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. */
body {
-webkit-font-smoothing: antialiased;
font-size: 85%;
}
@media (prefers-color-scheme: dark) {
html {
background: rgb(53, 54, 58);
color: rgb(232, 234, 237); /* --google-grey-200 */
}
}
h1 {
font-size: 200%;
font-weight: 400;
margin-bottom: .77em;
}
p {
line-height: 1.5;
margin: .588em 0;
text-align: start;
}
a {
color: rgb(51, 103, 214);
}
a:hover {
text-decoration: underline;
}
.learn-more-button {
color: rgb(66, 133, 244);
display: inline-block;
font-size: 92.8%;
font-weight: 500;
margin-top: 1.98em;
padding: 10.5px 12px;
text-decoration: none;
}
@media (prefers-color-scheme: dark) {
:-webkit-any(a, .learn-more-button) {
color: rgb(138, 180, 248); /* --google-blue-refresh-300 */
}
}
.content {
box-sizing: border-box;
margin: 3.5em auto 0;
max-width: 480px;
min-width: 240px;
padding: 30px 35px;
text-align: center;
}
html[hascustombackground='true'] .content {
border-radius: 2px;
box-shadow: 0 4px 6px 1px rgba(0, 0, 0, 0.4);
}
.content > span {
display: block;
}
@media (max-width:700px) {
body {
margin: 1em 2em 2em;
}
}
@media (max-width:400px) {
body {
margin: 3em 1.5em 2em;
}
/* Adjustment for narrow screen to prevent horizontal scrollbar. */
.content {
padding: 16px 8px;
}
}
@media (max-height:480px) and (max-width:400px) {
.content {
margin: auto;
}
}
......@@ -4,7 +4,7 @@
<meta charset="utf-8">
<title>$i18n{title}</title>
<link rel="stylesheet" href="chrome://resources/css/text_defaults_md.css">
<link rel="stylesheet" href="incognito_and_guest_tab.css">
<link rel="stylesheet" href="guest_tab.css">
</head>
<body>
<div class="content">
......
......@@ -6,89 +6,227 @@
body {
-webkit-font-smoothing: antialiased;
font-size: 85%;
font-size: 100%;
margin: 0;
}
@media (prefers-color-scheme: dark) {
html {
background: rgb(53, 54, 58);
color: rgb(232, 234, 237); /* --google-grey-200 */
}
[hidden] {
display: none !important;
}
/** Typography -------------------------------------------------------------- */
.content {
font-size: calc(100% - 2px);
line-height: calc(100% + 6px);
min-width: 240px;
}
h1 {
font-size: 200%;
font-size: calc(100% + 8px);
font-weight: 400;
margin-bottom: .77em;
line-height: calc(100% + 8px);
}
p {
line-height: 1.5;
margin: .588em 0;
text-align: start;
em {
color: white;
font-style: normal;
}
a {
color: rgb(51, 103, 214);
}
a:hover {
text-decoration: underline;
cursor: pointer;
}
.learn-more-button {
color: rgb(66, 133, 244);
display: inline-block;
font-size: 92.8%;
font-weight: 500;
margin-top: 1.98em;
padding: 10.5px 12px;
text-decoration: none;
}
@media (prefers-color-scheme: dark) {
:-webkit-any(a, .learn-more-button) {
color: rgb(138, 180, 248); /* --google-blue-refresh-300 */
/* Small font on small screens. */
@media (max-width: 240px),
(max-height: 320px) {
.content {
font-size: calc(100% - 4px);
line-height: calc(100% + 6px);
}
h1 {
font-size: calc(100% + 4px);
line-height: calc(100% + 4px);
}
}
/** The "Learn more" link --------------------------------------------------- */
/* By default, we only show the inline "Learn more" link. */
.content > .learn-more-button {
display: none;
}
/* On narrow screens, we show the standalone "Learn more" link. */
@media (max-width: 720px) {
#subtitle > .learn-more-button {
display: none;
}
.content > .learn-more-button {
display: block;
}
}
/** Layout ------------------------------------------------------------------ */
/* Align the content and title to the center. */
.content {
box-sizing: border-box;
margin: 3.5em auto 0;
max-width: 480px;
min-width: 240px;
padding: 30px 35px;
margin-inline-end: auto;
margin-inline-start: auto;
max-width: 600px;
}
h1 {
text-align: center;
}
html[hascustombackground='true'] .content {
border-radius: 2px;
box-shadow: 0 4px 6px 1px rgba(0, 0, 0, 0.4);
/* Align the two columns of bulletpoints next to each other. */
#bulletpoints-wrapper {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.content > span {
display: block;
.bulletpoints {
flex-basis: 285px; /* (600px - 30px) / 2. */
flex-grow: 1;
flex-shrink: 0;
}
@media (max-width:700px) {
body {
margin: 1em 2em 2em;
.bulletpoints.first {
margin-inline-end: 30px;
}
/* On narrow screens, align everything to the left. */
@media (max-width: 720px) {
.content {
max-width: 600px !important; /* must override the rule set by JS which
* is only valid for width > 720px cases. */
text-align: start;
}
h1 {
text-align: start;
}
}
@media (max-width:400px) {
body {
margin: 3em 1.5em 2em;
/** Paddings and margins ---------------------------------------------------- */
.bulletpoints ul {
margin: 4px 0 0;
padding-inline-start: 16px;
}
/* Wide screens. */
@media (min-width: 720px) {
h1,
#subtitle,
.learn-more-button {
margin-top: 1.5rem;
}
h1,
#subtitle,
.bulletpoints {
margin-bottom: 1.5rem;
}
.content {
margin-top: 40px;
min-width: 240px;
padding: 8px 48px 24px;
}
/* Snap the content box to the whole height on short screens. */
@media (max-height: 480px) {
html,
body,
.content {
height: 100%;
}
.content {
margin-bottom: 0;
margin-top: 0;
padding-bottom: 0;
padding-top: 0;
}
}
/* Smaller vertical margins on very short screens. */
@media (max-height: 320px) {
h1,
#subtitle {
margin-bottom: 16px;
margin-top: 16px;
}
.learn-more-button,
.bulletpoints {
margin-bottom: 16px;
}
}
}
/* Adjustment for narrow screen to prevent horizontal scrollbar. */
/* Narrow screens */
@media (max-width: 720px) {
.content {
padding: 16px 8px;
min-width: 176px;
padding: 72px 32px;
}
h1,
#subtitle {
margin-bottom: 1.5rem;
margin-top: 1.5rem;
}
.bulletpoints,
.learn-more-button {
margin-bottom: 1.5rem;
}
/* Smaller offsets on smaller screens. */
@media (max-height: 600px) {
.content {
padding-top: 48px;
}
h1,
#subtitle {
margin-bottom: 1rem;
margin-top: 1rem;
}
.bulletpoints,
.learn-more-button {
margin-bottom: 1rem;
}
}
/* Small top offset on very small screens. */
@media (max-height: 480px) {
.content {
padding-top: 32px;
}
}
.learn-more-button {
margin-bottom: 0;
}
}
@media (max-height:480px) and (max-width:400px) {
/* Very narrow screens. */
@media (max-width: 240px) {
.content {
margin: auto;
min-width: 192px;
padding-inline-end: 24px;
padding-inline-start: 24px;
}
}
......@@ -2,16 +2,6 @@
* Use of this source code is governed by a BSD-style license that can be
* found in the LICENSE file. */
body {
-webkit-font-smoothing: antialiased;
font-size: 100%;
margin: 0;
}
[hidden] {
display: none !important;
}
/** Typography -------------------------------------------------------------- */
.content {
......@@ -19,39 +9,10 @@ body {
for the case when a theme with a background image is installed. */
background-color: rgb(53, 54, 58);
color: rgb(232, 234, 237); /* --google-grey-200 */
font-size: calc(100% - 2px);
line-height: calc(100% + 6px);
min-width: 240px;
}
h1 {
font-size: calc(100% + 8px);
font-weight: 400;
line-height: calc(100% + 8px);
}
em {
color: white;
font-style: normal;
}
.learn-more-button {
color: rgb(138, 180, 248);
text-decoration: none;
}
/* Small font on small screens. */
@media (max-width: 240px),
(max-height: 320px) {
.content {
font-size: calc(100% - 4px);
line-height: calc(100% + 6px);
}
h1 {
font-size: calc(100% + 4px);
line-height: calc(100% + 4px);
}
}
/** Icon -------------------------------------------------------------------- */
......@@ -139,101 +100,34 @@ em {
/** Layout ------------------------------------------------------------------ */
/* Align the content, icon, and title to to the center. */
.content {
margin-inline-end: auto;
margin-inline-start: auto;
max-width: 600px;
}
/* Align the icon to the center. */
.icon {
margin-inline-end: auto;
margin-inline-start: auto;
}
h1 {
text-align: center;
}
/* Align the two columns of bulletpoints next to each other. */
#bulletpoints-wrapper {
display: flex;
flex-wrap: wrap;
justify-content: space-between;
}
.bulletpoints {
flex-basis: 285px; /* (600px - 30px) / 2. */
flex-grow: 1;
flex-shrink: 0;
}
.bulletpoints.first {
margin-inline-end: 30px;
}
/* On narrow screens, align everything to the left. */
@media (max-width: 720px) {
.content {
max-width: 600px !important; /* must override the rule set by JS which
* is only valid for width > 720px cases. */
text-align: start;
}
.icon {
margin-inline-start: 0;
}
h1 {
text-align: start;
margin-inline-start: 0;
}
}
/** Paddings and margins ---------------------------------------------------- */
.bulletpoints ul {
margin: 4px 0 0;
padding-inline-start: 16px;
}
/* Wide screens. */
@media (min-width: 720px) {
.icon,
h1,
#subtitle,
.learn-more-button {
.icon {
margin-top: 1.5rem;
}
.icon,
h1,
#subtitle,
.bulletpoints,
#cookie-controls {
margin-bottom: 1.5rem;
}
.content {
margin-top: 40px;
min-width: 240px;
padding: 8px 48px 24px;
}
/* Snap the content box to the whole height on short screens. */
@media (max-height: 480px) {
html,
body,
.content {
height: 100%;
}
.content {
margin-bottom: 0;
margin-top: 0;
padding-bottom: 0;
padding-top: 0;
}
.icon {
margin-top: 0;
padding-top: 32px; /* Define the top offset through the icon's padding,
......@@ -243,14 +137,6 @@ h1 {
/* Smaller vertical margins on very short screens. */
@media (max-height: 320px) {
h1,
#subtitle {
margin-bottom: 16px;
margin-top: 16px;
}
.learn-more-button,
.bulletpoints,
.icon,
#cookie-controls {
margin-bottom: 16px;
......@@ -260,66 +146,29 @@ h1 {
/* Narrow screens */
@media (max-width: 720px) {
.content {
min-width: 176px;
padding: 72px 32px;
}
.icon,
h1,
#subtitle {
.icon {
margin-bottom: 1.5rem;
margin-top: 1.5rem;
}
.bulletpoints,
.learn-more-button,
#cookie-controls {
margin-bottom: 1.5rem;
}
/* Smaller offsets on smaller screens. */
@media (max-height: 600px) {
.content {
padding-top: 48px;
}
.icon,
h1,
#subtitle {
.icon {
margin-bottom: 1rem;
margin-top: 1rem;
}
.bulletpoints,
.learn-more-button,
#cookie-controls {
margin-bottom: 1rem;
}
}
/* Small top offset on very small screens. */
@media (max-height: 480px) {
.content {
padding-top: 32px;
}
}
/* Undo the first and last elements margins. */
.icon {
margin-top: 0;
}
.learn-more-button {
margin-bottom: 0;
}
}
/* Very narrow screens. */
@media (max-width: 240px) {
.content {
min-width: 192px;
padding-inline-end: 24px;
padding-inline-start: 24px;
}
}
......@@ -17,6 +17,7 @@ $('incognitothemecss').href =
'chrome://theme/css/incognito_tab_theme.css?' + Date.now();
</script>
<link rel="stylesheet" href="chrome://resources/css/text_defaults_md.css">
<link rel="stylesheet" href="incognito_and_guest_tab.css">
<link rel="stylesheet" href="incognito_tab.css">
</head>
<body>
......
......@@ -9,7 +9,6 @@
#include "base/bind.h"
#include "base/macros.h"
#include "base/strings/utf_string_conversions.h"
#include "base/supports_user_data.h"
#include "base/task/post_task.h"
#include "base/threading/thread_task_runner_handle.h"
#include "build/build_config.h"
......@@ -47,6 +46,7 @@ namespace signin_util {
namespace {
constexpr char kSignoutSettingKey[] = "signout_setting";
constexpr char kGuestSignedInUserDataKey[] = "guest_signin";
#if defined(CAN_DELETE_PROFILE)
// Manager that presents the profile will be deleted dialog on the first active
......@@ -260,4 +260,27 @@ void EnsurePrimaryAccountAllowedForProfile(Profile* profile) {
#endif // !defined(OS_CHROMEOS)
}
// TODO(crbug.com/1134111): Remove GuestSignedInUserData when Ephemeral Guest
// sign in functioncality is implemented.
void GuestSignedInUserData::SetIsSignedIn(Profile* profile, bool is_signed_in) {
GuestSignedInUserData* data = GetForProfile(profile);
data->is_signed_in_ = is_signed_in;
}
bool GuestSignedInUserData::IsSignedIn(Profile* profile) {
return GetForProfile(profile)->is_signed_in_;
}
GuestSignedInUserData* GuestSignedInUserData::GetForProfile(Profile* profile) {
GuestSignedInUserData* data = static_cast<GuestSignedInUserData*>(
profile->GetUserData(kGuestSignedInUserDataKey));
if (!data) {
profile->SetUserData(kGuestSignedInUserDataKey,
std::make_unique<GuestSignedInUserData>());
data = static_cast<GuestSignedInUserData*>(
profile->GetUserData(kGuestSignedInUserDataKey));
}
return data;
}
} // namespace signin_util
......@@ -5,10 +5,25 @@
#ifndef CHROME_BROWSER_SIGNIN_SIGNIN_UTIL_H_
#define CHROME_BROWSER_SIGNIN_SIGNIN_UTIL_H_
#include "base/supports_user_data.h"
class Profile;
namespace signin_util {
// TODO(crbug.com/1134111): Remove GuestSignedInUserData when Ephemeral Guest
// sign in functioncality is implemented.
class GuestSignedInUserData : public base::SupportsUserData::Data {
public:
static void SetIsSignedIn(Profile* profile, bool is_signed_in);
static bool IsSignedIn(Profile* profile);
private:
static GuestSignedInUserData* GetForProfile(Profile* profile);
bool is_signed_in_ = false;
};
// Return whether the force sign in policy is enabled or not.
// The state of this policy will not be changed without relaunch Chrome.
bool IsForceSigninEnabled();
......
......@@ -1370,6 +1370,8 @@ static_library("ui") {
"webui/ntp/cookie_controls_handler.h",
"webui/ntp/core_app_launcher_handler.cc",
"webui/ntp/core_app_launcher_handler.h",
"webui/ntp/ephemeral_guest_signin_handler.cc",
"webui/ntp/ephemeral_guest_signin_handler.h",
"webui/ntp/new_tab_ui.cc",
"webui/ntp/new_tab_ui.h",
"webui/ntp/ntp_resource_cache.cc",
......
// Copyright 2020 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/ntp/ephemeral_guest_signin_handler.h"
#include "base/bind.h"
#include "base/values.h"
#include "chrome/browser/signin/signin_util.h"
EphemeralGuestSigninHandler::EphemeralGuestSigninHandler(Profile* profile)
: profile_(profile) {}
EphemeralGuestSigninHandler::~EphemeralGuestSigninHandler() = default;
// WebUIMessageHandler
void EphemeralGuestSigninHandler::RegisterMessages() {
web_ui()->RegisterMessageCallback(
"onChangeSignInStatusClicked",
base::BindRepeating(
&EphemeralGuestSigninHandler::HandleOnChangeSignInStatusClicked,
base::Unretained(this)));
}
void EphemeralGuestSigninHandler::HandleOnChangeSignInStatusClicked(
const base::ListValue* args) {
IsSignedIn() ? SignOutAsGuest() : SignInAsGuest();
}
void EphemeralGuestSigninHandler::SignInAsGuest() {
// TODO(crbug.com/1134111): Use IdentityManager to sign in when Ephemeral
// Guest sign in functioncality is implemented.
signin_util::GuestSignedInUserData::SetIsSignedIn(profile_,
/*is_signed_in*/ true);
}
void EphemeralGuestSigninHandler::SignOutAsGuest() {
// TODO(crbug.com/1134111): Use IdentityManager to sign out when Ephemeral
// Guest sign in functioncality is implemented.
signin_util::GuestSignedInUserData::SetIsSignedIn(profile_,
/*is_signed_in*/ false);
}
bool EphemeralGuestSigninHandler::IsSignedIn() {
// TODO(crbug.com/1134111): Use IdentityManager to check sign in status when
// Ephemeral Guest sign in functioncality is implemented.
return signin_util::GuestSignedInUserData::IsSignedIn(profile_);
}
// Copyright 2020 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_NTP_EPHEMERAL_GUEST_SIGNIN_HANDLER_H_
#define CHROME_BROWSER_UI_WEBUI_NTP_EPHEMERAL_GUEST_SIGNIN_HANDLER_H_
#include "chrome/browser/profiles/profile.h"
#include "content/public/browser/web_ui_message_handler.h"
namespace base {
class ListValue;
} // namespace base
// TODO(crbug.com/1125474): Rename to GuestSigninHandler once all audit is done
// and all instances of non-ephemeral Guest profiles are deprecated.
// Communicates with the ephemeral guest ntp to handle sign-in and sign-out.
class EphemeralGuestSigninHandler : public content::WebUIMessageHandler {
public:
explicit EphemeralGuestSigninHandler(Profile* profile);
~EphemeralGuestSigninHandler() override;
// WebUIMessageHandler
void RegisterMessages() override;
// Resolves JS call to sign in or sign out based on the |profile_| sign in
// status.
void HandleOnChangeSignInStatusClicked(const base::ListValue*);
private:
// Helper methods to handle sign in and sign out.
void SignInAsGuest();
void SignOutAsGuest();
bool IsSignedIn();
Profile* profile_;
DISALLOW_COPY_AND_ASSIGN(EphemeralGuestSigninHandler);
};
#endif // CHROME_BROWSER_UI_WEBUI_NTP_EPHEMERAL_GUEST_SIGNIN_HANDLER_H_
......@@ -17,6 +17,7 @@
#include "chrome/browser/ui/webui/ntp/app_launcher_handler.h"
#include "chrome/browser/ui/webui/ntp/cookie_controls_handler.h"
#include "chrome/browser/ui/webui/ntp/core_app_launcher_handler.h"
#include "chrome/browser/ui/webui/ntp/ephemeral_guest_signin_handler.h"
#include "chrome/browser/ui/webui/ntp/ntp_resource_cache.h"
#include "chrome/browser/ui/webui/ntp/ntp_resource_cache_factory.h"
#include "chrome/browser/ui/webui/theme_handler.h"
......@@ -63,6 +64,9 @@ NewTabUI::NewTabUI(content::WebUI* web_ui) : content::WebUIController(web_ui) {
web_ui->AddMessageHandler(
std::make_unique<CookieControlsHandler>(profile));
}
} else if (profile->IsEphemeralGuestProfile()) {
web_ui->AddMessageHandler(
std::make_unique<EphemeralGuestSigninHandler>(profile));
}
// content::URLDataSource assumes the ownership of the html source.
......
......@@ -8,7 +8,6 @@
#include <utility>
#include "base/bind.h"
#include "base/memory/ref_counted_memory.h"
#include "base/no_destructor.h"
#include "base/stl_util.h"
#include "base/strings/string16.h"
......@@ -22,6 +21,7 @@
#include "chrome/browser/policy/profile_policy_connector.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/signin/signin_util.h"
#include "chrome/browser/themes/theme_properties.h"
#include "chrome/browser/themes/theme_service.h"
#include "chrome/browser/themes/theme_service_factory.h"
......@@ -91,6 +91,10 @@ const char kLearnMoreGuestSessionUrl[] =
"https://support.google.com/chrome/?p=ui_guest";
#endif
// The URL for the Learn More page shown on ephermal guest session new tab.
const char kLearnMoreEphemeralGuestSessionUrl[] =
"https://support.google.com/chrome/?p=ui_guest";
SkColor GetThemeColor(const ui::ThemeProvider& tp, int id) {
SkColor color = tp.GetColor(id);
// If web contents are being inverted because the system is in high-contrast
......@@ -212,12 +216,30 @@ NTPResourceCache::WindowType NTPResourceCache::GetWindowType(
return NORMAL;
}
base::RefCountedMemory* NTPResourceCache::GetNewTabGuestHTML() {
if (!profile_->IsEphemeralGuestProfile()) {
if (!new_tab_guest_html_) {
GuestNTPInfo guest_ntp_info{kLearnMoreGuestSessionUrl, IDR_GUEST_TAB_HTML,
IDS_NEW_TAB_GUEST_SESSION_HEADING,
IDS_NEW_TAB_GUEST_SESSION_DESCRIPTION};
CreateNewTabGuestHTML(guest_ntp_info);
}
return new_tab_guest_html_.get();
}
// TODO(crbug.com/1134111): Use IdentityManager to check sign in status when
// Ephemeral Guest sign in functioncality is implemented.
const bool is_signed_in =
signin_util::GuestSignedInUserData::IsSignedIn(profile_);
return is_signed_in ? CreateNewTabEphemeralGuestSignedInHTML()
: CreateNewTabEphemeralGuestSignedOutHTML();
}
base::RefCountedMemory* NTPResourceCache::GetNewTabHTML(WindowType win_type) {
DCHECK_CURRENTLY_ON(BrowserThread::UI);
if (win_type == GUEST) {
if (!new_tab_guest_html_)
CreateNewTabGuestHTML();
return new_tab_guest_html_.get();
return GetNewTabGuestHTML();
}
if (win_type == INCOGNITO) {
......@@ -281,6 +303,7 @@ void NTPResourceCache::Invalidate() {
new_tab_incognito_css_ = nullptr;
new_tab_css_ = nullptr;
new_tab_guest_html_ = nullptr;
new_tab_guest_signed_in_html_ = nullptr;
}
void NTPResourceCache::CreateNewTabIncognitoHTML() {
......@@ -345,15 +368,47 @@ void NTPResourceCache::CreateNewTabIncognitoHTML() {
new_tab_incognito_html_ = base::RefCountedString::TakeString(&full_html);
}
void NTPResourceCache::CreateNewTabGuestHTML() {
base::RefCountedMemory*
NTPResourceCache::CreateNewTabEphemeralGuestSignedInHTML() {
if (!new_tab_guest_signed_in_html_) {
GuestNTPInfo guest_ntp_info{
kLearnMoreEphemeralGuestSessionUrl,
IDR_EPHEMERAL_GUEST_TAB_HTML,
IDS_NEW_TAB_EPHEMERAL_GUEST_SESSION_HEADING_SIGNED_IN,
IDS_NEW_TAB_EPHEMERAL_GUEST_SESSION_DESCRIPTION_SIGNED_IN,
IDS_NEW_TAB_EPHEMERAL_GUEST_NOT_SAVED_SIGNED_IN,
IDS_NEW_TAB_EPHEMERAL_GUEST_SAVED};
new_tab_guest_signed_in_html_ = CreateNewTabGuestHTML(guest_ntp_info);
}
return new_tab_guest_signed_in_html_.get();
}
base::RefCountedMemory*
NTPResourceCache::CreateNewTabEphemeralGuestSignedOutHTML() {
// Clear cached signed in HTML on sign out to avoid loading previously cached
// user name from other signed in guest sessions.
new_tab_guest_signed_in_html_ = nullptr;
if (!new_tab_guest_signed_out_html_) {
GuestNTPInfo guest_ntp_info{
kLearnMoreEphemeralGuestSessionUrl,
IDR_EPHEMERAL_GUEST_TAB_HTML,
IDS_NEW_TAB_EPHEMERAL_GUEST_SESSION_HEADING_SIGNED_OUT,
IDS_NEW_TAB_EPHEMERAL_GUEST_SESSION_DESCRIPTION_SIGNED_OUT,
IDS_NEW_TAB_EPHEMERAL_GUEST_NOT_SAVED_SIGNED_OUT,
IDS_NEW_TAB_EPHEMERAL_GUEST_SAVED};
new_tab_guest_signed_out_html_ = CreateNewTabGuestHTML(guest_ntp_info);
}
return new_tab_guest_signed_out_html_.get();
}
scoped_refptr<base::RefCountedString> NTPResourceCache::CreateNewTabGuestHTML(
const GuestNTPInfo& guest_ntp_info) {
base::DictionaryValue localized_strings;
localized_strings.SetString("title",
l10n_util::GetStringUTF16(IDS_NEW_TAB_TITLE));
const char* guest_tab_link = kLearnMoreGuestSessionUrl;
int guest_tab_idr = IDR_GUEST_TAB_HTML;
int guest_tab_description_ids = IDS_NEW_TAB_GUEST_SESSION_DESCRIPTION;
int guest_tab_heading_ids = IDS_NEW_TAB_GUEST_SESSION_HEADING;
int guest_tab_link_ids = IDS_LEARN_MORE;
int guest_tab_idr = guest_ntp_info.html_idr;
#if defined(OS_CHROMEOS)
guest_tab_idr = IDR_GUEST_SESSION_TAB_HTML;
......@@ -389,13 +444,28 @@ void NTPResourceCache::CreateNewTabGuestHTML() {
}
#endif
localized_strings.SetString("guestTabDescription",
l10n_util::GetStringUTF16(guest_tab_description_ids));
localized_strings.SetString("guestTabHeading",
l10n_util::GetStringUTF16(guest_tab_heading_ids));
if (guest_ntp_info.features_ids != -1) {
localized_strings.SetString(
"guestTabFeatures",
l10n_util::GetStringUTF16(guest_ntp_info.features_ids));
}
if (guest_ntp_info.warnings_ids != -1) {
localized_strings.SetString(
"guestTabWarning",
l10n_util::GetStringUTF16(guest_ntp_info.warnings_ids));
}
localized_strings.SetString(
"guestTabDescription",
l10n_util::GetStringUTF16(guest_ntp_info.description_ids));
// TODO(crbug.com/1134111): Replace placeholder with user's name in the
// greeting message when the guest sign in functionality is implemented.
localized_strings.SetString(
"guestTabHeading", l10n_util::GetStringUTF16(guest_ntp_info.heading_ids));
localized_strings.SetString("learnMore",
l10n_util::GetStringUTF16(guest_tab_link_ids));
localized_strings.SetString("learnMoreLink", guest_tab_link);
l10n_util::GetStringUTF16(IDS_LEARN_MORE));
localized_strings.SetString("learnMoreLink", guest_ntp_info.learn_more_link);
const std::string& app_locale = g_browser_process->GetApplicationLocale();
webui::SetLoadTimeDataDefaults(app_locale, &localized_strings);
......@@ -410,7 +480,7 @@ void NTPResourceCache::CreateNewTabGuestHTML() {
std::string full_html =
ReplaceTemplateExpressions(*guest_tab_html, replacements);
new_tab_guest_html_ = base::RefCountedString::TakeString(&full_html);
return base::RefCountedString::TakeString(&full_html);
}
// TODO(alancutter): Consider moving this utility function up somewhere where it
......
......@@ -10,6 +10,7 @@
#include "base/compiler_specific.h"
#include "base/macros.h"
#include "base/memory/ref_counted.h"
#include "base/memory/ref_counted_memory.h"
#include "base/scoped_observer.h"
#include "components/keyed_service/core/keyed_service.h"
#include "components/prefs/pref_change_registrar.h"
......@@ -50,6 +51,7 @@ class NTPResourceCache : public content::NotificationObserver,
explicit NTPResourceCache(Profile* profile);
~NTPResourceCache() override;
base::RefCountedMemory* GetNewTabGuestHTML();
base::RefCountedMemory* GetNewTabHTML(WindowType win_type);
base::RefCountedMemory* GetNewTabCSS(WindowType win_type);
......@@ -62,6 +64,28 @@ class NTPResourceCache : public content::NotificationObserver,
Profile* profile, content::RenderProcessHost* render_host);
private:
struct GuestNTPInfo {
explicit GuestNTPInfo(const char* learn_more_link,
int html_idr,
int heading_ids,
int description_ids,
int features_ids = -1,
int warnings_ids = -1)
: learn_more_link(learn_more_link),
html_idr(html_idr),
heading_ids(heading_ids),
description_ids(description_ids),
features_ids(features_ids),
warnings_ids(warnings_ids) {}
const char* learn_more_link;
int html_idr;
int heading_ids;
int description_ids;
int features_ids;
int warnings_ids;
};
// ui::NativeThemeObserver:
void OnNativeThemeUpdated(ui::NativeTheme* updated_theme) override;
......@@ -84,7 +108,13 @@ class NTPResourceCache : public content::NotificationObserver,
void CreateNewTabIncognitoHTML();
void CreateNewTabIncognitoCSS();
void CreateNewTabGuestHTML();
scoped_refptr<base::RefCountedString> CreateNewTabGuestHTML(
const GuestNTPInfo& guest_ntp_info);
// TODO(crbug.com/1125474): Rename to CreateNewTabGuestSigned{In|Out}HTML once
// all audit is done and all instances of non-ephemeral Guest profiles are
// deprecated.
base::RefCountedMemory* CreateNewTabEphemeralGuestSignedInHTML();
base::RefCountedMemory* CreateNewTabEphemeralGuestSignedOutHTML();
void SetDarkKey(base::Value* dict);
......@@ -93,6 +123,8 @@ class NTPResourceCache : public content::NotificationObserver,
scoped_refptr<base::RefCountedMemory> new_tab_html_;
scoped_refptr<base::RefCountedMemory> new_tab_css_;
scoped_refptr<base::RefCountedMemory> new_tab_guest_html_;
scoped_refptr<base::RefCountedMemory> new_tab_guest_signed_in_html_;
scoped_refptr<base::RefCountedMemory> new_tab_guest_signed_out_html_;
scoped_refptr<base::RefCountedMemory> new_tab_incognito_html_;
scoped_refptr<base::RefCountedMemory> new_tab_incognito_css_;
content::NotificationRegistrar registrar_;
......
......@@ -177,4 +177,56 @@
When on, sites can't use cookies that track you across the web. Features on some sites may break.
</message>
<!-- Ephemeral Guest Tab strings -->
<!-- TODO(crbug.com/1125474): Rename strings to *GUEST* instead of *EPHEMERAL_GUEST* once all audit is done and all instances of non-ephemeral Guest profiles are deprecated.-->
<message name="IDS_NEW_TAB_EPHEMERAL_GUEST_SESSION_HEADING_SIGNED_OUT"
desc="This is a greeting message that apprears when the user opens a new ephemeral guest tab while they are signed out of chrome guest session.">
You’re browsing as a Guest
</message>
<message name="IDS_NEW_TAB_EPHEMERAL_GUEST_SESSION_HEADING_SIGNED_IN"
desc="This is greeting message with the user's name, appears when user opens a new ephemeral guest tab while they are signed in to chrome guest session.">
Hi <ph name="USERNAME">%s<ex>Mariam</ex></ph>,
<ph name="BR">&lt;br&gt;</ph>
You’re browsing as a Guest
</message>
<message name="IDS_NEW_TAB_EPHEMERAL_GUEST_SESSION_DESCRIPTION_SIGNED_OUT"
desc="This is a message displayed on the ephemeral guest NTP when the user is signed out of chrome guest session emphasing that no chrome profile info will be available unless the user chooses to sign in. The user can click on 'sign in' to start the sign in to chrome guest session flow.">
You won't see any Chrome profile's info in Guest mode. You can <ph name="LINK_BEGIN">&lt;a id="change-sign-in-status"&gt;</ph>sign in<ph name="LINK_END">&lt;/a&gt;</ph> to access your Google account info like passwords and payment methods.
</message>
<message name="IDS_NEW_TAB_EPHEMERAL_GUEST_SESSION_DESCRIPTION_SIGNED_IN"
desc="This is a message displayed on the ephemeral guest NTP when the user is signed in to chrome guest session to encourage closing all open guest windows in order to delete their browsing activity from the device in use.">
Close all Guest windows so your browsing activity is deleted from this device.
</message>
<message name="IDS_NEW_TAB_EPHEMERAL_GUEST_NOT_SAVED_SIGNED_OUT"
desc="A list of bullet points that appears on the ephemeral guest NTP listing data that won't be saved on the device after closing all guest windows. This shows when the user is signed out of chrome guest session.">
<ph name="BEGIN_BOLD">&lt;b&gt;</ph>
Activity that won't stay on this device:
<ph name="END_BOLD">&lt;/b&gt;</ph>
<ph name="BEGIN_LIST">&lt;ul&gt;</ph>
<ph name="LIST_ITEM">&lt;li&gt;</ph>Pages you view in this window
<ph name="LIST_ITEM">&lt;li&gt;</ph>Cookies and site data
<ph name="END_LIST">&lt;/ul&gt;</ph>
</message>
<message name="IDS_NEW_TAB_EPHEMERAL_GUEST_NOT_SAVED_SIGNED_IN"
desc="A list of bullet points that appears on the ephemeral guest NTP listing data that won't be saved on the device after closing all guest windows. The user can click 'sign out' to sign out of the guest session. This shows when the user is signed in to chrome guest session.">
<ph name="BEGIN_BOLD">&lt;b&gt;</ph>
Activity that won't stay on this device:
<ph name="END_BOLD">&lt;/b&gt;</ph>
<ph name="BEGIN_LIST">&lt;ul&gt;</ph>
<ph name="LIST_ITEM">&lt;li&gt;</ph>Pages you view in this window
<ph name="LIST_ITEM">&lt;li&gt;</ph>Cookies and site data
<ph name="LIST_ITEM">&lt;li&gt;</ph>Account information (<ph name="LINK_BEGIN">&lt;a id="change-sign-in-status"&gt;</ph>sign out<ph name="LINK_END">&lt;/a&gt;</ph>)
<ph name="END_LIST">&lt;/ul&gt;</ph>
</message>
<message name="IDS_NEW_TAB_EPHEMERAL_GUEST_SAVED"
desc="A list of bullet points that appears on the ephemeral guest NTP listing data that will be saved on the device after closing all guest windows.">
<ph name="BEGIN_BOLD">&lt;b&gt;</ph>
Your activity that stays on this device:
<ph name="END_BOLD">&lt;/b&gt;</ph>
<ph name="BEGIN_LIST">&lt;ul&gt;</ph>
<ph name="LIST_ITEM">&lt;li&gt;</ph>Any files you download in this window
<ph name="END_LIST">&lt;/ul&gt;</ph>
</message>
</grit-part>
86bfc1bb0860fe4e7c5087945f3aaa62c3bc4b67
\ No newline at end of file
3cd7f2320f25ed84487cbcd1cc1b0680daa9f0cd
\ No newline at end of file
e73c15ea0f9910de922dc6dc8d06eac889489fcc
\ No newline at end of file
estade@chromium.org
rbyers@chromium.org
file://chrome/browser/ui/webui/ntp/OWNERS
# TEAM: ntp-dev@chromium.org
# COMPONENT: UI>Browser>NewTabPage
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