Skip to content
This repository was archived by the owner on Sep 2, 2021. It is now read-only.

Commit e472eac

Browse files
committed
Merge pull request #15 from adobe/rlim/quit-and-close
Rlim/quit and close
2 parents cce7647 + d8b32b7 commit e472eac

23 files changed

+847
-176
lines changed

Brackets.vcxproj

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

appshell.xcodeproj/project.pbxproj

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,14 +97,14 @@
9797
B0DDE91F41250836E3EC6D6F /* ffmpegsumo.so in Copy to $(BUILT_PRODUCTS_DIR)/Brackets.app/Contents/Frameworks/Chromium Embedded Framework.framework/Libraries/ */ = {isa = PBXBuildFile; fileRef = 960AF2FA67AD34478B16E1FE /* ffmpegsumo.so */; };
9898
B335BA5FA3951D47696662CB /* client_switches.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 1CB166DE5C11F00828B7B417 /* client_switches.cpp */; };
9999
B9B6E151D671D73B99611F36 /* domnode_ctocpp.cc in Sources */ = {isa = PBXBuildFile; fileRef = 7644365DE7CC78D2DEA79A85 /* domnode_ctocpp.cc */; };
100+
BB10F73F618857F79C7F65D9 /* appshell_extensions.js in Resources */ = {isa = PBXBuildFile; fileRef = F7EB475CDCCC2A30AF8D4A0C /* appshell_extensions.js */; };
100101
BB89173AA3CFC876A054FB7B /* display_handler_cpptoc.cc in Sources */ = {isa = PBXBuildFile; fileRef = EF2C2EC4E5A1D08B06CF0FD7 /* display_handler_cpptoc.cc */; };
101102
BD01EF6C6486A5B613FA7017 /* web_plugin_info_ctocpp.cc in Sources */ = {isa = PBXBuildFile; fileRef = 0C66A0123DAA2BBD73A2939C /* web_plugin_info_ctocpp.cc */; };
102103
C1E637FD616AE3950058FE96 /* proxy_handler_cpptoc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 2BA3A8374DBB04156F6EF07C /* proxy_handler_cpptoc.cc */; };
103104
C307B48058592FA0A775CBE0 /* client_cpptoc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 32AC2CDB85725E3715C728CB /* client_cpptoc.cc */; };
104105
C5EBE4A85C81F593EDF064F5 /* cefclient_mac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 79A2E45EB29CAA66453661C6 /* cefclient_mac.mm */; };
105106
C7429BF3C7C74CB98723F6C0 /* command_line_ctocpp.cc in Sources */ = {isa = PBXBuildFile; fileRef = EB60AE270B721E13CF1126AD /* command_line_ctocpp.cc */; };
106107
C90FB710D7B25572E80BFD69 /* v8accessor_cpptoc.cc in Sources */ = {isa = PBXBuildFile; fileRef = 845EEC823278584B42AFB2B7 /* v8accessor_cpptoc.cc */; };
107-
CF1EE9AEF2671F90918C896C /* brackets_extensions.js in Resources */ = {isa = PBXBuildFile; fileRef = F55C44F44BBA964EFE0B704F /* brackets_extensions.js */; };
108108
D44993FFF44DE7241797A865 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 117371CDDB44775B39107AA8 /* AppKit.framework */; };
109109
DDA2289823F976BECC01755A /* menu_model_ctocpp.cc in Sources */ = {isa = PBXBuildFile; fileRef = 86E19C99BCCDDA939F257FE0 /* menu_model_ctocpp.cc */; };
110110
DFF56C4CCC0DF43679368430 /* response_ctocpp.cc in Sources */ = {isa = PBXBuildFile; fileRef = 8637A80D02FB4C99759A9768 /* response_ctocpp.cc */; };
@@ -266,6 +266,7 @@
266266
32AC2CDB85725E3715C728CB /* client_cpptoc.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = client_cpptoc.cc; sourceTree = "<group>"; };
267267
33499D33F1F9DC890F636536 /* life_span_handler_cpptoc.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = life_span_handler_cpptoc.h; sourceTree = "<group>"; };
268268
3458504ADE6A6AF8C60A2C67 /* domevent_ctocpp.cc */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = domevent_ctocpp.cc; sourceTree = "<group>"; };
269+
34EA46718B3A0AB6A5AD8EF8 /* command_callbacks.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = command_callbacks.h; sourceTree = "<group>"; };
269270
35C4DBE8E4BAEC7160CD210E /* release_impl_official.gypi */ = {isa = PBXFileReference; lastKnownFileType = text; name = release_impl_official.gypi; path = ../../cef3/chromium/src/build/internal/release_impl_official.gypi; sourceTree = "<group>"; };
270271
365EDD3D82156D2204917D12 /* cef_cookie.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cef_cookie.h; sourceTree = "<group>"; };
271272
37158D1FB9718895411FDA83 /* cef_string_types.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cef_string_types.h; sourceTree = "<group>"; };
@@ -337,6 +338,7 @@
337338
79A2E45EB29CAA66453661C6 /* cefclient_mac.mm */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.objcpp; path = cefclient_mac.mm; sourceTree = "<group>"; };
338339
7A23EBE1C5CFE1625F63FD57 /* cef_context_menu_handler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cef_context_menu_handler.h; sourceTree = "<group>"; };
339340
7B1F678D2890FCB53A883C89 /* cef_stream_capi.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cef_stream_capi.h; sourceTree = "<group>"; };
341+
7D1CB415BC5D03739649D7E6 /* appshell_extensions_platform.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = appshell_extensions_platform.h; sourceTree = "<group>"; };
340342
7D96382DCC9DC64414EC6E05 /* string_util.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = string_util.cpp; sourceTree = "<group>"; };
341343
7E9FDC3988B247C56F392E33 /* cef_string.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cef_string.h; sourceTree = "<group>"; };
342344
7FC6441C12E0D2D5C46FFFE2 /* cef_byte_read_handler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cef_byte_read_handler.h; sourceTree = "<group>"; };
@@ -458,8 +460,8 @@
458460
F1989B67661244ED4B756EE5 /* libcef.dylib */ = {isa = PBXFileReference; lastKnownFileType = "compiled.mach-o.dylib"; path = libcef.dylib; sourceTree = "<group>"; };
459461
F31B254B0DC7D754A1D4D56C /* cef_resource_handler_capi.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cef_resource_handler_capi.h; sourceTree = "<group>"; };
460462
F41FB3563A8DCA978ABCB8F0 /* appshell_extensions.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = appshell_extensions.cpp; sourceTree = "<group>"; };
461-
F55C44F44BBA964EFE0B704F /* brackets_extensions.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = brackets_extensions.js; sourceTree = "<group>"; };
462463
F7D894242D95F2E165D0ECF6 /* cef_request_capi.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cef_request_capi.h; sourceTree = "<group>"; };
464+
F7EB475CDCCC2A30AF8D4A0C /* appshell_extensions.js */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.javascript; path = appshell_extensions.js; sourceTree = "<group>"; };
463465
F8650F6813183C119C198C0F /* stream_writer_ctocpp.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = stream_writer_ctocpp.h; sourceTree = "<group>"; };
464466
F920274FE06506D9C02842CB /* command_line_ctocpp.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = command_line_ctocpp.h; sourceTree = "<group>"; };
465467
FAD7E647FB13C82A751604CC /* cef_resource_bundle_handler.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = cef_resource_bundle_handler.h; sourceTree = "<group>"; };
@@ -570,8 +572,9 @@
570572
2CF60921DE182D498BFC8418 /* mac */,
571573
F41FB3563A8DCA978ABCB8F0 /* appshell_extensions.cpp */,
572574
2C6200DAA24D72696664A534 /* appshell_extensions.h */,
575+
F7EB475CDCCC2A30AF8D4A0C /* appshell_extensions.js */,
573576
95AC844F2FA9D42891B3B718 /* appshell_extensions_mac.mm */,
574-
F55C44F44BBA964EFE0B704F /* brackets_extensions.js */,
577+
7D1CB415BC5D03739649D7E6 /* appshell_extensions_platform.h */,
575578
522C920B68963035E6CE38FE /* cefclient.cpp */,
576579
217F2C98268E9035AD8D9C14 /* cefclient.h */,
577580
79A2E45EB29CAA66453661C6 /* cefclient_mac.mm */,
@@ -584,6 +587,7 @@
584587
E93F80CFC491C3C09AFDD87B /* client_handler_mac.mm */,
585588
1CB166DE5C11F00828B7B417 /* client_switches.cpp */,
586589
6F16FF80521076B63DF9A19F /* client_switches.h */,
590+
34EA46718B3A0AB6A5AD8EF8 /* command_callbacks.h */,
587591
726E17688DB25A1076C57E0E /* config.h */,
588592
73BD18BBE14A6CD1DE6E5E57 /* process_helper_mac.cpp */,
589593
B079D80809064D7C62742C71 /* resource_util.h */,
@@ -994,7 +998,7 @@
994998
92D1A00BA8DD26C04841665A /* brackets.icns in Resources */,
995999
EB4A35C3C60BE898F8FB7EC6 /* InfoPlist.strings in Resources */,
9961000
6B295097B29E8FB628815A1B /* MainMenu.xib in Resources */,
997-
CF1EE9AEF2671F90918C896C /* brackets_extensions.js in Resources */,
1001+
BB10F73F618857F79C7F65D9 /* appshell_extensions.js in Resources */,
9981002
);
9991003
runOnlyForDeploymentPostprocessing = 0;
10001004
};

