OLD | NEW |
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('cr.ui.dialogs', function() { | 5 cr.define('cr.ui.dialogs', function() { |
6 | 6 |
7 function BaseDialog(parentNode) { | 7 function BaseDialog(parentNode) { |
8 this.parentNode_ = parentNode; | 8 this.parentNode_ = parentNode; |
9 this.document_ = parentNode.ownerDocument; | 9 this.document_ = parentNode.ownerDocument; |
10 | 10 |
(...skipping 106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
117 this.show_(title, onOk, onCancel, onShow); | 117 this.show_(title, onOk, onCancel, onShow); |
118 }; | 118 }; |
119 | 119 |
120 BaseDialog.prototype.findFocusableElements_ = function(doc) { | 120 BaseDialog.prototype.findFocusableElements_ = function(doc) { |
121 var elements = Array.prototype.filter.call( | 121 var elements = Array.prototype.filter.call( |
122 doc.querySelectorAll('*'), | 122 doc.querySelectorAll('*'), |
123 function(n) { return n.tabIndex >= 0; }); | 123 function(n) { return n.tabIndex >= 0; }); |
124 | 124 |
125 var iframes = doc.querySelectorAll('iframe'); | 125 var iframes = doc.querySelectorAll('iframe'); |
126 for (var i = 0; i < iframes.length; i++) { | 126 for (var i = 0; i < iframes.length; i++) { |
127 elements = elements.concat(this.findFocusableElements_( | 127 // Some iframes have an undefined contentDocument for security reasons, |
128 iframes[i].contentDocument)); | 128 // such as chrome://terms (which is used in the chromeos OOBE screens). |
| 129 var contentDoc = iframes[i].contentDocument; |
| 130 if (contentDoc) |
| 131 elements = elements.concat(this.findFocusableElements_(contentDoc)); |
129 } | 132 } |
130 return elements; | 133 return elements; |
131 }; | 134 }; |
132 | 135 |
133 BaseDialog.prototype.showWithTitle = function(title, message, | 136 BaseDialog.prototype.showWithTitle = function(title, message, |
134 onOk, onCancel, onShow) { | 137 onOk, onCancel, onShow) { |
135 this.text_.textContent = message; | 138 this.text_.textContent = message; |
136 this.show_(title, onOk, onCancel, onShow); | 139 this.show_(title, onOk, onCancel, onShow); |
137 }; | 140 }; |
138 | 141 |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
283 this.onOk_(this.getValue()); | 286 this.onOk_(this.getValue()); |
284 }; | 287 }; |
285 | 288 |
286 return { | 289 return { |
287 BaseDialog: BaseDialog, | 290 BaseDialog: BaseDialog, |
288 AlertDialog: AlertDialog, | 291 AlertDialog: AlertDialog, |
289 ConfirmDialog: ConfirmDialog, | 292 ConfirmDialog: ConfirmDialog, |
290 PromptDialog: PromptDialog | 293 PromptDialog: PromptDialog |
291 }; | 294 }; |
292 }); | 295 }); |
OLD | NEW |