Commit 09ba3e5e authored by rbpotter's avatar rbpotter Committed by Commit Bot

Print Preview: Disable cloud print unless pref override is enabled

Unless the policy/pref for suppressing cloud print warnings is enabled,
disable cloud print in Print Preview, as M88 Stable launch is expected
to occur after December 2020, when cloud print is deprecated.

Bug: 1144931

Change-Id: I5579d29be2fd122a15424362ec1d1184e8cce3a0
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2510741Reviewed-by: default avatarDaniel Hosseinian <dhoss@chromium.org>
Reviewed-by: default avatardpapad <dpapad@chromium.org>
Commit-Queue: Rebekah Potter <rbpotter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#824695}
parent 45b716c6
...@@ -5,12 +5,14 @@ ...@@ -5,12 +5,14 @@
} }
</if> </if>
</style> </style>
<print-preview-user-manager id="userManager" active-user="{{activeUser_}}" <template is="dom-if" if="[[!cloudPrintDisabled_]]">
cloud-print-disabled="[[cloudPrintDisabled_]]" <print-preview-user-manager id="userManager" active-user="{{activeUser_}}"
users="{{users_}}" destination-store="[[destinationStore_]]" cloud-print-disabled="[[cloudPrintDisabled_]]"
invitation-store="[[invitationStore_]]" users="{{users_}}" destination-store="[[destinationStore_]]"
should-reload-cookies="[[isDialogOpen_]]"> invitation-store="[[invitationStore_]]"
</print-preview-user-manager> should-reload-cookies="[[isDialogOpen_]]">
</print-preview-user-manager>
</template>
<if expr="not chromeos"> <if expr="not chromeos">
<print-preview-destination-select id="destinationSelect" <print-preview-destination-select id="destinationSelect"
active-user="[[activeUser_]]" dark="[[dark]]" active-user="[[activeUser_]]" dark="[[dark]]"
......
...@@ -27,7 +27,7 @@ import {WebUIListenerBehavior} from 'chrome://resources/js/web_ui_listener_behav ...@@ -27,7 +27,7 @@ import {WebUIListenerBehavior} from 'chrome://resources/js/web_ui_listener_behav
import {beforeNextRender, html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js'; import {beforeNextRender, html, Polymer} from 'chrome://resources/polymer/v3_0/polymer/polymer_bundled.min.js';
import {CloudPrintInterfaceImpl} from '../cloud_print_interface_impl.js'; import {CloudPrintInterfaceImpl} from '../cloud_print_interface_impl.js';
import {createDestinationKey, createRecentDestinationKey, Destination, DestinationOrigin, makeRecentDestination, RecentDestination} from '../data/destination.js'; import {CloudOrigins, createDestinationKey, createRecentDestinationKey, Destination, DestinationOrigin, makeRecentDestination, RecentDestination} from '../data/destination.js';
// <if expr="chromeos"> // <if expr="chromeos">
import {SAVE_TO_DRIVE_CROS_DESTINATION_KEY} from '../data/destination.js'; import {SAVE_TO_DRIVE_CROS_DESTINATION_KEY} from '../data/destination.js';
// </if> // </if>
...@@ -138,10 +138,7 @@ Polymer({ ...@@ -138,10 +138,7 @@ Polymer({
// </if> // </if>
/** @private {?InvitationStore} */ /** @private {?InvitationStore} */
invitationStore_: { invitationStore_: Object,
type: Object,
value: null,
},
/** @private {boolean} */ /** @private {boolean} */
isDialogOpen_: { isDialogOpen_: {
...@@ -198,7 +195,6 @@ Polymer({ ...@@ -198,7 +195,6 @@ Polymer({
attached() { attached() {
this.destinationStore_ = this.destinationStore_ =
new DestinationStore(this.addWebUIListener.bind(this)); new DestinationStore(this.addWebUIListener.bind(this));
this.invitationStore_ = new InvitationStore();
this.tracker_.add( this.tracker_.add(
this.destinationStore_, DestinationStore.EventType.DESTINATION_SELECT, this.destinationStore_, DestinationStore.EventType.DESTINATION_SELECT,
this.onDestinationSelect_.bind(this)); this.onDestinationSelect_.bind(this));
...@@ -229,7 +225,9 @@ Polymer({ ...@@ -229,7 +225,9 @@ Polymer({
/** @override */ /** @override */
detached() { detached() {
this.invitationStore_.resetTracker(); if (!this.cloudPrintDisabled_) {
this.invitationStore_.resetTracker();
}
this.destinationStore_.resetTracker(); this.destinationStore_.resetTracker();
this.tracker_.removeAll(); this.tracker_.removeAll();
}, },
...@@ -332,16 +330,39 @@ Polymer({ ...@@ -332,16 +330,39 @@ Polymer({
defaultPrinter, pdfPrinterDisabled, isDriveMounted, defaultPrinter, pdfPrinterDisabled, isDriveMounted,
serializedDefaultDestinationRulesStr, userAccounts, syncAvailable) { serializedDefaultDestinationRulesStr, userAccounts, syncAvailable) {
const cloudPrintInterface = CloudPrintInterfaceImpl.getInstance(); const cloudPrintInterface = CloudPrintInterfaceImpl.getInstance();
this.pdfPrinterDisabled_ = pdfPrinterDisabled;
let recentDestinations =
/** @type {!Array<!RecentDestination>} */ (
this.getSettingValue('recentDestinations'));
if (cloudPrintInterface.isConfigured()) { if (cloudPrintInterface.isConfigured()) {
this.cloudPrintDisabled_ = false; this.cloudPrintDisabled_ = false;
this.destinationStore_.setCloudPrintInterface(cloudPrintInterface); this.destinationStore_.setCloudPrintInterface(cloudPrintInterface);
this.invitationStore_ = new InvitationStore();
this.invitationStore_.setCloudPrintInterface(cloudPrintInterface); this.invitationStore_.setCloudPrintInterface(cloudPrintInterface);
beforeNextRender(this, () => {
this.shadowRoot.querySelector('#userManager')
.initUserAccounts(userAccounts, syncAvailable);
recentDestinations = recentDestinations.slice(
0, this.getRecentDestinationsDisplayCount_(recentDestinations));
this.destinationStore_.init(
this.pdfPrinterDisabled_, isDriveMounted, defaultPrinter,
serializedDefaultDestinationRulesStr, recentDestinations);
});
return;
} }
this.pdfPrinterDisabled_ = pdfPrinterDisabled;
this.$.userManager.initUserAccounts(userAccounts, syncAvailable); // Remove unsupported cloud printers from the sticky settings, to free up
let recentDestinations = // these spots for supported printers.
/** @type {!Array<!RecentDestination>} */ ( if (!loadTimeData.getBoolean('cloudPrintDeprecationWarningsSuppressed')) {
this.getSettingValue('recentDestinations')); const filteredRecentDestinations =
recentDestinations.filter(d => !CloudOrigins.includes(d.origin));
if (filteredRecentDestinations.length !== recentDestinations.length) {
this.setSetting('recentDestinations', filteredRecentDestinations);
recentDestinations = filteredRecentDestinations;
}
}
recentDestinations = recentDestinations.slice( recentDestinations = recentDestinations.slice(
0, this.getRecentDestinationsDisplayCount_(recentDestinations)); 0, this.getRecentDestinationsDisplayCount_(recentDestinations));
this.destinationStore_.init( this.destinationStore_.init(
...@@ -602,7 +623,9 @@ Polymer({ ...@@ -602,7 +623,9 @@ Polymer({
* @private * @private
*/ */
onAccountChange_(e) { onAccountChange_(e) {
this.$.userManager.updateActiveUser(e.detail, true); assert(!this.cloudPrintDisabled_);
this.shadowRoot.querySelector('#userManager')
.updateActiveUser(e.detail, true);
this.updateDriveDestination_(); this.updateDriveDestination_();
}, },
......
...@@ -647,6 +647,9 @@ void PrintPreviewHandler::HandleGetPreview(const base::ListValue* args) { ...@@ -647,6 +647,9 @@ void PrintPreviewHandler::HandleGetPreview(const base::ListValue* args) {
CHECK(settings.is_dict()); CHECK(settings.is_dict());
int request_id = settings.FindIntKey(kPreviewRequestID).value(); int request_id = settings.FindIntKey(kPreviewRequestID).value();
CHECK_GT(request_id, -1); CHECK_GT(request_id, -1);
PrinterType printer_type = static_cast<PrinterType>(
settings.FindIntKey(kSettingPrinterType).value());
CHECK(printer_type != PrinterType::kCloud || IsCloudPrintEnabled());
CHECK(!base::Contains(preview_callbacks_, request_id)); CHECK(!base::Contains(preview_callbacks_, request_id));
preview_callbacks_[request_id] = callback_id; preview_callbacks_[request_id] = callback_id;
...@@ -1110,6 +1113,9 @@ void PrintPreviewHandler::SendPrinterSetup(const std::string& callback_id, ...@@ -1110,6 +1113,9 @@ void PrintPreviewHandler::SendPrinterSetup(const std::string& callback_id,
void PrintPreviewHandler::SendCloudPrintJob( void PrintPreviewHandler::SendCloudPrintJob(
const std::string& callback_id, const std::string& callback_id,
const base::RefCountedMemory* data) { const base::RefCountedMemory* data) {
// Crash if a cloud print job is requested and cloud print is not enabled.
CHECK(IsCloudPrintEnabled());
// BASE64 encode the job data. // BASE64 encode the job data.
const base::StringPiece raw_data(data->front_as<char>(), data->size()); const base::StringPiece raw_data(data->front_as<char>(), data->size());
std::string base64_data; std::string base64_data;
...@@ -1348,7 +1354,8 @@ void PrintPreviewHandler::RegisterForGaiaCookieChanges() { ...@@ -1348,7 +1354,8 @@ void PrintPreviewHandler::RegisterForGaiaCookieChanges() {
DCHECK(!identity_manager_); DCHECK(!identity_manager_);
cloud_print_enabled_ = cloud_print_enabled_ =
!base::Contains(printer_type_deny_list_, PrinterType::kCloud) && !base::Contains(printer_type_deny_list_, PrinterType::kCloud) &&
GetPrefs()->GetBoolean(prefs::kCloudPrintSubmitEnabled); GetPrefs()->GetBoolean(prefs::kCloudPrintSubmitEnabled) &&
GetPrefs()->GetBoolean(prefs::kCloudPrintDeprecationWarningsSuppressed);
if (!cloud_print_enabled_) if (!cloud_print_enabled_)
return; return;
......
...@@ -994,9 +994,14 @@ suite(destination_settings_test.suiteName, function() { ...@@ -994,9 +994,14 @@ suite(destination_settings_test.suiteName, function() {
// 'getPrinters' will be called because there are no printers known to // 'getPrinters' will be called because there are no printers known to
// the destination store and the 'Save as PDF' fallback is // the destination store and the 'Save as PDF' fallback is
// unavailable. // unavailable.
return nativeLayer.whenCalled('getPrinters').then(() => { return Promise
assertDropdownItems(['noDestinations']); .all([
}); nativeLayer.whenCalled('getPrinters'),
// TODO (rbpotter): remove this wait once user manager is fully
// removed.
waitBeforeNextRender(destinationSettings),
])
.then(() => assertDropdownItems(['noDestinations']));
}); });
/** /**
......
...@@ -107,6 +107,8 @@ suite(invalid_settings_browsertest.suiteName, function() { ...@@ -107,6 +107,8 @@ suite(invalid_settings_browsertest.suiteName, function() {
* @param {!Array<!Destination>} printers * @param {!Array<!Destination>} printers
*/ */
function setupInvalidCertificateTest(printers) { function setupInvalidCertificateTest(printers) {
loadTimeData.overrideValues(
{cloudPrintDeprecationWarningsSuppressed: true});
initialSettings.printerName = ''; initialSettings.printerName = '';
initialSettings.serializedAppStateStr = JSON.stringify({ initialSettings.serializedAppStateStr = JSON.stringify({
version: 2, version: 2,
......
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