Pin Chrome's shortcut to the Win10 Start menu on install and OS upgrade.
[chromium-blink-merge.git] / third_party / libaddressinput / chromium / chrome_metadata_source.h
blob1058cb001dc45bc35396cdee748caba7c99a8670
1 // Copyright 2014 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 THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_METADATA_SOURCE_H_
6 #define THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_METADATA_SOURCE_H_
8 #include <map>
9 #include <string>
11 #include "base/memory/scoped_vector.h"
12 #include "net/url_request/url_fetcher_delegate.h"
13 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/source.h"
15 namespace net {
16 class URLFetcher;
17 class URLRequestContextGetter;
20 namespace autofill {
22 // A class for downloading rules to let libaddressinput validate international
23 // addresses.
24 class ChromeMetadataSource : public ::i18n::addressinput::Source,
25 public net::URLFetcherDelegate {
26 public:
27 ChromeMetadataSource(const std::string& validation_data_url,
28 net::URLRequestContextGetter* getter);
29 virtual ~ChromeMetadataSource();
31 // ::i18n::addressinput::Source:
32 virtual void Get(const std::string& key,
33 const Callback& downloaded) const override;
35 // net::URLFetcherDelegate:
36 virtual void OnURLFetchComplete(const net::URLFetcher* source) override;
38 private:
39 struct Request {
40 Request(const std::string& key,
41 scoped_ptr<net::URLFetcher> fetcher,
42 const Callback& callback);
44 std::string key;
45 // The data that's received.
46 std::string data;
47 // The object that manages retrieving the data.
48 scoped_ptr<net::URLFetcher> fetcher;
49 const Callback& callback;
52 // Non-const method actually implementing Get().
53 void Download(const std::string& key, const Callback& downloaded);
55 const std::string validation_data_url_;
56 net::URLRequestContextGetter* const getter_; // weak
58 // Maps from active URL fetcher to request metadata. The value is owned.
59 std::map<const net::URLFetcher*, Request*> requests_;
61 DISALLOW_COPY_AND_ASSIGN(ChromeMetadataSource);
64 } // namespace autofill
66 #endif // THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_METADATA_SOURCE_H_