1 // Copyright 2020 The Chromium Embedded Framework Authors. 2 // Portions copyright 2012 The Chromium Authors. All rights reserved. 3 // Use of this source code is governed by a BSD-style license that can be 4 // found in the LICENSE file. 5 6 #ifndef CEF_LIBCEF_BROWSER_CHROME_CHROME_CONTENT_BROWSER_CLIENT_CEF_ 7 #define CEF_LIBCEF_BROWSER_CHROME_CHROME_CONTENT_BROWSER_CLIENT_CEF_ 8 9 #include <memory> 10 11 #include "libcef/browser/request_context_impl.h" 12 13 #include "chrome/browser/chrome_content_browser_client.h" 14 15 class ChromeBrowserMainExtraPartsCef; 16 17 // CEF override of ChromeContentBrowserClient. 18 class ChromeContentBrowserClientCef : public ChromeContentBrowserClient { 19 public: 20 ChromeContentBrowserClientCef(); 21 22 ChromeContentBrowserClientCef(const ChromeContentBrowserClientCef&) = delete; 23 ChromeContentBrowserClientCef& operator=( 24 const ChromeContentBrowserClientCef&) = delete; 25 26 ~ChromeContentBrowserClientCef() override; 27 28 // ChromeContentBrowserClient overrides. 29 std::unique_ptr<content::BrowserMainParts> CreateBrowserMainParts( 30 content::MainFunctionParams parameters) override; 31 void AppendExtraCommandLineSwitches(base::CommandLine* command_line, 32 int child_process_id) override; 33 void RenderProcessWillLaunch(content::RenderProcessHost* host) override; 34 bool CanCreateWindow(content::RenderFrameHost* opener, 35 const GURL& opener_url, 36 const GURL& opener_top_level_frame_url, 37 const url::Origin& source_origin, 38 content::mojom::WindowContainerType container_type, 39 const GURL& target_url, 40 const content::Referrer& referrer, 41 const std::string& frame_name, 42 WindowOpenDisposition disposition, 43 const blink::mojom::WindowFeatures& features, 44 bool user_gesture, 45 bool opener_suppressed, 46 bool* no_javascript_access) override; 47 void OverrideWebkitPrefs(content::WebContents* web_contents, 48 blink::web_pref::WebPreferences* prefs) override; 49 bool WillCreateURLLoaderFactory( 50 content::BrowserContext* browser_context, 51 content::RenderFrameHost* frame, 52 int render_process_id, 53 URLLoaderFactoryType type, 54 const url::Origin& request_initiator, 55 absl::optional<int64_t> navigation_id, 56 ukm::SourceIdObj ukm_source_id, 57 mojo::PendingReceiver<network::mojom::URLLoaderFactory>* factory_receiver, 58 mojo::PendingRemote<network::mojom::TrustedURLLoaderHeaderClient>* 59 header_client, 60 bool* bypass_redirect_checks, 61 bool* disable_secure_dns, 62 network::mojom::URLLoaderFactoryOverridePtr* factory_override) override; 63 bool HandleExternalProtocol( 64 const GURL& url, 65 content::WebContents::Getter web_contents_getter, 66 int child_id, 67 int frame_tree_node_id, 68 content::NavigationUIData* navigation_data, 69 bool is_main_frame, 70 network::mojom::WebSandboxFlags sandbox_flags, 71 ui::PageTransition page_transition, 72 bool has_user_gesture, 73 const absl::optional<url::Origin>& initiating_origin, 74 content::RenderFrameHost* initiator_document, 75 mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) 76 override; 77 bool HandleExternalProtocol( 78 content::WebContents::Getter web_contents_getter, 79 int frame_tree_node_id, 80 content::NavigationUIData* navigation_data, 81 network::mojom::WebSandboxFlags sandbox_flags, 82 const network::ResourceRequest& request, 83 const absl::optional<url::Origin>& initiating_origin, 84 content::RenderFrameHost* initiator_document, 85 mojo::PendingRemote<network::mojom::URLLoaderFactory>* out_factory) 86 override; 87 std::vector<std::unique_ptr<content::NavigationThrottle>> 88 CreateThrottlesForNavigation( 89 content::NavigationHandle* navigation_handle) override; 90 bool ConfigureNetworkContextParams( 91 content::BrowserContext* context, 92 bool in_memory, 93 const base::FilePath& relative_partition_path, 94 network::mojom::NetworkContextParams* network_context_params, 95 cert_verifier::mojom::CertVerifierCreationParams* 96 cert_verifier_creation_params) override; 97 std::unique_ptr<content::LoginDelegate> CreateLoginDelegate( 98 const net::AuthChallengeInfo& auth_info, 99 content::WebContents* web_contents, 100 const content::GlobalRequestID& request_id, 101 bool is_request_for_main_frame, 102 const GURL& url, 103 scoped_refptr<net::HttpResponseHeaders> response_headers, 104 bool first_auth_attempt, 105 LoginAuthRequiredCallback auth_required_callback) override; 106 void BrowserURLHandlerCreated(content::BrowserURLHandler* handler) override; 107 bool IsWebUIAllowedToMakeNetworkRequests(const url::Origin& origin) override; 108 void ExposeInterfacesToRenderer( 109 service_manager::BinderRegistry* registry, 110 blink::AssociatedInterfaceRegistry* associated_registry, 111 content::RenderProcessHost* render_process_host) override; 112 void RegisterBrowserInterfaceBindersForFrame( 113 content::RenderFrameHost* render_frame_host, 114 mojo::BinderMapWithContext<content::RenderFrameHost*>* map) override; 115 116 CefRefPtr<CefRequestContextImpl> request_context() const; 117 118 scoped_refptr<base::SingleThreadTaskRunner> background_task_runner() const; 119 scoped_refptr<base::SingleThreadTaskRunner> user_visible_task_runner() const; 120 scoped_refptr<base::SingleThreadTaskRunner> user_blocking_task_runner() const; 121 122 private: 123 ChromeBrowserMainExtraPartsCef* browser_main_parts_ = nullptr; 124 }; 125 126 #endif // CEF_LIBCEF_BROWSER_CHROME_CHROME_CONTENT_BROWSER_CLIENT_CEF_ 127