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

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: . 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, len = inputElements.length; i < len; 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 bannerDiv.hidden = true;
944 this.pageDiv.classList.remove('showing-banner');
Evan Stade 2012/02/29 02:36:46 this became necessary after all because I moved th
945 } else {
946 bannerDiv.hidden = false;
947 this.pageDiv.classList.add('showing-banner');
948
949 var text = bannerDiv.querySelector('.managed-prefs-text');
950 if (controlledByPolicy && !controlledByExtension) {
951 text.textContent = templateData.policyManagedPrefsBannerText;
952 } else if (!controlledByPolicy && controlledByExtension) {
953 text.textContent = templateData.extensionManagedPrefsBannerText;
954 } else if (controlledByPolicy && controlledByExtension) {
955 text.textContent =
956 templateData.policyAndExtensionManagedPrefsBannerText;
957 }
958 }
959 },
960
961 /**
909 * Gets page visibility state. 962 * Gets page visibility state.
910 */ 963 */
911 get visible() { 964 get visible() {
912 return !this.pageDiv.hidden; 965 return !this.pageDiv.hidden;
913 }, 966 },
914 967
915 /** 968 /**
916 * Sets page visibility. 969 * Sets page visibility.
917 */ 970 */
918 set visible(visible) { 971 set visible(visible) {
919 if ((this.visible && visible) || (!this.visible && !visible)) 972 if ((this.visible && visible) || (!this.visible && !visible))
920 return; 973 return;
921 974
922 this.pageDiv.hidden = !visible; 975 this.pageDiv.hidden = !visible;
923 this.setContainerVisibility_(visible); 976 this.setContainerVisibility_(visible);
924 977
925 OptionsPage.updatePageFreezeStates(); 978 OptionsPage.updatePageFreezeStates();
979 OptionsPage.updateManagedBannerVisibility();
926 980
927 // A subpage was shown or hidden. 981 // A subpage was shown or hidden.
928 if (!this.isOverlay && this.nestingLevel > 0) 982 if (!this.isOverlay && this.nestingLevel > 0)
929 OptionsPage.updateDisplayForShowOrHideSubpage_(); 983 OptionsPage.updateDisplayForShowOrHideSubpage_();
930 else if (this.isOverlay && !visible) 984 else if (this.isOverlay && !visible)
931 OptionsPage.updateScrollPosition_(); 985 OptionsPage.updateScrollPosition_();
932 986
933 cr.dispatchPropertyChange(this, 'visible', visible, !visible); 987 cr.dispatchPropertyChange(this, 'visible', visible, !visible);
934 }, 988 },
935 989
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after
1064 canShowPage: function() { 1118 canShowPage: function() {
1065 return true; 1119 return true;
1066 }, 1120 },
1067 }; 1121 };
1068 1122
1069 // Export 1123 // Export
1070 return { 1124 return {
1071 OptionsPage: OptionsPage 1125 OptionsPage: OptionsPage
1072 }; 1126 };
1073 }); 1127 });
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