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 /** | 5 /** |
6 * @fileoverview This file defines a singleton which provides access to all data | 6 * @fileoverview This file defines a singleton which provides access to all data |
7 * that is available as soon as the page's resources are loaded (before DOM | 7 * that is available as soon as the page's resources are loaded (before DOM |
8 * content has finished loading). This data includes both localized strings and | 8 * content has finished loading). This data includes both localized strings and |
9 * any data that is important to have ready from a very early stage (e.g. things | 9 * any data that is important to have ready from a very early stage (e.g. things |
10 * that must be displayed right away). | 10 * that must be displayed right away). |
(...skipping 24 matching lines...) Expand all Loading... | |
35 return id in this.data_; | 35 return id in this.data_; |
36 }, | 36 }, |
37 | 37 |
38 /** | 38 /** |
39 * Fetches a value, expecting that it exists. | 39 * Fetches a value, expecting that it exists. |
40 * @param {string} id The key that identifies the desired value. | 40 * @param {string} id The key that identifies the desired value. |
41 * @return {*} The corresponding value. | 41 * @return {*} The corresponding value. |
42 */ | 42 */ |
43 getValue: function(id) { | 43 getValue: function(id) { |
44 expect(this.data_, 'No data. Did you remember to include strings.js?'); | 44 expect(this.data_, 'No data. Did you remember to include strings.js?'); |
45 // If your value is not found here, inspect the contents of this.data_. | |
46 // If you find none of your values there, then make sure that | |
47 // GetLocalizedValues() in your handler class (in C++) is called. | |
Evan Stade
2012/05/18 21:08:26
this comment is inaccurate, GetLocalizedValues() d
Finnur
2012/05/18 22:02:04
Having gone through the exercise of trying to figu
Evan Stade
2012/05/18 22:14:23
not obvious where to go in the C++ code? You added
Finnur
2012/05/18 22:27:01
I added GetLocalizedValues() but overlooked the fa
| |
45 var value = this.data_[id]; | 48 var value = this.data_[id]; |
46 expect(typeof value != 'undefined', 'Could not find value for ' + id); | 49 expect(typeof value != 'undefined', 'Could not find value for ' + id); |
47 return value; | 50 return value; |
48 }, | 51 }, |
49 | 52 |
50 /** | 53 /** |
51 * As above, but also makes sure that the value is a string. | 54 * As above, but also makes sure that the value is a string. |
52 * @param {string} id The key that identifies the desired string. | 55 * @param {string} id The key that identifies the desired string. |
53 * @return {string} The corresponding string value. | 56 * @return {string} The corresponding string value. |
54 */ | 57 */ |
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
117 * @param {string} type The type we expect |value| to be. | 120 * @param {string} type The type we expect |value| to be. |
118 */ | 121 */ |
119 function expectIsType(id, value, type) { | 122 function expectIsType(id, value, type) { |
120 expect(typeof value == type, '[' + value + '] (' + id + | 123 expect(typeof value == type, '[' + value + '] (' + id + |
121 ') is not a ' + type); | 124 ') is not a ' + type); |
122 } | 125 } |
123 | 126 |
124 expect(!loadTimeData, 'should only include this file once'); | 127 expect(!loadTimeData, 'should only include this file once'); |
125 loadTimeData = new LoadTimeData; | 128 loadTimeData = new LoadTimeData; |
126 })(); | 129 })(); |
OLD | NEW |