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 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <string> | 9 #include <string> |
10 | 10 |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/gtest_prod_util.h" | 12 #include "base/gtest_prod_util.h" |
13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
14 #include "base/memory/singleton.h" | 14 #include "base/memory/singleton.h" |
15 #include "base/timer.h" | 15 #include "base/timer.h" |
16 #include "base/values.h" | 16 #include "base/values.h" |
17 #include "content/public/common/url_fetcher_delegate.h" | |
18 #include "googleurl/src/gurl.h" | 17 #include "googleurl/src/gurl.h" |
| 18 #include "net/url_request/url_fetcher_delegate.h" |
19 | 19 |
20 class FilePath; | 20 class FilePath; |
21 class PrefService; | 21 class PrefService; |
22 | 22 |
23 namespace base { | 23 namespace base { |
24 class DictionaryValue; | 24 class DictionaryValue; |
25 } | 25 } |
26 | 26 |
| 27 namespace net { |
| 28 class URLFetcher; |
| 29 } |
| 30 |
27 namespace chromeos { | 31 namespace chromeos { |
28 | 32 |
29 namespace system { | 33 namespace system { |
30 class StatisticsProvider; | 34 class StatisticsProvider; |
31 } // system | 35 } // system |
32 | 36 |
33 // Base class for OEM customization document classes. | 37 // Base class for OEM customization document classes. |
34 class CustomizationDocument { | 38 class CustomizationDocument { |
35 public: | 39 public: |
36 virtual ~CustomizationDocument(); | 40 virtual ~CustomizationDocument(); |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
104 | 108 |
105 DISALLOW_COPY_AND_ASSIGN(StartupCustomizationDocument); | 109 DISALLOW_COPY_AND_ASSIGN(StartupCustomizationDocument); |
106 }; | 110 }; |
107 | 111 |
108 // OEM services customization document class. | 112 // OEM services customization document class. |
109 // ServicesCustomizationDocument is fetched from network or local file but on | 113 // ServicesCustomizationDocument is fetched from network or local file but on |
110 // FILE thread therefore it may not be ready just after creation. Fetching of | 114 // FILE thread therefore it may not be ready just after creation. Fetching of |
111 // the manifest should be initiated outside this class by calling | 115 // the manifest should be initiated outside this class by calling |
112 // StartFetching() method. User of the file should check IsReady before use it. | 116 // StartFetching() method. User of the file should check IsReady before use it. |
113 class ServicesCustomizationDocument : public CustomizationDocument, | 117 class ServicesCustomizationDocument : public CustomizationDocument, |
114 private content::URLFetcherDelegate { | 118 private net::URLFetcherDelegate { |
115 public: | 119 public: |
116 static ServicesCustomizationDocument* GetInstance(); | 120 static ServicesCustomizationDocument* GetInstance(); |
117 | 121 |
118 // Registers preferences. | 122 // Registers preferences. |
119 static void RegisterPrefs(PrefService* local_state); | 123 static void RegisterPrefs(PrefService* local_state); |
120 | 124 |
121 // Return true if the customization was applied. Customization is applied only | 125 // Return true if the customization was applied. Customization is applied only |
122 // once per machine. | 126 // once per machine. |
123 static bool WasApplied(); | 127 static bool WasApplied(); |
124 | 128 |
(...skipping 16 matching lines...) Expand all Loading... |
141 ServicesCustomizationDocument(); | 145 ServicesCustomizationDocument(); |
142 | 146 |
143 // C-tor for test construction. | 147 // C-tor for test construction. |
144 explicit ServicesCustomizationDocument(const std::string& manifest); | 148 explicit ServicesCustomizationDocument(const std::string& manifest); |
145 | 149 |
146 virtual ~ServicesCustomizationDocument(); | 150 virtual ~ServicesCustomizationDocument(); |
147 | 151 |
148 // Save applied state in machine settings. | 152 // Save applied state in machine settings. |
149 static void SetApplied(bool val); | 153 static void SetApplied(bool val); |
150 | 154 |
151 // Overriden from content::URLFetcherDelegate: | 155 // Overriden from net::URLFetcherDelegate: |
152 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; | 156 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; |
153 | 157 |
154 // Initiate file fetching. | 158 // Initiate file fetching. |
155 void StartFileFetch(); | 159 void StartFileFetch(); |
156 | 160 |
157 // Executes on FILE thread and reads file to string. | 161 // Executes on FILE thread and reads file to string. |
158 void ReadFileInBackground(const FilePath& file); | 162 void ReadFileInBackground(const FilePath& file); |
159 | 163 |
160 // Services customization manifest URL. | 164 // Services customization manifest URL. |
161 GURL url_; | 165 GURL url_; |
162 | 166 |
163 // URLFetcher instance. | 167 // URLFetcher instance. |
164 scoped_ptr<content::URLFetcher> url_fetcher_; | 168 scoped_ptr<net::URLFetcher> url_fetcher_; |
165 | 169 |
166 // Timer to retry fetching file if network is not available. | 170 // Timer to retry fetching file if network is not available. |
167 base::OneShotTimer<ServicesCustomizationDocument> retry_timer_; | 171 base::OneShotTimer<ServicesCustomizationDocument> retry_timer_; |
168 | 172 |
169 // How many times we already tried to fetch customization manifest file. | 173 // How many times we already tried to fetch customization manifest file. |
170 int num_retries_; | 174 int num_retries_; |
171 | 175 |
172 DISALLOW_COPY_AND_ASSIGN(ServicesCustomizationDocument); | 176 DISALLOW_COPY_AND_ASSIGN(ServicesCustomizationDocument); |
173 }; | 177 }; |
174 | 178 |
175 } // namespace chromeos | 179 } // namespace chromeos |
176 | 180 |
177 #endif // CHROME_BROWSER_CHROMEOS_CUSTOMIZATION_DOCUMENT_H_ | 181 #endif // CHROME_BROWSER_CHROMEOS_CUSTOMIZATION_DOCUMENT_H_ |
OLD | NEW |