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
|
|
|
|
|
2016-01-06 20:20:54 +01:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
#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"
|
|
|
|
|
|
|
|
#include "content/public/renderer/render_view_observer.h"
|
|
|
|
|
|
|
|
class GURL;
|
2014-07-16 23:27:25 +02:00
|
|
|
struct CefMsg_LoadRequest_Params;
|
2012-04-03 03:34:16 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 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(
|
2013-11-08 22:28:56 +01:00
|
|
|
blink::WebFrame* frame);
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
// CefBrowser methods.
|
2014-11-12 20:25:15 +01:00
|
|
|
CefRefPtr<CefBrowserHost> GetHost() override;
|
|
|
|
bool CanGoBack() override;
|
|
|
|
void GoBack() override;
|
|
|
|
bool CanGoForward() override;
|
|
|
|
void GoForward() override;
|
|
|
|
bool IsLoading() override;
|
|
|
|
void Reload() override;
|
|
|
|
void ReloadIgnoreCache() override;
|
|
|
|
void StopLoad() override;
|
|
|
|
int GetIdentifier() override;
|
|
|
|
bool IsSame(CefRefPtr<CefBrowser> that) override;
|
|
|
|
bool IsPopup() override;
|
|
|
|
bool HasDocument() override;
|
|
|
|
CefRefPtr<CefFrame> GetMainFrame() override;
|
|
|
|
CefRefPtr<CefFrame> GetFocusedFrame() override;
|
|
|
|
CefRefPtr<CefFrame> GetFrame(int64 identifier) override;
|
|
|
|
CefRefPtr<CefFrame> GetFrame(const CefString& name) override;
|
|
|
|
size_t GetFrameCount() override;
|
|
|
|
void GetFrameIdentifiers(std::vector<int64>& identifiers) override;
|
|
|
|
void GetFrameNames(std::vector<CefString>& names) override;
|
|
|
|
bool SendProcessMessage(
|
2012-04-03 03:34:16 +02:00
|
|
|
CefProcessId target_process,
|
2014-11-12 20:25:15 +01:00
|
|
|
CefRefPtr<CefProcessMessage> message) override;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2012-11-20 21:08:36 +01:00
|
|
|
CefBrowserImpl(content::RenderView* render_view,
|
|
|
|
int browser_id,
|
2014-07-01 00:30:29 +02:00
|
|
|
bool is_popup,
|
|
|
|
bool is_windowless);
|
2014-11-12 20:25:15 +01:00
|
|
|
~CefBrowserImpl() override;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2014-07-16 23:27:25 +02:00
|
|
|
void LoadRequest(const CefMsg_LoadRequest_Params& params);
|
2012-04-03 03:34:16 +02:00
|
|
|
|
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.
|
2013-11-08 22:28:56 +01:00
|
|
|
CefRefPtr<CefFrameImpl> GetWebFrameImpl(blink::WebFrame* frame);
|
2016-01-06 20:20:54 +01:00
|
|
|
CefRefPtr<CefFrameImpl> GetWebFrameImpl(int64_t frame_id);
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2012-04-27 23:19:06 +02:00
|
|
|
// Frame objects will be deleted immediately before the frame is closed.
|
2016-01-06 20:20:54 +01:00
|
|
|
void AddFrameObject(int64_t frame_id, CefTrackNode* tracked_object);
|
2012-04-27 23:19:06 +02:00
|
|
|
|
2012-12-30 12:17:49 +01:00
|
|
|
int browser_id() const { return browser_id_; }
|
|
|
|
bool is_popup() const { return is_popup_; }
|
2014-07-01 00:30:29 +02:00
|
|
|
bool is_windowless() const { return is_windowless_; }
|
2013-09-13 01:36:54 +02:00
|
|
|
content::RenderView* render_view() const {
|
2012-04-03 03:34:16 +02:00
|
|
|
return content::RenderViewObserver::render_view();
|
|
|
|
}
|
|
|
|
|
2013-09-13 01:36:54 +02:00
|
|
|
bool is_swapped_out() const;
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
private:
|
|
|
|
// RenderViewObserver methods.
|
2014-11-12 20:25:15 +01:00
|
|
|
void OnDestruct() override;
|
|
|
|
void DidStartLoading() override;
|
|
|
|
void DidStopLoading() override;
|
|
|
|
void DidFailLoad(blink::WebLocalFrame* frame,
|
|
|
|
const blink::WebURLError& error) override;
|
|
|
|
void DidFinishLoad(blink::WebLocalFrame* frame) override;
|
|
|
|
void DidStartProvisionalLoad(blink::WebLocalFrame* frame) override;
|
|
|
|
void DidFailProvisionalLoad(
|
2014-04-30 19:14:40 +02:00
|
|
|
blink::WebLocalFrame* frame,
|
2014-11-12 20:25:15 +01:00
|
|
|
const blink::WebURLError& error) override;
|
|
|
|
void DidCommitProvisionalLoad(blink::WebLocalFrame* frame,
|
|
|
|
bool is_new_navigation) override;
|
|
|
|
void FrameDetached(blink::WebFrame* frame) override;
|
|
|
|
void FocusedNodeChanged(const blink::WebNode& node) override;
|
2015-04-24 15:48:32 +02:00
|
|
|
void DraggableRegionsChanged(blink::WebFrame* frame) override;
|
2014-11-12 20:25:15 +01:00
|
|
|
bool OnMessageReceived(const IPC::Message& message) override;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
// RenderViewObserver::OnMessageReceived message handlers.
|
|
|
|
void OnRequest(const Cef_Request_Params& params);
|
|
|
|
void OnResponse(const Cef_Response_Params& params);
|
|
|
|
void OnResponseAck(int request_id);
|
|
|
|
|
2013-09-13 01:36:54 +02:00
|
|
|
void OnLoadingStateChange(bool isLoading);
|
2014-04-30 19:14:40 +02:00
|
|
|
void OnLoadStart(blink::WebLocalFrame* frame);
|
|
|
|
void OnLoadEnd(blink::WebLocalFrame* frame);
|
|
|
|
void OnLoadError(blink::WebLocalFrame* frame,
|
|
|
|
const blink::WebURLError& error);
|
2013-09-13 01:36:54 +02:00
|
|
|
|
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_;
|
2014-07-01 00:30:29 +02:00
|
|
|
bool is_windowless_;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
// 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.
|
2016-04-27 22:38:52 +02:00
|
|
|
std::unique_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_
|