| OLD | NEW |
| 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_LOGIN_APPLY_SERVICES_CUSTOMIZATION_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_LOGIN_APPLY_SERVICES_CUSTOMIZATION_H_ |
| 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_APPLY_SERVICES_CUSTOMIZATION_H_ | 6 #define CHROME_BROWSER_CHROMEOS_LOGIN_APPLY_SERVICES_CUSTOMIZATION_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/scoped_ptr.h" | 11 #include "base/scoped_ptr.h" |
| 12 #include "base/timer.h" | 12 #include "base/timer.h" |
| 13 #include "chrome/common/net/url_fetcher.h" | 13 #include "chrome/common/net/url_fetcher.h" |
| 14 #include "googleurl/src/gurl.h" | 14 #include "googleurl/src/gurl.h" |
| 15 | 15 |
| 16 class FilePath; |
| 16 class PrefService; | 17 class PrefService; |
| 17 | 18 |
| 18 namespace chromeos { | 19 namespace chromeos { |
| 19 | 20 |
| 20 // This class fetches services customization document and apply it | 21 // This class fetches services customization document and apply it |
| 21 // as soon as the document is downloaded. | 22 // as soon as the document is downloaded. |
| 22 class ApplyServicesCustomization : public URLFetcher::Delegate { | 23 class ApplyServicesCustomization : public URLFetcher::Delegate { |
| 23 public: | 24 public: |
| 24 // This method checks if service customization has been applied and if not | 25 // This method checks if service customization has been applied and if not |
| 25 // starts the process. | 26 // starts the process. |
| (...skipping 18 matching lines...) Expand all Loading... |
| 44 virtual void OnURLFetchComplete(const URLFetcher* source, | 45 virtual void OnURLFetchComplete(const URLFetcher* source, |
| 45 const GURL& url, | 46 const GURL& url, |
| 46 const net::URLRequestStatus& status, | 47 const net::URLRequestStatus& status, |
| 47 int response_code, | 48 int response_code, |
| 48 const ResponseCookies& cookies, | 49 const ResponseCookies& cookies, |
| 49 const std::string& data); | 50 const std::string& data); |
| 50 | 51 |
| 51 // Applies given |manifest|. | 52 // Applies given |manifest|. |
| 52 void Apply(const std::string& manifest); | 53 void Apply(const std::string& manifest); |
| 53 | 54 |
| 55 // Applies given |manifest| and delete this object. |
| 56 void ApplyAndDelete(const std::string& manifest); |
| 57 |
| 58 // Executes on FILE thread and reads file to string. |
| 59 void ReadFileInBackground(const FilePath& file); |
| 60 |
| 54 // Remember in local state status of kServicesCustomizationAppliedPref. | 61 // Remember in local state status of kServicesCustomizationAppliedPref. |
| 55 static void SetApplied(bool val); | 62 static void SetApplied(bool val); |
| 56 | 63 |
| 57 // Services customization manifest URL. | 64 // Services customization manifest URL. |
| 58 GURL url_; | 65 GURL url_; |
| 59 | 66 |
| 60 // URLFetcher instance. | 67 // URLFetcher instance. |
| 61 scoped_ptr<URLFetcher> url_fetcher_; | 68 scoped_ptr<URLFetcher> url_fetcher_; |
| 62 | 69 |
| 63 // Timer to retry fetching file if network is not available. | 70 // Timer to retry fetching file if network is not available. |
| 64 base::OneShotTimer<ApplyServicesCustomization> retry_timer_; | 71 base::OneShotTimer<ApplyServicesCustomization> retry_timer_; |
| 65 | 72 |
| 66 // How many times we already tried to fetch customization manifest file. | 73 // How many times we already tried to fetch customization manifest file. |
| 67 int num_retries_; | 74 int num_retries_; |
| 68 | 75 |
| 69 DISALLOW_COPY_AND_ASSIGN(ApplyServicesCustomization); | 76 DISALLOW_COPY_AND_ASSIGN(ApplyServicesCustomization); |
| 70 }; | 77 }; |
| 71 | 78 |
| 72 } // namespace chromeos | 79 } // namespace chromeos |
| 73 | 80 |
| 74 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_APPLY_SERVICES_CUSTOMIZATION_H_ | 81 #endif // CHROME_BROWSER_CHROMEOS_LOGIN_APPLY_SERVICES_CUSTOMIZATION_H_ |
| OLD | NEW |