-
Notifications
You must be signed in to change notification settings - Fork 15k
/
electron_api_web_frame_main.h
104 lines (79 loc) · 3.2 KB
/
electron_api_web_frame_main.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
// Copyright (c) 2020 Samuel Maddock <sam@samuelmaddock.com>.
// Use of this source code is governed by the MIT license that can be
// found in the LICENSE file.
#ifndef SHELL_BROWSER_API_ELECTRON_API_WEB_FRAME_MAIN_H_
#define SHELL_BROWSER_API_ELECTRON_API_WEB_FRAME_MAIN_H_
#include <memory>
#include <string>
#include <vector>
#include "base/process/process.h"
#include "gin/handle.h"
#include "gin/wrappable.h"
#include "shell/common/gin_helper/constructible.h"
class GURL;
namespace content {
class RenderFrameHost;
}
namespace gin {
class Arguments;
}
namespace gin_helper {
class Dictionary;
}
namespace electron {
namespace api {
// Bindings for accessing frames from the main process.
class WebFrameMain : public gin::Wrappable<WebFrameMain>,
public gin_helper::Constructible<WebFrameMain> {
public:
// Create a new WebFrameMain and return the V8 wrapper of it.
static gin::Handle<WebFrameMain> New(v8::Isolate* isolate);
static gin::Handle<WebFrameMain> FromID(v8::Isolate* isolate,
int render_process_id,
int render_frame_id);
static gin::Handle<WebFrameMain> From(
v8::Isolate* isolate,
content::RenderFrameHost* render_frame_host);
// Called to mark any RenderFrameHost as disposed by any WebFrameMain that
// may be holding a weak reference.
static void RenderFrameDeleted(content::RenderFrameHost* rfh);
// Mark RenderFrameHost as disposed and to no longer access it. This can
// occur upon frame navigation.
void MarkRenderFrameDisposed();
// gin::Wrappable
static gin::WrapperInfo kWrapperInfo;
static v8::Local<v8::ObjectTemplate> FillObjectTemplate(
v8::Isolate*,
v8::Local<v8::ObjectTemplate>);
const char* GetTypeName() override;
protected:
explicit WebFrameMain(content::RenderFrameHost* render_frame);
~WebFrameMain() override;
private:
// WebFrameMain can outlive its RenderFrameHost pointer so we need to check
// whether its been disposed of prior to accessing it.
bool CheckRenderFrame() const;
v8::Local<v8::Promise> ExecuteJavaScript(gin::Arguments* args,
const base::string16& code);
bool Reload(v8::Isolate* isolate);
bool Send(const std::string& channel, v8::Local<v8::Value> args);
int FrameTreeNodeID(v8::Isolate* isolate) const;
std::string Name(v8::Isolate* isolate) const;
base::ProcessId OSProcessID(v8::Isolate* isolate) const;
int ProcessID(v8::Isolate* isolate) const;
int RoutingID(v8::Isolate* isolate) const;
GURL URL(v8::Isolate* isolate) const;
content::RenderFrameHost* Top(v8::Isolate* isolate) const;
content::RenderFrameHost* Parent(v8::Isolate* isolate) const;
std::vector<content::RenderFrameHost*> Frames(v8::Isolate* isolate) const;
std::vector<content::RenderFrameHost*> FramesInSubtree(
v8::Isolate* isolate) const;
content::RenderFrameHost* render_frame_ = nullptr;
// Whether the RenderFrameHost has been removed and that it should no longer
// be accessed.
bool render_frame_disposed_ = false;
DISALLOW_COPY_AND_ASSIGN(WebFrameMain);
};
} // namespace api
} // namespace electron
#endif // SHELL_BROWSER_API_ELECTRON_API_WEB_FRAME_MAIN_H_