Commit cd6c0f64 authored by Daniel Hosseinian's avatar Daniel Hosseinian Committed by Commit Bot

Add Cloud Print deprecation warning in destinations dialog

Show a Cloud Print deprecation warning at the top of the destinations
dialog if any of the destinations are being deprecated.

Screenshot of change: https://imgur.com/GClle7p

Bug: 1112581
Change-Id: I42d7086ea0da2f2443d2a59dd540e6aafdf78472
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2361046
Commit-Queue: Daniel Hosseinian <dhoss@chromium.org>
Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#799507}
parent 0f75f3b2
......@@ -9602,7 +9602,7 @@ Please help our engineers fix this problem. Tell us what happened right before y
<!--Cloud printing deprecation messages for chrome://devices & Print Preview-->
<message name="IDS_CLOUD_PRINTING_NOT_SUPPORTED_WARNING" desc="Warning shown to the user to inform them that cloud printing will no longer be supported.">
Cloud printing will no longer be supported after December 31. <ph name="BEGIN_LINK_LEARN_MORE">&lt;a is="action-link" href="$1" target="_blank"&gt;</ph>Learn more<ph name="END_LINK_LEARN_MORE">&lt;/a&gt;</ph>
Cloud printing will no longer be supported after December 31. <ph name="BEGIN_LINK_LEARN_MORE">&lt;a href="$1<ex>https://google.com/</ex>" target="_blank"&gt;</ph>Learn more<ph name="END_LINK_LEARN_MORE">&lt;/a&gt;</ph>
</message>
<message name="IDS_CLOUD_PRINTING_NOT_SUPPORTED_WARNING_ENTERPRISE" desc="Warning shown to users managed by enterprise policy to inform them that cloud printing will no longer be supported.">
Cloud printing will no longer be supported after December 31. Contact your administrator.
......
4718d4b2fdf1d1d568e31fc99b052ed9b9766243
\ No newline at end of file
87675a3014a60ca7b660e94df7edb4987ae9a8a2
\ No newline at end of file
......@@ -418,6 +418,9 @@
<message name="IDS_DESTINATION_NOT_SUPPORTED_WARNING" desc="Warning shown next to a destination to the user to inform them that the destination will no longer be supported.">
Not supported after December
</message>
<message name="IDS_WARNING_ICON_ARIA_LABEL" desc="Accessibility text for a warning icon that is next to a string indicating cloud printing will no longer be supported.">
Warning
</message>
<if expr="not chromeos">
<message name="IDS_GOOGLE_DRIVE_OPTION_NOT_SUPPORTED_WARNING" desc="Warning shown to the user to inform them that saving to Google Drive will no longer be supported.">
This option won't be supported after December. <ph name="BEGIN_LINK_LEARN_MORE">&lt;a href="$1<ex>https://google.com/</ex>" target="_blank"&gt;</ph>Learn more<ph name="END_LINK_LEARN_MORE">&lt;/a&gt;</ph>
......
87675a3014a60ca7b660e94df7edb4987ae9a8a2
\ No newline at end of file
......@@ -91,6 +91,24 @@
font-size: calc(10 / 13 * 1em);
font-weight: 500;
}
.destinations-status {
align-items: center;
display: flex;
margin-bottom: 16px;
}
iron-icon {
--google-orange-600: rgb(232, 113, 10); /* e8710a */
fill: var(--google-orange-600);
flex-shrink: 0;
padding-inline-end: 8px;
padding-inline-start: 4px;
}
#warning-message {
color: var(--cr-primary-text-color);
}
</style>
<cr-dialog id="dialog" on-close="onCloseOrCancel_">
<div slot="title" id="header">$i18n{destinationSearchTitle}</div>
......@@ -105,6 +123,13 @@
<option value="">$i18n{addAccountTitle}</option>
</select>
</div>
<div class="destinations-status" hidden$="[[!showCloudPrintWarning_]]">
<iron-icon icon="cr:warning" aria-label="$i18n{warningIconAriaLabel}">
</iron-icon>
<span id="warning-message">
$i18nRaw{cloudPrintingNotSupportedWarning}
</span>
</div>
<print-preview-search-box id="searchBox"
label="$i18n{searchBoxPlaceholder}" search-query="{{searchQuery_}}"
autofocus>
......
......@@ -9,6 +9,8 @@ import 'chrome://resources/cr_elements/shared_vars_css.m.js';
import 'chrome://resources/js/action_link.js';
import 'chrome://resources/cr_elements/action_link_css.m.js';
import 'chrome://resources/cr_elements/md_select_css.m.js';
import 'chrome://resources/cr_elements/icons.m.js';
import 'chrome://resources/polymer/v3_0/iron-icon/iron-icon.js';
import '../print_preview_utils.js';
import './destination_list.js';
import './print_preview_search_box.js';
......@@ -79,6 +81,13 @@ Polymer({
value: false,
},
/** @private {boolean} */
showCloudPrintWarning_: {
type: Boolean,
computed: 'computeShowCloudPrintWarning_(destinations_.splices)',
value: false,
},
/** @private {?RegExp} */
searchQuery_: {
type: Object,
......@@ -109,6 +118,18 @@ Polymer({
this.tracker_.removeAll();
},
/**
* @return {boolean} Whether the destinations dialog should show a Cloud Print
* deprecation warning.
* @private
*/
computeShowCloudPrintWarning_() {
return this.destinations_.some(destination => {
return destination.shouldShowSaveToDriveWarning ||
destination.shouldShowDeprecatedPrinterWarning;
});
},
/**
* @param {!KeyboardEvent} e Event containing the key
* @private
......
......@@ -315,6 +315,7 @@ void AddPrintPreviewStrings(content::WebUIDataSource* source) {
{"title", IDS_PRINT_PREVIEW_TITLE},
{"top", IDS_PRINT_PREVIEW_TOP_MARGIN_LABEL},
{"unsupportedCloudPrinter", IDS_PRINT_PREVIEW_UNSUPPORTED_CLOUD_PRINTER},
{"warningIconAriaLabel", IDS_WARNING_ICON_ARIA_LABEL},
#if defined(OS_CHROMEOS)
{"configuringFailedText", IDS_PRINT_CONFIGURING_FAILED_TEXT},
{"configuringInProgressText", IDS_PRINT_CONFIGURING_IN_PROGRESS_TEXT},
......@@ -352,9 +353,17 @@ void AddPrintPreviewStrings(content::WebUIDataSource* source) {
const bool is_enterprise_managed = webui::IsEnterpriseManaged();
if (is_enterprise_managed) {
source->AddLocalizedString(
"cloudPrintingNotSupportedWarning",
IDS_CLOUD_PRINTING_NOT_SUPPORTED_WARNING_ENTERPRISE);
source->AddLocalizedString("printerNotSupportedWarning",
IDS_PRINTER_NOT_SUPPORTED_WARNING_ENTERPRISE);
} else {
source->AddString(
"cloudPrintingNotSupportedWarning",
l10n_util::GetStringFUTF16(
IDS_CLOUD_PRINTING_NOT_SUPPORTED_WARNING,
base::ASCIIToUTF16(cloud_devices::kCloudPrintDeprecationHelpURL)));
source->AddString(
"printerNotSupportedWarning",
l10n_util::GetStringFUTF16(
......
......@@ -2,8 +2,9 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import {Destination, DestinationStore, InvitationStore, LocalDestinationInfo, makeRecentDestination, NativeLayerImpl, RecentDestination} from 'chrome://print/print_preview.js';
import {Destination, DestinationConnectionStatus, DestinationOrigin, DestinationStore, DestinationType, InvitationStore, LocalDestinationInfo, makeRecentDestination, NativeLayerImpl, RecentDestination} from 'chrome://print/print_preview.js';
import {assert} from 'chrome://resources/js/assert.m.js';
import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js';
import {keyEventOn} from 'chrome://resources/polymer/v3_0/iron-test-helpers/mock-interactions.js';
import {flush} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
......@@ -22,6 +23,15 @@ destination_dialog_test.TestNames = {
PrinterList: 'PrinterList',
ShowProvisionalDialog: 'ShowProvisionalDialog',
UserAccounts: 'UserAccounts',
CloudPrinterDeprecationWarnings: 'CloudPrinterDeprecationWarnings',
CloudPrinterDeprecationWarningsSuppressed:
'CloudPrinterDeprecationWarningsSuppressed',
SaveToDriveDeprecationWarnings: 'SaveToDriveDeprecationWarnings',
SaveToDriveDeprecationWarningsSuppressed:
'SaveToDriveDeprecationWarningsSuppressed',
SaveToDriveDeprecationWarningsCros: 'SaveToDriveDeprecationWarningsCros',
SaveToDriveDeprecationWarningsSuppressedCros:
'SaveToDriveDeprecationWarningsSuppressedCros',
};
suite(destination_dialog_test.suiteName, function() {
......@@ -285,4 +295,111 @@ suite(destination_dialog_test.suiteName, function() {
// Cloud print should have been queried again for the new account.
assertEquals(3, cloudPrintInterface.getCallCount('search'));
});
/**
* @param {boolean} warningsSuppressed Whether warnings are suppressed.
* @return{!function()} Async function that tests whether Cloud print
* deprecation warnings show when they're supposed to.
*/
function testCloudPrinterDeprecationWarnings(warningsSuppressed) {
return async () => {
loadTimeData.overrideValues(
{cloudPrintDeprecationWarningsSuppressed: warningsSuppressed});
// Set up the cloud print interface with a Cloud printer for an account.
const user = 'foo@chromium.org';
cloudPrintInterface.setPrinter(
new Destination(
'ID', DestinationType.GOOGLE, DestinationOrigin.COOKIES,
'Cloud Printer', DestinationConnectionStatus.ONLINE,
{account: user, isOwned: true}),
);
await finishSetup();
// Nobody is signed in. There are no cloud printers.
assertSignedInState('', 0);
const statusEl = dialog.$$('.destinations-status');
assertTrue(statusEl.hidden);
// Set an active user. There is a cloud printer.
destinationStore.setActiveUser(user);
destinationStore.reloadUserCookieBasedDestinations(user);
dialog.activeUser = user;
dialog.users = [user];
flush();
assertSignedInState(user, 1);
assertEquals(warningsSuppressed, statusEl.hidden);
};
}
// Test that Cloud print deprecation warnings appear.
test(
assert(destination_dialog_test.TestNames.CloudPrinterDeprecationWarnings),
testCloudPrinterDeprecationWarnings(false));
// Test that Cloud print deprecation warnings are suppressed.
test(
assert(destination_dialog_test.TestNames
.CloudPrinterDeprecationWarningsSuppressed),
testCloudPrinterDeprecationWarnings(true));
/**
* @param {boolean} warningsSuppressed Whether warnings are suppressed.
* @return{!function()} Async function that tests whether Cloud print
* deprecation warnings show when they're supposed to.
*/
function testSaveToDriveDeprecationWarnings(warningsSuppressed, isChromeOS) {
return async () => {
loadTimeData.overrideValues(
{cloudPrintDeprecationWarningsSuppressed: warningsSuppressed});
// Set up the cloud print interface with Google Drive printer for an
// account.
const user = 'foo@chromium.org';
cloudPrintInterface.setPrinter(getGoogleDriveDestination(user));
await finishSetup();
// Nobody is signed in. There are no cloud printers.
assertSignedInState('', 0);
const statusEl = dialog.$$('.destinations-status');
assertTrue(statusEl.hidden);
// Set an active user. There is a cloud printer (Save to Drive).
destinationStore.setActiveUser(user);
destinationStore.reloadUserCookieBasedDestinations(user);
dialog.activeUser = user;
dialog.users = [user];
flush();
assertSignedInState(user, 1);
// Warning should never appear on ChromeOS.
assertEquals(warningsSuppressed || isChromeOS, statusEl.hidden);
};
}
// Test that Save to Drive deprecation warnings appear.
test(
assert(destination_dialog_test.TestNames.SaveToDriveDeprecationWarnings),
testSaveToDriveDeprecationWarnings(false, false));
// Test that Save to Drive deprecation warnings are suppressed.
test(
assert(destination_dialog_test.TestNames
.SaveToDriveDeprecationWarningsSuppressed),
testSaveToDriveDeprecationWarnings(true, false));
// Test that Save to Drive deprecation warnings never appear.
test(
assert(
destination_dialog_test.TestNames.SaveToDriveDeprecationWarningsCros),
testSaveToDriveDeprecationWarnings(false, true));
// Test that Save to Drive deprecation warnings are suppressed.
test(
assert(destination_dialog_test.TestNames
.SaveToDriveDeprecationWarningsSuppressedCros),
testSaveToDriveDeprecationWarnings(true, true));
});
......@@ -655,6 +655,52 @@ TEST_F('PrintPreviewDestinationDialogTest', 'UserAccounts', function() {
this.runMochaTest(destination_dialog_test.TestNames.UserAccounts);
});
TEST_F(
'PrintPreviewDestinationDialogTest', 'CloudPrinterDeprecationWarnings',
function() {
this.runMochaTest(
destination_dialog_test.TestNames.CloudPrinterDeprecationWarnings);
});
TEST_F(
'PrintPreviewDestinationDialogTest',
'CloudPrinterDeprecationWarningsSuppressed', function() {
this.runMochaTest(destination_dialog_test.TestNames
.CloudPrinterDeprecationWarningsSuppressed);
});
// TODO(crbug.com/1111985): Different tests are needed because |isChromeOS| from
// cr.m.js does not match the behavior of the |OS_CHROMEOS| macro on Lacros.
GEN('#if defined(OS_CHROMEOS)');
TEST_F(
'PrintPreviewDestinationDialogTest', 'SaveToDriveDeprecationWarningsCros',
function() {
this.runMochaTest(
destination_dialog_test.TestNames.SaveToDriveDeprecationWarningsCros);
});
TEST_F(
'PrintPreviewDestinationDialogTest',
'SaveToDriveDeprecationWarningsSuppressedCros', function() {
this.runMochaTest(destination_dialog_test.TestNames
.SaveToDriveDeprecationWarningsSuppressedCros);
});
GEN('#else');
TEST_F(
'PrintPreviewDestinationDialogTest', 'SaveToDriveDeprecationWarnings',
function() {
this.runMochaTest(
destination_dialog_test.TestNames.SaveToDriveDeprecationWarnings);
});
TEST_F(
'PrintPreviewDestinationDialogTest',
'SaveToDriveDeprecationWarningsSuppressed', function() {
this.runMochaTest(destination_dialog_test.TestNames
.SaveToDriveDeprecationWarningsSuppressed);
});
GEN('#endif');
// eslint-disable-next-line no-var
var PrintPreviewAdvancedDialogTest = class extends PrintPreviewTest {
/** @override */
......
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