Skip to content

Commit 244a521

Browse files
author
Thomas Tangl
committed
[clear-browsing-data] Clean up code for dialog
Clean up code for clear browsing data dialog. Changes: - Remove template elements and add hidden attribute instead - Clean up tests - Remove argument from strings ($1 -> #) Bug: 893696 Change-Id: I0650a0a6fe0bd08884480f6eb4b53e379ba4ebba Reviewed-on: https://chromium-review.googlesource.com/c/1276771 Commit-Queue: Thomas Tangl <tangltom@chromium.org> Reviewed-by: Demetrios Papadopoulos <dpapad@chromium.org> Cr-Original-Commit-Position: refs/heads/master@{#599643}(cherry picked from commit 59736b1) Reviewed-on: https://chromium-review.googlesource.com/c/1284330 Reviewed-by: Thomas Tangl <tangltom@chromium.org> Cr-Commit-Position: refs/branch-heads/3578@{#58} Cr-Branched-From: 4226ddf-refs/heads/master@{#599034}
1 parent a44c6b4 commit 244a521

4 files changed

Lines changed: 35 additions & 50 deletions

File tree

chrome/app/settings_strings.grdp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1141,16 +1141,16 @@
11411141
Time range
11421142
</message>
11431143
<message name="IDS_SETTINGS_CLEAR_BROWSING_DATA_WITH_SYNC" desc="Description in the footer of the Clear Browsing Data dialog when the user is syncing.">
1144-
To clear browsing data from this device only, while keeping it in your Google Account, <ph name="BEGIN_LINK">&lt;a href="$1" target=&quot;_blank&quot;&gt;</ph>sign out<ph name="END_LINK">&lt;/a&gt;</ph>.
1144+
To clear browsing data from this device only, while keeping it in your Google Account, <ph name="BEGIN_LINK">&lt;a href="#" target=&quot;_blank&quot;&gt;</ph>sign out<ph name="END_LINK">&lt;/a&gt;</ph>.
11451145
</message>
11461146
<message name="IDS_SETTINGS_CLEAR_BROWSING_DATA_WITH_SYNC_ERROR" desc="Description in the footer of the Clear Browsing Data dialog when there is a sync error.">
1147-
To clear browsing data from all of your synced devices and your Google Account, <ph name="BEGIN_LINK">&lt;a href="$1" target=&quot;_blank&quot;&gt;</ph>visit sync settings<ph name="END_LINK">&lt;/a&gt;</ph>.
1147+
To clear browsing data from all of your synced devices and your Google Account, <ph name="BEGIN_LINK">&lt;a href="#" target=&quot;_blank&quot;&gt;</ph>visit sync settings<ph name="END_LINK">&lt;/a&gt;</ph>.
11481148
</message>
11491149
<message name="IDS_SETTINGS_CLEAR_BROWSING_DATA_WITH_SYNC_PASSPHRASE_ERROR" desc="Description in the footer of the Clear Browsing Data dialog when there is a sync passphrase error.">
1150-
To clear browsing data from all of your synced devices and your Google Account, <ph name="BEGIN_LINK">&lt;a href="$1" target=&quot;_blank&quot;&gt;</ph>enter your passphrase<ph name="END_LINK">&lt;/a&gt;</ph>.
1150+
To clear browsing data from all of your synced devices and your Google Account, <ph name="BEGIN_LINK">&lt;a href="#" target=&quot;_blank&quot;&gt;</ph>enter your passphrase<ph name="END_LINK">&lt;/a&gt;</ph>.
11511151
</message>
11521152
<message name="IDS_SETTINGS_CLEAR_BROWSING_DATA_WITH_SYNC_PAUSED" desc="Description in the footer of the Clear Browsing Data dialog when sync is paused.">
1153-
To clear browsing data from all of your synced devices and your Google Account, <ph name="BEGIN_LINK">&lt;a href="$1" target=&quot;_blank&quot;&gt;</ph>sign in<ph name="END_LINK">&lt;/a&gt;</ph>.
1153+
To clear browsing data from all of your synced devices and your Google Account, <ph name="BEGIN_LINK">&lt;a href="#" target=&quot;_blank&quot;&gt;</ph>sign in<ph name="END_LINK">&lt;/a&gt;</ph>.
11541154
</message>
11551155
<message name="IDS_SETTINGS_CLEAR_BROWSING_HISTORY" desc="Checkbox for deleting Browsing History">
11561156
Browsing history

chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.html

Lines changed: 14 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -262,29 +262,20 @@
262262
hide-buttons>
263263
</settings-sync-account-control>
264264
<div class="divider"></div>
265-
<div id="footer-description" on-tap="onSyncDescriptionLinkClicked_">
266-
<template is="dom-if" if="[[!syncStatus.hasError]]">
267-
<span id="sync-info">
268-
$i18nRaw{clearBrowsingDataWithSync}
269-
</span>
270-
</template>
271-
<template is="dom-if" if="[[syncStatus.hasError]]">
272-
<template is="dom-if" if="[[isSyncPaused_]]">
273-
<span id="sync-paused-info">
274-
$i18nRaw{clearBrowsingDataWithSyncPaused}
275-
</span>
276-
</template>
277-
<template is="dom-if" if="[[hasPassphraseError_]]">
278-
<span id="sync-passphrase-error-info">
279-
$i18nRaw{clearBrowsingDataWithSyncPassphraseError}
280-
</span>
281-
</template>
282-
<template is="dom-if" if="[[hasOtherSyncError_]]">
283-
<span id="sync-other-error-info">
284-
$i18nRaw{clearBrowsingDataWithSyncError}
285-
</span>
286-
</template>
287-
</template>
265+
<div id="footer-description" on-click="onSyncDescriptionLinkClicked_">
266+
<span id="sync-info" hidden="[[syncStatus.hasError]]">
267+
$i18nRaw{clearBrowsingDataWithSync}
268+
</span>
269+
<span id="sync-paused-info" hidden="[[!isSyncPaused_]]">
270+
$i18nRaw{clearBrowsingDataWithSyncPaused}
271+
</span>
272+
<span id="sync-passphrase-error-info"
273+
hidden="[[!hasPassphraseError_]]">
274+
$i18nRaw{clearBrowsingDataWithSyncPassphraseError}
275+
</span>
276+
<span id="sync-other-error-info" hidden="[[!hasOtherSyncError_]]">
277+
$i18nRaw{clearBrowsingDataWithSyncError}
278+
</span>
288279
</div>
289280
</div>
290281
</cr-dialog>

chrome/browser/resources/settings/clear_browsing_data_dialog/clear_browsing_data_dialog.js

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -390,10 +390,7 @@ Polymer({
390390
e.preventDefault();
391391
if (!this.syncStatus.hasError) {
392392
this.syncBrowserProxy_.pauseSync();
393-
return;
394-
}
395-
396-
if (this.isSyncPaused_) {
393+
} else if (this.isSyncPaused_) {
397394
this.syncBrowserProxy_.startSignIn();
398395
} else {
399396
// In any other error case, navigate to the sync page.

chrome/test/data/webui/settings/privacy_page_test.js

Lines changed: 16 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -169,7 +169,7 @@ cr.define('settings_privacy_page', function() {
169169
let testBrowserProxy;
170170

171171
/** @type {TestSyncBrowserProxy} */
172-
let testSyncBrowserProxy = null;
172+
let testSyncBrowserProxy;
173173

174174
/** @type {SettingsClearBrowsingDataDialogElement} */
175175
let element;
@@ -190,36 +190,36 @@ cr.define('settings_privacy_page', function() {
190190
element.set('prefs', getClearBrowsingDataPrefs());
191191
element.syncStatus = {signedIn: true, hasError: false};
192192
document.body.appendChild(element);
193-
return testBrowserProxy.whenCalled('initialize');
193+
return testBrowserProxy.whenCalled('initialize').then(() => {
194+
assertTrue(element.$$('#clearBrowsingDataDialog').open);
195+
});
194196
});
195197

196198
teardown(function() {
197199
element.remove();
198200
});
199201

200202
test('ClearBrowsingDataSyncAccountInfoDice', function() {
201-
assertTrue(element.$$('#clearBrowsingDataDialog').open);
202-
203203
// Not syncing: the footer is hidden.
204204
element.syncStatus = {
205205
signedIn: false,
206206
hasError: false,
207207
};
208208
Polymer.dom.flush();
209-
assertTrue(element.$$('#clearBrowsingDataDialog [slot=footer]').hidden);
209+
const footer = element.$$('#clearBrowsingDataDialog [slot=footer]');
210+
assertTrue(footer.hidden);
210211

211212
// Syncing: the footer is shown, with the normal sync info.
212213
element.syncStatus = {
213214
signedIn: true,
214215
hasError: false,
215216
};
216217
Polymer.dom.flush();
217-
assertFalse(
218-
element.$$('#clearBrowsingDataDialog [slot=footer]').hidden);
218+
assertFalse(footer.hidden);
219219
assertVisible(element.$$('#sync-info'), true);
220-
assertFalse(!!element.$$('#sync-paused-info'));
221-
assertFalse(!!element.$$('#sync-passphrase-error-info'));
222-
assertFalse(!!element.$$('#sync-other-error-info'));
220+
assertVisible(element.$$('#sync-paused-info'), false);
221+
assertVisible(element.$$('#sync-passphrase-error-info'), false);
222+
assertVisible(element.$$('#sync-other-error-info'), false);
223223

224224
// Sync is paused.
225225
element.syncStatus = {
@@ -228,10 +228,10 @@ cr.define('settings_privacy_page', function() {
228228
statusAction: settings.StatusAction.REAUTHENTICATE,
229229
};
230230
Polymer.dom.flush();
231-
assertVisible(element.$$('#sync-paused-info'), true);
232231
assertVisible(element.$$('#sync-info'), false);
233-
assertFalse(!!element.$$('#sync-passphrase-error-info'));
234-
assertFalse(!!element.$$('#sync-other-error-info'));
232+
assertVisible(element.$$('#sync-paused-info'), true);
233+
assertVisible(element.$$('#sync-passphrase-error-info'), false);
234+
assertVisible(element.$$('#sync-other-error-info'), false);
235235

236236
// Sync passphrase error.
237237
element.syncStatus = {
@@ -240,10 +240,10 @@ cr.define('settings_privacy_page', function() {
240240
statusAction: settings.StatusAction.ENTER_PASSPHRASE,
241241
};
242242
Polymer.dom.flush();
243-
assertVisible(element.$$('#sync-passphrase-error-info'), true);
244243
assertVisible(element.$$('#sync-info'), false);
245244
assertVisible(element.$$('#sync-paused-info'), false);
246-
assertFalse(!!element.$$('#sync-other-error-info'));
245+
assertVisible(element.$$('#sync-passphrase-error-info'), true);
246+
assertVisible(element.$$('#sync-other-error-info'), false);
247247

248248
// Other sync error.
249249
element.syncStatus = {
@@ -252,14 +252,13 @@ cr.define('settings_privacy_page', function() {
252252
statusAction: settings.StatusAction.NO_ACTION,
253253
};
254254
Polymer.dom.flush();
255-
assertVisible(element.$$('#sync-other-error-info'), true);
256255
assertVisible(element.$$('#sync-info'), false);
257256
assertVisible(element.$$('#sync-paused-info'), false);
258257
assertVisible(element.$$('#sync-passphrase-error-info'), false);
258+
assertVisible(element.$$('#sync-other-error-info'), true);
259259
});
260260

261261
test('ClearBrowsingDataPauseSyncDice', function() {
262-
assertTrue(element.$$('#clearBrowsingDataDialog').open);
263262
element.syncStatus = {
264263
signedIn: true,
265264
hasError: false,
@@ -277,7 +276,6 @@ cr.define('settings_privacy_page', function() {
277276
});
278277

279278
test('ClearBrowsingDataStartSignInDice', function() {
280-
assertTrue(element.$$('#clearBrowsingDataDialog').open);
281279
element.syncStatus = {
282280
signedIn: true,
283281
hasError: true,
@@ -296,7 +294,6 @@ cr.define('settings_privacy_page', function() {
296294
});
297295

298296
test('ClearBrowsingDataHandlePassphraseErrorDice', function() {
299-
assertTrue(element.$$('#clearBrowsingDataDialog').open);
300297
element.syncStatus = {
301298
signedIn: true,
302299
hasError: true,

0 commit comments

Comments
 (0)