OLD | NEW |
---|---|
(Empty) | |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | |
2 // Use of this source code is governed by a BSD-style license that can be | |
3 // found in the LICENSE file. | |
4 | |
5 #ifndef COMPONENTS_VARIATIONS_SERVICE_UI_STRING_OVERRIDER_H_ | |
6 #define COMPONENTS_VARIATIONS_SERVICE_UI_STRING_OVERRIDER_H_ | |
7 | |
8 #include "base/basictypes.h" | |
9 #include "base/strings/string16.h" | |
10 | |
11 namespace variations { | |
12 | |
13 // Provides a mapping from hashes of generated reosurce names to their IDs. The | |
14 // mapping is provided by the embedder as two arrays |resource_hashes|, a sorted | |
15 // array of resource name hashes, and |resource_indices| an array of resource | |
16 // indices in the same order. | |
17 // | |
18 // The mapping is created by generate_resources_map.py based on generated | |
19 // resources header files. The script ensure that if one header file contains | |
20 // |#define IDS_FOO 12345| then for some index |i|, |resource_hashes[i]| will | |
21 // be equal to |HASH("IDS_FOO")| and |resource_indices[i]| will be equal to | |
22 // |12345|. | |
23 // | |
24 // Both array must have the same length |num_resources|. They are not owned by | |
25 // the UIStringOverrider and the embedder is responsible for their lifetime | |
26 // (usually by passing pointer to static data). | |
27 class UIStringOverrider { | |
28 public: | |
29 UIStringOverrider(); | |
30 UIStringOverrider(const uint32_t* resource_hashes, | |
31 const int* resource_indices, | |
32 size_t num_resources); | |
33 ~UIStringOverrider(); | |
34 | |
35 // Returns the resource index corresponding to the given hash or -1 if no | |
36 // resources is found. Visible for testing. | |
37 int GetResourceIndex(uint32_t hash); | |
38 | |
39 // Overrides the string resource specified by |hash| with |string| in the | |
40 // resource bundle. | |
41 void OverrideUIString(uint32_t hash, const base::string16& string); | |
42 | |
43 private: | |
44 const uint32_t* resource_hashes_; | |
45 const int* resource_indices_; | |
46 size_t num_resources_; | |
Alexei Svitkine (slow)
2015/09/24 21:51:23
Can you declare all of these as const? ie. so they
sdefresne
2015/09/28 08:57:32
Done.
| |
47 }; | |
48 | |
49 } // namespace variations | |
50 | |
51 #endif // COMPONENTS_VARIATIONS_SERVICE_UI_STRING_OVERRIDER_H_ | |
OLD | NEW |