electron/atom/browser/api/atom_api_event.h

66 lines
1.7 KiB
C
Raw Normal View History

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.
2014-03-16 00:58:59 +00:00
#ifndef ATOM_BROWSER_API_ATOM_API_EVENT_H_
#define ATOM_BROWSER_API_ATOM_API_EVENT_H_
2013-04-18 13:42:20 +00:00
#include "atom/common/v8/scoped_persistent.h"
2013-04-18 13:42:20 +00:00
#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/strings/string16.h"
#include "content/public/browser/web_contents_observer.h"
2013-04-18 13:42:20 +00:00
#include "vendor/node/src/node_object_wrap.h"
namespace IPC {
class Message;
}
2013-04-18 13:42:20 +00:00
namespace atom {
namespace api {
class Event : public node::ObjectWrap,
public content::WebContentsObserver {
2013-04-18 13:42:20 +00:00
public:
virtual ~Event();
// Create a V8 Event object.
static v8::Handle<v8::Object> CreateV8Object();
// Pass the sender and message to be replied.
void SetSenderAndMessage(content::WebContents* sender, IPC::Message* message);
2013-04-18 13:42:20 +00:00
// Whether event.preventDefault() is called.
bool prevent_default() const { return prevent_default_; }
protected:
Event();
// content::WebContentsObserver implementations:
virtual void WebContentsDestroyed(content::WebContents*) OVERRIDE;
2013-04-18 13:42:20 +00:00
private:
static void New(const v8::FunctionCallbackInfo<v8::Value>& args);
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
static ScopedPersistent<v8::Function> constructor_template_;
2013-04-18 13:42:20 +00:00
// Replyer for the synchronous messages.
content::WebContents* sender_;
IPC::Message* message_;
2013-04-18 13:42:20 +00:00
bool prevent_default_;
DISALLOW_COPY_AND_ASSIGN(Event);
};
} // namespace api
} // namespace atom
2014-03-16 00:58:59 +00:00
#endif // ATOM_BROWSER_API_ATOM_API_EVENT_H_