Commit 1c30abaa authored by Esmael El-Moslimany's avatar Esmael El-Moslimany Committed by Commit Bot

Settings: use hidden for incognito checkbox

Bug: 849811
Cq-Include-Trybots: master.tryserver.chromium.linux:closure_compilation
Change-Id: Ib034544b40403e47e1c7c538b70b93e9d3f6ee8c
Reviewed-on: https://chromium-review.googlesource.com/1087783
Commit-Queue: Esmael El-Moslimany <aee@chromium.org>
Reviewed-by: default avatarHector Carmona <hcarmona@chromium.org>
Cr-Commit-Position: refs/heads/master@{#565457}
parent fdd23be0
...@@ -14,12 +14,7 @@ ...@@ -14,12 +14,7 @@
<template> <template>
<style include="settings-shared"> <style include="settings-shared">
#incognito { #incognito {
margin-bottom: 2px; padding-bottom: 10px;
margin-top: 15px;
}
[invisible] {
visibility: hidden;
} }
</style> </style>
<cr-dialog id="dialog" close-text="$i18n{close}"> <cr-dialog id="dialog" close-text="$i18n{close}">
...@@ -31,7 +26,8 @@ ...@@ -31,7 +26,8 @@
error-message="$i18n{notValidWebAddress}" spellcheck="false" error-message="$i18n{notValidWebAddress}" spellcheck="false"
autofocus></paper-input> autofocus></paper-input>
<cr-checkbox id="incognito" <cr-checkbox id="incognito"
invisible$="[[!showIncognitoSessionOnly_]]"> hidden$="[[!showIncognitoSessionOnly_(hasIncognito,
contentSetting)]]">
$i18n{incognitoSiteOnly} $i18n{incognitoSiteOnly}
</cr-checkbox> </cr-checkbox>
</div> </div>
......
...@@ -26,7 +26,10 @@ Polymer({ ...@@ -26,7 +26,10 @@ Polymer({
contentSetting: String, contentSetting: String,
/** @private */ /** @private */
showIncognitoSessionOnly_: Boolean, hasIncognito: {
type: Boolean,
observer: 'hasIncognitoChanged_',
},
/** /**
* The site to add an exception for. * The site to add an exception for.
...@@ -39,17 +42,8 @@ Polymer({ ...@@ -39,17 +42,8 @@ Polymer({
attached: function() { attached: function() {
assert(this.category); assert(this.category);
assert(this.contentSetting); assert(this.contentSetting);
}, assert(typeof this.hasIncognito != 'undefined');
/** Open the dialog. */
open: function() {
this.addWebUIListener('onIncognitoStatusChanged', hasIncognito => {
this.$.incognito.checked = false;
this.showIncognitoSessionOnly_ = hasIncognito &&
!loadTimeData.getBoolean('isGuest') &&
this.contentSetting != settings.ContentSetting.SESSION_ONLY;
});
this.browserProxy.updateIncognitoStatus();
this.$.dialog.showModal(); this.$.dialog.showModal();
}, },
...@@ -90,4 +84,16 @@ Polymer({ ...@@ -90,4 +84,16 @@ Polymer({
this.$.incognito.checked); this.$.incognito.checked);
this.$.dialog.close(); this.$.dialog.close();
}, },
/** @private */
showIncognitoSessionOnly_: function() {
return this.hasIncognito && !loadTimeData.getBoolean('isGuest') &&
this.contentSetting != settings.ContentSetting.SESSION_ONLY;
},
/** @private */
hasIncognitoChanged_: function() {
if (!this.hasIncognito)
this.$.incognito.checked = false;
},
}); });
...@@ -115,6 +115,12 @@ ...@@ -115,6 +115,12 @@
on-close="onEditExceptionDialogClosed_"> on-close="onEditExceptionDialogClosed_">
</settings-edit-exception-dialog> </settings-edit-exception-dialog>
</template> </template>
<template is="dom-if" if="[[showAddSiteDialog_]]" restamp>
<add-site-dialog has-incognito="[[hasIncognito_]]" category="[[category]]"
content-setting="[[categorySubtype]]"
on-close="onAddSiteDialogClosed_">
</add-site-dialog>
</template>
</template> </template>
<script src="site_list.js"></script> <script src="site_list.js"></script>
</dom-module> </dom-module>
...@@ -65,6 +65,12 @@ Polymer({ ...@@ -65,6 +65,12 @@ Polymer({
value: settings.INVALID_CATEGORY_SUBTYPE, value: settings.INVALID_CATEGORY_SUBTYPE,
}, },
/** @private */
hasIncognito_: Boolean,
/** @private */
showAddSiteDialog_: Boolean,
/** /**
* Whether to show the Allow action in the action menu. * Whether to show the Allow action in the action menu.
* @private * @private
...@@ -115,6 +121,7 @@ Polymer({ ...@@ -115,6 +121,7 @@ Polymer({
this.siteWithinCategoryChanged_.bind(this)); this.siteWithinCategoryChanged_.bind(this));
this.addWebUIListener( this.addWebUIListener(
'onIncognitoStatusChanged', this.onIncognitoStatusChanged_.bind(this)); 'onIncognitoStatusChanged', this.onIncognitoStatusChanged_.bind(this));
this.browserProxy.updateIncognitoStatus();
}, },
/** /**
...@@ -134,7 +141,9 @@ Polymer({ ...@@ -134,7 +141,9 @@ Polymer({
* Another message is sent when the *last* incognito window closes. * Another message is sent when the *last* incognito window closes.
* @private * @private
*/ */
onIncognitoStatusChanged_: function() { onIncognitoStatusChanged_: function(hasIncognito) {
this.hasIncognito_ = hasIncognito;
// The SESSION_ONLY list won't have any incognito exceptions. (Minor // The SESSION_ONLY list won't have any incognito exceptions. (Minor
// optimization, not required). // optimization, not required).
if (this.categorySubtype == settings.ContentSetting.SESSION_ONLY) if (this.categorySubtype == settings.ContentSetting.SESSION_ONLY)
...@@ -202,23 +211,17 @@ Polymer({ ...@@ -202,23 +211,17 @@ Polymer({
/** /**
* A handler for the Add Site button. * A handler for the Add Site button.
* @param {!Event} e
* @private * @private
*/ */
onAddSiteTap_: function(e) { onAddSiteTap_: function() {
assert(!this.readOnlyList); assert(!this.readOnlyList);
e.preventDefault(); this.showAddSiteDialog_ = true;
const dialog = document.createElement('add-site-dialog'); },
dialog.category = this.category;
dialog.contentSetting = this.categorySubtype;
this.shadowRoot.appendChild(dialog);
dialog.open(this.categorySubtype);
dialog.addEventListener('close', () => { /** @private */
cr.ui.focusWithoutInk(assert(this.$.addSite)); onAddSiteDialogClosed_: function() {
dialog.remove(); this.showAddSiteDialog_ = false;
}); cr.ui.focusWithoutInk(assert(this.$.addSite));
}, },
/** /**
......
...@@ -991,8 +991,8 @@ suite('AddExceptionDialog', function() { ...@@ -991,8 +991,8 @@ suite('AddExceptionDialog', function() {
dialog = document.createElement('add-site-dialog'); dialog = document.createElement('add-site-dialog');
dialog.category = settings.ContentSettingsTypes.GEOLOCATION; dialog.category = settings.ContentSettingsTypes.GEOLOCATION;
dialog.contentSetting = settings.ContentSetting.ALLOW; dialog.contentSetting = settings.ContentSetting.ALLOW;
dialog.hasIncognito = false;
document.body.appendChild(dialog); document.body.appendChild(dialog);
dialog.open();
}); });
teardown(function() { teardown(function() {
...@@ -1000,15 +1000,13 @@ suite('AddExceptionDialog', function() { ...@@ -1000,15 +1000,13 @@ suite('AddExceptionDialog', function() {
}); });
test('incognito', function() { test('incognito', function() {
cr.webUIListenerCallback( dialog.set('hasIncognito', true);
'onIncognitoStatusChanged', Polymer.dom.flush();
/*hasIncognito=*/true);
assertFalse(dialog.$.incognito.checked); assertFalse(dialog.$.incognito.checked);
dialog.$.incognito.checked = true; dialog.$.incognito.checked = true;
// Changing the incognito status will reset the checkbox. // Changing the incognito status will reset the checkbox.
cr.webUIListenerCallback( dialog.set('hasIncognito', false);
'onIncognitoStatusChanged', Polymer.dom.flush();
/*hasIncognito=*/false);
assertFalse(dialog.$.incognito.checked); assertFalse(dialog.$.incognito.checked);
}); });
......
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