Commit 037078bf authored by Rohit Agarwal's avatar Rohit Agarwal Committed by Commit Bot

Relaunch chrome warns about the open incognito windows.

Chrome didn't warn the users about open incognito windows that would
be lost during the update.

Added a general warning in the settings and a personailzed warning,
indicating the count of open incognito windows in the Relaunch Chrome
dialog.

Bug: 810989
Change-Id: Ibd6bf11024e94b0490964f3cdf2236d10c14d998
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1814924Reviewed-by: default avatarElly Fong-Jones <ellyjones@chromium.org>
Reviewed-by: default avatarGreg Thompson <grt@chromium.org>
Commit-Queue: Rohit Agarwal <roagarwal@chromium.org>
Cr-Commit-Position: refs/heads/master@{#706010}
parent 1258a956
......@@ -837,8 +837,11 @@ Chromium is unable to recover your settings.
<message name="IDS_UPDATE_RECOMMENDED_DIALOG_TITLE" desc="The window title for the Update Recommended dialog.">
Relaunch Chromium
</message>
<message name="IDS_UPDATE_RECOMMENDED" desc="The main text of the Update Recommended dialog.">
A new update for Chromium is available and will be applied as soon as you relaunch.
<message name="IDS_UPDATE_RECOMMENDED" desc="The main text of the Update Recommended dialog with a count of open incognito windows.">
{COUNT, plural,
=0 {A new update for Chromium is available and will be applied as soon as you relaunch.}
=1 {A new update for Chromium is available and will be applied as soon as you relaunch. Your Incognito window won't reopen.}
other {A new update for Chromium is available and will be applied as soon as you relaunch. Your # Incognito windows won't reopen.}}
</message>
<message name="IDS_RELAUNCH_AND_UPDATE" desc="The button in the Update Recommended dialog which updates and relaunches Chrome.">
Relaunch
......@@ -1012,8 +1015,11 @@ Chromium is unable to recover your settings.
=1 {A Chromium update is available}
other {A Chromium update has been available for # days}}
</message>
<message name="IDS_RELAUNCH_RECOMMENDED_BODY" desc="The body text of a dialog that tells users that a browser relaunch is recommended for an update.">
Your administrator asks that you relaunch Chromium to apply this update
<message name="IDS_RELAUNCH_RECOMMENDED_BODY" desc="The body text of a dialog that tells users that a browser relaunch is recommended for an update with Incognito counter.">
{COUNT, plural,
=0 {Your administrator asks that you relaunch Chromium to apply this update}
=1 {Your administrator asks that you relaunch Chromium to apply this update. Your Incognito window won't reopen.}
other {Your administrator asks that you relaunch Chromium to apply this update. Your # Incognito windows won't reopen.}}
</message>
<message name="IDS_RELAUNCH_REQUIRED_TITLE_DAYS" desc="The title of a dialog that tells users the browser must be relaunched within two or more days.">
{0, plural,
......@@ -1036,8 +1042,11 @@ Chromium is unable to recover your settings.
=1 {Chromium will relaunch in 1 second}
other {Chromium will relaunch in # seconds}}
</message>
<message name="IDS_RELAUNCH_REQUIRED_BODY" desc="The body text of a dialog that tells users the browser must be relaunched.">
Your administrator requires that you relaunch Chromium to apply an update
<message name="IDS_RELAUNCH_REQUIRED_BODY" desc="The body text of a dialog that tells users the browser must be relaunched with Incognito counter.">
{COUNT, plural,
=0 {Your administrator requires that you relaunch Chromium to apply an update}
=1 {Your administrator requires that you relaunch Chromium to apply an update. Your Incognito window won't reopen.}
other {Your administrator requires that you relaunch Chromium to apply an update. Your # Incognito windows won't reopen.}}
</message>
</if>
</if>
......
5d5c957d3b23f4e9f3fe56d8ba610b32001d52e9
\ No newline at end of file
5d9a7b76a0f59fbf8fbf74c8305da20dc9507338
\ No newline at end of file
f00092413633d4d1bfc0b64944c193348192fb87
\ No newline at end of file
270baa6fde66cb826f416520ea42c091fc90ae6d
\ No newline at end of file
2985a8b008208c2791a0542a7d0afc60e27883f2
\ No newline at end of file
4067572daf58a1cd160431ce3a5279101d4bc2f0
\ No newline at end of file
ead8fbc8e9aac9306bf9c7f66d6b2e473321857f
\ No newline at end of file
a42aaa2f757b722732a1b4c8f369872fcddfa8d1
\ No newline at end of file
dbb4063327ffaf3a727db7e6c64f95642e314689
\ No newline at end of file
......@@ -856,8 +856,11 @@ Google Chrome is unable to recover your settings.
<message name="IDS_UPDATE_RECOMMENDED_DIALOG_TITLE" desc="The window title for the Update Recommended dialog.">
Relaunch Chrome
</message>
<message name="IDS_UPDATE_RECOMMENDED" desc="The main text of the Update Recommended dialog.">
A new update for Chrome is available and will be applied as soon as you relaunch.
<message name="IDS_UPDATE_RECOMMENDED" desc="The main text of the Update Recommended dialog with a count of open incognito windows.">
{COUNT, plural,
=0 {A new update for Chrome is available and will be applied as soon as you relaunch.}
=1 {A new update for Chrome is available and will be applied as soon as you relaunch. Your Incognito window won't reopen.}
other {A new update for Chrome is available and will be applied as soon as you relaunch. Your # Incognito windows won't reopen.}}
</message>
<message name="IDS_RELAUNCH_AND_UPDATE" desc="The button in the Update Recommended dialog which updates and relaunches Chrome.">
Relaunch
......@@ -1031,8 +1034,11 @@ Google Chrome is unable to recover your settings.
=1 {A Chrome update is available}
other {A Chrome update has been available for # days}}
</message>
<message name="IDS_RELAUNCH_RECOMMENDED_BODY" desc="The body text of a dialog that tells users that a browser relaunch is recommended for an update.">
Your administrator asks that you relaunch Chrome to apply this update
<message name="IDS_RELAUNCH_RECOMMENDED_BODY" desc="The body text of a dialog that tells users that a browser relaunch is recommended for an update with Incognito counter.">
{COUNT, plural,
=0 {Your administrator asks that you relaunch Chrome to apply this update}
=1 {Your administrator asks that you relaunch Chrome to apply this update. Your Incognito window won't reopen.}
other {Your administrator asks that you relaunch Chrome to apply this update. Your # Incognito windows won't reopen.}}
</message>
<message name="IDS_RELAUNCH_REQUIRED_TITLE_DAYS" desc="The title of a dialog that tells users the browser must be relaunched within two or more days.">
{0, plural,
......@@ -1055,8 +1061,11 @@ Google Chrome is unable to recover your settings.
=1 {Chrome will relaunch in 1 second}
other {Chrome will relaunch in # seconds}}
</message>
<message name="IDS_RELAUNCH_REQUIRED_BODY" desc="The body text of a dialog that tells users the browser must be relaunched.">
Your administrator requires that you relaunch Chrome to apply an update
<message name="IDS_RELAUNCH_REQUIRED_BODY" desc="The body text of a dialog that tells users the browser must be relaunched with Incognito counter">
{COUNT, plural,
=0 {Your administrator requires that you relaunch Chrome to apply an update}
=1 {Your administrator requires that you relaunch Chrome to apply an update. Your Incognito window won't reopen.}
other {Your administrator requires that you relaunch Chrome to apply an update. Your # Incognito windows won't reopen.}}
</message>
</if>
</if>
......
......@@ -16,7 +16,7 @@
Updating Google Chrome (<ph name="PROGRESS_PERCENT">$1<ex>90%</ex></ph>)
</message>
<message name="IDS_SETTINGS_UPGRADE_SUCCESSFUL_RELAUNCH" desc="Status label: Successfully updated Google Chrome">
Nearly up to date! Relaunch Google Chrome to finish updating.
Nearly up to date! Relaunch Google Chrome to finish updating. Incognito windows won't reopen.
</message>
<message name="IDS_SETTINGS_UPGRADE_UP_TO_DATE" desc="Status label: Already up to date (Google Chrome)">
Google Chrome is up to date
......
......@@ -333,6 +333,15 @@ int BrowserList::GetIncognitoSessionsActiveForProfile(Profile* profile) {
});
}
// static
size_t BrowserList::GetIncognitoBrowserCount() {
BrowserList* list = BrowserList::GetInstance();
return std::count_if(list->begin(), list->end(), [](Browser* browser) {
return browser->profile()->IsIncognitoProfile() &&
!browser->is_type_devtools();
});
}
// static
bool BrowserList::IsIncognitoSessionInUse(Profile* profile) {
BrowserList* list = BrowserList::GetInstance();
......
......@@ -123,8 +123,14 @@ class BrowserList {
// Returns the number of active incognito sessions for |profile| across all
// desktops. Note that this function does not count devtools windows opened
// for incognito windows.
// TODO(crbug.com/1014002) : Refactor the name from IncognitoSessions to
// IncognitoBrowser here and elsewhere in this file, wherever applicable.
static int GetIncognitoSessionsActiveForProfile(Profile* profile);
// Returns the number of active incognito browsers except devtools windows
// across all desktops.
static size_t GetIncognitoBrowserCount();
// Returns true if the incognito session for |profile| is in use in any window
// across all desktops. This function considers devtools windows as well.
static bool IsIncognitoSessionInUse(Profile* profile);
......
......@@ -14,6 +14,7 @@
#include "base/time/time.h"
#include "build/build_config.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "chrome/browser/ui/views/frame/browser_view.h"
#include "chrome/browser/ui/views/toolbar/browser_app_menu_button.h"
......@@ -104,11 +105,13 @@ bool RelaunchRecommendedBubbleView::ShouldShowWindowIcon() const {
void RelaunchRecommendedBubbleView::Init() {
SetLayoutManager(std::make_unique<views::FillLayout>());
body_label_ =
new views::Label(l10n_util::GetStringUTF16(IDS_RELAUNCH_RECOMMENDED_BODY),
views::style::CONTEXT_MESSAGE_BOX_BODY_TEXT);
body_label_->SetMultiLine(true);
body_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
auto label = std::make_unique<views::Label>(
l10n_util::GetPluralStringFUTF16(IDS_RELAUNCH_RECOMMENDED_BODY,
BrowserList::GetIncognitoBrowserCount()),
views::style::CONTEXT_MESSAGE_BOX_BODY_TEXT);
label->SetMultiLine(true);
label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
// Align the body label with the left edge of the bubble's title.
// TODO(bsep): Remove this when fixing https://crbug.com/810970.
......@@ -117,10 +120,10 @@ void RelaunchRecommendedBubbleView::Init() {
->GetInsetsMetric(views::INSETS_DIALOG_TITLE)
.left() +
kTitleIconSize;
body_label_->SetBorder(views::CreateEmptyBorder(
label->SetBorder(views::CreateEmptyBorder(
gfx::Insets(0, title_offset - margins().left(), 0, 0)));
AddChildView(body_label_);
AddChildView(std::move(label));
base::RecordAction(base::UserMetricsAction("RelaunchRecommendedShown"));
}
......@@ -149,7 +152,6 @@ RelaunchRecommendedBubbleView::RelaunchRecommendedBubbleView(
base::RepeatingClosure on_accept)
: LocationBarBubbleDelegateView(anchor_button, nullptr),
on_accept_(std::move(on_accept)),
body_label_(nullptr),
relaunch_recommended_timer_(
detection_time,
base::BindRepeating(&RelaunchRecommendedBubbleView::UpdateWindowTitle,
......
......@@ -15,7 +15,6 @@ class Browser;
namespace views {
class Button;
class Label;
class Widget;
} // namespace views
......@@ -60,9 +59,6 @@ class RelaunchRecommendedBubbleView : public LocationBarBubbleDelegateView {
// A callback run if the user accepts the prompt to relaunch the browser.
base::RepeatingClosure on_accept_;
// The label containing the body text of the bubble.
views::Label* body_label_;
// Timer that schedules title refreshes.
RelaunchRecommendedTimer relaunch_recommended_timer_;
......
......@@ -11,6 +11,7 @@
#include "base/metrics/user_metrics_action.h"
#include "chrome/browser/ui/browser.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/browser_window.h"
#include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "chrome/grit/chromium_strings.h"
......@@ -108,7 +109,6 @@ RelaunchRequiredDialogView::RelaunchRequiredDialogView(
base::Time deadline,
base::RepeatingClosure on_accept)
: on_accept_(on_accept),
body_label_(nullptr),
relaunch_required_timer_(
deadline,
base::BindRepeating(&RelaunchRequiredDialogView::UpdateWindowTitle,
......@@ -125,11 +125,12 @@ RelaunchRequiredDialogView::RelaunchRequiredDialogView(
set_margins(ChromeLayoutProvider::Get()->GetDialogInsetsForContentType(
views::TEXT, views::TEXT));
body_label_ =
new views::Label(l10n_util::GetStringUTF16(IDS_RELAUNCH_REQUIRED_BODY),
views::style::CONTEXT_MESSAGE_BOX_BODY_TEXT);
body_label_->SetMultiLine(true);
body_label_->SetHorizontalAlignment(gfx::ALIGN_LEFT);
auto label = std::make_unique<views::Label>(
l10n_util::GetPluralStringFUTF16(IDS_RELAUNCH_REQUIRED_BODY,
BrowserList::GetIncognitoBrowserCount()),
views::style::CONTEXT_MESSAGE_BOX_BODY_TEXT);
label->SetMultiLine(true);
label->SetHorizontalAlignment(gfx::ALIGN_LEFT);
// Align the body label with the left edge of the dialog's title.
// TODO(bsep): Remove this when fixing https://crbug.com/810970.
......@@ -137,10 +138,10 @@ RelaunchRequiredDialogView::RelaunchRequiredDialogView(
->GetInsetsMetric(views::INSETS_DIALOG_TITLE)
.left() +
kTitleIconSize;
body_label_->SetBorder(views::CreateEmptyBorder(
label->SetBorder(views::CreateEmptyBorder(
gfx::Insets(0, title_offset - margins().left(), 0, 0)));
AddChildView(body_label_);
AddChildView(std::move(label));
base::RecordAction(base::UserMetricsAction("RelaunchRequiredShown"));
}
......
......@@ -13,7 +13,6 @@
class Browser;
namespace views {
class Label;
class Widget;
} // namespace views
......@@ -63,9 +62,6 @@ class RelaunchRequiredDialogView : views::DialogDelegateView {
// A callback to run if the user accepts the prompt to relaunch the browser.
base::RepeatingClosure on_accept_;
// The label containing the body text of the dialog.
views::Label* body_label_;
// Timer that schedules title refreshes.
RelaunchRequiredTimer relaunch_required_timer_;
......
......@@ -7,6 +7,7 @@
#include "build/build_config.h"
#include "chrome/browser/lifetime/application_lifetime.h"
#include "chrome/browser/ui/browser_dialogs.h"
#include "chrome/browser/ui/browser_list.h"
#include "chrome/browser/ui/views/chrome_layout_provider.h"
#include "chrome/grit/chromium_strings.h"
#include "components/constrained_window/constrained_window_views.h"
......@@ -42,8 +43,15 @@ UpdateRecommendedMessageBox::UpdateRecommendedMessageBox() {
ui::DIALOG_BUTTON_OK, l10n_util::GetStringUTF16(IDS_RELAUNCH_AND_UPDATE));
DialogDelegate::set_button_label(ui::DIALOG_BUTTON_CANCEL,
l10n_util::GetStringUTF16(IDS_NOT_NOW));
views::MessageBoxView::InitParams params(
l10n_util::GetStringUTF16(IDS_UPDATE_RECOMMENDED));
base::string16 update_message;
#if defined(OS_CHROMEOS)
update_message = l10n_util::GetStringUTF16(IDS_UPDATE_RECOMMENDED);
#else
update_message = l10n_util::GetPluralStringFUTF16(
IDS_UPDATE_RECOMMENDED, BrowserList::GetIncognitoBrowserCount());
#endif
views::MessageBoxView::InitParams params(update_message);
params.message_width = ChromeLayoutProvider::Get()->GetDistanceMetric(
ChromeDistanceMetric::DISTANCE_MODAL_DIALOG_PREFERRED_WIDTH);
// Also deleted when the window closes.
......
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