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 #ifndef CHROME_BROWSER_CHROMEOS_MOBILE_CONFIG_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_MOBILE_CONFIG_H_ |
6 #define CHROME_BROWSER_CHROMEOS_MOBILE_CONFIG_H_ | 6 #define CHROME_BROWSER_CHROMEOS_MOBILE_CONFIG_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | 9 #include <map> |
10 #include <string> | 10 #include <string> |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 // It's not shown when one of the "Buy plan" / "Activate" is shown. | 109 // It's not shown when one of the "Buy plan" / "Activate" is shown. |
110 // All "Buy plan" / "Activate" / "View account" buttons launch | 110 // All "Buy plan" / "Activate" / "View account" buttons launch |
111 // carrier portal (chrome://mobilesetup/ extension). | 111 // carrier portal (chrome://mobilesetup/ extension). |
112 bool show_portal_button_; | 112 bool show_portal_button_; |
113 | 113 |
114 CarrierDeals deals_; | 114 CarrierDeals deals_; |
115 | 115 |
116 DISALLOW_COPY_AND_ASSIGN(Carrier); | 116 DISALLOW_COPY_AND_ASSIGN(Carrier); |
117 }; | 117 }; |
118 | 118 |
| 119 // Carrier config for a specific initial locale. |
| 120 class LocaleConfig { |
| 121 public: |
| 122 explicit LocaleConfig(base::DictionaryValue* locale_dict); |
| 123 ~LocaleConfig(); |
| 124 |
| 125 const std::string& setup_url() const { return setup_url_; } |
| 126 |
| 127 // Initializes local config carrier from supplied dictionary. |
| 128 // Multiple calls supported (i.e. second call for local config). |
| 129 void InitFromDictionary(base::DictionaryValue* locale_dict); |
| 130 |
| 131 private: |
| 132 // Carrier setup URL. Used in network menu ("Set-up Mobile Data" link). |
| 133 // Displayed when SIM card is not installed on the device with a |
| 134 // particular initial locale. |
| 135 std::string setup_url_; |
| 136 |
| 137 DISALLOW_COPY_AND_ASSIGN(LocaleConfig); |
| 138 }; |
| 139 |
119 // External carrier ID (ex. "Verizon (us)") mapping to internal carrier ID. | 140 // External carrier ID (ex. "Verizon (us)") mapping to internal carrier ID. |
120 typedef std::map<std::string, std::string> CarrierIdMap; | 141 typedef std::map<std::string, std::string> CarrierIdMap; |
121 | 142 |
122 // Internal carrier ID mapping to Carrier config. | 143 // Internal carrier ID mapping to Carrier config. |
123 typedef std::map<std::string, Carrier*> Carriers; | 144 typedef std::map<std::string, Carrier*> Carriers; |
124 | 145 |
125 static MobileConfig* GetInstance(); | 146 static MobileConfig* GetInstance(); |
126 | 147 |
127 // Returns carrier by external ID. | 148 // Returns carrier by external ID or NULL if there's no such carrier. |
128 const MobileConfig::Carrier* GetCarrier(const std::string& carrier_id) const; | 149 const MobileConfig::Carrier* GetCarrier(const std::string& carrier_id) const; |
129 | 150 |
| 151 // Returns locale specific config by initial locale or NULL |
| 152 // if there's no such config defined. |
| 153 const MobileConfig::LocaleConfig* GetLocaleConfig() const; |
| 154 |
130 protected: | 155 protected: |
131 virtual bool LoadManifestFromString(const std::string& manifest) OVERRIDE; | 156 virtual bool LoadManifestFromString(const std::string& manifest) OVERRIDE; |
132 | 157 |
133 private: | 158 private: |
134 FRIEND_TEST_ALL_PREFIXES(MobileConfigTest, Basic); | 159 FRIEND_TEST_ALL_PREFIXES(MobileConfigTest, Basic); |
135 FRIEND_TEST_ALL_PREFIXES(MobileConfigTest, BadManifest); | 160 FRIEND_TEST_ALL_PREFIXES(MobileConfigTest, BadManifest); |
136 FRIEND_TEST_ALL_PREFIXES(MobileConfigTest, DealOtherLocale); | 161 FRIEND_TEST_ALL_PREFIXES(MobileConfigTest, DealOtherLocale); |
137 FRIEND_TEST_ALL_PREFIXES(MobileConfigTest, OldDeal); | 162 FRIEND_TEST_ALL_PREFIXES(MobileConfigTest, OldDeal); |
138 FRIEND_TEST_ALL_PREFIXES(MobileConfigTest, LocalConfigNoDeals); | 163 FRIEND_TEST_ALL_PREFIXES(MobileConfigTest, LocalConfigNoDeals); |
139 FRIEND_TEST_ALL_PREFIXES(MobileConfigTest, LocalConfig); | 164 FRIEND_TEST_ALL_PREFIXES(MobileConfigTest, LocalConfig); |
(...skipping 18 matching lines...) Expand all Loading... |
158 // Executes on FILE thread and reads config files to string. | 183 // Executes on FILE thread and reads config files to string. |
159 void ReadConfigInBackground(const FilePath& global_config_file, | 184 void ReadConfigInBackground(const FilePath& global_config_file, |
160 const FilePath& local_config_file); | 185 const FilePath& local_config_file); |
161 | 186 |
162 // Maps external carrier ID to internal carrier ID. | 187 // Maps external carrier ID to internal carrier ID. |
163 CarrierIdMap carrier_id_map_; | 188 CarrierIdMap carrier_id_map_; |
164 | 189 |
165 // Carrier configuration (including carrier deals). | 190 // Carrier configuration (including carrier deals). |
166 Carriers carriers_; | 191 Carriers carriers_; |
167 | 192 |
| 193 // Initial locale specific config if defined. |
| 194 scoped_ptr<LocaleConfig> locale_config_; |
| 195 |
168 // Initial locale value. | 196 // Initial locale value. |
169 std::string initial_locale_; | 197 std::string initial_locale_; |
170 | 198 |
171 // Root value of the local config (if it exists). | 199 // Root value of the local config (if it exists). |
172 // Global config is stored in root_ of the base class. | 200 // Global config is stored in root_ of the base class. |
173 scoped_ptr<base::DictionaryValue> local_config_root_; | 201 scoped_ptr<base::DictionaryValue> local_config_root_; |
174 | 202 |
175 DISALLOW_COPY_AND_ASSIGN(MobileConfig); | 203 DISALLOW_COPY_AND_ASSIGN(MobileConfig); |
176 }; | 204 }; |
177 | 205 |
178 } // namespace chromeos | 206 } // namespace chromeos |
179 | 207 |
180 #endif // CHROME_BROWSER_CHROMEOS_MOBILE_CONFIG_H_ | 208 #endif // CHROME_BROWSER_CHROMEOS_MOBILE_CONFIG_H_ |
OLD | NEW |