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

Side by Side Diff: site/try/src/user_option.dart

Issue 408783002: Enable Try Dart to run on IE11. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: removed dynamic, marked one test as Fail on IE11 Created 6 years, 4 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) 2014, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 library trydart.userOption; 5 library trydart.userOption;
6 6
7 /// Persistent user-configurable option. 7 /// Persistent user-configurable option.
8 /// 8 ///
9 /// Options included in [options] in settings.dart will automatically be 9 /// Options included in [options] in settings.dart will automatically be
10 /// included in the settings UI unless [isHidden] is true. 10 /// included in the settings UI unless [isHidden] is true.
(...skipping 17 matching lines...) Expand all
28 28
29 static var storage; 29 static var storage;
30 30
31 const UserOption(this.name, {this.isHidden: false}); 31 const UserOption(this.name, {this.isHidden: false});
32 32
33 get value => storage[name]; 33 get value => storage[name];
34 34
35 void set value(newValue) { 35 void set value(newValue) {
36 storage[name] = newValue; 36 storage[name] = newValue;
37 } 37 }
38
39 void setIfNotInitialized(newValueEvaluator()) {
40 if (storage[name] == null) {
41 value = newValueEvaluator();
42 }
43 }
38 } 44 }
39 45
40 class BooleanUserOption extends UserOption { 46 class BooleanUserOption extends UserOption {
41 const BooleanUserOption(String name, {bool isHidden: false}) 47 const BooleanUserOption(String name, {bool isHidden: false})
42 : super(name, isHidden: isHidden); 48 : super(name, isHidden: isHidden);
43 49
44 bool get value => super.value == 'true'; 50 bool get value => super.value == 'true';
45 51
46 void set value(bool newValue) { 52 void set value(bool newValue) {
47 super.value = '$newValue'; 53 super.value = '$newValue';
48 } 54 }
49 } 55 }
50 56
51 class StringUserOption extends UserOption { 57 class StringUserOption extends UserOption {
52 const StringUserOption(String name, {bool isHidden: false}) 58 const StringUserOption(String name, {bool isHidden: false})
53 : super(name, isHidden: isHidden); 59 : super(name, isHidden: isHidden);
54 60
55 String get value => super.value == null ? '' : super.value; 61 String get value => super.value == null ? '' : super.value;
56 62
57 void set value(String newValue) { 63 void set value(String newValue) {
58 super.value = newValue; 64 super.value = newValue;
59 } 65 }
60 } 66 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698