2013-04-18 13:42:20 +00:00
|
|
|
// Copyright (c) 2013 GitHub, Inc. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
|
|
// found in the LICENSE file.
|
|
|
|
|
|
|
|
#ifndef ATOM_BROWSER_ATOM_API_EVENT_H_
|
|
|
|
#define ATOM_BROWSER_ATOM_API_EVENT_H_
|
|
|
|
|
|
|
|
#include "base/basictypes.h"
|
2013-09-22 02:43:54 +00:00
|
|
|
#include "base/compiler_specific.h"
|
2013-12-10 06:14:05 +00:00
|
|
|
#include "base/strings/string16.h"
|
2014-03-16 00:30:26 +00:00
|
|
|
#include "atom/browser/native_window_observer.h"
|
|
|
|
#include "atom/common/v8/scoped_persistent.h"
|
2013-04-18 13:42:20 +00:00
|
|
|
#include "vendor/node/src/node_object_wrap.h"
|
|
|
|
|
2013-09-22 01:52:58 +00:00
|
|
|
namespace IPC {
|
|
|
|
class Message;
|
|
|
|
}
|
|
|
|
|
2013-04-18 13:42:20 +00:00
|
|
|
namespace atom {
|
|
|
|
|
2013-09-22 02:43:54 +00:00
|
|
|
class NativeWindow;
|
|
|
|
|
2013-04-18 13:42:20 +00:00
|
|
|
namespace api {
|
|
|
|
|
2013-09-22 02:43:54 +00:00
|
|
|
class Event : public node::ObjectWrap,
|
|
|
|
public NativeWindowObserver {
|
2013-04-18 13:42:20 +00:00
|
|
|
public:
|
|
|
|
virtual ~Event();
|
|
|
|
|
|
|
|
// Create a V8 Event object.
|
|
|
|
static v8::Handle<v8::Object> CreateV8Object();
|
|
|
|
|
2013-09-22 01:52:58 +00:00
|
|
|
// Pass the sender and message to be replied.
|
2013-09-22 02:43:54 +00:00
|
|
|
void SetSenderAndMessage(NativeWindow* sender, IPC::Message* message);
|
2013-09-22 01:52:58 +00:00
|
|
|
|
2013-04-18 13:42:20 +00:00
|
|
|
// Whether event.preventDefault() is called.
|
|
|
|
bool prevent_default() const { return prevent_default_; }
|
|
|
|
|
|
|
|
protected:
|
|
|
|
Event();
|
|
|
|
|
2013-09-22 02:43:54 +00:00
|
|
|
// NativeWindowObserver implementations:
|
|
|
|
virtual void OnWindowClosed() OVERRIDE;
|
|
|
|
|
2013-04-18 13:42:20 +00:00
|
|
|
private:
|
2013-12-11 07:48:19 +00:00
|
|
|
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
|
2013-09-22 01:52:58 +00:00
|
|
|
|
2013-12-11 07:48:19 +00:00
|
|
|
static void PreventDefault(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void SendReply(const v8::FunctionCallbackInfo<v8::Value>& args);
|
|
|
|
static void Destroy(const v8::FunctionCallbackInfo<v8::Value>& args);
|
2013-04-18 13:42:20 +00:00
|
|
|
|
2013-12-11 07:48:19 +00:00
|
|
|
static ScopedPersistent<v8::Function> constructor_template_;
|
2013-04-18 13:42:20 +00:00
|
|
|
|
2013-09-22 01:52:58 +00:00
|
|
|
// Replyer for the synchronous messages.
|
2013-09-22 02:43:54 +00:00
|
|
|
NativeWindow* sender_;
|
2013-09-22 01:52:58 +00:00
|
|
|
IPC::Message* message_;
|
|
|
|
|
2013-04-18 13:42:20 +00:00
|
|
|
bool prevent_default_;
|
|
|
|
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(Event);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace api
|
|
|
|
|
|
|
|
} // namespace atom
|
|
|
|
|
|
|
|
#endif // ATOM_BROWSER_ATOM_API_EVENT_H_
|