2013-01-03 18:24:24 +01:00
|
|
|
// Copyright (c) 2013 The Chromium Embedded Framework Authors.
|
|
|
|
// Portions copyright (c) 2011 The Chromium Authors. All rights reserved.
|
2012-04-03 03:34:16 +02:00
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef CEF_LIBCEF_RENDERER_CONTENT_RENDERER_CLIENT_H_
|
|
|
|
#define CEF_LIBCEF_RENDERER_CONTENT_RENDERER_CLIENT_H_
|
|
|
|
#pragma once
|
|
|
|
|
2012-04-24 20:01:48 +02:00
|
|
|
#include <list>
|
2012-04-03 03:34:16 +02:00
|
|
|
#include <map>
|
|
|
|
#include <string>
|
2012-12-31 11:41:15 +01:00
|
|
|
#include <vector>
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
#include "libcef/renderer/browser_impl.h"
|
|
|
|
|
|
|
|
#include "base/compiler_specific.h"
|
|
|
|
#include "base/memory/scoped_ptr.h"
|
2013-02-02 01:21:59 +01:00
|
|
|
#include "base/message_loop.h"
|
2013-01-03 18:24:24 +01:00
|
|
|
#include "base/sequenced_task_runner.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "content/public/renderer/content_renderer_client.h"
|
|
|
|
|
|
|
|
class CefRenderProcessObserver;
|
2012-12-31 11:41:15 +01:00
|
|
|
struct Cef_CrossOriginWhiteListEntry_Params;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2013-02-02 01:21:59 +01:00
|
|
|
class CefContentRendererClient : public content::ContentRendererClient,
|
2013-04-16 00:16:01 +02:00
|
|
|
public base::MessageLoop::DestructionObserver {
|
2012-04-03 03:34:16 +02:00
|
|
|
public:
|
|
|
|
CefContentRendererClient();
|
|
|
|
virtual ~CefContentRendererClient();
|
|
|
|
|
|
|
|
// Returns the singleton CefContentRendererClient instance.
|
|
|
|
static CefContentRendererClient* Get();
|
|
|
|
|
|
|
|
// Returns the browser associated with the specified RenderView.
|
|
|
|
CefRefPtr<CefBrowserImpl> GetBrowserForView(content::RenderView* view);
|
|
|
|
|
|
|
|
// Returns the browser associated with the specified main WebFrame.
|
|
|
|
CefRefPtr<CefBrowserImpl> GetBrowserForMainFrame(WebKit::WebFrame* frame);
|
|
|
|
|
|
|
|
// Called from CefBrowserImpl::OnDestruct().
|
|
|
|
void OnBrowserDestroyed(CefBrowserImpl* browser);
|
|
|
|
|
2013-01-03 18:24:24 +01:00
|
|
|
// Render thread task runner.
|
|
|
|
base::SequencedTaskRunner* render_task_runner() const {
|
|
|
|
return render_task_runner_.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
int uncaught_exception_stack_size() const {
|
|
|
|
return uncaught_exception_stack_size_;
|
|
|
|
}
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2012-12-31 11:41:15 +01:00
|
|
|
void WebKitInitialized();
|
2013-01-03 18:24:24 +01:00
|
|
|
void OnRenderProcessShutdown();
|
2012-12-31 11:41:15 +01:00
|
|
|
|
2012-11-02 19:16:28 +01:00
|
|
|
void DevToolsAgentAttached();
|
|
|
|
void DevToolsAgentDetached();
|
2013-01-03 18:24:24 +01:00
|
|
|
|
|
|
|
// Returns the task runner for the current thread. If this is a WebWorker
|
|
|
|
// thread and the task runner does not already exist it will be created.
|
|
|
|
// Returns NULL if the current thread is not a valid render process thread.
|
|
|
|
scoped_refptr<base::SequencedTaskRunner> GetCurrentTaskRunner();
|
|
|
|
|
|
|
|
// Returns the task runner for the specified worker ID or NULL if the
|
|
|
|
// specified worker ID is not valid.
|
|
|
|
scoped_refptr<base::SequencedTaskRunner> GetWorkerTaskRunner(int worker_id);
|
|
|
|
|
|
|
|
// Remove the task runner associated with the specified worker ID.
|
|
|
|
void RemoveWorkerTaskRunner(int worker_id);
|
2012-11-02 19:16:28 +01:00
|
|
|
|
2013-02-02 01:21:59 +01:00
|
|
|
// Perform cleanup work that needs to occur before shutdown when running in
|
|
|
|
// single-process mode. Blocks until cleanup is complete.
|
|
|
|
void RunSingleProcessCleanup();
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
private:
|
|
|
|
// ContentRendererClient implementation.
|
|
|
|
virtual void RenderThreadStarted() OVERRIDE;
|
|
|
|
virtual void RenderViewCreated(content::RenderView* render_view) OVERRIDE;
|
2012-11-09 19:47:09 +01:00
|
|
|
virtual bool HandleNavigation(WebKit::WebFrame* frame,
|
|
|
|
const WebKit::WebURLRequest& request,
|
|
|
|
WebKit::WebNavigationType type,
|
|
|
|
WebKit::WebNavigationPolicy default_policy,
|
|
|
|
bool is_redirect) OVERRIDE;
|
2012-04-03 03:34:16 +02:00
|
|
|
virtual void DidCreateScriptContext(WebKit::WebFrame* frame,
|
|
|
|
v8::Handle<v8::Context> context,
|
|
|
|
int extension_group,
|
|
|
|
int world_id) OVERRIDE;
|
|
|
|
virtual void WillReleaseScriptContext(WebKit::WebFrame* frame,
|
|
|
|
v8::Handle<v8::Context> context,
|
|
|
|
int world_id) OVERRIDE;
|
|
|
|
|
2013-02-02 01:21:59 +01:00
|
|
|
// MessageLoop::DestructionObserver implementation.
|
|
|
|
virtual void WillDestroyCurrentMessageLoop() OVERRIDE;
|
|
|
|
|
|
|
|
// Perform cleanup work for single-process mode.
|
|
|
|
void RunSingleProcessCleanupOnUIThread();
|
|
|
|
|
2013-01-03 18:24:24 +01:00
|
|
|
scoped_refptr<base::SequencedTaskRunner> render_task_runner_;
|
2012-04-03 03:34:16 +02:00
|
|
|
scoped_ptr<CefRenderProcessObserver> observer_;
|
|
|
|
|
|
|
|
// Map of RenderView pointers to CefBrowserImpl references.
|
|
|
|
typedef std::map<content::RenderView*, CefRefPtr<CefBrowserImpl> > BrowserMap;
|
|
|
|
BrowserMap browsers_;
|
2012-04-24 20:01:48 +02:00
|
|
|
|
2012-12-31 11:41:15 +01:00
|
|
|
// Cross-origin white list entries that need to be registered with WebKit.
|
|
|
|
typedef std::vector<Cef_CrossOriginWhiteListEntry_Params> CrossOriginList;
|
|
|
|
CrossOriginList cross_origin_whitelist_entries_;
|
|
|
|
|
2012-11-02 19:16:28 +01:00
|
|
|
int devtools_agent_count_;
|
|
|
|
int uncaught_exception_stack_size_;
|
2013-01-03 18:24:24 +01:00
|
|
|
|
|
|
|
// Map of worker thread IDs to task runners. Access must be protected by
|
|
|
|
// |worker_task_runner_lock_|.
|
|
|
|
typedef std::map<int, scoped_refptr<base::SequencedTaskRunner> >
|
|
|
|
WorkerTaskRunnerMap;
|
|
|
|
WorkerTaskRunnerMap worker_task_runner_map_;
|
|
|
|
base::Lock worker_task_runner_lock_;
|
2013-02-02 01:21:59 +01:00
|
|
|
|
|
|
|
// Used in single-process mode to test when cleanup is complete.
|
|
|
|
// Access must be protected by |single_process_cleanup_lock_|.
|
|
|
|
bool single_process_cleanup_complete_;
|
|
|
|
base::Lock single_process_cleanup_lock_;
|
2012-04-03 03:34:16 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_RENDERER_CONTENT_RENDERER_CLIENT_H_
|