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

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

Issue 11272026: Remove the managed banner from the Chrome settings UI (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 1 month 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 400 matching lines...) Expand 10 before | Expand all | Expand 10 after
411 411
412 /** 412 /**
413 * Hides the currently visible bubble, if any. 413 * Hides the currently visible bubble, if any.
414 */ 414 */
415 OptionsPage.hideBubble = function() { 415 OptionsPage.hideBubble = function() {
416 if (OptionsPage.bubble_) 416 if (OptionsPage.bubble_)
417 OptionsPage.bubble_.hide(); 417 OptionsPage.bubble_.hide();
418 }; 418 };
419 419
420 /** 420 /**
421 * Updates managed banner visibility state based on the topmost page.
422 */
423 OptionsPage.updateManagedBannerVisibility = function() {
424 var topPage = this.getTopmostVisiblePage();
425 if (topPage)
426 topPage.updateManagedBannerVisibility();
427 };
428
429 /**
430 * Shows the tab contents for the given navigation tab. 421 * Shows the tab contents for the given navigation tab.
431 * @param {!Element} tab The tab that the user clicked. 422 * @param {!Element} tab The tab that the user clicked.
432 */ 423 */
433 OptionsPage.showTab = function(tab) { 424 OptionsPage.showTab = function(tab) {
434 // Search parents until we find a tab, or the nav bar itself. This allows 425 // Search parents until we find a tab, or the nav bar itself. This allows
435 // tabs to have child nodes, e.g. labels in separately-styled spans. 426 // tabs to have child nodes, e.g. labels in separately-styled spans.
436 while (tab && !tab.classList.contains('subpages-nav-tabs') && 427 while (tab && !tab.classList.contains('subpages-nav-tabs') &&
437 !tab.classList.contains('tab')) { 428 !tab.classList.contains('tab')) {
438 tab = tab.parentNode; 429 tab = tab.parentNode;
439 } 430 }
(...skipping 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
708 * @type {OptionsPage} 699 * @type {OptionsPage}
709 */ 700 */
710 associatedControls: null, 701 associatedControls: null,
711 702
712 /** 703 /**
713 * Initializes page content. 704 * Initializes page content.
714 */ 705 */
715 initializePage: function() {}, 706 initializePage: function() {},
716 707
717 /** 708 /**
718 * Updates managed banner visibility state. This function iterates over
719 * all input fields of a page and if any of these is marked as managed
720 * it triggers the managed banner to be visible. The banner can be enforced
721 * being on through the managed flag of this class but it can not be forced
722 * being off if managed items exist.
723 */
724 updateManagedBannerVisibility: function() {
725 var bannerDiv = this.pageDiv.querySelector('.managed-prefs-banner');
726 // Create a banner for the overlay if we don't have one.
727 if (!bannerDiv) {
728 bannerDiv = $('managed-prefs-banner').cloneNode(true);
729 bannerDiv.id = null;
730
731 if (this.isOverlay) {
732 var content = this.pageDiv.querySelector('.content-area');
733 content.parentElement.insertBefore(bannerDiv, content);
734 } else {
735 bannerDiv.classList.add('main-page-banner');
736 var header = this.pageDiv.querySelector('header');
737 header.appendChild(bannerDiv);
738 }
739 }
740
741 var controlledByPolicy = false;
742 var controlledByExtension = false;
743 var inputElements = this.pageDiv.querySelectorAll('input[controlled-by]');
744 for (var i = 0; i < inputElements.length; i++) {
745 if (inputElements[i].controlledBy == 'policy')
746 controlledByPolicy = true;
747 else if (inputElements[i].controlledBy == 'extension')
748 controlledByExtension = true;
749 }
750
751 if (!controlledByPolicy && !controlledByExtension) {
752 this.pageDiv.classList.remove('showing-banner');
753 } else {
754 this.pageDiv.classList.add('showing-banner');
755
756 var text = bannerDiv.querySelector('#managed-prefs-text');
Joao da Silva 2012/10/25 11:07:52 An element with id 'managed-prefs-text' exists in
bartfab (slow) 2012/10/25 13:13:13 The managed mode banner actually has a completely
757 if (controlledByPolicy && !controlledByExtension) {
758 text.textContent =
759 loadTimeData.getString('policyManagedPrefsBannerText');
760 } else if (!controlledByPolicy && controlledByExtension) {
761 text.textContent =
762 loadTimeData.getString('extensionManagedPrefsBannerText');
763 } else if (controlledByPolicy && controlledByExtension) {
764 text.textContent = loadTimeData.getString(
765 'policyAndExtensionManagedPrefsBannerText');
766 }
767 }
768 },
769
770 /**
771 * Gets the container div for this page if it is an overlay. 709 * Gets the container div for this page if it is an overlay.
772 * @type {HTMLElement} 710 * @type {HTMLElement}
773 */ 711 */
774 get container() { 712 get container() {
775 assert(this.isOverlay); 713 assert(this.isOverlay);
776 return this.pageDiv.parentNode; 714 return this.pageDiv.parentNode;
777 }, 715 },
778 716
779 /** 717 /**
780 * Gets page visibility state. 718 * Gets page visibility state.
(...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after
885 } 823 }
886 }, 824 },
887 825
888 /** 826 /**
889 * Called when a page is shown or hidden to update the root options page 827 * Called when a page is shown or hidden to update the root options page
890 * based on this page's visibility. 828 * based on this page's visibility.
891 * @private 829 * @private
892 */ 830 */
893 onVisibilityChanged_: function() { 831 onVisibilityChanged_: function() {
894 OptionsPage.updateRootPageFreezeState(); 832 OptionsPage.updateRootPageFreezeState();
895 OptionsPage.updateManagedBannerVisibility();
896 833
897 if (this.isOverlay && !this.visible) 834 if (this.isOverlay && !this.visible)
898 OptionsPage.updateScrollPosition_(); 835 OptionsPage.updateScrollPosition_();
899 }, 836 },
900 837
901 /** 838 /**
902 * The nesting level of this page. 839 * The nesting level of this page.
903 * @type {number} The nesting level of this page (0 for top-level page) 840 * @type {number} The nesting level of this page (0 for top-level page)
904 */ 841 */
905 get nestingLevel() { 842 get nestingLevel() {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 canShowPage: function() { 881 canShowPage: function() {
945 return true; 882 return true;
946 }, 883 },
947 }; 884 };
948 885
949 // Export 886 // Export
950 return { 887 return {
951 OptionsPage: OptionsPage 888 OptionsPage: OptionsPage
952 }; 889 };
953 }); 890 });
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698