|
@@ -18,14 +18,19 @@
|
|
|
18
18
|
*/
|
|
19
19
|
|
|
20
20
|
#include "OutOfProcess.h"
|
|
21
|
-
#include <interfaces/json/
|
|
21
|
+
#include <interfaces/json/JWebBrowser.h>
|
|
22
|
+
#include <interfaces/json/JWebBrowserExt.h>
|
|
23
|
+
#include <interfaces/json/JBrowserResources.h>
|
|
24
|
+
#include <interfaces/json/JBrowserSecurity.h>
|
|
25
|
+
#include <interfaces/json/JBrowserScripting.h>
|
|
26
|
+
#include <interfaces/json/JBrowserCookieJar.h>
|
|
22
27
|
|
|
23
28
|
namespace Thunder {
|
|
24
29
|
namespace Plugin {
|
|
25
30
|
|
|
26
31
|
namespace {
|
|
27
32
|
|
|
28
|
-
static Metadata<OutOfProcess>metadata(
|
|
33
|
+
static Metadata<OutOfProcess> metadata(
|
|
29
34
|
// Version
|
|
30
35
|
1, 0, 0,
|
|
31
36
|
// Preconditions
|
|
@@ -78,11 +83,14 @@ namespace Plugin {
|
|
|
78
83
|
if (_implBrowserCookieJar == nullptr) {
|
|
79
84
|
message = _T("Failed to acquire IBrowserCookieJar interface.");
|
|
80
85
|
} else {
|
|
86
|
+
_implBrowser->Register(&_notification);
|
|
87
|
+
_implWebBrowser->Register(&_notification);
|
|
81
88
|
Exchange::JWebBrowser::Register(*this, _implWebBrowser);
|
|
82
89
|
Exchange::JWebBrowserExt::Register(*this, _implWebBrowserExt);
|
|
83
90
|
Exchange::JBrowserResources::Register(*this, _implBrowserResources);
|
|
84
91
|
Exchange::JBrowserSecurity::Register(*this, _implBrowserSecurity);
|
|
85
92
|
Exchange::JBrowserScripting::Register(*this, _implBrowserScripting);
|
|
93
|
+
_implBrowserCookieJar->Register(&_notification);
|
|
86
94
|
Exchange::JBrowserCookieJar::Register(*this, _implBrowserCookieJar);
|
|
87
95
|
}
|
|
88
96
|
}
|
|
@@ -106,6 +114,7 @@ namespace Plugin {
|
|
|
106
114
|
|
|
107
115
|
if (_implWebBrowser != nullptr) {
|
|
108
116
|
Exchange::JWebBrowser::Unregister(*this);
|
|
117
|
+
_implWebBrowser->Unregister(&_notification);
|
|
109
118
|
_implWebBrowser->Release();
|
|
110
119
|
_implWebBrowser = nullptr;
|
|
111
120
|
}
|
|
@@ -136,9 +145,11 @@ namespace Plugin {
|
|
|
136
145
|
|
|
137
146
|
if (_implBrowserCookieJar != nullptr) {
|
|
138
147
|
Exchange::JBrowserCookieJar::Unregister(*this);
|
|
148
|
+
_implBrowserCookieJar->Unregister(&_notification);
|
|
139
149
|
_implBrowserCookieJar->Release();
|
|
140
150
|
_implBrowserCookieJar = nullptr;
|
|
141
151
|
}
|
|
152
|
+
_implBrowser->Unregister(&_notification);
|
|
142
153
|
|
|
143
154
|
RPC::IRemoteConnection* connection(service->RemoteConnection(_connectionId));
|
|
144
155
|
VARIABLE_IS_NOT_USED uint32_t result = _implBrowser->Release();
|
|
@@ -178,10 +189,27 @@ namespace Plugin {
|
|
|
178
189
|
if (interfaceId == Exchange::IBrowser::INotification::ID) {
|
|
179
190
|
auto* revokedInterface = remote->QueryInterface<Exchange::IBrowser::INotification>();
|
|
180
191
|
if (revokedInterface) {
|
|
181
|
-
_implBrowser->Unregister(revokedInterface);
|
|
192
|
+
_implBrowser->Unregister(const_cast<Exchange::IBrowser::INotification*>(revokedInterface));
|
|
182
193
|
revokedInterface->Release();
|
|
183
194
|
}
|
|
184
195
|
}
|
|
196
|
+
|
|
197
|
+
if (interfaceId == Exchange::IWebBrowser::INotification::ID) {
|
|
198
|
+
auto* revokedInterface = remote->QueryInterface<Exchange::IWebBrowser::INotification>();
|
|
199
|
+
if (revokedInterface) {
|
|
200
|
+
_implWebBrowser->Unregister(const_cast<Exchange::IWebBrowser::INotification*>(revokedInterface));
|
|
201
|
+
revokedInterface->Release();
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
if (interfaceId == Exchange::IBrowserCookieJar::INotification::ID) {
|
|
206
|
+
auto* revokedInterface = remote->QueryInterface<Exchange::IBrowserCookieJar::INotification>();
|
|
207
|
+
if (revokedInterface) {
|
|
208
|
+
_implBrowserCookieJar->Unregister(const_cast<Exchange::IBrowserCookieJar::INotification*>(revokedInterface));
|
|
209
|
+
revokedInterface->Release();
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
185
213
|
}
|
|
186
214
|
|
|
187
215
|
} // Plugin
|
|
@@ -21,7 +21,8 @@
|
|
|
21
21
|
|
|
22
22
|
#include "Module.h"
|
|
23
23
|
#include <interfaces/IBrowser.h>
|
|
24
|
-
#include <interfaces/json/
|
|
24
|
+
#include <interfaces/json/JWebBrowser.h>
|
|
25
|
+
#include <interfaces/json/JBrowserCookieJar.h>
|
|
25
26
|
|
|
26
27
|
namespace Thunder {
|
|
27
28
|
namespace Plugin {
|
|
@@ -50,7 +51,8 @@ namespace Plugin {
|
|
|
50
51
|
}
|
|
51
52
|
|
|
52
53
|
~OutOfProcess() override = default;
|
|
53
|
-
|
|
54
|
+
private:
|
|
55
|
+
class Notification : public RPC::IRemoteConnection::INotification, public PluginHost::IShell::ICOMLink::INotification, public Exchange::IWebBrowser::INotification, public Exchange::IBrowserCookieJar::INotification {
|
|
54
56
|
public:
|
|
55
57
|
Notification(const Notification&) = delete;
|
|
56
58
|
Notification& operator=(const Notification&) = delete;
|
|
@@ -61,7 +63,8 @@ namespace Plugin {
|
|
|
61
63
|
explicit Notification(OutOfProcess& parent)
|
|
62
64
|
: RPC::IRemoteConnection::INotification()
|
|
63
65
|
, PluginHost::IShell::ICOMLink::INotification()
|
|
64
|
-
, Exchange::
|
|
66
|
+
, Exchange::IWebBrowser::INotification()
|
|
67
|
+
, Exchange::IBrowserCookieJar::INotification()
|
|
65
68
|
, _parent(parent)
|
|
66
69
|
{
|
|
67
70
|
}
|
|
@@ -79,22 +82,32 @@ namespace Plugin {
|
|
|
79
82
|
void Dangling(const Core::IUnknown* remote, const uint32_t interfaceId) override {
|
|
80
83
|
_parent.Dangling(remote, interfaceId);
|
|
81
84
|
}
|
|
82
|
-
void LoadFinished(const string& URL) override {
|
|
83
|
-
Exchange::
|
|
85
|
+
void LoadFinished(const string& URL, const int32_t httpstatus) override {
|
|
86
|
+
Exchange::JWebBrowser::Event::LoadFinished(_parent, URL, httpstatus);
|
|
87
|
+
}
|
|
88
|
+
void LoadFailed(const string& URL) override {
|
|
89
|
+
Exchange::JWebBrowser::Event::LoadFailed(_parent, URL);
|
|
90
|
+
}
|
|
91
|
+
void URLChange(const string& URL, const bool loaded) override {
|
|
92
|
+
Exchange::JWebBrowser::Event::URLChange(_parent, URL, loaded);
|
|
93
|
+
}
|
|
94
|
+
void VisibilityChange(const bool hidden) override {
|
|
95
|
+
Exchange::JWebBrowser::Event::VisibilityChange(_parent, hidden);
|
|
84
96
|
}
|
|
85
|
-
void
|
|
86
|
-
Exchange::
|
|
97
|
+
void PageClosure() override {
|
|
98
|
+
Exchange::JWebBrowser::Event::PageClosure(_parent);
|
|
87
99
|
}
|
|
88
|
-
void
|
|
89
|
-
Exchange::
|
|
100
|
+
void BridgeQuery(const string& message) override {
|
|
101
|
+
Exchange::JWebBrowser::Event::BridgeQuery(_parent, message);
|
|
90
102
|
}
|
|
91
|
-
void
|
|
92
|
-
Exchange::
|
|
103
|
+
void CookieJarChanged() override {
|
|
104
|
+
Exchange::JBrowserCookieJar::Event::CookieJarChanged(_parent);
|
|
93
105
|
}
|
|
94
106
|
BEGIN_INTERFACE_MAP(Notification)
|
|
95
107
|
INTERFACE_ENTRY(RPC::IRemoteConnection::INotification)
|
|
96
108
|
INTERFACE_ENTRY(PluginHost::IShell::ICOMLink::INotification)
|
|
97
|
-
INTERFACE_ENTRY(Exchange::
|
|
109
|
+
INTERFACE_ENTRY(Exchange::IWebBrowser::INotification)
|
|
110
|
+
INTERFACE_ENTRY(Exchange::IBrowserCookieJar::INotification)
|
|
98
111
|
END_INTERFACE_MAP
|
|
99
112
|
private:
|
|
100
113
|
OutOfProcess& _parent;
|
|
@@ -39,7 +39,8 @@ namespace Plugin {
|
|
|
39
39
|
, Exchange::IBrowserScripting()
|
|
40
40
|
, Exchange::IBrowserCookieJar()
|
|
41
41
|
, _adminLock()
|
|
42
|
-
,
|
|
42
|
+
, _webbrowserNotification()
|
|
43
|
+
, _browsercookiejarNotification()
|
|
43
44
|
{
|
|
44
45
|
}
|
|
45
46
|
~OutOfProcessImplementation() override = default;
|
|
@@ -56,47 +57,22 @@ namespace Plugin {
|
|
|
56
57
|
INTERFACE_ENTRY(Exchange::IBrowserCookieJar)
|
|
57
58
|
END_INTERFACE_MAP
|
|
58
59
|
|
|
59
|
-
//
|
|
60
|
-
|
|
61
|
-
void Register(Exchange::IBrowser::INotification* notification) override {
|
|
62
|
-
|
|
63
|
-
ASSERT(notification != nullptr);
|
|
60
|
+
// Type aliases copied from interface headers
|
|
61
|
+
using IStringIterator = RPC::IIteratorType<string, RPC::ID_STRINGITERATOR>;
|
|
64
62
|
|
|
65
|
-
|
|
66
|
-
auto item = std::find(_browserNotification.begin(), _browserNotification.end(), notification);
|
|
67
|
-
ASSERT(item == _browserNotification.end());
|
|
68
|
-
|
|
69
|
-
if (item == _browserNotification.end()) {
|
|
70
|
-
notification->AddRef();
|
|
71
|
-
_browserNotification.push_back(notification);
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
_adminLock.Unlock();
|
|
63
|
+
// IBrowser methods
|
|
75
64
|
|
|
65
|
+
void Register(IBrowser::INotification* /* sink */) override {
|
|
76
66
|
}
|
|
77
67
|
|
|
78
|
-
void Unregister(
|
|
79
|
-
|
|
80
|
-
ASSERT(notification != nullptr);
|
|
81
|
-
|
|
82
|
-
_adminLock.Lock();
|
|
83
|
-
auto item = std::find(_browserNotification.begin(), _browserNotification.end(), notification);
|
|
84
|
-
ASSERT(item != _browserNotification.end());
|
|
85
|
-
|
|
86
|
-
if (item != _browserNotification.end()) {
|
|
87
|
-
_browserNotification.erase(item);
|
|
88
|
-
notification->Release();
|
|
89
|
-
}
|
|
90
|
-
_adminLock.Unlock();
|
|
91
|
-
|
|
68
|
+
void Unregister(IBrowser::INotification* /* sink */) override {
|
|
92
69
|
}
|
|
93
70
|
|
|
94
71
|
void SetURL(const string& /* URL */) override {
|
|
95
|
-
return Core::ERROR_NONE;
|
|
96
72
|
}
|
|
97
73
|
|
|
98
74
|
string GetURL() const override {
|
|
99
|
-
return
|
|
75
|
+
return string();
|
|
100
76
|
}
|
|
101
77
|
|
|
102
78
|
uint32_t GetFPS() const override {
|
|
@@ -104,41 +80,37 @@ namespace Plugin {
|
|
|
104
80
|
}
|
|
105
81
|
|
|
106
82
|
void Hide(const bool /* hidden */) override {
|
|
107
|
-
return Core::ERROR_NONE;
|
|
108
83
|
}
|
|
109
84
|
|
|
110
85
|
// IWebBrowser methods
|
|
111
86
|
|
|
112
|
-
void
|
|
113
|
-
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
void LoadFailed(const string& /* URL */) override {
|
|
117
|
-
return Core::ERROR_NONE;
|
|
118
|
-
}
|
|
87
|
+
void Register(Exchange::IWebBrowser::INotification* notification) override {
|
|
88
|
+
ASSERT(notification != nullptr);
|
|
119
89
|
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
90
|
+
_adminLock.Lock();
|
|
91
|
+
auto item = std::find(_webbrowserNotification.begin(), _webbrowserNotification.end(), notification);
|
|
92
|
+
ASSERT(item == _webbrowserNotification.end());
|
|
123
93
|
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
94
|
+
if (item == _webbrowserNotification.end()) {
|
|
95
|
+
notification->AddRef();
|
|
96
|
+
_webbrowserNotification.push_back(notification);
|
|
97
|
+
}
|
|
127
98
|
|
|
128
|
-
|
|
129
|
-
return Core::ERROR_NONE;
|
|
99
|
+
_adminLock.Unlock();
|
|
130
100
|
}
|
|
131
101
|
|
|
132
|
-
void
|
|
133
|
-
|
|
134
|
-
}
|
|
102
|
+
void Unregister(Exchange::IWebBrowser::INotification* notification) override {
|
|
103
|
+
ASSERT(notification != nullptr);
|
|
135
104
|
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
105
|
+
_adminLock.Lock();
|
|
106
|
+
auto item = std::find(_webbrowserNotification.begin(), _webbrowserNotification.end(), notification);
|
|
107
|
+
ASSERT(item != _webbrowserNotification.end());
|
|
139
108
|
|
|
140
|
-
|
|
141
|
-
|
|
109
|
+
if (item != _webbrowserNotification.end()) {
|
|
110
|
+
_webbrowserNotification.erase(item);
|
|
111
|
+
notification->Release();
|
|
112
|
+
}
|
|
113
|
+
_adminLock.Unlock();
|
|
142
114
|
}
|
|
143
115
|
|
|
144
116
|
uint32_t URL(string& /* url */ /* @out */) const override {
|
|
@@ -279,16 +251,33 @@ namespace Plugin {
|
|
|
279
251
|
|
|
280
252
|
// IBrowserCookieJar methods
|
|
281
253
|
|
|
282
|
-
void
|
|
283
|
-
|
|
284
|
-
}
|
|
254
|
+
void Register(Exchange::IBrowserCookieJar::INotification* notification) override {
|
|
255
|
+
ASSERT(notification != nullptr);
|
|
285
256
|
|
|
286
|
-
|
|
287
|
-
|
|
257
|
+
_adminLock.Lock();
|
|
258
|
+
auto item = std::find(_browsercookiejarNotification.begin(), _browsercookiejarNotification.end(), notification);
|
|
259
|
+
ASSERT(item == _browsercookiejarNotification.end());
|
|
260
|
+
|
|
261
|
+
if (item == _browsercookiejarNotification.end()) {
|
|
262
|
+
notification->AddRef();
|
|
263
|
+
_browsercookiejarNotification.push_back(notification);
|
|
264
|
+
}
|
|
265
|
+
|
|
266
|
+
_adminLock.Unlock();
|
|
288
267
|
}
|
|
289
268
|
|
|
290
|
-
void Unregister(INotification*
|
|
291
|
-
|
|
269
|
+
void Unregister(Exchange::IBrowserCookieJar::INotification* notification) override {
|
|
270
|
+
ASSERT(notification != nullptr);
|
|
271
|
+
|
|
272
|
+
_adminLock.Lock();
|
|
273
|
+
auto item = std::find(_browsercookiejarNotification.begin(), _browsercookiejarNotification.end(), notification);
|
|
274
|
+
ASSERT(item != _browsercookiejarNotification.end());
|
|
275
|
+
|
|
276
|
+
if (item != _browsercookiejarNotification.end()) {
|
|
277
|
+
_browsercookiejarNotification.erase(item);
|
|
278
|
+
notification->Release();
|
|
279
|
+
}
|
|
280
|
+
_adminLock.Unlock();
|
|
292
281
|
}
|
|
293
282
|
|
|
294
283
|
uint32_t CookieJar(Config& /* cookieJarInfo */ /* @out */) const override {
|
|
@@ -298,8 +287,10 @@ namespace Plugin {
|
|
|
298
287
|
uint32_t CookieJar(const Config& /* cookieJarInfo */) override {
|
|
299
288
|
return Core::ERROR_NONE;
|
|
300
289
|
}
|
|
290
|
+
|
|
301
291
|
private:
|
|
302
|
-
using
|
|
292
|
+
using WebBrowserNotificationContainer = std::vector<Exchange::IWebBrowser::INotification*>;
|
|
293
|
+
using BrowserCookieJarNotificationContainer = std::vector<Exchange::IBrowserCookieJar::INotification*>;
|
|
303
294
|
|
|
304
295
|
void NotifyLoadFinished(const string& URL) const {
|
|
305
296
|
_adminLock.Lock();
|
|
@@ -333,8 +324,65 @@ namespace Plugin {
|
|
|
333
324
|
_adminLock.Unlock();
|
|
334
325
|
}
|
|
335
326
|
|
|
327
|
+
void NotifyLoadFinished(const string& URL, const int32_t httpstatus) const {
|
|
328
|
+
_adminLock.Lock();
|
|
329
|
+
for (auto* notification : _webbrowserNotification) {
|
|
330
|
+
notification->LoadFinished(URL, httpstatus);
|
|
331
|
+
}
|
|
332
|
+
_adminLock.Unlock();
|
|
333
|
+
}
|
|
334
|
+
|
|
335
|
+
void NotifyLoadFailed(const string& URL) const {
|
|
336
|
+
_adminLock.Lock();
|
|
337
|
+
for (auto* notification : _webbrowserNotification) {
|
|
338
|
+
notification->LoadFailed(URL);
|
|
339
|
+
}
|
|
340
|
+
_adminLock.Unlock();
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
void NotifyURLChange(const string& URL, const bool loaded) const {
|
|
344
|
+
_adminLock.Lock();
|
|
345
|
+
for (auto* notification : _webbrowserNotification) {
|
|
346
|
+
notification->URLChange(URL, loaded);
|
|
347
|
+
}
|
|
348
|
+
_adminLock.Unlock();
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
void NotifyVisibilityChange(const bool hidden) const {
|
|
352
|
+
_adminLock.Lock();
|
|
353
|
+
for (auto* notification : _webbrowserNotification) {
|
|
354
|
+
notification->VisibilityChange(hidden);
|
|
355
|
+
}
|
|
356
|
+
_adminLock.Unlock();
|
|
357
|
+
}
|
|
358
|
+
|
|
359
|
+
void NotifyPageClosure() const {
|
|
360
|
+
_adminLock.Lock();
|
|
361
|
+
for (auto* notification : _webbrowserNotification) {
|
|
362
|
+
notification->PageClosure();
|
|
363
|
+
}
|
|
364
|
+
_adminLock.Unlock();
|
|
365
|
+
}
|
|
366
|
+
|
|
367
|
+
void NotifyBridgeQuery(const string& message) const {
|
|
368
|
+
_adminLock.Lock();
|
|
369
|
+
for (auto* notification : _webbrowserNotification) {
|
|
370
|
+
notification->BridgeQuery(message);
|
|
371
|
+
}
|
|
372
|
+
_adminLock.Unlock();
|
|
373
|
+
}
|
|
374
|
+
|
|
375
|
+
void NotifyCookieJarChanged() const {
|
|
376
|
+
_adminLock.Lock();
|
|
377
|
+
for (auto* notification : _browsercookiejarNotification) {
|
|
378
|
+
notification->CookieJarChanged();
|
|
379
|
+
}
|
|
380
|
+
_adminLock.Unlock();
|
|
381
|
+
}
|
|
382
|
+
|
|
336
383
|
mutable Core::CriticalSection _adminLock;
|
|
337
|
-
|
|
384
|
+
WebBrowserNotificationContainer _webbrowserNotification;
|
|
385
|
+
BrowserCookieJarNotificationContainer _browsercookiejarNotification;
|
|
338
386
|
};
|
|
339
387
|
|
|
340
388
|
SERVICE_REGISTRATION(OutOfProcessImplementation, 1, 0)
|