mirror of
https://github.com/atom/atom.git
synced 2026-02-12 23:55:10 -05:00
All of the methods from Native are now implemented in native_handler
This commit is contained in:
@@ -70,10 +70,8 @@
|
||||
CefRefPtr<NativeHandler> nativeHandler = new NativeHandler();
|
||||
global->SetValue("$native", nativeHandler->m_object, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
|
||||
if (_pathToOpen) {
|
||||
CefRefPtr<CefV8Value> pathToOpen = CefV8Value::CreateString([_pathToOpen UTF8String]);
|
||||
global->SetValue("$pathToOpen", pathToOpen, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
}
|
||||
CefRefPtr<CefV8Value> pathToOpen = _pathToOpen ? CefV8Value::CreateString([_pathToOpen UTF8String]) : CefV8Value::CreateNull();
|
||||
global->SetValue("$pathToOpen", pathToOpen, V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
|
||||
global->SetValue("atom", _atomContext->GetGlobal()->GetValue("atom"), V8_PROPERTY_ATTRIBUTE_NONE);
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ NSString *stringFromCefV8Value(const CefRefPtr<CefV8Value>& value) {
|
||||
NativeHandler::NativeHandler() : CefV8Handler() {
|
||||
m_object = CefV8Value::CreateObject(NULL);
|
||||
|
||||
const char *functionNames[] = {"exists", "read", "write", "absolute", "list", "isFile", "isDirectory", "remove", "asyncList", "open", "openDialog", "quit", "writeToPasteboard", "readFromPasteboard", "showDevTools"};
|
||||
const char *functionNames[] = {"exists", "read", "write", "absolute", "list", "isFile", "isDirectory", "remove", "asyncList", "open", "openDialog", "quit", "writeToPasteboard", "readFromPasteboard", "showDevTools", "newWindow", "saveDialog"};
|
||||
NSUInteger arrayLength = sizeof(functionNames) / sizeof(const char *);
|
||||
for (NSUInteger i = 0; i < arrayLength; i++) {
|
||||
const char *functionName = functionNames[i];
|
||||
@@ -214,7 +214,6 @@ bool NativeHandler::Execute(const CefString& name,
|
||||
[panel setCanChooseDirectories:YES];
|
||||
if ([panel runModal] == NSFileHandlingPanelOKButton) {
|
||||
NSURL *url = [[panel URLs] lastObject];
|
||||
NSLog(@"An URL %@", [url path]);
|
||||
retval = CefV8Value::CreateString([[url path] UTF8String]);
|
||||
}
|
||||
else {
|
||||
@@ -229,6 +228,23 @@ bool NativeHandler::Execute(const CefString& name,
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (name == "newWindow") {
|
||||
[NSApp open:nil];
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (name == "saveDialog") {
|
||||
NSSavePanel *panel = [NSSavePanel savePanel];
|
||||
if ([panel runModal] == NSFileHandlingPanelOKButton) {
|
||||
NSURL *url = [panel URL];
|
||||
retval = CefV8Value::CreateString([[url path] UTF8String]);
|
||||
}
|
||||
else {
|
||||
return CefV8Value::CreateNull();
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
else if (name == "quit") {
|
||||
[NSApp terminate:nil];
|
||||
return true;
|
||||
@@ -239,4 +255,4 @@ bool NativeHandler::Execute(const CefString& name,
|
||||
}
|
||||
|
||||
return false;
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user