| Index: components/password_manager/core/browser/site_affiliation/asset_link_retriever.h
|
| diff --git a/components/password_manager/core/browser/site_affiliation/asset_link_retriever.h b/components/password_manager/core/browser/site_affiliation/asset_link_retriever.h
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..42ae1a121ce0f1cdbdbd6480cc298e5a7fb6989f
|
| --- /dev/null
|
| +++ b/components/password_manager/core/browser/site_affiliation/asset_link_retriever.h
|
| @@ -0,0 +1,67 @@
|
| +// Copyright 2017 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +#ifndef COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_SITE_AFFILIATION_ASSET_LINK_RETRIEVER_H_
|
| +#define COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_SITE_AFFILIATION_ASSET_LINK_RETRIEVER_H_
|
| +
|
| +#include <memory>
|
| +
|
| +#include "base/macros.h"
|
| +#include "base/memory/ref_counted.h"
|
| +#include "net/url_request/url_fetcher_delegate.h"
|
| +#include "url/gurl.h"
|
| +
|
| +namespace net {
|
| +class URLRequestContextGetter;
|
| +}
|
| +
|
| +namespace password_manager {
|
| +
|
| +// The class is responsible for fetching and parsing the digit asset links file.
|
| +// The file is a JSON containing different directives for the domain. The class
|
| +// is only interested in those related to credentials delegations.
|
| +// The spec is
|
| +// https://github.com/google/digitalassetlinks/blob/master/well-known/details.md
|
| +class AssetLinkRetriever : public base::RefCounted<AssetLinkRetriever>,
|
| + public net::URLFetcherDelegate {
|
| + public:
|
| + enum class State {
|
| + INACTIVE,
|
| + NETWORK_REQUEST,
|
| + FINISHED,
|
| + };
|
| +
|
| + explicit AssetLinkRetriever(GURL file_url);
|
| +
|
| + // Starts a network request if the current state is INACTIVE. All the calls
|
| + // afterwards are ignored.
|
| + void Start(net::URLRequestContextGetter* context_getter);
|
| +
|
| + State state() const { return state_; }
|
| +
|
| + bool error() const { return error_; }
|
| +
|
| + private:
|
| + friend class base::RefCounted<AssetLinkRetriever>;
|
| + ~AssetLinkRetriever() override;
|
| +
|
| + // net::URLFetcherDelegate:
|
| + void OnURLFetchComplete(const net::URLFetcher* source) override;
|
| +
|
| + // URL of the file retrieved.
|
| + const GURL url_;
|
| +
|
| + // Current state of the retrieval.
|
| + State state_;
|
| +
|
| + // Whether the reading finished with error.
|
| + bool error_;
|
| +
|
| + std::unique_ptr<net::URLFetcher> fetcher_;
|
| +
|
| + DISALLOW_COPY_AND_ASSIGN(AssetLinkRetriever);
|
| +};
|
| +
|
| +} // namespace password_manager
|
| +#endif // COMPONENTS_PASSWORD_MANAGER_CORE_BROWSER_SITE_AFFILIATION_ASSET_LINK_RETRIEVER_H_
|
|
|