Emit 'open-file' event when OS X is trying to open file with the app.

This commit is contained in:
Cheng Zhao 2013-05-30 16:03:10 +08:00
parent 01af2fd0c5
commit 7dd48e24d3
10 changed files with 49 additions and 3 deletions

View file

@ -4,6 +4,7 @@
#include "browser/api/atom_api_app.h"
#include "base/values.h"
#include "base/command_line.h"
#include "browser/browser.h"
#include "vendor/node/src/node.h"
@ -29,6 +30,12 @@ void App::OnWindowAllClosed() {
Emit("window-all-closed");
}
void App::OnOpenFile(bool* prevent_default, const std::string& file_path) {
base::ListValue args;
args.AppendString(file_path);
*prevent_default = Emit("open-file", &args);
}
// static
v8::Handle<v8::Value> App::New(const v8::Arguments &args) {
v8::HandleScope scope;

View file

@ -26,6 +26,8 @@ class App : public EventEmitter,
// BrowserObserver implementations:
virtual void OnWillQuit(bool* prevent_default) OVERRIDE;
virtual void OnWindowAllClosed() OVERRIDE;
virtual void OnOpenFile(bool* prevent_default,
const std::string& file_path) OVERRIDE;
private:
static v8::Handle<v8::Value> New(const v8::Arguments &args);