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_
11 #include "net/url_request/url_fetcher_delegate.h"
12 #include "third_party/libaddressinput/src/cpp/include/libaddressinput/source.h"
16 class URLRequestContextGetter
;
21 // A class for downloading rules to let libaddressinput validate international
23 class ChromeMetadataSource
: public ::i18n::addressinput::Source
,
24 public net::URLFetcherDelegate
{
26 ChromeMetadataSource(const std::string
& validation_data_url
,
27 net::URLRequestContextGetter
* getter
);
28 virtual ~ChromeMetadataSource();
30 // ::i18n::addressinput::Source:
31 virtual void Get(const std::string
& key
,
32 const Callback
& downloaded
) const override
;
34 // net::URLFetcherDelegate:
35 virtual void OnURLFetchComplete(const net::URLFetcher
* source
) override
;
39 Request(const std::string
& key
,
40 scoped_ptr
<net::URLFetcher
> fetcher
,
41 const Callback
& callback
);
44 // The data that's received.
46 // The object that manages retrieving the data.
47 scoped_ptr
<net::URLFetcher
> fetcher
;
48 const Callback
& callback
;
51 // Non-const method actually implementing Get().
52 void Download(const std::string
& key
, const Callback
& downloaded
);
54 const std::string validation_data_url_
;
55 net::URLRequestContextGetter
* const getter_
; // weak
57 // Maps from active URL fetcher to request metadata. The value is owned.
58 std::map
<const net::URLFetcher
*, Request
*> requests_
;
60 DISALLOW_COPY_AND_ASSIGN(ChromeMetadataSource
);
63 } // namespace autofill
65 #endif // THIRD_PARTY_LIBADDRESSINPUT_CHROMIUM_CHROME_METADATA_SOURCE_H_