2013-04-15 16:25:08 +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_API_ATOM_API_EVENT_EMITTER_H_
|
|
|
|
#define ATOM_BROWSER_API_ATOM_API_EVENT_EMITTER_H_
|
|
|
|
|
2013-07-01 13:56:46 +00:00
|
|
|
#include <string>
|
2013-04-18 15:50:47 +00:00
|
|
|
|
2013-04-25 07:02:58 +00:00
|
|
|
#include "base/basictypes.h"
|
|
|
|
#include "vendor/node/src/node_object_wrap.h"
|
2013-04-15 16:25:08 +00:00
|
|
|
|
2013-04-18 15:50:47 +00:00
|
|
|
namespace base {
|
|
|
|
class ListValue;
|
|
|
|
}
|
|
|
|
|
2013-04-15 16:25:08 +00:00
|
|
|
namespace atom {
|
|
|
|
|
|
|
|
namespace api {
|
|
|
|
|
|
|
|
// Class interiting EventEmitter should assume it's a javascript object which
|
|
|
|
// interits require('events').EventEmitter, this class provides many helper
|
|
|
|
// methods to do event processing in C++.
|
2013-04-25 07:02:58 +00:00
|
|
|
class EventEmitter : public node::ObjectWrap {
|
2013-04-15 16:25:08 +00:00
|
|
|
public:
|
|
|
|
virtual ~EventEmitter();
|
|
|
|
|
2013-04-18 15:50:47 +00:00
|
|
|
// Emit an event and returns whether the handler has called preventDefault().
|
2013-05-02 10:19:07 +00:00
|
|
|
bool Emit(const std::string& name);
|
2013-04-18 15:50:47 +00:00
|
|
|
bool Emit(const std::string& name, base::ListValue* args);
|
|
|
|
|
2013-04-15 16:25:08 +00:00
|
|
|
protected:
|
|
|
|
explicit EventEmitter(v8::Handle<v8::Object> wrapper);
|
|
|
|
|
|
|
|
private:
|
|
|
|
DISALLOW_COPY_AND_ASSIGN(EventEmitter);
|
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace api
|
|
|
|
|
|
|
|
} // namespace atom
|
|
|
|
|
|
|
|
#endif // ATOM_BROWSER_API_ATOM_API_EVENT_EMITTER_H_
|