1 // Copyright 2019 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.
4 
5 #ifndef CONTENT_PUBLIC_BROWSER_NETWORK_CONTEXT_CLIENT_BASE_H_
6 #define CONTENT_PUBLIC_BROWSER_NETWORK_CONTEXT_CLIENT_BASE_H_
7 
8 #include "build/build_config.h"
9 #include "content/common/content_export.h"
10 #include "mojo/public/cpp/bindings/pending_remote.h"
11 #include "services/network/public/mojom/network_context.mojom.h"
12 
13 namespace content {
14 
15 // This is a mostly empty NetworkContextClient implementation that code can use
16 // as a default client. The only method it implements is OnFileUploadRequested
17 // so that POSTs in a given NetworkContext work.
18 class CONTENT_EXPORT NetworkContextClientBase
19     : public network::mojom::NetworkContextClient {
20  public:
21   NetworkContextClientBase();
22   ~NetworkContextClientBase() override;
23 
24   // network::mojom::NetworkContextClient implementation:
25   void OnAuthRequired(
26       const base::Optional<base::UnguessableToken>& window_id,
27       int32_t process_id,
28       int32_t routing_id,
29       uint32_t request_id,
30       const GURL& url,
31       bool first_auth_attempt,
32       const net::AuthChallengeInfo& auth_info,
33       network::mojom::URLResponseHeadPtr head,
34       mojo::PendingRemote<network::mojom::AuthChallengeResponder>
35           auth_challenge_responder) override;
36   void OnCertificateRequested(
37       const base::Optional<base::UnguessableToken>& window_id,
38       int32_t process_id,
39       int32_t routing_id,
40       uint32_t request_id,
41       const scoped_refptr<net::SSLCertRequestInfo>& cert_info,
42       mojo::PendingRemote<network::mojom::ClientCertificateResponder>
43           cert_responder) override;
44   void OnSSLCertificateError(int32_t process_id,
45                              int32_t routing_id,
46                              const GURL& url,
47                              int net_error,
48                              const net::SSLInfo& ssl_info,
49                              bool fatal,
50                              OnSSLCertificateErrorCallback response) override;
51   void OnFileUploadRequested(int32_t process_id,
52                              bool async,
53                              const std::vector<base::FilePath>& file_paths,
54                              OnFileUploadRequestedCallback callback) override;
55   void OnCanSendReportingReports(
56       const std::vector<url::Origin>& origins,
57       OnCanSendReportingReportsCallback callback) override;
58   void OnCanSendDomainReliabilityUpload(
59       const GURL& origin,
60       OnCanSendDomainReliabilityUploadCallback callback) override;
61   void OnClearSiteData(int32_t process_id,
62                        int32_t routing_id,
63                        const GURL& url,
64                        const std::string& header_value,
65                        int load_flags,
66                        OnClearSiteDataCallback callback) override;
67   void OnCookiesChanged(
68       bool is_service_worker,
69       int32_t process_id,
70       int32_t routing_id,
71       const GURL& url,
72       const net::SiteForCookies& site_for_cookies,
73       const std::vector<net::CookieWithStatus>& cookie_list) override;
74   void OnCookiesRead(
75       bool is_service_worker,
76       int32_t process_id,
77       int32_t routing_id,
78       const GURL& url,
79       const net::SiteForCookies& site_for_cookies,
80       const std::vector<net::CookieWithStatus>& cookie_list) override;
81 #if defined(OS_ANDROID)
82   void OnGenerateHttpNegotiateAuthToken(
83       const std::string& server_auth_token,
84       bool can_delegate,
85       const std::string& auth_negotiate_android_account_type,
86       const std::string& spn,
87       OnGenerateHttpNegotiateAuthTokenCallback callback) override;
88 #endif
89 #if defined(OS_CHROMEOS)
90   void OnTrustAnchorUsed() override;
91 #endif
92 };
93 
94 }  // namespace content
95 
96 #endif  // CONTENT_PUBLIC_BROWSER_NETWORK_CONTEXT_CLIENT_BASE_H_
97