Commit 5f9e51f8 authored by Daniel Hosseinian's avatar Daniel Hosseinian Committed by Commit Bot

Add "Save to Drive" deprecation warning

Add a deprecation warning message and icon for the "Save to Drive"
destination in the destinations dialog.

Add a pref, "cloudPrintDeprecationWarningSuppressed", to suppress all
Cloud Print deprecation warnings.

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

Bug: 1112581
Change-Id: If6ee65f5178d41a0455bef0ddcabe63a55d1bb1b
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2348414
Commit-Queue: Daniel Hosseinian <dhoss@chromium.org>
Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#797824}
parent a6e66047
...@@ -408,6 +408,13 @@ export class Destination { ...@@ -408,6 +408,13 @@ export class Destination {
this.certificateStatus_ = opt_params && opt_params.certificateStatus || this.certificateStatus_ = opt_params && opt_params.certificateStatus ||
DestinationCertificateStatus.NONE; DestinationCertificateStatus.NONE;
/**
* Whether cloud print deprecation warnings are suppressed.
* @private {boolean}
*/
this.cloudPrintDeprecationWarningsSuppressed_ =
loadTimeData.getBoolean('cloudPrintDeprecationWarningsSuppressed');
// <if expr="chromeos"> // <if expr="chromeos">
/** /**
* EULA url for printer's PPD. Empty string indicates no provided EULA. * EULA url for printer's PPD. Empty string indicates no provided EULA.
...@@ -525,7 +532,9 @@ export class Destination { ...@@ -525,7 +532,9 @@ export class Destination {
* if it was not provided. * if it was not provided.
*/ */
get description() { get description() {
return this.description_; return this.shouldShowSaveToDriveWarning ?
loadTimeData.getString('destinationNotSupportedWarning') :
this.description_;
} }
/** /**
...@@ -657,6 +666,15 @@ export class Destination { ...@@ -657,6 +666,15 @@ export class Destination {
!loadTimeData.getBoolean('isEnterpriseManaged'); !loadTimeData.getBoolean('isEnterpriseManaged');
} }
/**
* @return {boolean} Whether this destination's description and icon should
* warn that "Save to Drive" is deprecated.
*/
get shouldShowSaveToDriveWarning() {
return !isChromeOS && this.id_ === Destination.GooglePromotedId.DOCS &&
!this.cloudPrintDeprecationWarningsSuppressed_;
}
/** @return {boolean} Whether the destination is considered offline. */ /** @return {boolean} Whether the destination is considered offline. */
get isOffline() { get isOffline() {
return [ return [
...@@ -713,6 +731,9 @@ export class Destination { ...@@ -713,6 +731,9 @@ export class Destination {
/** @return {string} Path to the SVG for the destination's icon. */ /** @return {string} Path to the SVG for the destination's icon. */
get icon() { get icon() {
if (this.shouldShowSaveToDriveWarning) {
return 'print-preview:save-to-drive-not-supported';
}
if (this.id_ === Destination.GooglePromotedId.DOCS) { if (this.id_ === Destination.GooglePromotedId.DOCS) {
return 'print-preview:save-to-drive'; return 'print-preview:save-to-drive';
} }
...@@ -790,7 +811,7 @@ export class Destination { ...@@ -790,7 +811,7 @@ export class Destination {
} }
/** /**
* @return (Object} Copies capability of this destination. * @return {Object} Copies capability of this destination.
* @private * @private
*/ */
copiesCapability_() { copiesCapability_() {
......
<iron-iconset-svg name="print-preview" size="24"> <iron-iconset-svg name="print-preview" size="24">
<svg> <svg>
<defs> <defs>
<!-- Custom svgs (namratakannan). --> <!-- Custom SVGs (namratakannan) -->
<g id="printer-shared" viewBox="0 0 106 96"> <g id="printer-shared" viewBox="0 0 106 96">
<path d="M44 59H32v26h12v11H21.2V74.462H0V42.154C0 33.215 7.102 26 15.9 26h74.2c8.798 0 15.9 7.215 15.9 16.154V59H91.393A15.943 15.943 0 0 0 93 52c0-8.84-7.16-16-16-16s-16 7.16-16 16c0 2.51.578 4.886 1.607 7H44zM84 0H21v22h63V0z"></path> <path d="M44 59H32v26h12v11H21.2V74.462H0V42.154C0 33.215 7.102 26 15.9 26h74.2c8.798 0 15.9 7.215 15.9 16.154V59H91.393A15.943 15.943 0 0 0 93 52c0-8.84-7.16-16-16-16s-16 7.16-16 16c0 2.51.578 4.886 1.607 7H44zM84 0H21v22h63V0z"></path>
<path d="M77 68c-9.679 0-29 6.253-29 18.667V96h58v-9.333C106 74.253 86.679 68 77 68zM77 64c6.63 0 12-5.37 12-12s-5.37-12-12-12-12 5.37-12 12 5.37 12 12 12z" fill="#4A93F9"></path> <path d="M77 68c-9.679 0-29 6.253-29 18.667V96h58v-9.333C106 74.253 86.679 68 77 68zM77 64c6.63 0 12-5.37 12-12s-5.37-12-12-12-12 5.37-12 12 5.37 12 12 12z" fill="#4A93F9"></path>
...@@ -15,6 +15,12 @@ ...@@ -15,6 +15,12 @@
<path d="M-5-5h32v32H-5z"> <path d="M-5-5h32v32H-5z">
</g> </g>
<!-- Custom SVGs (shuom) -->
<g id="save-to-drive-not-supported" viewBox="0 0 19 15">
<path d="M6.8 0H1.7C0.765 0 0.0085 0.7875 0.0085 1.75L0 12.25C0 13.2125 0.765 14 1.7 14H6.2L13 3L17 9.5V3.5C17 2.5375 16.235 1.75 15.3 1.75H8.5L6.8 0Z"></path>
<path fill-rule="evenodd" clip-rule="evenodd" d="M19 15L13 5L7 15H19ZM13.5453 13.6616H12.4544V12.5789H13.5453V13.6616ZM12.4544 11.4962H13.5453V9.33075H12.4544V11.4962Z" fill="#E8710A"></path>
</g>
<!-- Icon from http://icons/ --> <!-- Icon from http://icons/ -->
<g id="save-to-drive"> <g id="save-to-drive">
<path fill="none" d="M0 0h24v24H0z"></path> <path fill="none" d="M0 0h24v24H0z"></path>
......
...@@ -12,6 +12,8 @@ namespace printing { ...@@ -12,6 +12,8 @@ namespace printing {
// static // static
void PolicySettings::RegisterProfilePrefs( void PolicySettings::RegisterProfilePrefs(
user_prefs::PrefRegistrySyncable* registry) { user_prefs::PrefRegistrySyncable* registry) {
registry->RegisterBooleanPref(prefs::kCloudPrintDeprecationWarningsSuppressed,
false);
registry->RegisterListPref(prefs::kPrinterTypeDenyList); registry->RegisterListPref(prefs::kPrinterTypeDenyList);
registry->RegisterBooleanPref(prefs::kPrintHeaderFooter, true); registry->RegisterBooleanPref(prefs::kPrintHeaderFooter, true);
registry->RegisterIntegerPref(prefs::kPrintingAllowedBackgroundGraphicsModes, registry->RegisterIntegerPref(prefs::kPrintingAllowedBackgroundGraphicsModes,
......
...@@ -220,6 +220,7 @@ void AddPrintPreviewStrings(content::WebUIDataSource* source) { ...@@ -220,6 +220,7 @@ void AddPrintPreviewStrings(content::WebUIDataSource* source) {
{"customMargins", IDS_PRINT_PREVIEW_CUSTOM_MARGINS}, {"customMargins", IDS_PRINT_PREVIEW_CUSTOM_MARGINS},
{"defaultMargins", IDS_PRINT_PREVIEW_DEFAULT_MARGINS}, {"defaultMargins", IDS_PRINT_PREVIEW_DEFAULT_MARGINS},
{"destinationLabel", IDS_PRINT_PREVIEW_DESTINATION_LABEL}, {"destinationLabel", IDS_PRINT_PREVIEW_DESTINATION_LABEL},
{"destinationNotSupportedWarning", IDS_DESTINATION_NOT_SUPPORTED_WARNING},
{"destinationSearchTitle", IDS_PRINT_PREVIEW_DESTINATION_SEARCH_TITLE}, {"destinationSearchTitle", IDS_PRINT_PREVIEW_DESTINATION_SEARCH_TITLE},
{"dpiItemLabel", IDS_PRINT_PREVIEW_DPI_ITEM_LABEL}, {"dpiItemLabel", IDS_PRINT_PREVIEW_DPI_ITEM_LABEL},
{"dpiLabel", IDS_PRINT_PREVIEW_DPI_LABEL}, {"dpiLabel", IDS_PRINT_PREVIEW_DPI_LABEL},
...@@ -374,6 +375,12 @@ void AddPrintPreviewFlags(content::WebUIDataSource* source, Profile* profile) { ...@@ -374,6 +375,12 @@ void AddPrintPreviewFlags(content::WebUIDataSource* source, Profile* profile) {
source->AddBoolean("isEnterpriseManaged", webui::IsEnterpriseManaged()); source->AddBoolean("isEnterpriseManaged", webui::IsEnterpriseManaged());
bool cloud_print_deprecation_warnings_suppressed =
profile->GetPrefs()->GetBoolean(
prefs::kCloudPrintDeprecationWarningsSuppressed);
source->AddBoolean("cloudPrintDeprecationWarningsSuppressed",
cloud_print_deprecation_warnings_suppressed);
#if defined(OS_CHROMEOS) #if defined(OS_CHROMEOS)
source->AddBoolean( source->AddBoolean(
"showPrinterStatus", "showPrinterStatus",
......
...@@ -2475,6 +2475,10 @@ const char kCloudPrintPrinters[] = "cloud_print.user_settings.printers"; ...@@ -2475,6 +2475,10 @@ const char kCloudPrintPrinters[] = "cloud_print.user_settings.printers";
// A boolean indicating whether submitting jobs to Google Cloud Print is // A boolean indicating whether submitting jobs to Google Cloud Print is
// blocked by policy. // blocked by policy.
const char kCloudPrintSubmitEnabled[] = "cloud_print.submit_enabled"; const char kCloudPrintSubmitEnabled[] = "cloud_print.submit_enabled";
// A boolean indicating whether Cloud Print deprecation warnings should be
// suppressed.
const char kCloudPrintDeprecationWarningsSuppressed[] =
"cloud_print.deprecation_warnings_suppressed";
// Preference to store proxy settings. // Preference to store proxy settings.
const char kMaxConnectionsPerProxy[] = "net.max_connections_per_proxy"; const char kMaxConnectionsPerProxy[] = "net.max_connections_per_proxy";
......
...@@ -672,6 +672,7 @@ extern const char kCloudPrintXmppPingTimeout[]; ...@@ -672,6 +672,7 @@ extern const char kCloudPrintXmppPingTimeout[];
extern const char kCloudPrintPrinters[]; extern const char kCloudPrintPrinters[];
extern const char kCloudPrintSubmitEnabled[]; extern const char kCloudPrintSubmitEnabled[];
extern const char kCloudPrintUserSettings[]; extern const char kCloudPrintUserSettings[];
extern const char kCloudPrintDeprecationWarningsSuppressed[];
extern const char kMaxConnectionsPerProxy[]; extern const char kMaxConnectionsPerProxy[];
......
...@@ -4,6 +4,7 @@ ...@@ -4,6 +4,7 @@
import {Destination, DestinationConnectionStatus, DestinationOrigin, DestinationType, getSelectDropdownBackground} from 'chrome://print/print_preview.js'; import {Destination, DestinationConnectionStatus, DestinationOrigin, DestinationType, getSelectDropdownBackground} from 'chrome://print/print_preview.js';
import {assert} from 'chrome://resources/js/assert.m.js'; import {assert} from 'chrome://resources/js/assert.m.js';
import {loadTimeData} from 'chrome://resources/js/load_time_data.m.js';
import {Base} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; import {Base} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
import {assertEquals, assertFalse, assertTrue} from '../chai_assert.js'; import {assertEquals, assertFalse, assertTrue} from '../chai_assert.js';
...@@ -17,6 +18,7 @@ destination_select_test.suiteName = 'DestinationSelectTest'; ...@@ -17,6 +18,7 @@ destination_select_test.suiteName = 'DestinationSelectTest';
destination_select_test.TestNames = { destination_select_test.TestNames = {
UpdateStatus: 'update status', UpdateStatus: 'update status',
ChangeIcon: 'change icon', ChangeIcon: 'change icon',
ChangeIconDeprecationWarnings: 'change icon deprecation warnings',
}; };
suite(destination_select_test.suiteName, function() { suite(destination_select_test.suiteName, function() {
...@@ -77,9 +79,11 @@ suite(destination_select_test.suiteName, function() { ...@@ -77,9 +79,11 @@ suite(destination_select_test.suiteName, function() {
/** /**
* Test that changing different destinations results in the correct icon being * Test that changing different destinations results in the correct icon being
* shown. * shown.
* @param {boolean} cloudPrintDeprecationWarningsSuppressed Whether cloud
* print deprecation warnings should be suppressed.
* @return {!Promise} Promise that resolves when the test finishes. * @return {!Promise} Promise that resolves when the test finishes.
*/ */
function testChangeIcon() { function testChangeIcon(cloudPrintDeprecationWarningsSuppressed) {
const destination = recentDestinationList[0]; const destination = recentDestinationList[0];
destinationSelect.destination = destination; destinationSelect.destination = destination;
destinationSelect.updateDestination(); destinationSelect.updateDestination();
...@@ -94,13 +98,19 @@ suite(destination_select_test.suiteName, function() { ...@@ -94,13 +98,19 @@ suite(destination_select_test.suiteName, function() {
return selectOption(destinationSelect, driveKey) return selectOption(destinationSelect, driveKey)
.then(() => { .then(() => {
// Icon updates early based on the ID. // Icon updates early based on the ID.
// TODO(dhoss): This icon should be 'save-to-drive-not-supported'
// after all cloud print deprecation warnings are implemented.
compareIcon(selectEl, 'save-to-drive'); compareIcon(selectEl, 'save-to-drive');
// Update the destination. // Update the destination.
destinationSelect.destination = getGoogleDriveDestination(account); destinationSelect.destination = getGoogleDriveDestination(account);
const saveToDriveIcon = cloudPrintDeprecationWarningsSuppressed ?
'save-to-drive' :
'save-to-drive-not-supported';
// Still Save to Drive icon. // Still Save to Drive icon.
compareIcon(selectEl, 'save-to-drive'); compareIcon(selectEl, saveToDriveIcon);
// Select a destination with the shared printer icon. // Select a destination with the shared printer icon.
return selectOption( return selectOption(
...@@ -141,6 +151,21 @@ suite(destination_select_test.suiteName, function() { ...@@ -141,6 +151,21 @@ suite(destination_select_test.suiteName, function() {
}); });
test(assert(destination_select_test.TestNames.ChangeIcon), function() { test(assert(destination_select_test.TestNames.ChangeIcon), function() {
return testChangeIcon(); loadTimeData.overrideValues(
{cloudPrintDeprecationWarningsSuppressed: true});
// Repopulate |recentDestinationList| to have
// |cloudPrintDeprecationWarningsSuppressed| take effect during creation of
// new Destinations.
populateRecentDestinationList();
destinationSelect.recentDestinationList = recentDestinationList;
return testChangeIcon(true);
});
test(
assert(destination_select_test.TestNames.ChangeIconDeprecationWarnings),
function() {
return testChangeIcon(false);
}); });
}); });
...@@ -1301,6 +1301,13 @@ TEST_F('PrintPreviewDestinationSelectTest', 'UpdateStatus', function() { ...@@ -1301,6 +1301,13 @@ TEST_F('PrintPreviewDestinationSelectTest', 'UpdateStatus', function() {
TEST_F('PrintPreviewDestinationSelectTest', 'ChangeIcon', function() { TEST_F('PrintPreviewDestinationSelectTest', 'ChangeIcon', function() {
this.runMochaTest(destination_select_test.TestNames.ChangeIcon); this.runMochaTest(destination_select_test.TestNames.ChangeIcon);
}); });
TEST_F(
'PrintPreviewDestinationSelectTest', 'ChangeIconDeprecationWarnings',
function() {
this.runMochaTest(
destination_select_test.TestNames.ChangeIconDeprecationWarnings);
});
GEN('#endif'); GEN('#endif');
// eslint-disable-next-line no-var // eslint-disable-next-line no-var
......
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