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_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 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/compiler_specific.h" | 10 #include "base/compiler_specific.h" |
11 #include "base/gtest_prod_util.h" | 11 #include "base/gtest_prod_util.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
13 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
14 #include "base/timer.h" | 14 #include "base/timer.h" |
15 #include "base/values.h" | 15 #include "base/values.h" |
16 #include "googleurl/src/gurl.h" | 16 #include "googleurl/src/gurl.h" |
17 #include "net/url_request/url_fetcher_delegate.h" | 17 #include "net/url_request/url_fetcher_delegate.h" |
18 | 18 |
19 class FilePath; | |
20 class PrefServiceSimple; | 19 class PrefServiceSimple; |
21 | 20 |
22 namespace base { | 21 namespace base { |
23 class DictionaryValue; | 22 class DictionaryValue; |
| 23 class FilePath; |
24 } | 24 } |
25 | 25 |
26 namespace net { | 26 namespace net { |
27 class URLFetcher; | 27 class URLFetcher; |
28 } | 28 } |
29 | 29 |
30 namespace chromeos { | 30 namespace chromeos { |
31 | 31 |
32 namespace system { | 32 namespace system { |
33 class StatisticsProvider; | 33 class StatisticsProvider; |
34 } // system | 34 } // system |
35 | 35 |
36 // Base class for OEM customization document classes. | 36 // Base class for OEM customization document classes. |
37 class CustomizationDocument { | 37 class CustomizationDocument { |
38 public: | 38 public: |
39 virtual ~CustomizationDocument(); | 39 virtual ~CustomizationDocument(); |
40 | 40 |
41 // Return true if the document was successfully fetched and parsed. | 41 // Return true if the document was successfully fetched and parsed. |
42 bool IsReady() const { return root_.get(); } | 42 bool IsReady() const { return root_.get(); } |
43 | 43 |
44 protected: | 44 protected: |
45 explicit CustomizationDocument(const std::string& accepted_version); | 45 explicit CustomizationDocument(const std::string& accepted_version); |
46 | 46 |
47 virtual bool LoadManifestFromFile(const FilePath& manifest_path); | 47 virtual bool LoadManifestFromFile(const base::FilePath& manifest_path); |
48 virtual bool LoadManifestFromString(const std::string& manifest); | 48 virtual bool LoadManifestFromString(const std::string& manifest); |
49 | 49 |
50 std::string GetLocaleSpecificString(const std::string& locale, | 50 std::string GetLocaleSpecificString(const std::string& locale, |
51 const std::string& dictionary_name, | 51 const std::string& dictionary_name, |
52 const std::string& entry_name) const; | 52 const std::string& entry_name) const; |
53 | 53 |
54 scoped_ptr<base::DictionaryValue> root_; | 54 scoped_ptr<base::DictionaryValue> root_; |
55 | 55 |
56 // Value of the "version" attribute that is supported. | 56 // Value of the "version" attribute that is supported. |
57 // Otherwise config is not loaded. | 57 // Otherwise config is not loaded. |
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
151 // Save applied state in machine settings. | 151 // Save applied state in machine settings. |
152 static void SetApplied(bool val); | 152 static void SetApplied(bool val); |
153 | 153 |
154 // Overriden from net::URLFetcherDelegate: | 154 // Overriden from net::URLFetcherDelegate: |
155 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 155 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
156 | 156 |
157 // Initiate file fetching. | 157 // Initiate file fetching. |
158 void StartFileFetch(); | 158 void StartFileFetch(); |
159 | 159 |
160 // Executes on FILE thread and reads file to string. | 160 // Executes on FILE thread and reads file to string. |
161 void ReadFileInBackground(const FilePath& file); | 161 void ReadFileInBackground(const base::FilePath& file); |
162 | 162 |
163 // Services customization manifest URL. | 163 // Services customization manifest URL. |
164 GURL url_; | 164 GURL url_; |
165 | 165 |
166 // URLFetcher instance. | 166 // URLFetcher instance. |
167 scoped_ptr<net::URLFetcher> url_fetcher_; | 167 scoped_ptr<net::URLFetcher> url_fetcher_; |
168 | 168 |
169 // Timer to retry fetching file if network is not available. | 169 // Timer to retry fetching file if network is not available. |
170 base::OneShotTimer<ServicesCustomizationDocument> retry_timer_; | 170 base::OneShotTimer<ServicesCustomizationDocument> retry_timer_; |
171 | 171 |
172 // How many times we already tried to fetch customization manifest file. | 172 // How many times we already tried to fetch customization manifest file. |
173 int num_retries_; | 173 int num_retries_; |
174 | 174 |
175 DISALLOW_COPY_AND_ASSIGN(ServicesCustomizationDocument); | 175 DISALLOW_COPY_AND_ASSIGN(ServicesCustomizationDocument); |
176 }; | 176 }; |
177 | 177 |
178 } // namespace chromeos | 178 } // namespace chromeos |
179 | 179 |
180 #endif // CHROME_BROWSER_CHROMEOS_CUSTOMIZATION_DOCUMENT_H_ | 180 #endif // CHROME_BROWSER_CHROMEOS_CUSTOMIZATION_DOCUMENT_H_ |
OLD | NEW |