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

Side by Side Diff: chrome/browser/chromeos/customization_document.h

Issue 7778043: [cros] Support global carrier config. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: cleanup Created 9 years, 3 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_CUSTOMIZATION_DOCUMENT_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_CUSTOMIZATION_DOCUMENT_H_
6 #define CHROME_BROWSER_CHROMEOS_CUSTOMIZATION_DOCUMENT_H_ 6 #define CHROME_BROWSER_CHROMEOS_CUSTOMIZATION_DOCUMENT_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map>
10 #include <string> 9 #include <string>
11 10
12 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
13 #include "base/memory/scoped_ptr.h" 12 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/singleton.h" 13 #include "base/memory/singleton.h"
15 #include "base/timer.h" 14 #include "base/timer.h"
16 #include "base/values.h" 15 #include "base/values.h"
17 #include "content/common/url_fetcher.h" 16 #include "content/common/url_fetcher.h"
18 #include "googleurl/src/gurl.h" 17 #include "googleurl/src/gurl.h"
19 18
20 class FilePath; 19 class FilePath;
21 class PrefService; 20 class PrefService;
22 21
23 namespace base { 22 namespace base {
24 class DictionaryValue; 23 class DictionaryValue;
25 class ListValue; 24 class ListValue;
26 class Time;
27 } 25 }
28 26
29 namespace chromeos { 27 namespace chromeos {
30 28
31 namespace system { 29 namespace system {
32 class StatisticsProvider; 30 class StatisticsProvider;
33 } // system 31 } // system
34 32
35 // Base class for OEM customization document classes. 33 // Base class for OEM customization document classes.
36 class CustomizationDocument { 34 class CustomizationDocument {
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after
104 }; 102 };
105 103
106 // OEM services customization document class. 104 // OEM services customization document class.
107 // ServicesCustomizationDocument is fetched from network or local file but on 105 // ServicesCustomizationDocument is fetched from network or local file but on
108 // FILE thread therefore it may not be ready just after creation. Fetching of 106 // FILE thread therefore it may not be ready just after creation. Fetching of
109 // the manifest should be initiated outside this class by calling 107 // the manifest should be initiated outside this class by calling
110 // StartFetching() method. User of the file should check IsReady before use it. 108 // StartFetching() method. User of the file should check IsReady before use it.
111 class ServicesCustomizationDocument : public CustomizationDocument, 109 class ServicesCustomizationDocument : public CustomizationDocument,
112 private URLFetcher::Delegate { 110 private URLFetcher::Delegate {
113 public: 111 public:
114 // OEM specific carrier deal.
115 class CarrierDeal {
116 public:
117 explicit CarrierDeal(base::DictionaryValue* deal_dict);
118 ~CarrierDeal();
119
120 // Returns string with the specified |locale| and |id|.
121 // If there's no version for |locale|, default one is returned.
122 // If there's no string with specified |id|, empty string is returned.
123 std::string GetLocalizedString(const std::string& locale,
124 const std::string& id) const;
125
126 const std::string& deal_locale() const { return deal_locale_; }
127 const std::string& info_url() const { return info_url_; }
128 const std::string& top_up_url() const { return top_up_url_; }
129 int notification_count() const { return notification_count_; }
130 base::Time expire_date() const { return expire_date_; }
131
132 private:
133 std::string deal_locale_;
134 std::string info_url_;
135 std::string top_up_url_;
136 int notification_count_;
137 base::Time expire_date_;
138 base::DictionaryValue* localized_strings_;
139
140 DISALLOW_COPY_AND_ASSIGN(CarrierDeal);
141 };
142
143 // Carrier ID (ex. "Verizon (us)") mapping to carrier deals.
144 typedef std::map<std::string, CarrierDeal*> CarrierDeals;
145
146 static ServicesCustomizationDocument* GetInstance(); 112 static ServicesCustomizationDocument* GetInstance();
147 113
148 // Registers preferences. 114 // Registers preferences.
149 static void RegisterPrefs(PrefService* local_state); 115 static void RegisterPrefs(PrefService* local_state);
150 116
151 // Return true if the customization was applied. Customization is applied only 117 // Return true if the customization was applied. Customization is applied only
152 // once per machine. 118 // once per machine.
153 static bool WasApplied(); 119 static bool WasApplied();
154 120
155 // Start fetching customization document. 121 // Start fetching customization document.
156 void StartFetching(); 122 void StartFetching();
157 123
158 // Apply customization and save in machine options that customization was 124 // Apply customization and save in machine options that customization was
159 // applied successfully. Return true if customization was applied. 125 // applied successfully. Return true if customization was applied.
160 bool ApplyCustomization(); 126 bool ApplyCustomization();
161 127
162 std::string GetInitialStartPage(const std::string& locale) const; 128 std::string GetInitialStartPage(const std::string& locale) const;
163 std::string GetSupportPage(const std::string& locale) const; 129 std::string GetSupportPage(const std::string& locale) const;
164 130
165 // Returns carrier deal by specified |carrier_id|.
166 // Also checks deal restrictions, such as deal locale (launch locale) and
167 // deal expiration date if |check_restrictions| is true.
168 const ServicesCustomizationDocument::CarrierDeal* GetCarrierDeal(
169 const std::string& carrier_id, bool check_restrictions) const;
170
171 protected:
172 virtual bool LoadManifestFromString(const std::string& manifest) OVERRIDE;
173
174 private: 131 private:
175 FRIEND_TEST(ServicesCustomizationDocumentTest, Basic); 132 FRIEND_TEST(ServicesCustomizationDocumentTest, Basic);
Dmitry Polukhin 2011/09/05 06:33:11 Please replace with FRIEND_TEST_ALL_PREFIXES.
Nikita (slow) 2011/09/05 10:13:44 Done.
176 FRIEND_TEST(ServicesCustomizationDocumentTest, BadManifest); 133 FRIEND_TEST(ServicesCustomizationDocumentTest, BadManifest);
177 FRIEND_TEST(ServicesCustomizationDocumentTest, DealOtherLocale);
178 FRIEND_TEST(ServicesCustomizationDocumentTest, NoDealRestrictions);
179 FRIEND_TEST(ServicesCustomizationDocumentTest, OldDeal);
180 friend struct DefaultSingletonTraits<ServicesCustomizationDocument>; 134 friend struct DefaultSingletonTraits<ServicesCustomizationDocument>;
181 135
182 // C-tor for singleton construction. 136 // C-tor for singleton construction.
183 ServicesCustomizationDocument(); 137 ServicesCustomizationDocument();
184 138
185 // C-tor for test construction. 139 // C-tor for test construction.
186 ServicesCustomizationDocument(const std::string& manifest, 140 explicit ServicesCustomizationDocument(const std::string& manifest);
187 const std::string& initial_locale);
188 141
189 virtual ~ServicesCustomizationDocument(); 142 virtual ~ServicesCustomizationDocument();
190 143
191 // Save applied state in machine settings. 144 // Save applied state in machine settings.
192 static void SetApplied(bool val); 145 static void SetApplied(bool val);
193 146
194 // Overriden from URLFetcher::Delegate: 147 // Overriden from URLFetcher::Delegate:
195 virtual void OnURLFetchComplete(const URLFetcher* source, 148 virtual void OnURLFetchComplete(const URLFetcher* source,
196 const GURL& url, 149 const GURL& url,
197 const net::URLRequestStatus& status, 150 const net::URLRequestStatus& status,
(...skipping 12 matching lines...) Expand all
210 163
211 // URLFetcher instance. 164 // URLFetcher instance.
212 scoped_ptr<URLFetcher> url_fetcher_; 165 scoped_ptr<URLFetcher> url_fetcher_;
213 166
214 // Timer to retry fetching file if network is not available. 167 // Timer to retry fetching file if network is not available.
215 base::OneShotTimer<ServicesCustomizationDocument> retry_timer_; 168 base::OneShotTimer<ServicesCustomizationDocument> retry_timer_;
216 169
217 // How many times we already tried to fetch customization manifest file. 170 // How many times we already tried to fetch customization manifest file.
218 int num_retries_; 171 int num_retries_;
219 172
220 // Carrier-specific deals.
221 CarrierDeals carrier_deals_;
222
223 // Initial locale value.
224 std::string initial_locale_;
225
226 DISALLOW_COPY_AND_ASSIGN(ServicesCustomizationDocument); 173 DISALLOW_COPY_AND_ASSIGN(ServicesCustomizationDocument);
227 }; 174 };
228 175
229 } // namespace chromeos 176 } // namespace chromeos
230 177
231 #endif // CHROME_BROWSER_CHROMEOS_CUSTOMIZATION_DOCUMENT_H_ 178 #endif // CHROME_BROWSER_CHROMEOS_CUSTOMIZATION_DOCUMENT_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/chromeos/customization_document.cc » ('j') | chrome/browser/chromeos/mobile_config.h » ('J')

Powered by Google App Engine
This is Rietveld 408576698