content_browser_client.h 5.15 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
// Copyright (c) 2011 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 CEF_LIBCEF_BROWSER_CONTENT_BROWSER_CLIENT_H_
#define CEF_LIBCEF_BROWSER_CONTENT_BROWSER_CLIENT_H_
#pragma once

#include <string>
#include <utility>

12
#include "include/cef_request_context_handler.h"
13
#include "libcef/browser/browser_context_impl.h"
14
#include "libcef/browser/net/url_request_context_getter_impl.h"
15

16
#include "base/macros.h"
17
#include "base/memory/ref_counted.h"
18
#include "build/build_config.h"
19
#include "content/public/browser/content_browser_client.h"
20
#include "third_party/skia/include/core/SkColor.h"
21 22

class CefBrowserMainParts;
23
class CefDevToolsDelegate;
24
class CefResourceDispatcherHostDelegate;
25 26

namespace content {
27
class PluginServiceFilter;
28 29 30 31 32 33
class SiteInstance;
}

class CefContentBrowserClient : public content::ContentBrowserClient {
 public:
  CefContentBrowserClient();
34
  ~CefContentBrowserClient() override;
35

36 37 38
  // Returns the singleton CefContentBrowserClient instance.
  static CefContentBrowserClient* Get();

39
  // ContentBrowserClient implementation.
40 41 42 43
  content::BrowserMainParts* CreateBrowserMainParts(
      const content::MainFunctionParams& parameters) override;
  void RenderProcessWillLaunch(
      content::RenderProcessHost* host) override;
44 45
  bool ShouldUseProcessPerSite(content::BrowserContext* browser_context,
                               const GURL& effective_url) override;
46
  bool IsHandledURL(const GURL& url) override;
47 48
  void SiteInstanceGotProcess(content::SiteInstance* site_instance) override;
  void SiteInstanceDeleting(content::SiteInstance* site_instance) override;
49
  std::unique_ptr<base::Value> GetServiceManifestOverlay(
50
      base::StringPiece name) override;
51 52 53 54 55 56
  void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
                                              int child_process_id) override;
  content::QuotaPermissionContext*
      CreateQuotaPermissionContext() override;
  content::MediaObserver* GetMediaObserver() override;
  content::SpeechRecognitionManagerDelegate*
57
      CreateSpeechRecognitionManagerDelegate() override;
58
  void AllowCertificateError(
59
      content::WebContents* web_contents,
60 61 62
      int cert_error,
      const net::SSLInfo& ssl_info,
      const GURL& request_url,
63
      content::ResourceType resource_type,
64 65
      bool overridable,
      bool strict_enforcement,
66
      bool expired_previous_decision,
67 68
      const base::Callback<
          void(content::CertificateRequestResultType)>& callback) override;
69 70 71
  void SelectClientCertificate(
      content::WebContents* web_contents,
      net::SSLCertRequestInfo* cert_request_info,
72
      std::unique_ptr<content::ClientCertificateDelegate> delegate) override;
73 74 75
  bool CanCreateWindow(int opener_render_process_id,
                       int opener_render_frame_id,
                       const GURL& opener_url,
76 77 78 79 80
                       const GURL& opener_top_level_frame_url,
                       const GURL& source_origin,
                       WindowContainerType container_type,
                       const GURL& target_url,
                       const content::Referrer& referrer,
81
                       const std::string& frame_name,
82 83 84 85 86 87 88 89 90 91 92 93
                       WindowOpenDisposition disposition,
                       const blink::WebWindowFeatures& features,
                       bool user_gesture,
                       bool opener_suppressed,
                       content::ResourceContext* context,
                       bool* no_javascript_access) override;
  void ResourceDispatcherHostCreated() override;
  void OverrideWebkitPrefs(content::RenderViewHost* rvh,
                           content::WebPreferences* prefs) override;
  void BrowserURLHandlerCreated(
      content::BrowserURLHandler* handler) override;
  std::string GetDefaultDownloadName() override;
94
  void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) override;
95 96
  content::DevToolsManagerDelegate* GetDevToolsManagerDelegate()
      override;
97 98
  std::vector<std::unique_ptr<content::NavigationThrottle>>
  CreateThrottlesForNavigation(
99
      content::NavigationHandle* navigation_handle) override;
100

101
#if defined(OS_POSIX) && !defined(OS_MACOSX)
102
  void GetAdditionalMappedFilesForChildProcess(
103
      const base::CommandLine& command_line,
104
      int child_process_id,
105
      content::FileDescriptorInfo* mappings) override;
106 107
#endif

108
#if defined(OS_WIN)
109
  const wchar_t* GetResourceDllName();
110
  bool PreSpawnRenderer(sandbox::TargetPolicy* policy) override;
111
#endif
112

113 114
  // Perform browser process registration for the custom scheme.
  void RegisterCustomScheme(const std::string& scheme);
115

116
  scoped_refptr<CefBrowserContextImpl> browser_context() const;
117
  CefDevToolsDelegate* devtools_delegate() const;
118

119
 private:
120 121 122 123
  // Returns the extension or app associated with |site_instance| or NULL.
  const extensions::Extension* GetExtension(
      content::SiteInstance* site_instance);

124 125
  CefBrowserMainParts* browser_main_parts_;

126 127
  std::unique_ptr<content::PluginServiceFilter> plugin_service_filter_;
  std::unique_ptr<CefResourceDispatcherHostDelegate>
128
      resource_dispatcher_host_delegate_;
129 130 131
};

#endif  // CEF_LIBCEF_BROWSER_CONTENT_BROWSER_CLIENT_H_