2014-10-31 11:17:05 -07:00
|
|
|
// Copyright (c) 2014 GitHub, Inc.
|
2014-04-25 17:49:37 +08:00
|
|
|
// Use of this source code is governed by the MIT license that can be
|
2014-04-17 17:12:27 +08:00
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef ATOM_BROWSER_API_EVENT_H_
|
|
|
|
#define ATOM_BROWSER_API_EVENT_H_
|
|
|
|
|
|
|
|
#include "content/public/browser/web_contents_observer.h"
|
|
|
|
#include "native_mate/handle.h"
|
2016-08-26 15:30:02 -07:00
|
|
|
#include "native_mate/wrappable.h"
|
2014-04-17 17:12:27 +08:00
|
|
|
|
|
|
|
namespace IPC {
|
|
|
|
class Message;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace mate {
|
|
|
|
|
2018-04-17 21:44:10 -04:00
|
|
|
class Event : public Wrappable<Event>, public content::WebContentsObserver {
|
2014-04-17 17:12:27 +08:00
|
|
|
public:
|
|
|
|
static Handle<Event> Create(v8::Isolate* isolate);
|
|
|
|
|
2016-04-25 10:17:54 +09:00
|
|
|
static void BuildPrototype(v8::Isolate* isolate,
|
2016-08-02 18:08:12 +09:00
|
|
|
v8::Local<v8::FunctionTemplate> prototype);
|
2016-04-25 10:17:54 +09:00
|
|
|
|
2014-04-17 17:12:27 +08:00
|
|
|
// Pass the sender and message to be replied.
|
2018-03-09 15:01:09 +05:30
|
|
|
void SetSenderAndMessage(content::RenderFrameHost* sender,
|
|
|
|
IPC::Message* message);
|
2014-04-17 17:12:27 +08:00
|
|
|
|
|
|
|
// event.PreventDefault().
|
2014-10-27 17:55:28 +08:00
|
|
|
void PreventDefault(v8::Isolate* isolate);
|
2014-04-17 17:12:27 +08:00
|
|
|
|
2018-06-13 04:38:31 -03:00
|
|
|
// event.sendReply(array), used for replying synchronous message.
|
|
|
|
bool SendReply(const base::ListValue& result);
|
2014-04-17 17:12:27 +08:00
|
|
|
|
|
|
|
protected:
|
2016-04-25 10:17:54 +09:00
|
|
|
explicit Event(v8::Isolate* isolate);
|
|
|
|
~Event() override;
|
2014-04-17 17:12:27 +08:00
|
|
|
|
|
|
|
// content::WebContentsObserver implementations:
|
2018-03-09 15:01:09 +05:30
|
|
|
void RenderFrameDeleted(content::RenderFrameHost* rfh) override;
|
|
|
|
void RenderFrameHostChanged(content::RenderFrameHost* old_rfh,
|
|
|
|
content::RenderFrameHost* new_rfh) override;
|
|
|
|
void FrameDeleted(content::RenderFrameHost* rfh) override;
|
2014-04-17 17:12:27 +08:00
|
|
|
|
|
|
|
private:
|
|
|
|
// Replyer for the synchronous messages.
|
2018-05-22 00:18:38 +02:00
|
|
|
content::RenderFrameHost* sender_ = nullptr;
|
|
|
|
IPC::Message* message_ = nullptr;
|
2014-04-17 17:12:27 +08:00
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(Event);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace mate
|
|
|
|
|
|
|
|
#endif // ATOM_BROWSER_API_EVENT_H_
|