2012-04-03 03:34:16 +02:00
|
|
|
// Copyright (c) 2012 The Chromium Embedded Framework 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_FRAME_IMPL_H_
|
|
|
|
#define CEF_LIBCEF_RENDERER_FRAME_IMPL_H_
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
#include "include/cef_frame.h"
|
|
|
|
#include "include/cef_v8.h"
|
|
|
|
|
2021-05-14 18:58:55 +02:00
|
|
|
#include "base/memory/weak_ptr.h"
|
|
|
|
#include "cef/libcef/common/mojom/cef.mojom.h"
|
|
|
|
#include "mojo/public/cpp/bindings/pending_receiver.h"
|
|
|
|
#include "mojo/public/cpp/bindings/receiver_set.h"
|
|
|
|
#include "mojo/public/cpp/bindings/remote.h"
|
|
|
|
#include "services/service_manager/public/cpp/binder_registry.h"
|
|
|
|
|
2019-05-24 22:23:43 +02:00
|
|
|
namespace base {
|
|
|
|
class ListValue;
|
|
|
|
}
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2013-11-08 22:28:56 +01:00
|
|
|
namespace blink {
|
2020-12-02 23:31:49 +01:00
|
|
|
class ResourceLoadInfoNotifierWrapper;
|
2017-07-27 01:19:27 +02:00
|
|
|
class WebLocalFrame;
|
2020-12-02 23:31:49 +01:00
|
|
|
class WebURLLoader;
|
2019-05-11 00:14:48 +02:00
|
|
|
class WebURLLoaderFactory;
|
|
|
|
} // namespace blink
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2019-05-24 22:23:43 +02:00
|
|
|
class GURL;
|
|
|
|
|
|
|
|
class CefBrowserImpl;
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
// Implementation of CefFrame. CefFrameImpl objects are owned by the
|
|
|
|
// CefBrowerImpl and will be detached when the browser is notified that the
|
|
|
|
// associated renderer WebFrame will close.
|
2021-05-14 18:58:55 +02:00
|
|
|
class CefFrameImpl : public CefFrame, public cef::mojom::RenderFrame {
|
2012-04-03 03:34:16 +02:00
|
|
|
public:
|
2018-07-09 20:36:37 +02:00
|
|
|
CefFrameImpl(CefBrowserImpl* browser,
|
|
|
|
blink::WebLocalFrame* frame,
|
|
|
|
int64_t frame_id);
|
2014-11-12 20:25:15 +01:00
|
|
|
~CefFrameImpl() override;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
// CefFrame implementation.
|
2014-11-12 20:25:15 +01:00
|
|
|
bool IsValid() override;
|
|
|
|
void Undo() override;
|
|
|
|
void Redo() override;
|
|
|
|
void Cut() override;
|
|
|
|
void Copy() override;
|
|
|
|
void Paste() override;
|
|
|
|
void Delete() override;
|
|
|
|
void SelectAll() override;
|
|
|
|
void ViewSource() override;
|
|
|
|
void GetSource(CefRefPtr<CefStringVisitor> visitor) override;
|
|
|
|
void GetText(CefRefPtr<CefStringVisitor> visitor) override;
|
|
|
|
void LoadRequest(CefRefPtr<CefRequest> request) override;
|
|
|
|
void LoadURL(const CefString& url) override;
|
|
|
|
void ExecuteJavaScript(const CefString& jsCode,
|
|
|
|
const CefString& scriptUrl,
|
|
|
|
int startLine) override;
|
|
|
|
bool IsMain() override;
|
|
|
|
bool IsFocused() override;
|
|
|
|
CefString GetName() override;
|
|
|
|
int64 GetIdentifier() override;
|
|
|
|
CefRefPtr<CefFrame> GetParent() override;
|
|
|
|
CefString GetURL() override;
|
|
|
|
CefRefPtr<CefBrowser> GetBrowser() override;
|
|
|
|
CefRefPtr<CefV8Context> GetV8Context() override;
|
|
|
|
void VisitDOM(CefRefPtr<CefDOMVisitor> visitor) override;
|
2019-05-11 00:14:48 +02:00
|
|
|
CefRefPtr<CefURLRequest> CreateURLRequest(
|
|
|
|
CefRefPtr<CefRequest> request,
|
|
|
|
CefRefPtr<CefURLRequestClient> client) override;
|
2019-05-24 22:23:43 +02:00
|
|
|
void SendProcessMessage(CefProcessId target_process,
|
|
|
|
CefRefPtr<CefProcessMessage> message) override;
|
2019-05-11 00:14:48 +02:00
|
|
|
|
|
|
|
// Used by CefRenderURLRequest.
|
2020-12-02 23:31:49 +01:00
|
|
|
std::unique_ptr<blink::WebURLLoader> CreateURLLoader();
|
|
|
|
std::unique_ptr<blink::ResourceLoadInfoNotifierWrapper>
|
|
|
|
CreateResourceLoadInfoNotifierWrapper();
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2019-05-24 22:23:43 +02:00
|
|
|
// Forwarded from CefRenderFrameObserver.
|
2021-05-14 18:58:55 +02:00
|
|
|
void OnAttached(service_manager::BinderRegistry* registry);
|
2019-05-24 22:23:43 +02:00
|
|
|
void OnDidFinishLoad();
|
|
|
|
void OnDraggableRegionsChanged();
|
2021-05-21 03:42:58 +02:00
|
|
|
void OnContextCreated();
|
2019-05-24 22:23:43 +02:00
|
|
|
void OnDetached();
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2017-07-27 01:19:27 +02:00
|
|
|
blink::WebLocalFrame* web_frame() const { return frame_; }
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2016-07-21 23:21:32 +02:00
|
|
|
private:
|
2021-05-21 03:42:58 +02:00
|
|
|
// Execute an action on the associated WebLocalFrame. This will queue the
|
|
|
|
// action if the JavaScript context is not yet created.
|
|
|
|
using LocalFrameAction =
|
|
|
|
base::OnceCallback<void(blink::WebLocalFrame* frame)>;
|
|
|
|
void ExecuteOnLocalFrame(const std::string& function_name,
|
|
|
|
LocalFrameAction action);
|
|
|
|
|
2021-05-14 18:58:55 +02:00
|
|
|
// Returns the remote BrowserFrame object.
|
|
|
|
const mojo::Remote<cef::mojom::BrowserFrame>& GetBrowserFrame();
|
|
|
|
|
|
|
|
void BindRenderFrameReceiver(
|
|
|
|
mojo::PendingReceiver<cef::mojom::RenderFrame> receiver);
|
|
|
|
|
|
|
|
// cef::mojom::RenderFrame methods:
|
|
|
|
void SendMessage(const std::string& name, base::Value arguments) override;
|
|
|
|
void SendCommand(const std::string& command) override;
|
|
|
|
void SendCommandWithResponse(
|
|
|
|
const std::string& command,
|
|
|
|
cef::mojom::RenderFrame::SendCommandWithResponseCallback callback)
|
|
|
|
override;
|
|
|
|
void SendJavaScript(const std::u16string& jsCode,
|
|
|
|
const std::string& scriptUrl,
|
|
|
|
int32_t startLine) override;
|
|
|
|
void LoadRequest(cef::mojom::RequestParamsPtr params) override;
|
|
|
|
void DidStopLoading() override;
|
|
|
|
void MoveOrResizeStarted() override;
|
2019-05-24 22:23:43 +02:00
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
CefBrowserImpl* browser_;
|
2017-07-27 01:19:27 +02:00
|
|
|
blink::WebLocalFrame* frame_;
|
2019-05-24 22:23:43 +02:00
|
|
|
const int64 frame_id_;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2021-05-21 03:42:58 +02:00
|
|
|
bool context_created_ = false;
|
|
|
|
std::queue<std::pair<std::string, LocalFrameAction>> queued_actions_;
|
|
|
|
|
2019-05-11 00:14:48 +02:00
|
|
|
std::unique_ptr<blink::WebURLLoaderFactory> url_loader_factory_;
|
|
|
|
|
2021-05-14 18:58:55 +02:00
|
|
|
mojo::ReceiverSet<cef::mojom::RenderFrame> receivers_;
|
|
|
|
|
|
|
|
mojo::Remote<cef::mojom::BrowserFrame> browser_frame_;
|
|
|
|
|
|
|
|
base::WeakPtrFactory<CefFrameImpl> weak_ptr_factory_{this};
|
2019-05-24 22:23:43 +02:00
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
IMPLEMENT_REFCOUNTING(CefFrameImpl);
|
2015-12-09 17:10:16 +01:00
|
|
|
DISALLOW_COPY_AND_ASSIGN(CefFrameImpl);
|
2012-04-03 03:34:16 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CEF_LIBCEF_RENDERER_FRAME_IMPL_H_
|