Commit 5bbd46dc authored by Gavin Williams's avatar Gavin Williams Committed by Commit Bot

Remove isDriveMounted from destination select

|driveDestinationKey| now triggers whether to show the Save to Drive
destination in the dropdown on Chrome OS.

Bug: 1112416
Change-Id: I2cb61425796fe80dac4e862f048da5addea3c46a
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2441954
Commit-Queue: Gavin Williams <gavinwill@chromium.org>
Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#814935}
parent 5a2478df
...@@ -341,11 +341,6 @@ Polymer({ ...@@ -341,11 +341,6 @@ Polymer({
settings.serializedDefaultDestinationSelectionRulesStr, settings.serializedDefaultDestinationSelectionRulesStr,
settings.userAccounts || null, settings.syncAvailable, settings.userAccounts || null, settings.syncAvailable,
settings.pdfPrinterDisabled, settings.isDriveMounted || false); settings.pdfPrinterDisabled, settings.isDriveMounted || false);
// <if expr="chromeos">
if (this.saveToDriveFlagEnabled_) {
this.$.sidebar.setIsDriveMounted(settings.isDriveMounted);
}
// </if>
this.destinationsManaged_ = settings.destinationsManaged; this.destinationsManaged_ = settings.destinationsManaged;
this.isInKioskAutoPrintMode_ = settings.isInKioskAutoPrintMode; this.isInKioskAutoPrintMode_ = settings.isInKioskAutoPrintMode;
......
...@@ -26,8 +26,8 @@ ...@@ -26,8 +26,8 @@
<option value="[[pdfDestinationKey_]]" hidden$="[[pdfPrinterDisabled]]"> <option value="[[pdfDestinationKey_]]" hidden$="[[pdfPrinterDisabled]]">
$i18n{printToPDF} $i18n{printToPDF}
</option> </option>
<option value="[[driveDestinationKeyCros_]]" <option value="[[driveDestinationKey]]"
hidden$="[[!driveDestinationKeyCros_]]"> hidden$="[[!driveDestinationKey]]">
$i18n{printToGoogleDrive} $i18n{printToGoogleDrive}
</option> </option>
<option value="noDestinations" <option value="noDestinations"
...@@ -45,7 +45,7 @@ ...@@ -45,7 +45,7 @@
value="[[destination]]" hidden$="[[!loaded]]" value="[[destination]]" hidden$="[[!loaded]]"
item-list="[[recentDestinationList]]" item-list="[[recentDestinationList]]"
pdf-destination-key="[[pdfDestinationKey_]]" pdf-destination-key="[[pdfDestinationKey_]]"
drive-destination-key="[[driveDestinationKeyCros_]]" drive-destination-key="[[driveDestinationKey]]"
no-destinations="[[noDestinations]]" no-destinations="[[noDestinations]]"
pdf-printer-disabled="[[pdfPrinterDisabled]]" pdf-printer-disabled="[[pdfPrinterDisabled]]"
destination-icon="[[destinationIcon_]]" disabled="[[disabled]]" destination-icon="[[destinationIcon_]]" disabled="[[disabled]]"
......
...@@ -46,11 +46,6 @@ Polymer({ ...@@ -46,11 +46,6 @@ Polymer({
driveDestinationKey: String, driveDestinationKey: String,
isDriveMounted: {
type: Boolean,
value: true,
},
loaded: Boolean, loaded: Boolean,
noDestinations: Boolean, noDestinations: Boolean,
...@@ -115,13 +110,6 @@ Polymer({ ...@@ -115,13 +110,6 @@ Polymer({
}, },
readOnly: true, readOnly: true,
}, },
/** @private */
driveDestinationKeyCros_: {
type: String,
computed: 'computeDriveDestinationKeyCros_(' +
'driveDestinationKey, saveToDriveFlagEnabled_, isDriveMounted)',
},
}, },
/** @private {!IronMetaElement} */ /** @private {!IronMetaElement} */
...@@ -356,16 +344,4 @@ Polymer({ ...@@ -356,16 +344,4 @@ Polymer({
.shadowRoot.querySelectorAll('.list-item:not([hidden])') : .shadowRoot.querySelectorAll('.list-item:not([hidden])') :
this.shadowRoot.querySelectorAll('option:not([hidden])'); this.shadowRoot.querySelectorAll('option:not([hidden])');
}, },
/**
* @return {string}
* @private
*/
computeDriveDestinationKeyCros_: function() {
if (!this.saveToDriveFlagEnabled_) {
return this.driveDestinationKey;
}
return this.isDriveMounted ? SAVE_TO_DRIVE_CROS_DESTINATION_KEY : '';
},
}); });
...@@ -28,6 +28,9 @@ import {beforeNextRender, html, Polymer} from 'chrome://resources/polymer/v3_0/p ...@@ -28,6 +28,9 @@ import {beforeNextRender, html, Polymer} from 'chrome://resources/polymer/v3_0/p
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 {createDestinationKey, createRecentDestinationKey, Destination, DestinationOrigin, makeRecentDestination, RecentDestination} from '../data/destination.js';
// <if expr="chromeos">
import {SAVE_TO_DRIVE_CROS_DESTINATION_KEY} from '../data/destination.js';
// </if>
import {getPrinterTypeForDestination, PrinterType} from '../data/destination_match.js'; import {getPrinterTypeForDestination, PrinterType} from '../data/destination_match.js';
import {DestinationErrorType, DestinationStore} from '../data/destination_store.js'; import {DestinationErrorType, DestinationStore} from '../data/destination_store.js';
import {InvitationStore} from '../data/invitation_store.js'; import {InvitationStore} from '../data/invitation_store.js';
...@@ -173,6 +176,15 @@ Polymer({ ...@@ -173,6 +176,15 @@ Polymer({
}, },
readOnly: true, readOnly: true,
}, },
/** @private */
saveToDriveFlagEnabled_: {
type: Boolean,
value() {
return loadTimeData.getBoolean('printSaveToDrive');
},
readOnly: true,
},
// </if> // </if>
}, },
...@@ -224,9 +236,14 @@ Polymer({ ...@@ -224,9 +236,14 @@ Polymer({
/** @private */ /** @private */
updateDriveDestination_() { updateDriveDestination_() {
const key = createDestinationKey( let key = createDestinationKey(
Destination.GooglePromotedId.DOCS, DestinationOrigin.COOKIES, Destination.GooglePromotedId.DOCS, DestinationOrigin.COOKIES,
this.activeUser_); this.activeUser_);
// <if expr="chromeos">
if (this.saveToDriveFlagEnabled_) {
key = SAVE_TO_DRIVE_CROS_DESTINATION_KEY;
}
// </if>
this.driveDestinationKey_ = this.driveDestinationKey_ =
this.destinationStore_.getDestinationByKey(key) ? key : ''; this.destinationStore_.getDestinationByKey(key) ? key : '';
}, },
...@@ -640,10 +657,5 @@ Polymer({ ...@@ -640,10 +657,5 @@ Polymer({
this.destination.eulaUrl = e.detail; this.destination.eulaUrl = e.detail;
this.notifyPath('destination.eulaUrl'); this.notifyPath('destination.eulaUrl');
}, },
/** @param {boolean} isDriveMounted */
setIsDriveMounted(isDriveMounted) {
this.$.destinationSelect.isDriveMounted = isDriveMounted;
},
// </if> // </if>
}); });
...@@ -237,11 +237,4 @@ Polymer({ ...@@ -237,11 +237,4 @@ Polymer({
const linkContainer = this.$$('print-preview-link-container'); const linkContainer = this.$$('print-preview-link-container');
return !!linkContainer && linkContainer.systemDialogLinkAvailable(); return !!linkContainer && linkContainer.systemDialogLinkAvailable();
}, },
// <if expr="chromeos">
/** @param {boolean} isDriveMounted */
setIsDriveMounted(isDriveMounted) {
this.$.destinationSettings.setIsDriveMounted(isDriveMounted);
},
// </if>
}); });
...@@ -354,7 +354,6 @@ destination_select_test_cros.TestNames = { ...@@ -354,7 +354,6 @@ destination_select_test_cros.TestNames = {
ChangeIconDeprecationWarnings: 'change icon deprecation warnings', ChangeIconDeprecationWarnings: 'change icon deprecation warnings',
EulaIsDisplayed: 'eula is displayed', EulaIsDisplayed: 'eula is displayed',
SelectDriveDestination: 'select drive destination', SelectDriveDestination: 'select drive destination',
IsDriveMounted: 'is drive mounted',
}; };
suite(destination_select_test_cros.suiteName, function() { suite(destination_select_test_cros.suiteName, function() {
...@@ -442,8 +441,6 @@ suite(destination_select_test_cros.suiteName, function() { ...@@ -442,8 +441,6 @@ suite(destination_select_test_cros.suiteName, function() {
return selectOption( return selectOption(
destinationSelect, destinationSelect,
loadTimeData.getBoolean('printSaveToDrive') ?
SAVE_TO_DRIVE_CROS_DESTINATION_KEY :
driveKey); driveKey);
}) })
.then(() => { .then(() => {
...@@ -633,27 +630,4 @@ suite(destination_select_test_cros.suiteName, function() { ...@@ -633,27 +630,4 @@ suite(destination_select_test_cros.suiteName, function() {
expectedKey, destinationSelect.$$('.md-select').value); expectedKey, destinationSelect.$$('.md-select').value);
}); });
}); });
test(
assert(destination_select_test_cros.TestNames.IsDriveMounted),
function() {
return waitBeforeNextRender(destinationSelect)
.then(() => {
const options =
Array.from(destinationSelect.getVisibleItemsForTest());
assertTrue(!!options.find(
option =>
option.value === SAVE_TO_DRIVE_CROS_DESTINATION_KEY));
destinationSelect.isDriveMounted = false;
return waitBeforeNextRender(destinationSelect);
})
.then(() => {
const options =
Array.from(destinationSelect.getVisibleItemsForTest());
assertTrue(!options.find(
option =>
option.value === SAVE_TO_DRIVE_CROS_DESTINATION_KEY));
});
});
}); });
...@@ -35,7 +35,8 @@ destination_settings_test.TestNames = { ...@@ -35,7 +35,8 @@ destination_settings_test.TestNames = {
ResetDestinationOnSignOut: 'reset destination on sign out', ResetDestinationOnSignOut: 'reset destination on sign out',
DisabledSaveAsPdf: 'disabled save as pdf', DisabledSaveAsPdf: 'disabled save as pdf',
NoDestinations: 'no destinations', NoDestinations: 'no destinations',
EulaIsRetrieved: 'eula is retrieved' EulaIsRetrieved: 'eula is retrieved',
DriveIsNotMounted: 'drive is not mounted',
}; };
suite(destination_settings_test.suiteName, function() { suite(destination_settings_test.suiteName, function() {
...@@ -66,6 +67,9 @@ suite(destination_settings_test.suiteName, function() { ...@@ -66,6 +67,9 @@ suite(destination_settings_test.suiteName, function() {
/** @type {boolean} */ /** @type {boolean} */
let pdfPrinterDisabled = false; let pdfPrinterDisabled = false;
/** @type {boolean} */
let isDriveMounted = true;
/** @type {string} */ /** @type {string} */
const defaultUser = 'foo@chromium.org'; const defaultUser = 'foo@chromium.org';
...@@ -125,7 +129,7 @@ suite(destination_settings_test.suiteName, function() { ...@@ -125,7 +129,7 @@ suite(destination_settings_test.suiteName, function() {
// still not loaded. // still not loaded.
destinationSettings.init( destinationSettings.init(
'FooDevice' /* printerName */, false /* pdfPrinterDisabled */, 'FooDevice' /* printerName */, false /* pdfPrinterDisabled */,
true /* isDriveMounted */, isDriveMounted,
'' /* serializedDefaultDestinationSelectionRulesStr */, '' /* serializedDefaultDestinationSelectionRulesStr */,
[] /* userAccounts */, true /* syncAvailable */); [] /* userAccounts */, true /* syncAvailable */);
assertFalse(dropdown.loaded); assertFalse(dropdown.loaded);
...@@ -199,7 +203,7 @@ suite(destination_settings_test.suiteName, function() { ...@@ -199,7 +203,7 @@ suite(destination_settings_test.suiteName, function() {
destinationSettings.setSetting('recentDestinations', recentDestinations); destinationSettings.setSetting('recentDestinations', recentDestinations);
destinationSettings.appKioskMode = false; destinationSettings.appKioskMode = false;
destinationSettings.init( destinationSettings.init(
'' /* printerName */, pdfPrinterDisabled, true /* isDriveMounted */, '' /* printerName */, pdfPrinterDisabled, isDriveMounted,
'' /* serializedDefaultDestinationSelectionRulesStr */, initialAccounts, '' /* serializedDefaultDestinationSelectionRulesStr */, initialAccounts,
true /* syncAvailable */); true /* syncAvailable */);
destinationSettings.state = State.READY; destinationSettings.state = State.READY;
...@@ -938,7 +942,6 @@ suite(destination_settings_test.suiteName, function() { ...@@ -938,7 +942,6 @@ suite(destination_settings_test.suiteName, function() {
}); });
}); });
if (isChromeOS) {
/** /**
* Tests that destinations with a EULA will fetch the EULA URL when * Tests that destinations with a EULA will fetch the EULA URL when
* selected. * selected.
...@@ -1005,5 +1008,21 @@ suite(destination_settings_test.suiteName, function() { ...@@ -1005,5 +1008,21 @@ suite(destination_settings_test.suiteName, function() {
expectedUrl, destinationSettings.destination.eulaUrl); expectedUrl, destinationSettings.destination.eulaUrl);
}); });
}); });
}
// Tests that disabling Google Drive on Chrome OS hides the Save to Drive
// destination.
test(
assert(destination_settings_test.TestNames.DriveIsNotMounted),
function() {
isDriveMounted = false;
initialize();
return nativeLayer.whenCalled('getPrinterCapabilities')
.then(() => {
return waitBeforeNextRender(destinationSettings);
})
.then(() => {
assertDropdownItems(['Save as PDF/local/']);
});
});
}); });
...@@ -1294,60 +1294,6 @@ TEST_F( ...@@ -1294,60 +1294,6 @@ TEST_F(
destination_select_test_cros.TestNames.SelectDriveDestination); destination_select_test_cros.TestNames.SelectDriveDestination);
}); });
// eslint-disable-next-line no-var
var PrintPreviewDestinationSelectTestCrOSSaveToDriveEnabled =
class extends PrintPreviewTest {
/** @override */
get browsePreload() {
return 'chrome://print/test_loader.html?module=print_preview/destination_select_test_cros.js';
}
/** @override */
get suiteName() {
return destination_select_test_cros.suiteName;
}
/** @override */
get featureList() {
const kPrinterStatus = ['chromeos::features::kPrinterStatus'];
const kPrintSaveToDrive = ['chromeos::features::kPrintSaveToDrive'];
const featureList = super.featureList || [];
featureList.disabled = featureList.disabled ?
featureList.disabled.concat(kPrinterStatus) :
kPrinterStatus;
featureList.enabled = featureList.enabled ?
featureList.enabled.concat(kPrintSaveToDrive) :
kPrintSaveToDrive;
return featureList;
}
};
TEST_F(
'PrintPreviewDestinationSelectTestCrOSSaveToDriveEnabled',
'SelectDriveDestination', function() {
this.runMochaTest(
destination_select_test_cros.TestNames.SelectDriveDestination);
});
TEST_F(
'PrintPreviewDestinationSelectTestCrOSSaveToDriveEnabled', 'ChangeIcon',
function() {
this.runMochaTest(destination_select_test_cros.TestNames.ChangeIcon);
});
TEST_F(
'PrintPreviewDestinationSelectTestCrOSSaveToDriveEnabled',
'ChangeIconDeprecationWarnings', function() {
this.runMochaTest(
destination_select_test_cros.TestNames.ChangeIconDeprecationWarnings);
});
TEST_F(
'PrintPreviewDestinationSelectTestCrOSSaveToDriveEnabled', 'IsDriveMounted',
function() {
this.runMochaTest(destination_select_test_cros.TestNames.IsDriveMounted);
});
// eslint-disable-next-line no-var // eslint-disable-next-line no-var
var PrintPreviewPrinterStatusTestCros = class extends PrintPreviewTest { var PrintPreviewPrinterStatusTestCros = class extends PrintPreviewTest {
/** @override */ /** @override */
...@@ -1585,9 +1531,38 @@ TEST_F('PrintPreviewDestinationSettingsTest', 'NoDestinations', function() { ...@@ -1585,9 +1531,38 @@ TEST_F('PrintPreviewDestinationSettingsTest', 'NoDestinations', function() {
}); });
GEN('#if defined(OS_CHROMEOS)'); GEN('#if defined(OS_CHROMEOS)');
TEST_F('PrintPreviewDestinationSettingsTest', 'EulaIsRetrieved', function() { // eslint-disable-next-line no-var
this.runMochaTest(destination_settings_test.TestNames.EulaIsRetrieved); var PrintPreviewDestinationSettingsTestCros = class extends PrintPreviewTest {
}); /** @override */
get browsePreload() {
return 'chrome://print/test_loader.html?module=print_preview/destination_settings_test.js';
}
/** @override */
get suiteName() {
return destination_settings_test.suiteName;
}
/** @override */
get featureList() {
const kPrintSaveToDrive = ['chromeos::features::kPrintSaveToDrive'];
const featureList = super.featureList || [];
featureList.enabled = featureList.enabled ?
featureList.enabled.concat(kPrintSaveToDrive) :
kPrintSaveToDrive;
return featureList;
}
};
TEST_F(
'PrintPreviewDestinationSettingsTestCros', 'EulaIsRetrieved', function() {
this.runMochaTest(destination_settings_test.TestNames.EulaIsRetrieved);
});
TEST_F(
'PrintPreviewDestinationSettingsTestCros', 'DriveIsNotMounted', function() {
this.runMochaTest(destination_settings_test.TestNames.DriveIsNotMounted);
});
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