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

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

Issue 7093004: Sync: Refactor the ProfileSyncService and sync setup flow to remove use of WebUI from PSS. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Review fixes and cleanups. Created 9 years, 6 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.
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 // Notify pages if they will be hidden. 111 // Notify pages if they will be hidden.
112 for (var name in this.registeredPages) { 112 for (var name in this.registeredPages) {
113 var page = this.registeredPages[name]; 113 var page = this.registeredPages[name];
114 if (!page.parentPage && isRootPageLocked) 114 if (!page.parentPage && isRootPageLocked)
115 continue; 115 continue;
116 if (page.willHidePage && name != pageName && 116 if (page.willHidePage && name != pageName &&
117 !page.isAncestorOfPage(targetPage)) 117 !page.isAncestorOfPage(targetPage))
118 page.willHidePage(); 118 page.willHidePage();
119 } 119 }
120 120
121 var prevVisible = false;
122
121 // Update visibilities to show only the hierarchy of the target page. 123 // Update visibilities to show only the hierarchy of the target page.
122 for (var name in this.registeredPages) { 124 for (var name in this.registeredPages) {
123 var page = this.registeredPages[name]; 125 var page = this.registeredPages[name];
124 if (!page.parentPage && isRootPageLocked) 126 if (!page.parentPage && isRootPageLocked)
125 continue; 127 continue;
128 prevVisible = page.visible;
126 page.visible = name == pageName || 129 page.visible = name == pageName ||
127 (!document.documentElement.classList.contains('hide-menu') && 130 (!document.documentElement.classList.contains('hide-menu') &&
128 page.isAncestorOfPage(targetPage)); 131 page.isAncestorOfPage(targetPage));
129 } 132 }
130 133
131 // Update the history and current location. 134 // Update the history and current location.
132 if (updateHistory) 135 if (updateHistory)
133 this.updateHistoryState_(); 136 this.updateHistoryState_();
134 137
135 // Always update the page title. 138 // Always update the page title.
136 document.title = targetPage.title; 139 document.title = targetPage.title;
137 140
138 // Notify pages if they were shown. 141 // Notify pages if they were shown.
139 for (var name in this.registeredPages) { 142 for (var name in this.registeredPages) {
140 var page = this.registeredPages[name]; 143 var page = this.registeredPages[name];
141 if (!page.parentPage && isRootPageLocked) 144 if (!page.parentPage && isRootPageLocked)
142 continue; 145 continue;
143 if (page.didShowPage && (name == pageName || 146 if (!prevVisible && page.didShowPage && (name == pageName ||
144 page.isAncestorOfPage(targetPage))) 147 page.isAncestorOfPage(targetPage)))
145 page.didShowPage(); 148 page.didShowPage();
146 } 149 }
147 }; 150 };
148 151
149 /** 152 /**
150 * Updates the visibility and stacking order of the subpage backdrop 153 * Updates the visibility and stacking order of the subpage backdrop
151 * according to which subpage is topmost and visible. 154 * according to which subpage is topmost and visible.
152 * @private 155 * @private
153 */ 156 */
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
200 * @return {boolean} whether we showed an overlay. 203 * @return {boolean} whether we showed an overlay.
201 */ 204 */
202 OptionsPage.showOverlay_ = function(overlayName, rootPage) { 205 OptionsPage.showOverlay_ = function(overlayName, rootPage) {
203 var overlay = this.registeredOverlayPages[overlayName.toLowerCase()]; 206 var overlay = this.registeredOverlayPages[overlayName.toLowerCase()];
204 if (!overlay || !overlay.canShowPage()) 207 if (!overlay || !overlay.canShowPage())
205 return false; 208 return false;
206 209
207 if ((!rootPage || !rootPage.sticky) && overlay.parentPage) 210 if ((!rootPage || !rootPage.sticky) && overlay.parentPage)
208 this.showPageByName(overlay.parentPage.name, false); 211 this.showPageByName(overlay.parentPage.name, false);
209 212
210 overlay.visible = true; 213 if (!overlay.visible) {
211 if (overlay.didShowPage) overlay.didShowPage(); 214 overlay.visible = true;
215 if (overlay.didShowPage) overlay.didShowPage();
216 }
217
212 return true; 218 return true;
213 }; 219 };
214 220
215 /** 221 /**
216 * Returns whether or not an overlay is visible. 222 * Returns whether or not an overlay is visible.
217 * @return {boolean} True if an overlay is visible. 223 * @return {boolean} True if an overlay is visible.
218 * @private 224 * @private
219 */ 225 */
220 OptionsPage.isOverlayVisible_ = function() { 226 OptionsPage.isOverlayVisible_ = function() {
221 return this.getVisibleOverlay_() != null; 227 return this.getVisibleOverlay_() != null;
222 }; 228 };
223 229
224 /** 230 /**
225 * @return {boolean} True if the visible overlay should be closed.
226 * @private
227 */
228 OptionsPage.shouldCloseOverlay_ = function() {
229 var overlay = this.getVisibleOverlay_();
230 return overlay && overlay.shouldClose();
231 };
232
233 /**
234 * Returns the currently visible overlay, or null if no page is visible. 231 * Returns the currently visible overlay, or null if no page is visible.
235 * @return {OptionPage} The visible overlay. 232 * @return {OptionPage} The visible overlay.
236 */ 233 */
237 OptionsPage.getVisibleOverlay_ = function() { 234 OptionsPage.getVisibleOverlay_ = function() {
238 for (var name in this.registeredOverlayPages) { 235 for (var name in this.registeredOverlayPages) {
239 var page = this.registeredOverlayPages[name]; 236 var page = this.registeredOverlayPages[name];
240 if (page.visible) 237 if (page.visible)
241 return page; 238 return page;
242 } 239 }
243 return null; 240 return null;
(...skipping 495 matching lines...) Expand 10 before | Expand all | Expand 10 after
739 }; 736 };
740 737
741 /** 738 /**
742 * A function to handle key press events. 739 * A function to handle key press events.
743 * @return {Event} a keydown event. 740 * @return {Event} a keydown event.
744 * @private 741 * @private
745 */ 742 */
746 OptionsPage.keyDownEventHandler_ = function(event) { 743 OptionsPage.keyDownEventHandler_ = function(event) {
747 // Close the top overlay or sub-page on esc. 744 // Close the top overlay or sub-page on esc.
748 if (event.keyCode == 27) { // Esc 745 if (event.keyCode == 27) { // Esc
749 if (this.isOverlayVisible_()) { 746 if (this.isOverlayVisible_())
750 if (this.shouldCloseOverlay_()) 747 this.closeOverlay();
751 this.closeOverlay(); 748 else
752 } else {
753 this.closeTopSubPage_(); 749 this.closeTopSubPage_();
754 }
755 } 750 }
756 }; 751 };
757 752
758 OptionsPage.setClearPluginLSODataEnabled = function(enabled) { 753 OptionsPage.setClearPluginLSODataEnabled = function(enabled) {
759 if (enabled) { 754 if (enabled) {
760 document.documentElement.setAttribute( 755 document.documentElement.setAttribute(
761 'flashPluginSupportsClearSiteData', ''); 756 'flashPluginSupportsClearSiteData', '');
762 } else { 757 } else {
763 document.documentElement.removeAttribute( 758 document.documentElement.removeAttribute(
764 'flashPluginSupportsClearSiteData'); 759 'flashPluginSupportsClearSiteData');
(...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after
1001 return false; 996 return false;
1002 }, 997 },
1003 998
1004 /** 999 /**
1005 * Whether it should be possible to show the page. 1000 * Whether it should be possible to show the page.
1006 * @return {boolean} True if the page should be shown 1001 * @return {boolean} True if the page should be shown
1007 */ 1002 */
1008 canShowPage: function() { 1003 canShowPage: function() {
1009 return true; 1004 return true;
1010 }, 1005 },
1011
1012 /**
1013 * Whether an overlay should be closed. Used by overlay implementation to
1014 * handle special closing behaviors.
1015 * @return {boolean} True if the overlay should be closed.
1016 */
1017 shouldClose: function() {
1018 return true;
1019 },
1020 }; 1006 };
1021 1007
1022 // Export 1008 // Export
1023 return { 1009 return {
1024 OptionsPage: OptionsPage 1010 OptionsPage: OptionsPage
1025 }; 1011 };
1026 }); 1012 });
OLDNEW
« no previous file with comments | « chrome/browser/profiles/profile_manager.cc ('k') | chrome/browser/resources/options/personal_options.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698