Commit 0ed5e21e authored by Daniel Hosseinian's avatar Daniel Hosseinian Committed by Commit Bot

Remove Cloud Print sign-in promo from Print Preview

In preparation for cloud print deprecation, users should not be
encouraged to use cloud print if they aren't already signed on.

Bug: 1113881
Change-Id: I5865f8b790de58210603e427ec7bda4b343367cb
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2341762
Commit-Queue: Daniel Hosseinian <dhoss@chromium.org>
Reviewed-by: default avatarRebekah Potter <rbpotter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#796255}
parent 88e33621
......@@ -202,9 +202,6 @@
<message name="IDS_PRINT_PREVIEW_ADD_ACCOUNT_TITLE" desc="Title of the selection control item to let user to sign into another account.">
Add account...
</message>
<message name="IDS_PRINT_PREVIEW_CLOUD_PRINT_PROMOTION" desc="Message describing features of Google Cloud Print.">
Print to Google Docs and other cloud destinations. <ph name="BEGIN_LINK">$1<ex>&lt;span&gt;</ex></ph>Sign in<ph name="END_LINK">$2<ex>&lt;/span&gt;</ex></ph> to print to Google Cloud Print.
</message>
<message name="IDS_PRINT_PREVIEW_SEARCH_BOX_PLACEHOLDER" desc="Text to put in a search box when user has not entered a search query.">
Search destinations
</message>
......
......@@ -266,10 +266,8 @@ export class NativeLayer {
/**
* Opens the Google Cloud Print sign-in tab. If the user signs in
* successfully, the user-accounts-updated event will be sent in response.
* @param {boolean} addAccount Whether to open an 'add a new account' or
* default sign in page.
*/
signIn(addAccount) {}
signIn() {}
// <if expr="chromeos">
/**
......@@ -381,8 +379,8 @@ export class NativeLayerImpl {
}
/** @override */
signIn(addAccount) {
chrome.send('signIn', [addAccount]);
signIn() {
chrome.send('signIn', [true]);
}
// <if expr="chromeos">
......
......@@ -62,33 +62,12 @@
}
}
#dialog .promo {
#invitationPromo {
align-items: center;
color: var(--cr-primary-text-color);
display: flex;
padding: 16px 20px;
}
#cloudprintPromo .promo-text {
flex: 1;
}
#cloudprintPromo iron-icon {
margin-inline-end: 16px;
width: 20px;
}
#cloudPrintClose {
--cr-icon-button-size: 20px;
--cr-icon-button-icon-size: 16px;
margin-inline-start: 16px;
min-height: 14px;
min-width: 14px;
padding: 0;
}
#invitationPromo {
flex-direction: column;
padding: 16px 20px;
text-align: center;
}
......@@ -148,16 +127,8 @@
$i18n{cancel}
</cr-button>
</div>
<div id="promos" slot="footer" hidden="[[!shouldShowFooter_(
shouldShowCloudPrintPromo_, invitation_)]]">
<div class="promo" id="cloudprintPromo"
hidden$="[[!shouldShowCloudPrintPromo_]]">
<iron-icon icon="print-preview:cloud-queue" alt=""></iron-icon>
<div class="promo-text"></div>
<cr-icon-button id="cloudPrintClose" class="icon-clear"
on-click="onCloudPrintPromoDismissed_"></cr-icon-button>
</div>
<div class="promo" id="invitationPromo" hidden="[[!invitation_]]">
<div id="promos" slot="footer" hidden="[[!invitation_]]">
<div id="invitationPromo">
<div inner-h-t-m-l="[[getInvitationText_(invitation_)]]"></div>
<div class="invitation-buttons">
<cr-button on-click="onInvitationAcceptClick_">
......
......@@ -4,15 +4,11 @@
import 'chrome://resources/cr_elements/cr_button/cr_button.m.js';
import 'chrome://resources/cr_elements/cr_dialog/cr_dialog.m.js';
import 'chrome://resources/cr_elements/cr_icon_button/cr_icon_button.m.js';
import 'chrome://resources/cr_elements/hidden_style_css.m.js';
import 'chrome://resources/cr_elements/icons.m.js';
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/polymer/v3_0/iron-icon/iron-icon.js';
import './icons.js';
import '../print_preview_utils.js';
import './destination_list.js';
import './print_preview_search_box.js';
......@@ -71,14 +67,6 @@ Polymer({
value: null,
},
cloudPrintDisabled: Boolean,
/** @private */
cloudPrintPromoDismissed_: {
type: Boolean,
value: false,
},
/** @private {!Array<!Destination>} */
destinations_: {
type: Array,
......@@ -96,14 +84,6 @@ Polymer({
type: Object,
value: null,
},
/** @private {boolean} */
shouldShowCloudPrintPromo_: {
type: Boolean,
computed: 'computeShouldShowCloudPrintPromo_(' +
'cloudPrintDisabled, activeUser, cloudPrintPromoDismissed_)',
observer: 'onShouldShowCloudPrintPromoChanged_',
},
},
listeners: {
......@@ -124,21 +104,6 @@ Polymer({
/** @private {boolean} */
initialized_: false,
/** @override */
ready() {
this.$$('.promo-text').innerHTML =
this.i18nAdvanced('cloudPrintPromotion', {
substitutions: ['<a is="action-link" class="sign-in">', '</a>'],
attrs: ['is', 'class', 'tabindex', 'role'],
});
},
/** @override */
attached() {
this.tracker_.add(
assert(this.$$('.sign-in')), 'click', this.onSignInClick_.bind(this));
},
/** @override */
detached() {
this.tracker_.removeAll();
......@@ -332,17 +297,6 @@ Polymer({
return this.$.dialog.hasAttribute('open');
},
/** @private */
onSignInClick_() {
this.metrics_.record(Metrics.DestinationSearchBucket.SIGNIN_TRIGGERED);
NativeLayerImpl.getInstance().signIn(false);
},
/** @private */
onCloudPrintPromoDismissed_() {
this.cloudPrintPromoDismissed_ = true;
},
/**
* Updates printer sharing invitations UI.
* @private
......@@ -421,40 +375,12 @@ Polymer({
this.metrics_.record(Metrics.DestinationSearchBucket.ACCOUNT_CHANGED);
} else {
select.value = this.activeUser;
NativeLayerImpl.getInstance().signIn(true);
NativeLayerImpl.getInstance().signIn();
this.metrics_.record(
Metrics.DestinationSearchBucket.ADD_ACCOUNT_SELECTED);
}
},
/**
* @return {boolean} Whether to show the cloud print promo.
* @private
*/
computeShouldShowCloudPrintPromo_() {
return !this.activeUser && !this.cloudPrintDisabled &&
!this.cloudPrintPromoDismissed_;
},
/** @private */
onShouldShowCloudPrintPromoChanged_() {
if (this.shouldShowCloudPrintPromo_) {
this.metrics_.record(Metrics.DestinationSearchBucket.SIGNIN_PROMPT);
} else {
// Since the sign in link/dismiss promo button is disappearing, focus the
// search box.
this.$.searchBox.focus();
}
},
/**
* @return {boolean} Whether to show the footer.
* @private
*/
shouldShowFooter_() {
return this.shouldShowCloudPrintPromo_ || !!this.invitation_;
},
/** @private */
onOpenSettingsPrintPage_() {
this.metrics_.record(Metrics.DestinationSearchBucket.MANAGE_BUTTON_CLICKED);
......
......@@ -42,7 +42,6 @@
<cr-lazy-render id="destinationDialog">
<template>
<print-preview-destination-dialog
cloud-print-disabled="[[cloudPrintDisabled_]]"
destination-store="[[destinationStore_]]"
invitation-store="[[invitationStore_]]"
recent-destination-list="[[recentDestinationList_]]"
......
......@@ -27,7 +27,6 @@
-->
<g id="business"><path d="M12 7V3H2v18h20V7H12zM6 19H4v-2h2v2zm0-4H4v-2h2v2zm0-4H4V9h2v2zm0-4H4V5h2v2zm4 12H8v-2h2v2zm0-4H8v-2h2v2zm0-4H8V9h2v2zm0-4H8V5h2v2zm10 12h-8v-2h2v-2h-2v-2h2v-2h-2V9h8v10zm-2-8h-2v2h2v-2zm0 4h-2v2h2v-2z"></path></g>
<g id="smartphone"><path d="M17 1.01L7 1c-1.1 0-2 .9-2 2v18c0 1.1.9 2 2 2h10c1.1 0 2-.9 2-2V3c0-1.1-.9-1.99-2-1.99zM17 19H7V5h10v14z"></path></g>
<g id="cloud-queue"><path d="M19.35 10.04C18.67 6.59 15.64 4 12 4 9.11 4 6.6 5.64 5.35 8.04 2.34 8.36 0 10.91 0 14c0 3.31 2.69 6 6 6h13c2.76 0 5-2.24 5-5 0-2.64-2.05-4.78-4.65-4.96zM19 18H6c-2.21 0-4-1.79-4-4s1.79-4 4-4h.71C7.37 7.69 9.48 6 12 6c3.04 0 5.5 2.46 5.5 5.5v.5H19c1.66 0 3 1.34 3 3s-1.34 3-3 3z"></path></g>
<g id="print"><path d="M19 8H5c-1.66 0-3 1.34-3 3v6h4v4h12v-4h4v-6c0-1.66-1.34-3-3-3zm-3 11H8v-5h8v5zm3-7c-.55 0-1-.45-1-1s.45-1 1-1 1 .45 1 1-.45 1-1 1zm-1-9H6v4h12V3z"></path></g>
</defs>
</svg>
......
......@@ -221,7 +221,6 @@ void AddPrintPreviewStrings(content::WebUIDataSource* source) {
{"bottom", IDS_PRINT_PREVIEW_BOTTOM_MARGIN_LABEL},
{"cancel", IDS_CANCEL},
{"clearSearch", IDS_CLEAR_SEARCH},
{"cloudPrintPromotion", IDS_PRINT_PREVIEW_CLOUD_PRINT_PROMOTION},
{"copiesInstruction", IDS_PRINT_PREVIEW_COPIES_INSTRUCTION},
{"copiesLabel", IDS_PRINT_PREVIEW_COPIES_LABEL},
{"couldNotPrint", IDS_PRINT_PREVIEW_COULD_NOT_PRINT},
......
......@@ -21,7 +21,6 @@ destination_dialog_interactive_test.suiteName =
/** @enum {string} */
destination_dialog_interactive_test.TestNames = {
FocusSearchBox: 'focus search box',
FocusSearchBoxOnSignIn: 'focus search box on sign in',
EscapeSearchBox: 'escape search box',
};
......@@ -92,44 +91,6 @@ suite(destination_dialog_interactive_test.suiteName, function() {
return whenFocusDone;
});
// Tests that the search input text field is automatically focused when the
// user signs in successfully after clicking the sign in link. See
// https://crbug.com/924921
test(
assert(
destination_dialog_interactive_test.TestNames.FocusSearchBoxOnSignIn),
function() {
const searchInput = /** @type {!PrintPreviewSearchBoxElement} */ (
dialog.$$('#searchBox'))
.getSearchInput();
assertTrue(!!searchInput);
const signInLink = dialog.$$('.sign-in');
assertTrue(!!signInLink);
const whenFocusDone = eventToPromise('focus', searchInput);
dialog.destinationStore.startLoadAllDestinations();
dialog.show();
return whenFocusDone
.then(() => {
signInLink.focus();
nativeLayer.setSignIn([]);
signInLink.click();
return nativeLayer.whenCalled('signIn');
})
.then(() => {
// Link stays focused until successful signin.
// See https://crbug.com/979603.
assertEquals(signInLink, dialog.shadowRoot.activeElement);
nativeLayer.setSignIn(['foo@chromium.org']);
const whenSearchFocused = eventToPromise('focus', searchInput);
signInLink.click();
return whenSearchFocused;
})
.then(() => {
assertEquals('foo@chromium.org', dialog.activeUser);
assertEquals(1, dialog.users.length);
});
});
// Tests that pressing the escape key while the search box is focused
// closes the dialog if and only if the query is empty.
test(
......
......@@ -170,7 +170,6 @@ suite(destination_dialog_test.suiteName, function() {
*/
function assertSignedInState(account, numUsers) {
const signedIn = account !== '';
assertEquals(signedIn, dialog.$$('#cloudprintPromo').hidden);
assertEquals(!signedIn, dialog.$$('.user-info').hidden);
if (numUsers > 0) {
......@@ -211,15 +210,11 @@ suite(destination_dialog_test.suiteName, function() {
let userSelect = null;
await finishSetup();
// Check that both cloud print promo and dropdown are hidden when
// cloud print is disabled.
dialog.cloudPrintDisabled = true;
assertTrue(dialog.$$('#cloudprintPromo').hidden);
// Check that the user dropdown is hidden when there are no active users.
assertTrue(dialog.$$('.user-info').hidden);
userSelect = dialog.$$('.md-select');
// Enable cloud print.
dialog.cloudPrintDisabled = false;
assertSignedInState('', 0);
// Local, extension, privet, and cloud (since
// startLoadAllDestinations() was called).
......@@ -229,22 +224,14 @@ suite(destination_dialog_test.suiteName, function() {
// 6 printers, no Google drive (since not signed in).
assertNumPrintersWithDriveAccount(6, '');
// Simulate signing in to an account.
destinationStore.setActiveUser(user1);
dialog.$$('#cloudprintPromo').querySelector('[is=\'action-link\']').click();
let addAccount = await nativeLayer.whenCalled('signIn');
assertFalse(addAccount);
nativeLayer.resetResolver('signIn');
// This will be done by print-preview-user-info, in response to sign
// in.
// Set an active user.
destinationStore.setActiveUser(user1);
destinationStore.reloadUserCookieBasedDestinations(user1);
dialog.activeUser = user1;
dialog.users = [user1];
flush();
// Promo is hidden and select shows the signed in user.
// Select shows the signed in user.
assertSignedInState(user1, 1);
// Now have 7 printers (Google Drive), with user1 signed in.
......@@ -257,8 +244,7 @@ suite(destination_dialog_test.suiteName, function() {
userSelect.value = '';
userSelect.dispatchEvent(new CustomEvent('change'));
addAccount = await nativeLayer.whenCalled('signIn');
assertTrue(addAccount);
await nativeLayer.whenCalled('signIn');
// No new printer fetch until the user actually changes the active
// account.
assertEquals(3, nativeLayer.getCallCount('getPrinters'));
......@@ -266,7 +252,7 @@ suite(destination_dialog_test.suiteName, function() {
dialog.users = [user1, user2];
flush();
// Promo is hidden and select shows the signed in user.
// Select shows the signed in user.
assertSignedInState(user1, 2);
// Still have 7 printers (Google Drive), with user1 signed in.
......
......@@ -240,10 +240,10 @@ export class NativeLayerStub extends TestBrowserProxy {
}
/** @override */
signIn(addAccount) {
this.methodCalled('signIn', addAccount);
signIn() {
this.methodCalled('signIn');
const accounts = this.accounts_ || ['foo@chromium.org'];
if (!this.accounts_ && addAccount) {
if (!this.accounts_) {
accounts.push('bar@chromium.org');
}
if (accounts.length > 0) {
......@@ -263,14 +263,6 @@ export class NativeLayerStub extends TestBrowserProxy {
/** @override */
openSettingsPrintPage() {}
/**
* @param {!Array<string>} accounts The accounts to send when signIn is
* called.
*/
setSignIn(accounts) {
this.accounts_ = accounts;
}
/**
* @param {!NativeInitialSettings} settings The settings
* to return as a response to |getInitialSettings|.
......
......@@ -88,14 +88,6 @@ TEST_F(
destination_dialog_interactive_test.TestNames.FocusSearchBox);
});
TEST_F(
'PrintPreviewDestinationDialogInteractiveTest', 'FocusSearchBoxOnSignIn',
function() {
this.runMochaTest(
destination_dialog_interactive_test.TestNames.FocusSearchBoxOnSignIn);
});
TEST_F(
'PrintPreviewDestinationDialogInteractiveTest', 'EscapeSearchBox',
function() {
......
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