content_browser_client.h 3.33 KB
Newer Older
1 2 3 4 5 6 7 8
// 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

9
#include <map>
10 11 12 13 14 15
#include <string>
#include <utility>
#include <vector>

#include "base/compiler_specific.h"
#include "base/memory/scoped_ptr.h"
16
#include "base/synchronization/lock.h"
17 18 19 20
#include "content/public/browser/content_browser_client.h"

class CefBrowserMainParts;
class CefMediaObserver;
21
class CefResourceDispatcherHostDelegate;
22 23

namespace content {
24
class PluginServiceFilter;
25 26 27 28 29 30 31 32
class SiteInstance;
}

class CefContentBrowserClient : public content::ContentBrowserClient {
 public:
  CefContentBrowserClient();
  virtual ~CefContentBrowserClient();

33 34 35
  // Returns the singleton CefContentBrowserClient instance.
  static CefContentBrowserClient* Get();

36 37 38 39
  CefBrowserMainParts* browser_main_parts() const {
    return browser_main_parts_;
  }

40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55
  // During popup window creation there is a race between the call to
  // CefBrowserMessageFilter::OnGetNewBrowserInfo on the IO thread and the call
  // to CefBrowserHostImpl::WebContentsCreated on the UI thread. To resolve this
  // race we create the info when requested for the first time.
  class NewPopupBrowserInfo {
   public:
    NewPopupBrowserInfo()
        : browser_id(0) {}
    int browser_id;
  };
  void GetNewPopupBrowserInfo(int render_process_id,
                              int render_view_id,
                              NewPopupBrowserInfo* info);
  void ClearNewPopupBrowserInfo(int render_process_id,
                                int render_view_id);

56 57 58 59 60 61
  virtual content::BrowserMainParts* CreateBrowserMainParts(
      const content::MainFunctionParams& parameters) OVERRIDE;
  virtual void RenderProcessHostCreated(
      content::RenderProcessHost* host) OVERRIDE;
  virtual void AppendExtraCommandLineSwitches(CommandLine* command_line,
                                              int child_process_id) OVERRIDE;
62 63
  virtual content::QuotaPermissionContext*
      CreateQuotaPermissionContext() OVERRIDE;
64 65
  virtual content::MediaObserver* GetMediaObserver() OVERRIDE;
  virtual content::AccessTokenStore* CreateAccessTokenStore() OVERRIDE;
66
  virtual void ResourceDispatcherHostCreated() OVERRIDE;
67 68
  virtual void OverrideWebkitPrefs(content::RenderViewHost* rvh,
                                   const GURL& url,
69
                                   webkit_glue::WebPreferences* prefs) OVERRIDE;
70 71
  virtual void BrowserURLHandlerCreated(
      content::BrowserURLHandler* handler) OVERRIDE;
72
  virtual std::string GetDefaultDownloadName() OVERRIDE;
73 74 75
#if defined(OS_WIN)
  const wchar_t* GetResourceDllName() OVERRIDE;
#endif
76 77 78 79 80

 private:
  CefBrowserMainParts* browser_main_parts_;

  scoped_ptr<CefMediaObserver> media_observer_;
81
  scoped_ptr<content::PluginServiceFilter> plugin_service_filter_;
82 83
  scoped_ptr<CefResourceDispatcherHostDelegate>
      resource_dispatcher_host_delegate_;
84 85 86 87 88 89 90 91

  base::Lock new_popup_browser_lock_;

  // Map of (render_process_id, render_view_id) to info. Access must be
  // protected by |new_popup_browser_lock_|.
  typedef std::map<std::pair<int, int>, NewPopupBrowserInfo>
      NewPopupBrowserInfoMap;
  NewPopupBrowserInfoMap new_popup_browser_info_map_;
92 93 94
};

#endif  // CEF_LIBCEF_BROWSER_CONTENT_BROWSER_CLIENT_H_