OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 /////////////////////////////////////////////////////////////////////////////// | 5 /////////////////////////////////////////////////////////////////////////////// |
6 // OptionsPage class: | 6 // OptionsPage class: |
7 | 7 |
8 /** | 8 /** |
9 * Base class for options page. | 9 * Base class for options page. |
10 * @constructor | 10 * @constructor |
(...skipping 96 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 * OptionsPage. | 107 * OptionsPage. |
108 */ | 108 */ |
109 OptionsPage.registerOverlay = function(page) { | 109 OptionsPage.registerOverlay = function(page) { |
110 OptionsPage.registeredOverlayPages_[page.name] = page; | 110 OptionsPage.registeredOverlayPages_[page.name] = page; |
111 page.tab = undefined; | 111 page.tab = undefined; |
112 page.isOverlay = true; | 112 page.isOverlay = true; |
113 page.initializePage(); | 113 page.initializePage(); |
114 }; | 114 }; |
115 | 115 |
116 /** | 116 /** |
| 117 * Callback for window.onpopstate. |
| 118 * @param {Object} data State data pushed into history. |
| 119 */ |
| 120 OptionsPage.setState = function(data) { |
| 121 if (data && data.pageName) { |
| 122 OptionsPage.showPageByName(data.pageName); |
| 123 } |
| 124 }; |
| 125 |
| 126 /** |
117 * Initializes the complete options page. This will cause | 127 * Initializes the complete options page. This will cause |
118 * all C++ handlers to be invoked to do final setup. | 128 * all C++ handlers to be invoked to do final setup. |
119 */ | 129 */ |
120 OptionsPage.initialize = function() { | 130 OptionsPage.initialize = function() { |
121 chrome.send('coreOptionsInitialize'); | 131 chrome.send('coreOptionsInitialize'); |
122 }; | 132 }; |
123 | 133 |
124 OptionsPage.prototype = { | 134 OptionsPage.prototype = { |
125 __proto__: cr.EventTarget.prototype, | 135 __proto__: cr.EventTarget.prototype, |
126 | 136 |
(...skipping 17 matching lines...) Expand all Loading... |
144 set visible(visible) { | 154 set visible(visible) { |
145 if ((this.visible && visible) || (!this.visible && !visible)) | 155 if ((this.visible && visible) || (!this.visible && !visible)) |
146 return; | 156 return; |
147 | 157 |
148 if (visible) { | 158 if (visible) { |
149 this.pageDiv.style.display = 'block'; | 159 this.pageDiv.style.display = 'block'; |
150 if (this.isOverlay) { | 160 if (this.isOverlay) { |
151 var overlay = $('overlay'); | 161 var overlay = $('overlay'); |
152 overlay.classList.remove('hidden'); | 162 overlay.classList.remove('hidden'); |
153 } else { | 163 } else { |
| 164 // Recent webkit change no longer allows url change from "chrome://". |
154 window.history.pushState({pageName: this.name}, | 165 window.history.pushState({pageName: this.name}, |
155 this.title, | 166 this.title); |
156 '/' + this.name); | |
157 } | 167 } |
158 if (this.tab) { | 168 if (this.tab) { |
159 this.tab.classList.add('navbar-item-selected'); | 169 this.tab.classList.add('navbar-item-selected'); |
160 if (this.tab.parentNode && this.tab.parentNode.id == 'subpagesnav') | 170 if (this.tab.parentNode && this.tab.parentNode.id == 'subpagesnav') |
161 this.tab.classList.remove('hidden'); | 171 this.tab.classList.remove('hidden'); |
162 } | 172 } |
163 } else { | 173 } else { |
164 if (this.isOverlay) { | 174 if (this.isOverlay) { |
165 var overlay = $('overlay'); | 175 var overlay = $('overlay'); |
166 overlay.classList.add('hidden'); | 176 overlay.classList.add('hidden'); |
167 } | 177 } |
168 this.pageDiv.style.display = 'none'; | 178 this.pageDiv.style.display = 'none'; |
169 if (this.tab) { | 179 if (this.tab) { |
170 this.tab.classList.remove('navbar-item-selected'); | 180 this.tab.classList.remove('navbar-item-selected'); |
171 if (this.tab.parentNode && this.tab.parentNode.id == 'subpagesnav') | 181 if (this.tab.parentNode && this.tab.parentNode.id == 'subpagesnav') |
172 this.tab.classList.add('hidden'); | 182 this.tab.classList.add('hidden'); |
173 } | 183 } |
174 } | 184 } |
175 | 185 |
176 cr.dispatchPropertyChange(this, 'visible', visible, !visible); | 186 cr.dispatchPropertyChange(this, 'visible', visible, !visible); |
177 } | 187 } |
178 }; | 188 }; |
OLD | NEW |