BookmarkManager: Fix 'new folder text field size changes on clicking it' issue.
[chromium-blink-merge.git] / chrome / browser / profile_resetter / brandcode_config_fetcher.h
blob449545489b21a8d96d0e205ebbedf1ccff7f898b
1 // Copyright 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_PROFILE_RESETTER_BRANDCODE_CONFIG_FETCHER_H_
6 #define CHROME_BROWSER_PROFILE_RESETTER_BRANDCODE_CONFIG_FETCHER_H_
8 #include "base/basictypes.h"
9 #include "base/callback.h"
10 #include "base/timer/timer.h"
11 #include "net/url_request/url_fetcher_delegate.h"
13 class BrandcodedDefaultSettings;
14 class GURL;
16 // BrandcodeConfigFetcher fetches and parses the xml containing the brandcoded
17 // default settings. Caller should provide a FetchCallback.
18 class BrandcodeConfigFetcher : public net::URLFetcherDelegate {
19 public:
20 typedef base::Callback<void ()> FetchCallback;
22 BrandcodeConfigFetcher(const FetchCallback& callback,
23 const GURL& url,
24 const std::string& brandcode);
25 ~BrandcodeConfigFetcher() override;
27 bool IsActive() const { return config_fetcher_; }
29 scoped_ptr<BrandcodedDefaultSettings> GetSettings() {
30 return default_settings_.Pass();
33 // Sets the new callback. The previous one won't be called.
34 void SetCallback(const FetchCallback& callback);
36 private:
37 // net::URLFetcherDelegate:
38 void OnURLFetchComplete(const net::URLFetcher* source) override;
40 void OnDownloadTimeout();
42 // Timer that enforces a timeout on the attempt to download the
43 // config file.
44 base::OneShotTimer<BrandcodeConfigFetcher> download_timer_;
46 // |fetch_callback_| called when fetching succeeded or failed.
47 FetchCallback fetch_callback_;
49 // Helper to fetch the online config file.
50 scoped_ptr<net::URLFetcher> config_fetcher_;
52 // Fetched settings.
53 scoped_ptr<BrandcodedDefaultSettings> default_settings_;
55 DISALLOW_COPY_AND_ASSIGN(BrandcodeConfigFetcher);
58 #endif // CHROME_BROWSER_PROFILE_RESETTER_BRANDCODE_CONFIG_FETCHER_H_