2012-04-03 03:34:16 +02:00
|
|
|
// 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
|
|
|
|
|
2012-12-30 12:17:49 +01:00
|
|
|
#include <list>
|
2012-11-20 21:08:36 +01:00
|
|
|
#include <map>
|
2012-04-03 03:34:16 +02:00
|
|
|
#include <string>
|
|
|
|
#include <utility>
|
|
|
|
|
|
|
|
#include "base/compiler_specific.h"
|
2012-12-30 12:17:49 +01:00
|
|
|
#include "base/memory/ref_counted.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "base/memory/scoped_ptr.h"
|
2012-11-20 21:08:36 +01:00
|
|
|
#include "base/synchronization/lock.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "content/public/browser/content_browser_client.h"
|
|
|
|
|
2012-12-30 12:17:49 +01:00
|
|
|
class CefBrowserInfo;
|
2012-04-03 03:34:16 +02:00
|
|
|
class CefBrowserMainParts;
|
|
|
|
class CefMediaObserver;
|
2012-06-25 23:21:27 +02:00
|
|
|
class CefResourceDispatcherHostDelegate;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
namespace content {
|
2012-09-28 22:14:02 +02:00
|
|
|
class PluginServiceFilter;
|
2012-04-03 03:34:16 +02:00
|
|
|
class SiteInstance;
|
|
|
|
}
|
|
|
|
|
|
|
|
class CefContentBrowserClient : public content::ContentBrowserClient {
|
|
|
|
public:
|
|
|
|
CefContentBrowserClient();
|
|
|
|
virtual ~CefContentBrowserClient();
|
|
|
|
|
2012-11-20 21:08:36 +01:00
|
|
|
// Returns the singleton CefContentBrowserClient instance.
|
|
|
|
static CefContentBrowserClient* Get();
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
CefBrowserMainParts* browser_main_parts() const {
|
|
|
|
return browser_main_parts_;
|
|
|
|
}
|
|
|
|
|
2012-12-30 12:17:49 +01:00
|
|
|
// Methods for managing CefBrowserInfo life span. Do not add new callers of
|
|
|
|
// these methods.
|
2012-11-20 21:08:36 +01:00
|
|
|
// 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
|
2012-12-30 12:17:49 +01:00
|
|
|
// race CefBrowserInfo may be created when requested for the first time and
|
|
|
|
// before the associated CefBrowserHostImpl is created.
|
|
|
|
scoped_refptr<CefBrowserInfo> CreateBrowserInfo();
|
|
|
|
scoped_refptr<CefBrowserInfo> GetOrCreateBrowserInfo(int render_process_id,
|
|
|
|
int render_view_id);
|
|
|
|
void RemoveBrowserInfo(scoped_refptr<CefBrowserInfo> browser_info);
|
|
|
|
void DestroyAllBrowsers();
|
|
|
|
|
|
|
|
// Retrieves the CefBrowserInfo matching the specified IDs or an empty
|
|
|
|
// pointer if no match is found. It is allowed to add new callers of this
|
|
|
|
// method but consider using CefContext::GetBrowserByRoutingID() instead.
|
|
|
|
scoped_refptr<CefBrowserInfo> GetBrowserInfo(int render_process_id,
|
|
|
|
int render_view_id);
|
2012-11-20 21:08:36 +01:00
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
virtual content::BrowserMainParts* CreateBrowserMainParts(
|
|
|
|
const content::MainFunctionParams& parameters) OVERRIDE;
|
|
|
|
virtual void RenderProcessHostCreated(
|
|
|
|
content::RenderProcessHost* host) OVERRIDE;
|
2012-11-21 01:40:15 +01:00
|
|
|
virtual content::WebContentsView* OverrideCreateWebContentsView(
|
|
|
|
content::WebContents* web_contents,
|
|
|
|
content::RenderViewHostDelegateView** rvhdv) OVERRIDE;
|
2012-04-03 03:34:16 +02:00
|
|
|
virtual void AppendExtraCommandLineSwitches(CommandLine* command_line,
|
|
|
|
int child_process_id) OVERRIDE;
|
2012-09-28 00:52:15 +02:00
|
|
|
virtual content::QuotaPermissionContext*
|
|
|
|
CreateQuotaPermissionContext() OVERRIDE;
|
2012-04-03 03:34:16 +02:00
|
|
|
virtual content::MediaObserver* GetMediaObserver() OVERRIDE;
|
|
|
|
virtual content::AccessTokenStore* CreateAccessTokenStore() OVERRIDE;
|
2012-06-25 23:21:27 +02:00
|
|
|
virtual void ResourceDispatcherHostCreated() OVERRIDE;
|
2012-04-03 03:34:16 +02:00
|
|
|
virtual void OverrideWebkitPrefs(content::RenderViewHost* rvh,
|
|
|
|
const GURL& url,
|
2012-05-18 17:04:56 +02:00
|
|
|
webkit_glue::WebPreferences* prefs) OVERRIDE;
|
2012-10-08 19:47:37 +02:00
|
|
|
virtual void BrowserURLHandlerCreated(
|
|
|
|
content::BrowserURLHandler* handler) OVERRIDE;
|
2012-04-03 03:34:16 +02:00
|
|
|
virtual std::string GetDefaultDownloadName() OVERRIDE;
|
2012-11-21 01:40:15 +01:00
|
|
|
|
2012-09-11 00:19:19 +02:00
|
|
|
#if defined(OS_WIN)
|
|
|
|
const wchar_t* GetResourceDllName() OVERRIDE;
|
|
|
|
#endif
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
private:
|
|
|
|
CefBrowserMainParts* browser_main_parts_;
|
|
|
|
|
|
|
|
scoped_ptr<CefMediaObserver> media_observer_;
|
2012-09-28 22:14:02 +02:00
|
|
|
scoped_ptr<content::PluginServiceFilter> plugin_service_filter_;
|
2012-06-25 23:21:27 +02:00
|
|
|
scoped_ptr<CefResourceDispatcherHostDelegate>
|
|
|
|
resource_dispatcher_host_delegate_;
|
2012-11-20 21:08:36 +01:00
|
|
|
|
2012-12-30 12:17:49 +01:00
|
|
|
base::Lock browser_info_lock_;
|
2012-11-20 21:08:36 +01:00
|
|
|
|
2012-12-30 12:17:49 +01:00
|
|
|
// Access must be protected by |browser_info_lock_|.
|
|
|
|
typedef std::list<scoped_refptr<CefBrowserInfo> > BrowserInfoList;
|
|
|
|
BrowserInfoList browser_info_list_;
|
|
|
|
int next_browser_id_;
|
2012-04-03 03:34:16 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_BROWSER_CONTENT_BROWSER_CLIENT_H_
|