Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(249)

Side by Side Diff: chrome/browser/resources/options2/options_page.js

Issue 9513016: uber managed pref banners (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fixed merge Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 cr.define('options', function() { 5 cr.define('options', function() {
6 ///////////////////////////////////////////////////////////////////////////// 6 /////////////////////////////////////////////////////////////////////////////
7 // OptionsPage class: 7 // OptionsPage class:
8 8
9 /** 9 /**
10 * Base class for options page. 10 * Base class for options page.
(...skipping 888 matching lines...) Expand 10 before | Expand all | Expand 10 after
899 * @type {OptionsPage} 899 * @type {OptionsPage}
900 */ 900 */
901 associatedControls: null, 901 associatedControls: null,
902 902
903 /** 903 /**
904 * Initializes page content. 904 * Initializes page content.
905 */ 905 */
906 initializePage: function() {}, 906 initializePage: function() {},
907 907
908 /** 908 /**
909 * Updates managed banner visibility state. This function iterates over
910 * all input fields of a page and if any of these is marked as managed
911 * it triggers the managed banner to be visible. The banner can be enforced
912 * being on through the managed flag of this class but it can not be forced
913 * being off if managed items exist.
914 */
915 updateManagedBannerVisibility: function() {
916 var bannerDiv = this.pageDiv.querySelector('.managed-prefs-banner');
917 // Create a banner for the overlay if we don't have one.
918 if (!bannerDiv) {
919 bannerDiv = $('managed-prefs-banner').cloneNode(true);
920 bannerDiv.id = null;
921
922 if (this.isOverlay) {
923 var content = this.pageDiv.querySelector('.content-area');
924 this.pageDiv.insertBefore(bannerDiv, content);
925 } else {
926 bannerDiv.classList.add('main-page-banner');
927 var header = this.pageDiv.querySelector('header');
928 header.appendChild(bannerDiv);
929 }
930 }
931
932 var controlledByPolicy = false;
933 var controlledByExtension = false;
934 var inputElements = this.pageDiv.querySelectorAll('input[controlled-by]');
935 for (var i = 0; i < inputElements.length; i++) {
936 if (inputElements[i].controlledBy == 'policy')
937 controlledByPolicy = true;
938 else if (inputElements[i].controlledBy == 'extension')
939 controlledByExtension = true;
940 }
941
942 if (!controlledByPolicy && !controlledByExtension) {
943 this.pageDiv.classList.remove('showing-banner');
944 } else {
945 this.pageDiv.classList.add('showing-banner');
946
947 var text = bannerDiv.querySelector('.managed-prefs-text');
948 if (controlledByPolicy && !controlledByExtension) {
949 text.textContent = templateData.policyManagedPrefsBannerText;
950 } else if (!controlledByPolicy && controlledByExtension) {
951 text.textContent = templateData.extensionManagedPrefsBannerText;
952 } else if (controlledByPolicy && controlledByExtension) {
953 text.textContent =
954 templateData.policyAndExtensionManagedPrefsBannerText;
955 }
956 }
957 },
958
959 /**
909 * Gets page visibility state. 960 * Gets page visibility state.
910 */ 961 */
911 get visible() { 962 get visible() {
912 return !this.pageDiv.hidden; 963 return !this.pageDiv.hidden;
913 }, 964 },
914 965
915 /** 966 /**
916 * Sets page visibility. 967 * Sets page visibility.
917 */ 968 */
918 set visible(visible) { 969 set visible(visible) {
919 if ((this.visible && visible) || (!this.visible && !visible)) 970 if ((this.visible && visible) || (!this.visible && !visible))
920 return; 971 return;
921 972
922 this.pageDiv.hidden = !visible; 973 this.pageDiv.hidden = !visible;
923 this.setContainerVisibility_(visible); 974 this.setContainerVisibility_(visible);
924 975
925 OptionsPage.updatePageFreezeStates(); 976 OptionsPage.updatePageFreezeStates();
977 OptionsPage.updateManagedBannerVisibility();
926 978
927 // A subpage was shown or hidden. 979 // A subpage was shown or hidden.
928 if (!this.isOverlay && this.nestingLevel > 0) 980 if (!this.isOverlay && this.nestingLevel > 0)
929 OptionsPage.updateDisplayForShowOrHideSubpage_(); 981 OptionsPage.updateDisplayForShowOrHideSubpage_();
930 else if (this.isOverlay && !visible) 982 else if (this.isOverlay && !visible)
931 OptionsPage.updateScrollPosition_(); 983 OptionsPage.updateScrollPosition_();
932 984
933 cr.dispatchPropertyChange(this, 'visible', visible, !visible); 985 cr.dispatchPropertyChange(this, 'visible', visible, !visible);
934 }, 986 },
935 987
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 canShowPage: function() { 1116 canShowPage: function() {
1065 return true; 1117 return true;
1066 }, 1118 },
1067 }; 1119 };
1068 1120
1069 // Export 1121 // Export
1070 return { 1122 return {
1071 OptionsPage: OptionsPage 1123 OptionsPage: OptionsPage
1072 }; 1124 };
1073 }); 1125 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/options2/options_page.css ('k') | chrome/browser/resources/options2/pref_ui.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698