| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <!-- | 2 <!-- |
| 3 Copyright (c) 2016 The Chromium Authors. All rights reserved. | 3 Copyright (c) 2016 The Chromium Authors. All rights reserved. |
| 4 Use of this source code is governed by a BSD-style license that can be | 4 Use of this source code is governed by a BSD-style license that can be |
| 5 found in the LICENSE file. | 5 found in the LICENSE file. |
| 6 --> | 6 --> |
| 7 | 7 |
| 8 <link rel="import" href="/tracing/base/settings.html"> | 8 <link rel="import" href="/tracing/base/settings.html"> |
| 9 <link rel="import" href="/tracing/ui/base/dom_helpers.html"> | 9 <link rel="import" href="/tracing/ui/base/dom_helpers.html"> |
| 10 <link rel="import" href="/tracing/ui/base/ui.html"> | 10 <link rel="import" href="/tracing/ui/base/ui.html"> |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 | 37 |
| 38 ready: function() { | 38 ready: function() { |
| 39 this.is_ready_ = true; | 39 this.is_ready_ = true; |
| 40 this.$.checkbox.addEventListener('click', function() { | 40 this.$.checkbox.addEventListener('click', function() { |
| 41 this.checked = this.$.checkbox.checked; | 41 this.checked = this.$.checkbox.checked; |
| 42 }.bind(this)); | 42 }.bind(this)); |
| 43 this.maybeUpdateElements_(); | 43 this.maybeUpdateElements_(); |
| 44 }, | 44 }, |
| 45 | 45 |
| 46 maybeUpdateElements_: function() { | 46 maybeUpdateElements_: function() { |
| 47 if (!this.is_ready_) | 47 if (!this.is_ready_) return; |
| 48 return; | |
| 49 this.$.label.innerText = this.label_; | 48 this.$.label.innerText = this.label_; |
| 50 this.$.checkbox.checked = this.checked_; | 49 this.$.checkbox.checked = this.checked_; |
| 51 }, | 50 }, |
| 52 | 51 |
| 53 get defaultCheckedValue() { | 52 get defaultCheckedValue() { |
| 54 return this.defaultCheckedValue_; | 53 return this.defaultCheckedValue_; |
| 55 }, | 54 }, |
| 56 | 55 |
| 57 set defaultCheckedValue(defaultCheckedValue) { | 56 set defaultCheckedValue(defaultCheckedValue) { |
| 58 if (!this.needsInit_) | 57 if (!this.needsInit_) { |
| 59 throw new Error('Already initialized.'); | 58 throw new Error('Already initialized.'); |
| 59 } |
| 60 this.defaultCheckedValue_ = defaultCheckedValue; | 60 this.defaultCheckedValue_ = defaultCheckedValue; |
| 61 this.maybeInit_(); | 61 this.maybeInit_(); |
| 62 }, | 62 }, |
| 63 | 63 |
| 64 get settingsKey() { | 64 get settingsKey() { |
| 65 return this.settingsKey_; | 65 return this.settingsKey_; |
| 66 }, | 66 }, |
| 67 | 67 |
| 68 set settingsKey(settingsKey) { | 68 set settingsKey(settingsKey) { |
| 69 if (!this.needsInit_) | 69 if (!this.needsInit_) { |
| 70 throw new Error('Already initialized.'); | 70 throw new Error('Already initialized.'); |
| 71 } |
| 71 this.settingsKey_ = settingsKey; | 72 this.settingsKey_ = settingsKey; |
| 72 this.maybeInit_(); | 73 this.maybeInit_(); |
| 73 }, | 74 }, |
| 74 | 75 |
| 75 maybeInit_: function() { | 76 maybeInit_: function() { |
| 76 if (!this.needsInit_) | 77 if (!this.needsInit_) return; |
| 77 return; | 78 if (this.settingsKey_ === undefined) return; |
| 78 if (this.settingsKey_ === undefined) | 79 if (this.defaultCheckedValue_ === undefined) return; |
| 79 return; | |
| 80 if (this.defaultCheckedValue_ === undefined) | |
| 81 return; | |
| 82 this.needsInit_ = false; | 80 this.needsInit_ = false; |
| 83 this.checked = tr.b.Settings.get( | 81 this.checked = tr.b.Settings.get( |
| 84 this.settingsKey_, this.defaultCheckedValue_); | 82 this.settingsKey_, this.defaultCheckedValue_); |
| 85 }, | 83 }, |
| 86 | 84 |
| 87 get label() { | 85 get label() { |
| 88 return this.label_; | 86 return this.label_; |
| 89 }, | 87 }, |
| 90 | 88 |
| 91 set label(label) { | 89 set label(label) { |
| 92 this.label_ = label; | 90 this.label_ = label; |
| 93 this.maybeUpdateElements_(); | 91 this.maybeUpdateElements_(); |
| 94 }, | 92 }, |
| 95 | 93 |
| 96 get checked() { | 94 get checked() { |
| 97 return this.checked_; | 95 return this.checked_; |
| 98 }, | 96 }, |
| 99 | 97 |
| 100 set checked(checked) { | 98 set checked(checked) { |
| 101 this.checked_ = checked; | 99 this.checked_ = checked; |
| 102 this.maybeUpdateElements_(); | 100 this.maybeUpdateElements_(); |
| 103 tr.b.Settings.set(this.settingsKey_, this.checked_); | 101 tr.b.Settings.set(this.settingsKey_, this.checked_); |
| 104 } | 102 } |
| 105 }); | 103 }); |
| 106 </script> | 104 </script> |
| 107 </dom-module> | 105 </dom-module> |
| OLD | NEW |