appshell/appshell_extensions.cpp

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
*
2222
*/
2323

24-
#include "appshell/appshell_extensions.h"
24+
#include "appshell_extensions.h"
25+
#include "appshell_extensions_platform.h"
2526

2627
namespace appshell_extensions {
2728

@@ -218,6 +219,22 @@ class ProcessMessageDelegate : public ClientHandler::ProcessMessageDelegate {
218219

219220
handler->ShowDevTools(browser);
220221

222+
} else if (message_name == "CloseWindow") {
223+
// Parameters - none
224+
225+
browser->GetHost()->CloseBrowser();
226+
227+
} else if (message_name == "QuitApplication") {
228+
// Parameters - none
229+
230+
// The DispatchCloseToNextBrowser() call initiates a quit sequence. The app will
231+
// quit if all browser windows are closed.
232+
handler->DispatchCloseToNextBrowser();
233+
234+
} else if (message_name == "AbortQuit") {
235+
// Parameters - none
236+
237+
handler->AbortQuit();
221238
} else {
222239
fprintf(stderr, "Native function not implemented yet: %s\n", message_name.c_str());
223240
return false;
@@ -244,9 +261,5 @@ void CreateProcessMessageDelegates(
244261
ClientHandler::ProcessMessageDelegateSet& delegates) {
245262
delegates.insert(new ProcessMessageDelegate);
246263
}
247-
248-
void CreateRequestDelegates(ClientHandler::RequestDelegateSet& delegates) {
249-
// delegates.insert(new RequestDelegate);
250-
}
251-
264+
252265
} // namespace appshell_extensions

appshell/appshell_extensions.h

Lines changed: 3 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -27,52 +27,8 @@
2727
#include "client_handler.h"
2828

2929
namespace appshell_extensions {
30-
31-
// Delegate creation. Called from ClientApp and ClientHandler.
32-
void CreateProcessMessageDelegates(
33-
ClientHandler::ProcessMessageDelegateSet& delegates);
34-
void CreateRequestDelegates(ClientHandler::RequestDelegateSet& delegates);
35-
} // namespace appshell_extensions
36-
37-
// Extension error codes. These MUST be in sync with the error
38-
// codes in brackets_extensions.js
39-
#if !defined(OS_WIN) // NO_ERROR is defined on windows
40-
static const int NO_ERROR = 0;
41-
#endif
42-
static const int ERR_UNKNOWN = 1;
43-
static const int ERR_INVALID_PARAMS = 2;
44-
static const int ERR_NOT_FOUND = 3;
45-
static const int ERR_CANT_READ = 4;
46-
static const int ERR_UNSUPPORTED_ENCODING = 5;
47-
static const int ERR_CANT_WRITE = 6;
48-
static const int ERR_OUT_OF_SPACE = 7;
49-
static const int ERR_NOT_FILE = 8;
50-
static const int ERR_NOT_DIRECTORY = 9;
51-
52-
#if defined(OS_WIN)
53-
typedef std::wstring ExtensionString;
54-
#else
55-
typedef std::string ExtensionString;
56-
#endif
57-
58-
// Native extension code. These are implemented in brackets_extensions_mac.mm
59-
// and brackets_extensions_win.cpp
60-
int32 ShowOpenDialog(bool allowMulitpleSelection,
61-
bool chooseDirectory,
62-
ExtensionString title,
63-
ExtensionString initialDirectory,
64-
ExtensionString fileTypes,
65-
CefRefPtr<CefListValue>& selectedFiles);
66-
67-
int32 ReadDir(ExtensionString path, CefRefPtr<CefListValue>& directoryContents);
6830

69-
int32 GetFileModificationTime(ExtensionString filename, uint32& modtime, bool& isDir);
70-
71-
int32 ReadFile(ExtensionString filename, ExtensionString encoding, std::string& contents);
72-
73-
int32 WriteFile(ExtensionString filename, std::string contents, ExtensionString encoding);
74-
75-
int32 SetPosixPermissions(ExtensionString filename, int32 mode);
76-
77-
int32 DeleteFileOrDirectory(ExtensionString filename);
31+
// Create message delegates that run in the browser process
32+
void CreateProcessMessageDelegates(ClientHandler::ProcessMessageDelegateSet& delegates);
7833

34+
} // namespace appshell_extensions

