content_browser_client.h 5.08 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 50 51 52 53 54
  void AppendExtraCommandLineSwitches(base::CommandLine* command_line,
                                              int child_process_id) override;
  content::QuotaPermissionContext*
      CreateQuotaPermissionContext() override;
  content::MediaObserver* GetMediaObserver() override;
  content::SpeechRecognitionManagerDelegate*
55
      CreateSpeechRecognitionManagerDelegate() override;
56
  void AllowCertificateError(
57
      content::WebContents* web_contents,
58 59 60
      int cert_error,
      const net::SSLInfo& ssl_info,
      const GURL& request_url,
61
      content::ResourceType resource_type,
62 63
      bool overridable,
      bool strict_enforcement,
64
      bool expired_previous_decision,
65 66
      const base::Callback<
          void(content::CertificateRequestResultType)>& callback) override;
67 68 69
  void SelectClientCertificate(
      content::WebContents* web_contents,
      net::SSLCertRequestInfo* cert_request_info,
70
      std::unique_ptr<content::ClientCertificateDelegate> delegate) override;
71 72 73 74 75 76
  bool CanCreateWindow(const GURL& opener_url,
                       const GURL& opener_top_level_frame_url,
                       const GURL& source_origin,
                       WindowContainerType container_type,
                       const GURL& target_url,
                       const content::Referrer& referrer,
77
                       const std::string& frame_name,
78 79 80 81 82 83
                       WindowOpenDisposition disposition,
                       const blink::WebWindowFeatures& features,
                       bool user_gesture,
                       bool opener_suppressed,
                       content::ResourceContext* context,
                       int render_process_id,
84 85
                       int opener_render_view_id,
                       int opener_render_frame_id,
86 87 88 89 90 91 92
                       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;
93
  void DidCreatePpapiPlugin(content::BrowserPpapiHost* browser_host) override;
94 95
  content::DevToolsManagerDelegate* GetDevToolsManagerDelegate()
      override;
96 97
  ScopedVector<content::NavigationThrottle> CreateThrottlesForNavigation(
      content::NavigationHandle* navigation_handle) override;
98

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

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

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

114
  scoped_refptr<CefBrowserContextImpl> browser_context() const;
115
  CefDevToolsDelegate* devtools_delegate() const;
116

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

122 123
  CefBrowserMainParts* browser_main_parts_;

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

#endif  // CEF_LIBCEF_BROWSER_CONTENT_BROWSER_CLIENT_H_