1 // Copyright 2015 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 HEADLESS_LIB_BROWSER_HEADLESS_CONTENT_BROWSER_CLIENT_H_ 6 #define HEADLESS_LIB_BROWSER_HEADLESS_CONTENT_BROWSER_CLIENT_H_ 7 8 #include <memory> 9 10 #include "content/public/browser/content_browser_client.h" 11 #include "headless/public/headless_browser.h" 12 13 namespace headless { 14 15 class HeadlessBrowserImpl; 16 17 class HeadlessContentBrowserClient : public content::ContentBrowserClient { 18 public: 19 explicit HeadlessContentBrowserClient(HeadlessBrowserImpl* browser); 20 ~HeadlessContentBrowserClient() override; 21 22 // content::ContentBrowserClient implementation: 23 std::unique_ptr<content::BrowserMainParts> CreateBrowserMainParts( 24 const content::MainFunctionParams&) override; 25 void OverrideWebkitPrefs(content::RenderViewHost* render_view_host, 26 blink::web_pref::WebPreferences* prefs) override; 27 content::DevToolsManagerDelegate* GetDevToolsManagerDelegate() override; 28 scoped_refptr<content::QuotaPermissionContext> CreateQuotaPermissionContext() 29 override; 30 content::GeneratedCodeCacheSettings GetGeneratedCodeCacheSettings( 31 content::BrowserContext* context) override; 32 #if defined(OS_POSIX) && !defined(OS_MAC) 33 void GetAdditionalMappedFilesForChildProcess( 34 const base::CommandLine& command_line, 35 int child_process_id, 36 content::PosixFileDescriptorInfo* mappings) override; 37 #endif 38 void AppendExtraCommandLineSwitches(base::CommandLine* command_line, 39 int child_process_id) override; 40 std::string GetApplicationLocale() override; 41 std::string GetAcceptLangs(content::BrowserContext* context) override; 42 void AllowCertificateError( 43 content::WebContents* web_contents, 44 int cert_error, 45 const net::SSLInfo& ssl_info, 46 const GURL& request_url, 47 bool is_main_frame_request, 48 bool strict_enforcement, 49 base::OnceCallback<void(content::CertificateRequestResultType)> callback) 50 override; 51 base::OnceClosure SelectClientCertificate( 52 content::WebContents* web_contents, 53 net::SSLCertRequestInfo* cert_request_info, 54 net::ClientCertIdentityList client_certs, 55 std::unique_ptr<content::ClientCertificateDelegate> delegate) override; 56 bool ShouldEnableStrictSiteIsolation() override; 57 58 void ConfigureNetworkContextParams( 59 content::BrowserContext* context, 60 bool in_memory, 61 const base::FilePath& relative_partition_path, 62 ::network::mojom::NetworkContextParams* network_context_params, 63 ::network::mojom::CertVerifierCreationParams* 64 cert_verifier_creation_params) override; 65 66 std::string GetProduct() override; 67 std::string GetUserAgent() override; 68 69 private: 70 HeadlessBrowserImpl* browser_; // Not owned. 71 72 // We store the callback here because we may call it from the I/O thread. 73 HeadlessBrowser::Options::AppendCommandLineFlagsCallback 74 append_command_line_flags_callback_; 75 76 DISALLOW_COPY_AND_ASSIGN(HeadlessContentBrowserClient); 77 }; 78 79 } // namespace headless 80 81 #endif // HEADLESS_LIB_BROWSER_HEADLESS_CONTENT_BROWSER_CLIENT_H_ 82