appshell/brackets_extensions.js renamed to appshell/appshell_extensions.js

Lines changed: 47 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -22,77 +22,77 @@
2222
*/
2323

2424
// This is the JavaScript code for bridging to native functionality
25-
// See brackets_extentions.mm for implementation of native methods.
25+
// See appshell_extentions_[platform] for implementation of native methods.
2626
//
2727
// Note: All file native file i/o functions are synchronous, but are exposed
2828
// here as asynchronous calls.
2929

3030
/*jslint vars: true, plusplus: true, devel: true, browser: true, nomen: true, indent: 4, forin: true, maxerr: 50, regexp: true */
3131
/*global define, native */
3232

33-
var brackets;
34-
if (!brackets) {
35-
brackets = {};
33+
var appshell;
34+
if (!appshell) {
35+
appshell = {};
3636
}
37-
if (!brackets.fs) {
38-
brackets.fs = {};
37+
if (!appshell.fs) {
38+
appshell.fs = {};
3939
}
40-
if (!brackets.app) {
41-
brackets.app = {};
40+
if (!appshell.app) {
41+
appshell.app = {};
4242
}
4343
(function () {
4444
// Error values. These MUST be in sync with the error values
45-
// at the top of brackets_extensions.h.
45+
// at the top of appshell_extensions_platform.h.
4646

4747
/**
4848
* @constant No error.
4949
*/
50-
brackets.fs.NO_ERROR = 0;
50+
appshell.fs.NO_ERROR = 0;
5151

5252
/**
5353
* @constant Unknown error occurred.
5454
*/
55-
brackets.fs.ERR_UNKNOWN = 1;
55+
appshell.fs.ERR_UNKNOWN = 1;
5656

5757
/**
5858
* @constant Invalid parameters passed to function.
5959
*/
60-
brackets.fs.ERR_INVALID_PARAMS = 2;
60+
appshell.fs.ERR_INVALID_PARAMS = 2;
6161

6262
/**
6363
* @constant File or directory was not found.
6464
*/
65-
brackets.fs.ERR_NOT_FOUND = 3;
65+
appshell.fs.ERR_NOT_FOUND = 3;
6666

6767
/**
6868
* @constant File or directory could not be read.
6969
*/
70-
brackets.fs.ERR_CANT_READ = 4;
70+
appshell.fs.ERR_CANT_READ = 4;
7171

7272
/**
7373
* @constant An unsupported encoding value was specified.
7474
*/
75-
brackets.fs.ERR_UNSUPPORTED_ENCODING = 5;
75+
appshell.fs.ERR_UNSUPPORTED_ENCODING = 5;
7676

7777
/**
7878
* @constant File could not be written.
7979
*/
80-
brackets.fs.ERR_CANT_WRITE = 6;
80+
appshell.fs.ERR_CANT_WRITE = 6;
8181

8282
/**
8383
* @constant Target directory is out of space. File could not be written.
8484
*/
85-
brackets.fs.ERR_OUT_OF_SPACE = 7;
85+
appshell.fs.ERR_OUT_OF_SPACE = 7;
8686

8787
/**
8888
* @constant Specified path does not point to a file.
8989
*/
90-
brackets.fs.ERR_NOT_FILE = 8;
90+
appshell.fs.ERR_NOT_FILE = 8;
9191

9292
/**
9393
* @constant Specified path does not point to a directory.
9494
*/
95-
brackets.fs.ERR_NOT_DIRECTORY = 9;
95+
appshell.fs.ERR_NOT_DIRECTORY = 9;
9696

9797
/**
9898
* Display the OS File Open dialog, allowing the user to select
@@ -116,7 +116,7 @@ if (!brackets.app) {
116116
* @return None. This is an asynchronous call that sends all return information to the callback.
117117
*/
118118
native function ShowOpenDialog();
119-
brackets.fs.showOpenDialog = function (allowMultipleSelection, chooseDirectory, title, initialPath, fileTypes, callback) {
119+
appshell.fs.showOpenDialog = function (allowMultipleSelection, chooseDirectory, title, initialPath, fileTypes, callback) {
120120
setTimeout(function () {
121121
ShowOpenDialog(callback, allowMultipleSelection, chooseDirectory,
122122
title || 'Open', initialPath || '',
@@ -141,7 +141,7 @@ if (!brackets.app) {
141141
* @return None. This is an asynchronous call that sends all return information to the callback.
142142
*/
143143
native function ReadDir();
144-
brackets.fs.readdir = function (path, callback) {
144+
appshell.fs.readdir = function (path, callback) {
145145
var resultString = ReadDir(callback, path);
146146
};
147147

@@ -160,7 +160,7 @@ if (!brackets.app) {
160160
* @return None. This is an asynchronous call that sends all return information to the callback.
161161
*/
162162
native function GetFileModificationTime();
163-
brackets.fs.stat = function (path, callback) {
163+
appshell.fs.stat = function (path, callback) {
164164
GetFileModificationTime(function (err, modtime, isDir) {
165165
callback(err, {
166166
isFile: function () {
@@ -174,19 +174,32 @@ if (!brackets.app) {
174174
}, path);
175175
};
176176

177+
native function CloseWindow();
178+
close = function () {
179+
CloseWindow();
180+
};
181+
177182
/**
178183
* Quits native shell application
179184
*/
180185
native function QuitApplication();
181-
brackets.app.quit = function () {
186+
appshell.app.quit = function () {
182187
QuitApplication();
183188
};
189+
190+
/**
191+
* Abort a quit operation
192+
*/
193+
native function AbortQuit();
194+
appshell.app.abortQuit = function () {
195+
AbortQuit();
196+
};
184197

185198
/**
186199
* Invokes developer tools application
187200
*/
188201
native function ShowDeveloperTools();
189-
brackets.app.showDeveloperTools = function () {
202+
appshell.app.showDeveloperTools = function () {
190203
ShowDeveloperTools();
191204
};
192205

@@ -208,7 +221,7 @@ if (!brackets.app) {
208221
* @return None. This is an asynchronous call that sends all return information to the callback.
209222
*/
210223
native function ReadFile();
211-
brackets.fs.readFile = function (path, encoding, callback) {
224+
appshell.fs.readFile = function (path, encoding, callback) {
212225
ReadFile(callback, path, encoding);
213226
};
214227

@@ -230,7 +243,7 @@ if (!brackets.app) {
230243
* @return None. This is an asynchronous call that sends all return information to the callback.
231244
*/
232245
native function WriteFile();
233-
brackets.fs.writeFile = function (path, data, encoding, callback) {
246+
appshell.fs.writeFile = function (path, data, encoding, callback) {
234247
WriteFile(callback, path, data, encoding);
235248
};
236249

@@ -249,7 +262,7 @@ if (!brackets.app) {
249262
* @return None. This is an asynchronous call that sends all return information to the callback.
250263
*/
251264
native function SetPosixPermissions();
252-
brackets.fs.chmod = function (path, mode, callback) {
265+
appshell.fs.chmod = function (path, mode, callback) {
253266
SetPosixPermissions(callback, path, mode);
254267
};
255268

@@ -268,7 +281,7 @@ if (!brackets.app) {
268281
* @return None. This is an asynchronous call that sends all return information to the callback.
269282
*/
270283
native function DeleteFileOrDirectory();
271-
brackets.fs.unlink = function (path, callback) {
284+
appshell.fs.unlink = function (path, callback) {
272285
DeleteFileOrDirectory(callback, path);
273286
};
274287

@@ -277,7 +290,7 @@ if (!brackets.app) {
277290
* was launched.
278291
*/
279292
native function GetElapsedMilliseconds();
280-
brackets.app.getElapsedMilliseconds = function () {
293+
appshell.app.getElapsedMilliseconds = function () {
281294
return GetElapsedMilliseconds();
282295
}
283296

@@ -296,7 +309,7 @@ if (!brackets.app) {
296309
* @return None. This is an asynchronous call that sends all return information to the callback.
297310
*/
298311
native function OpenLiveBrowser();
299-
brackets.app.openLiveBrowser = function (url, enableRemoteDebugging, callback) {
312+
appshell.app.openLiveBrowser = function (url, enableRemoteDebugging, callback) {
300313
/*
301314
// enableRemoteDebugging flag is ignored on mac
302315
setTimeout(function() {
@@ -320,9 +333,12 @@ if (!brackets.app) {
320333
* @return None. This is an asynchronous call that sends all return information to the callback.
321334
*/
322335
native function CloseLiveBrowser();
323-
brackets.app.closeLiveBrowser = function (callback) {
336+
appshell.app.closeLiveBrowser = function (callback) {
324337
/*
325338
CloseLiveBrowser(callback);
326339
*/
327340
};
341+
342+
// Alias the appshell object to brackets. This is temporary and should be removed.
343+
brackets = appshell;
328344
})();

0 commit comments

Comments
 (0)