| Index: chrome/browser/chromeos/login/apply_services_customization.h
|
| ===================================================================
|
| --- chrome/browser/chromeos/login/apply_services_customization.h (revision 54872)
|
| +++ chrome/browser/chromeos/login/apply_services_customization.h (working copy)
|
| @@ -2,26 +2,44 @@
|
| // Use of this source code is governed by a BSD-style license that can be
|
| // found in the LICENSE file.
|
|
|
| -#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_STRING_FETCHER_H_
|
| -#define CHROME_BROWSER_CHROMEOS_LOGIN_STRING_FETCHER_H_
|
| +#ifndef CHROME_BROWSER_CHROMEOS_LOGIN_APPLY_SERVICES_CUSTOMIZATION_H_
|
| +#define CHROME_BROWSER_CHROMEOS_LOGIN_APPLY_SERVICES_CUSTOMIZATION_H_
|
|
|
| #include <string>
|
|
|
| #include "base/basictypes.h"
|
| #include "base/scoped_ptr.h"
|
| +#include "base/timer.h"
|
| #include "chrome/common/net/url_fetcher.h"
|
| +#include "googleurl/src/gurl.h"
|
|
|
| -// This class is used to fetch an URL and store result as a string.
|
| -class StringFetcher : public URLFetcher::Delegate {
|
| +class PrefService;
|
| +
|
| +namespace chromeos {
|
| +
|
| +// This class fetches services customization document and apply it
|
| +// as soon as the document is downloaded.
|
| +class ApplyServicesCustomization : public URLFetcher::Delegate {
|
| public:
|
| - // Initiates URL fetch.
|
| - explicit StringFetcher(const std::string& url);
|
| + // This method checks if service customization has been applied and if not
|
| + // starts the process.
|
| + static void StartIfNeeded();
|
|
|
| - const std::string& result() const { return result_; }
|
| - int response_code() const { return response_code_; }
|
| - bool succeeded() const { return response_code_ == 200; }
|
| + // Registers preferences.
|
| + static void RegisterPrefs(PrefService* local_state);
|
|
|
| + // Returns true if service customization has been applied.
|
| + static bool IsApplied();
|
| +
|
| private:
|
| + explicit ApplyServicesCustomization(const std::string& url_str);
|
| +
|
| + // Initiate URL fetch, return true if the object will delete itself later.
|
| + bool Init();
|
| +
|
| + // Initiate file fetching.
|
| + void StartFileFetch();
|
| +
|
| // Overriden from URLFetcher::Delegate:
|
| virtual void OnURLFetchComplete(const URLFetcher* source,
|
| const GURL& url,
|
| @@ -29,19 +47,28 @@
|
| int response_code,
|
| const ResponseCookies& cookies,
|
| const std::string& data);
|
| - // Timer notification handler.
|
| - void OnTimeoutElapsed();
|
|
|
| + // Applies given |manifest|.
|
| + void Apply(const std::string& manifest);
|
| +
|
| + // Remember in local state status of kServicesCustomizationAppliedPref.
|
| + static void SetApplied(bool val);
|
| +
|
| + // Services customization manifest URL.
|
| + GURL url_;
|
| +
|
| // URLFetcher instance.
|
| scoped_ptr<URLFetcher> url_fetcher_;
|
|
|
| - // Fetch result.
|
| - std::string result_;
|
| + // Timer to retry fetching file if network is not available.
|
| + base::OneShotTimer<ApplyServicesCustomization> retry_timer_;
|
|
|
| - // Received HTTP response code.
|
| - int response_code_;
|
| + // How many times we already tried to fetch customization manifest file.
|
| + int num_retries_;
|
|
|
| - DISALLOW_COPY_AND_ASSIGN(StringFetcher);
|
| + DISALLOW_COPY_AND_ASSIGN(ApplyServicesCustomization);
|
| };
|
|
|
| -#endif // CHROME_BROWSER_CHROMEOS_LOGIN_STRING_FETCHER_H_
|
| +} // namespace chromeos
|
| +
|
| +#endif // CHROME_BROWSER_CHROMEOS_LOGIN_APPLY_SERVICES_CUSTOMIZATION_H_
|
|
|
| Property changes on: chrome/browser/chromeos/login/apply_services_customization.h
|
| ___________________________________________________________________
|
| Added: svn:mergeinfo
|
|
|
|
|