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

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

Issue 7342009: Show a different banner in chrome://settings for extension-controlled settings. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review Created 9 years, 5 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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.
11 * @constructor 11 * @constructor
12 * @param {string} name Options page name, also defines id of the div element 12 * @param {string} name Options page name, also defines id of the div element
13 * containing the options view and the name of options page navigation bar 13 * containing the options view and the name of options page navigation bar
14 * item as name+'PageNav'. 14 * item as name+'PageNav'.
15 * @param {string} title Options page title, used for navigation bar 15 * @param {string} title Options page title, used for navigation bar
16 * @extends {EventTarget} 16 * @extends {EventTarget}
17 */ 17 */
18 function OptionsPage(name, title, pageDivName) { 18 function OptionsPage(name, title, pageDivName) {
19 this.name = name; 19 this.name = name;
20 this.title = title; 20 this.title = title;
21 this.pageDivName = pageDivName; 21 this.pageDivName = pageDivName;
22 this.pageDiv = $(this.pageDivName); 22 this.pageDiv = $(this.pageDivName);
23 this.tab = null; 23 this.tab = null;
24 this.managed = false;
25 } 24 }
26 25
27 const SUBPAGE_SHEET_COUNT = 2; 26 const SUBPAGE_SHEET_COUNT = 2;
28 27
29 /** 28 /**
30 * Main level option pages. Maps lower-case page names to the respective page 29 * Main level option pages. Maps lower-case page names to the respective page
31 * object. 30 * object.
32 * @protected 31 * @protected
33 */ 32 */
34 OptionsPage.registeredPages = {}; 33 OptionsPage.registeredPages = {};
(...skipping 766 matching lines...) Expand 10 before | Expand all | Expand 10 after
801 * @type {OptionsPage} 800 * @type {OptionsPage}
802 */ 801 */
803 associatedControls: null, 802 associatedControls: null,
804 803
805 /** 804 /**
806 * Initializes page content. 805 * Initializes page content.
807 */ 806 */
808 initializePage: function() {}, 807 initializePage: function() {},
809 808
810 /** 809 /**
811 * Sets managed banner visibility state.
812 */
813 setManagedBannerVisibility: function(visible) {
814 this.managed = visible;
815 if (this.visible) {
816 this.updateManagedBannerVisibility();
817 }
818 },
819
820 /**
821 * Updates managed banner visibility state. This function iterates over 810 * Updates managed banner visibility state. This function iterates over
822 * all input fields of a window and if any of these is marked as managed 811 * all input fields of a window and if any of these is marked as managed
823 * it triggers the managed banner to be visible. The banner can be enforced 812 * it triggers the managed banner to be visible. The banner can be enforced
824 * being on through the managed flag of this class but it can not be forced 813 * being on through the managed flag of this class but it can not be forced
825 * being off if managed items exist. 814 * being off if managed items exist.
826 */ 815 */
827 updateManagedBannerVisibility: function() { 816 updateManagedBannerVisibility: function() {
828 var bannerDiv = $('managed-prefs-banner'); 817 var bannerDiv = $('managed-prefs-banner');
829 818
830 var hasManaged = this.managed; 819 var controlledByPolicy = false;
831 if (!hasManaged) { 820 var controlledByExtension = false;
832 var inputElements = this.pageDiv.querySelectorAll('input'); 821 var inputElements = this.pageDiv.querySelectorAll('input[controlledBy]');
833 for (var i = 0, len = inputElements.length; i < len; i++) { 822 for (var i = 0, len = inputElements.length; i < len; i++) {
834 if (inputElements[i].managed) { 823 if (inputElements[i].controlledBy == 'policy')
835 hasManaged = true; 824 controlledByPolicy = true;
836 break; 825 else if (inputElements[i].controlledBy == 'extension')
837 } 826 controlledByExtension = true;
838 }
839 } 827 }
840 if (hasManaged) { 828 if (!controlledByPolicy && !controlledByExtension) {
841 bannerDiv.hidden = false;
842 var height = window.getComputedStyle($('managed-prefs-banner')).height;
843 $('subpage-backdrop').style.top = height;
844 } else {
845 bannerDiv.hidden = true; 829 bannerDiv.hidden = true;
846 $('subpage-backdrop').style.top = '0'; 830 $('subpage-backdrop').style.top = '0';
831 } else {
832 bannerDiv.hidden = false;
833 var height = window.getComputedStyle(bannerDiv).height;
834 $('subpage-backdrop').style.top = height;
835 if (controlledByPolicy && !controlledByExtension) {
836 $('managed-prefs-text').textContent =
837 templateData.policyManagedPrefsBannerText;
838 } else if (!controlledByPolicy && controlledByExtension) {
839 $('managed-prefs-text').textContent =
840 templateData.extensionManagedPrefsBannerText;
841 } else if (controlledByPolicy && controlledByExtension) {
842 $('managed-prefs-text').textContent =
843 templateData.policyAndExtensionManagedPrefsBannerText;
844 }
847 } 845 }
848 }, 846 },
849 847
850 /** 848 /**
851 * Gets page visibility state. 849 * Gets page visibility state.
852 */ 850 */
853 get visible() { 851 get visible() {
854 return !this.pageDiv.hidden; 852 return !this.pageDiv.hidden;
855 }, 853 },
856 854
(...skipping 163 matching lines...) Expand 10 before | Expand all | Expand 10 after
1020 canShowPage: function() { 1018 canShowPage: function() {
1021 return true; 1019 return true;
1022 }, 1020 },
1023 }; 1021 };
1024 1022
1025 // Export 1023 // Export
1026 return { 1024 return {
1027 OptionsPage: OptionsPage 1025 OptionsPage: OptionsPage
1028 }; 1026 };
1029 }); 1027 });
OLDNEW
« no previous file with comments | « chrome/browser/resources/options/options.html ('k') | chrome/browser/resources/options/personal_options.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698