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;
|
|
|
|
}
|
|
|
|
|
2017-05-31 17:33:30 +02:00
|
|
|
namespace blink {
|
2017-07-27 01:19:27 +02:00
|
|
|
class WebFrame;
|
2017-05-31 17:33:30 +02:00
|
|
|
class WebNode;
|
2017-07-27 01:19:27 +02:00
|
|
|
} // namespace blink
|
2017-05-31 17:33:30 +02:00
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
// 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.
|
2017-05-17 11:29:28 +02:00
|
|
|
class CefBrowserImpl : public CefBrowser, public content::RenderViewObserver {
|
2012-04-03 03:34:16 +02:00
|
|
|
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;
|
2017-05-17 11:29:28 +02:00
|
|
|
bool SendProcessMessage(CefProcessId target_process,
|
|
|
|
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.
|
2017-07-27 01:19:27 +02:00
|
|
|
CefRefPtr<CefFrameImpl> GetWebFrameImpl(blink::WebLocalFrame* 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();
|
|
|
|
}
|
|
|
|
|
|
|
|
// RenderViewObserver methods.
|
2014-11-12 20:25:15 +01:00
|
|
|
void OnDestruct() override;
|
2017-05-17 11:29:28 +02:00
|
|
|
void DidFailProvisionalLoad(blink::WebLocalFrame* frame,
|
|
|
|
const blink::WebURLError& error) override;
|
2014-11-12 20:25:15 +01:00
|
|
|
void DidCommitProvisionalLoad(blink::WebLocalFrame* frame,
|
|
|
|
bool is_new_navigation) override;
|
|
|
|
bool OnMessageReceived(const IPC::Message& message) override;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2017-05-31 17:33:30 +02:00
|
|
|
// Forwarded from CefRenderFrameObserver.
|
|
|
|
void DidFinishLoad(blink::WebLocalFrame* frame);
|
|
|
|
void DidStartProvisionalLoad(blink::WebLocalFrame* frame);
|
2017-07-27 01:19:27 +02:00
|
|
|
void FrameDetached(blink::WebLocalFrame* frame);
|
2017-05-31 17:33:30 +02:00
|
|
|
void FocusedNodeChanged(const blink::WebNode& node);
|
2017-07-27 01:19:27 +02:00
|
|
|
void DraggableRegionsChanged(blink::WebLocalFrame* frame);
|
2017-05-31 17:33:30 +02:00
|
|
|
|
|
|
|
private:
|
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);
|
2018-10-24 22:37:39 +02:00
|
|
|
void OnDidStopLoading();
|
2012-04-03 03:34:16 +02:00
|
|
|
|
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.
|
2017-05-17 11:29:28 +02:00
|
|
|
typedef std::map<int64, CefRefPtr<CefFrameImpl>> FrameMap;
|
2012-04-03 03:34:16 +02:00
|
|
|
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.
|
2017-05-17 11:29:28 +02:00
|
|
|
typedef std::map<int64, CefRefPtr<CefTrackManager>> FrameObjectMap;
|
2012-04-27 23:19:06 +02:00
|
|
|
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_
|