Commit 0898a0b4 authored by Monica Basta's avatar Monica Basta Committed by Commit Bot

Show a message if sync is paused due to clear cookies on exit.

This CL implements a mockup that shows a message in the profile chooser view
explaining that sync is paused due to cookie settings set to clear cookies on
exit. On click on 'your settings' within the message, the user gets directed to
the cookie settings page. This view is only visible if sync is paused and
cookie settings is set to 'clear cookies on exit'.

Bug: 942456
Change-Id: Ia353fe6e5750b56a61d8771c09bea651a267810f
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1664081Reviewed-by: default avatarThomas Tangl <tangltom@chromium.org>
Reviewed-by: default avatarJesse Doherty <jwd@chromium.org>
Reviewed-by: default avatarMihai Sardarescu <msarda@chromium.org>
Reviewed-by: default avatarDan Beam <dbeam@chromium.org>
Commit-Queue: Monica Basta <msalama@google.com>
Cr-Commit-Position: refs/heads/master@{#672456}
parent 07b0e39e
......@@ -44,6 +44,12 @@
<message name="IDS_AVATAR_BUTTON_SYNC_PAUSED_TOOLTIP" desc="Tooltip for the avatar button when sync is paused for the current profile.">
<ph name="PROFILE_NAME">$1<ex>User</ex></ph>: Sync paused
</message>
<message name="IDS_SYNC_PAUSED_REASON_CLEAR_COOKIES_ON_EXIT" desc="Info text displayed in the user menu when sync is paused due to cookies cleared on exit.">
Sync is paused because you clear cookies on start up. Change <ph name="COOKIE_SETTINGS_LINK">$1<ex>your settings</ex></ph> to keep syncing.
</message>
<message name="IDS_SYNC_PAUSED_REASON_CLEAR_COOKIES_ON_EXIT_LINK_TEXT" desc="Link text part of the sync paused info text when sync is paused due to cookies cleared on exit.">
your settings
</message>
<message name="IDS_LEGACY_SUPERVISED_USER_NEW_AVATAR_LABEL" desc="Label shown in the new avatar menu for a supervised user.">
<ph name="PROFILE_DISPLAY_NAME">$1<ex>Markus</ex></ph> (Supervised)
</message>
......
......@@ -20,6 +20,7 @@
#include "chrome/browser/profiles/profile_avatar_icon_util.h"
#include "chrome/browser/profiles/profiles_state.h"
#include "chrome/browser/signin/account_consistency_mode_manager.h"
#include "chrome/browser/signin/chrome_signin_client_factory.h"
#include "chrome/browser/signin/identity_manager_factory.h"
#include "chrome/browser/signin/signin_error_controller_factory.h"
#include "chrome/browser/signin/signin_ui_util.h"
......@@ -94,6 +95,12 @@ void NavigateToGoogleAccountPage(Profile* profile, const std::string& email) {
Navigate(&params);
}
bool AreSigninCookiesClearedOnExit(Profile* profile) {
SigninClient* client =
ChromeSigninClientFactory::GetInstance()->GetForProfile(profile);
return client->AreSigninCookiesDeletedOnExit();
}
#if defined(GOOGLE_CHROME_BUILD)
// Returns the Google G icon in grey and with a padding of 2. The padding is
// needed to make the icon look smaller, otherwise it looks too big compared to
......@@ -158,6 +165,7 @@ void ProfileChooserView::Reset() {
addresses_button_ = nullptr;
signout_button_ = nullptr;
manage_google_account_button_ = nullptr;
cookies_cleared_on_exit_label_ = nullptr;
}
void ProfileChooserView::Init() {
......@@ -395,6 +403,17 @@ void ProfileChooserView::ButtonPressed(views::Button* sender,
}
}
void ProfileChooserView::StyledLabelLinkClicked(views::StyledLabel* label,
const gfx::Range& range,
int event_flags) {
DCHECK_EQ(cookies_cleared_on_exit_label_, label);
chrome::ShowSettingsSubPage(browser(), chrome::kContentSettingsSubPage +
std::string("/") +
chrome::kCookieSettingsSubPage);
base::RecordAction(
base::UserMetricsAction("ProfileChooser_CookieSettingsClicked"));
}
void ProfileChooserView::AddProfileChooserView(AvatarMenu* avatar_menu) {
// Separate items into active and alternatives.
const AvatarMenu::Item* active_item = nullptr;
......@@ -491,6 +510,10 @@ void ProfileChooserView::AddDiceSyncErrorView(
AddMenuGroup();
if (show_sync_paused_ui &&
AreSigninCookiesClearedOnExit(browser()->profile())) {
AddSyncPausedReasonCookiesClearedOnExit();
}
// Add profile card.
auto current_profile_photo = std::make_unique<BadgedProfilePhoto>(
show_sync_paused_ui
......@@ -522,6 +545,38 @@ void ProfileChooserView::AddDiceSyncErrorView(
}
}
void ProfileChooserView::AddSyncPausedReasonCookiesClearedOnExit() {
size_t offset = 0;
std::unique_ptr<views::StyledLabel> sync_paused_reason =
std::make_unique<views::StyledLabel>(base::string16(), this);
base::string16 link_text = l10n_util::GetStringUTF16(
IDS_SYNC_PAUSED_REASON_CLEAR_COOKIES_ON_EXIT_LINK_TEXT);
base::string16 message = l10n_util::GetStringFUTF16(
IDS_SYNC_PAUSED_REASON_CLEAR_COOKIES_ON_EXIT, link_text, &offset);
sync_paused_reason->SetText(message);
// Mark the link text as link.
sync_paused_reason->AddStyleRange(
gfx::Range(offset, offset + link_text.length()),
views::StyledLabel::RangeStyleInfo::CreateForLink());
// Mark the rest of the text as secondary text.
views::StyledLabel::RangeStyleInfo message_style;
message_style.text_style = STYLE_SECONDARY;
gfx::Range before_link_range(0, offset);
if (!before_link_range.is_empty())
sync_paused_reason->AddStyleRange(before_link_range, message_style);
gfx::Range after_link_range(offset + link_text.length(), message.length());
if (!after_link_range.is_empty())
sync_paused_reason->AddStyleRange(after_link_range, message_style);
cookies_cleared_on_exit_label_ = sync_paused_reason.get();
AddViewItem(std::move(sync_paused_reason));
}
void ProfileChooserView::AddCurrentProfileView(
const AvatarMenu::Item& avatar_item,
bool is_guest) {
......
......@@ -21,6 +21,7 @@
#include "chrome/browser/ui/views/profiles/profile_menu_view_base.h"
#include "components/signin/core/browser/signin_header_helper.h"
#include "services/identity/public/cpp/identity_manager.h"
#include "ui/views/controls/styled_label.h"
namespace views {
class Button;
......@@ -62,6 +63,11 @@ class ProfileChooserView : public ProfileMenuViewBase,
// views::ButtonListener:
void ButtonPressed(views::Button* sender, const ui::Event& event) override;
// views::StyledLabelListener
void StyledLabelLinkClicked(views::StyledLabel* label,
const gfx::Range& range,
int event_flags) override;
// AvatarMenuObserver:
void OnAvatarMenuChanged(AvatarMenu* avatar_menu) override;
......@@ -119,6 +125,10 @@ class ProfileChooserView : public ProfileMenuViewBase,
sync_ui_util::AvatarSyncErrorType error,
int button_string_id);
// Add a view showing that the reason for the sync paused is in the cookie
// settings setup. On click, will direct to the cookie settings page.
void AddSyncPausedReasonCookiesClearedOnExit();
// Adds a promo for signin, if dice is not enabled.
void AddPreDiceSigninPromo();
......@@ -168,6 +178,8 @@ class ProfileChooserView : public ProfileMenuViewBase,
views::Button* signout_button_;
views::Button* manage_google_account_button_;
views::StyledLabel* cookies_cleared_on_exit_label_;
// View for the signin/turn-on-sync button in the dice promo.
DiceSigninButtonView* dice_signin_button_view_;
......
......@@ -338,6 +338,7 @@ const char kAddressesSubPage[] = "addresses";
const char kAutofillSubPage[] = "autofill";
const char kClearBrowserDataSubPage[] = "clearBrowserData";
const char kContentSettingsSubPage[] = "content";
const char kCookieSettingsSubPage[] = "cookies";
const char kDeprecatedExtensionsSubPage[] = "extensions";
const char kHandlerSettingsSubPage[] = "handlers";
const char kImportDataSubPage[] = "importData";
......
......@@ -297,6 +297,7 @@ extern const char kAddressesSubPage[];
extern const char kAutofillSubPage[];
extern const char kClearBrowserDataSubPage[];
extern const char kContentSettingsSubPage[];
extern const char kCookieSettingsSubPage[];
extern const char kCreateProfileSubPage[];
extern const char kDeprecatedExtensionsSubPage[];
extern const char kHandlerSettingsSubPage[];
......
......@@ -16755,6 +16755,15 @@ should be able to be added at any place in this file.
</description>
</action>
<action name="ProfileChooser_CookieSettingsClicked">
<owner>msalama@chromium.org</owner>
<description>
User clicked on settings from the user menu prompted message to go to cookie
settings. The prompt was shown because sync is paused due to cookie settings
set to clear cookies on exit.
</description>
</action>
<action name="ProfileChooser_GuestClicked">
<owner>vasilii@chromium.org</owner>
<owner>ewald@chromium.org</owner>
......
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