2012-04-03 03:34:16 +02:00
|
|
|
// Copyright (c) 2012 The Chromium Embedded Framework Authors.
|
|
|
|
// Portions 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_RENDERER_BROWSER_IMPL_H_
|
|
|
|
#define CEF_LIBCEF_RENDERER_BROWSER_IMPL_H_
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <map>
|
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
#include "include/cef_browser.h"
|
|
|
|
#include "include/cef_client.h"
|
2012-04-27 23:19:06 +02:00
|
|
|
#include "libcef/common/tracker.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "libcef/renderer/frame_impl.h"
|
|
|
|
|
2012-05-18 23:18:01 +02:00
|
|
|
#include "base/memory/scoped_ptr.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "content/public/renderer/render_view_observer.h"
|
|
|
|
|
|
|
|
class GURL;
|
|
|
|
struct CefMsg_LoadRequest_Params;
|
|
|
|
struct Cef_Request_Params;
|
|
|
|
struct Cef_Response_Params;
|
|
|
|
class CefContentRendererClient;
|
2012-05-18 23:18:01 +02:00
|
|
|
class CefResponseManager;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
namespace base {
|
|
|
|
class ListValue;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace WebKit {
|
|
|
|
class WebFrame;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Renderer plumbing for CEF features. There is a one-to-one relationship
|
|
|
|
// between RenderView on the renderer side and RenderViewHost on the browser
|
|
|
|
// side.
|
|
|
|
//
|
|
|
|
// RenderViewObserver: Interface for observing RenderView notifications and IPC
|
|
|
|
// messages. IPC messages received by the RenderView will be forwarded to this
|
|
|
|
// RenderViewObserver implementation. IPC messages sent using
|
|
|
|
// RenderViewObserver::Send() will be forwarded to the RenderView. Use
|
|
|
|
// RenderViewObserver::routing_id() when sending IPC messages.
|
|
|
|
class CefBrowserImpl : public CefBrowser,
|
|
|
|
public content::RenderViewObserver {
|
|
|
|
public:
|
|
|
|
// Returns the browser associated with the specified RenderView.
|
|
|
|
static CefRefPtr<CefBrowserImpl> GetBrowserForView(content::RenderView* view);
|
|
|
|
// Returns the browser associated with the specified main WebFrame.
|
|
|
|
static CefRefPtr<CefBrowserImpl> GetBrowserForMainFrame(
|
|
|
|
WebKit::WebFrame* frame);
|
|
|
|
|
|
|
|
// CefBrowser methods.
|
|
|
|
virtual CefRefPtr<CefBrowserHost> GetHost() OVERRIDE;
|
|
|
|
virtual bool CanGoBack() OVERRIDE;
|
|
|
|
virtual void GoBack() OVERRIDE;
|
|
|
|
virtual bool CanGoForward() OVERRIDE;
|
|
|
|
virtual void GoForward() OVERRIDE;
|
|
|
|
virtual bool IsLoading() OVERRIDE;
|
|
|
|
virtual void Reload() OVERRIDE;
|
|
|
|
virtual void ReloadIgnoreCache() OVERRIDE;
|
|
|
|
virtual void StopLoad() OVERRIDE;
|
|
|
|
virtual int GetIdentifier() OVERRIDE;
|
2012-12-30 12:17:49 +01:00
|
|
|
virtual bool IsSame(CefRefPtr<CefBrowser> that) OVERRIDE;
|
2012-04-03 03:34:16 +02:00
|
|
|
virtual bool IsPopup() OVERRIDE;
|
|
|
|
virtual bool HasDocument() OVERRIDE;
|
|
|
|
virtual CefRefPtr<CefFrame> GetMainFrame() OVERRIDE;
|
|
|
|
virtual CefRefPtr<CefFrame> GetFocusedFrame() OVERRIDE;
|
|
|
|
virtual CefRefPtr<CefFrame> GetFrame(int64 identifier) OVERRIDE;
|
|
|
|
virtual CefRefPtr<CefFrame> GetFrame(const CefString& name) OVERRIDE;
|
|
|
|
virtual size_t GetFrameCount() OVERRIDE;
|
|
|
|
virtual void GetFrameIdentifiers(std::vector<int64>& identifiers) OVERRIDE;
|
|
|
|
virtual void GetFrameNames(std::vector<CefString>& names) OVERRIDE;
|
|
|
|
virtual bool SendProcessMessage(
|
|
|
|
CefProcessId target_process,
|
|
|
|
CefRefPtr<CefProcessMessage> message) OVERRIDE;
|
|
|
|
|
2012-11-20 21:08:36 +01:00
|
|
|
CefBrowserImpl(content::RenderView* render_view,
|
|
|
|
int browser_id,
|
|
|
|
bool is_popup);
|
2012-04-03 03:34:16 +02:00
|
|
|
virtual ~CefBrowserImpl();
|
|
|
|
|
|
|
|
void LoadRequest(const CefMsg_LoadRequest_Params& params);
|
|
|
|
|
2012-10-18 00:45:49 +02:00
|
|
|
// Avoids unnecessary string type conversions.
|
|
|
|
bool SendProcessMessage(CefProcessId target_process,
|
|
|
|
const std::string& name,
|
|
|
|
base::ListValue* arguments,
|
|
|
|
bool user_initiated);
|
|
|
|
|
2012-06-11 17:52:49 +02:00
|
|
|
// Returns the matching CefFrameImpl reference or creates a new one.
|
2012-04-03 03:34:16 +02:00
|
|
|
CefRefPtr<CefFrameImpl> GetWebFrameImpl(WebKit::WebFrame* frame);
|
|
|
|
CefRefPtr<CefFrameImpl> GetWebFrameImpl(int64 frame_id);
|
|
|
|
|
2012-04-27 23:19:06 +02:00
|
|
|
// Frame objects will be deleted immediately before the frame is closed.
|
|
|
|
void AddFrameObject(int64 frame_id, CefTrackNode* tracked_object);
|
|
|
|
|
2012-12-30 12:17:49 +01:00
|
|
|
int browser_id() const { return browser_id_; }
|
|
|
|
bool is_popup() const { return is_popup_; }
|
2012-04-03 03:34:16 +02:00
|
|
|
content::RenderView* render_view() {
|
|
|
|
return content::RenderViewObserver::render_view();
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
// RenderViewObserver methods.
|
|
|
|
virtual void OnDestruct() OVERRIDE;
|
2012-11-21 23:11:22 +01:00
|
|
|
virtual void DidFinishLoad(WebKit::WebFrame* frame) OVERRIDE;
|
2012-04-03 03:34:16 +02:00
|
|
|
virtual void DidStartProvisionalLoad(WebKit::WebFrame* frame) OVERRIDE;
|
|
|
|
virtual void FrameDetached(WebKit::WebFrame* frame) OVERRIDE;
|
|
|
|
virtual void FocusedNodeChanged(const WebKit::WebNode& node) OVERRIDE;
|
|
|
|
virtual void DidCreateDataSource(WebKit::WebFrame* frame,
|
|
|
|
WebKit::WebDataSource* ds) OVERRIDE;
|
|
|
|
virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
|
|
|
|
|
|
|
|
// RenderViewObserver::OnMessageReceived message handlers.
|
|
|
|
void OnRequest(const Cef_Request_Params& params);
|
|
|
|
void OnResponse(const Cef_Response_Params& params);
|
|
|
|
void OnResponseAck(int request_id);
|
|
|
|
|
2012-12-30 12:17:49 +01:00
|
|
|
// ID of the browser that this RenderView is associated with. During loading
|
|
|
|
// of cross-origin requests multiple RenderViews may be associated with the
|
|
|
|
// same browser ID.
|
|
|
|
int browser_id_;
|
2012-04-03 03:34:16 +02:00
|
|
|
bool is_popup_;
|
|
|
|
|
|
|
|
// Id of the last frame that had focus.
|
|
|
|
int64 last_focused_frame_id_;
|
|
|
|
|
|
|
|
// Map of unique frame ids to CefFrameImpl references.
|
|
|
|
typedef std::map<int64, CefRefPtr<CefFrameImpl> > FrameMap;
|
|
|
|
FrameMap frames_;
|
|
|
|
|
2012-04-27 23:19:06 +02:00
|
|
|
// Map of unique frame ids to CefTrackManager objects that need to be cleaned
|
|
|
|
// up when the frame is deleted.
|
|
|
|
typedef std::map<int64, CefRefPtr<CefTrackManager> > FrameObjectMap;
|
|
|
|
FrameObjectMap frame_objects_;
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
// Manages response registrations.
|
2012-05-18 23:18:01 +02:00
|
|
|
scoped_ptr<CefResponseManager> response_manager_;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
IMPLEMENT_REFCOUNTING(CefBrowserImpl);
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(CefBrowserImpl);
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_RENDERER_BROWSER_IMPL_H_
|