forked from adobe/brackets-shell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathappshell_extensions_platform.h
More file actions
178 lines (136 loc) · 7.14 KB
/
appshell_extensions_platform.h
File metadata and controls
178 lines (136 loc) · 7.14 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
/*
* Copyright (c) 2012 - present Adobe Systems Incorporated. All rights reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sublicense,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in
* all copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
*/
#pragma once
#include "include/cef_browser.h"
#include "include/cef_v8.h"
#include <string>
#include "config.h"
#ifdef OS_LINUX
#include <gtk/gtk.h>
#endif
// Extension error codes. These MUST be in sync with the error
// codes in appshell_extensions.js
#if !defined(OS_WIN) // NO_ERROR is defined on windows
static const int NO_ERROR = 0;
#endif
static const int ERR_UNKNOWN = 1;
static const int ERR_INVALID_PARAMS = 2;
static const int ERR_NOT_FOUND = 3;
static const int ERR_CANT_READ = 4;
static const int ERR_UNSUPPORTED_ENCODING = 5;
static const int ERR_CANT_WRITE = 6;
static const int ERR_OUT_OF_SPACE = 7;
static const int ERR_NOT_FILE = 8;
static const int ERR_NOT_DIRECTORY = 9;
static const int ERR_FILE_EXISTS = 10;
static const int ERR_BROWSER_NOT_INSTALLED = 11;
static const int ERR_CL_TOOLS_CANCELLED = 12;
static const int ERR_CL_TOOLS_RMFAILED = 13;
static const int ERR_CL_TOOLS_MKDIRFAILED = 14;
static const int ERR_CL_TOOLS_SYMLINKFAILED = 15;
static const int ERR_CL_TOOLS_SERVFAILED = 16;
static const int ERR_CL_TOOLS_NOTSUPPORTED = 17;
static const int ERR_PID_NOT_FOUND = -9999; // negative int to avoid confusion with real PIDs
#if defined(OS_WIN)
typedef std::wstring ExtensionString;
inline void* getMenuParent(CefRefPtr<CefBrowser>browser) {
if (browser.get() && browser->GetHost()) {
HWND frameHwnd = browser->GetHost()->GetWindowHandle();
return (browser->IsPopup()) ? frameHwnd : GetParent(frameHwnd);
}
return NULL;
}
inline int32 InstallCommandLineTools() { return ERR_CL_TOOLS_NOTSUPPORTED; }
#elif defined(OS_MACOSX)
typedef std::string ExtensionString;
inline void* getMenuParent(CefRefPtr<CefBrowser>browser) {return NULL;} // Mac uses a shared menu bar
int32 InstallCommandLineTools();
#else
typedef std::string ExtensionString;
inline void* getMenuParent(CefRefPtr<CefBrowser>browser) {
return gtk_widget_get_ancestor(
GTK_WIDGET(browser->GetHost()->GetWindowHandle()),
GTK_TYPE_VBOX);
}
inline int32 InstallCommandLineTools() { return ERR_CL_TOOLS_NOTSUPPORTED; }
#endif
// Native extension code. These are implemented in appshell_extensions_mac.mm
// and appshell_extensions_win.cpp
int32 OpenLiveBrowser(ExtensionString argURL, bool enableRemoteDebugging);
void CloseLiveBrowser(CefRefPtr<CefBrowser> browser, CefRefPtr<CefProcessMessage> response);
int32 OpenURLInDefaultBrowser(ExtensionString url);
#ifndef OS_MACOSX
int32 ShowOpenDialog(bool allowMulitpleSelection,
bool chooseDirectory,
ExtensionString title,
ExtensionString initialDirectory,
ExtensionString fileTypes,
CefRefPtr<CefListValue>& selectedFiles);
int32 ShowSaveDialog(ExtensionString title,
ExtensionString initialDirectory,
ExtensionString proposedNewFilename,
ExtensionString& newFilePath);
#else
void ShowOpenDialog(bool allowMulitpleSelection,
bool chooseDirectory,
ExtensionString title,
ExtensionString initialDirectory,
ExtensionString fileTypes,
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefProcessMessage> response);
void ShowSaveDialog(ExtensionString title,
ExtensionString initialDirectory,
ExtensionString proposedNewFilename,
CefRefPtr<CefBrowser> browser,
CefRefPtr<CefProcessMessage> response);
#endif
int32 IsNetworkDrive(ExtensionString path, bool& isRemote);
int32 ReadDir(ExtensionString path, CefRefPtr<CefListValue>& directoryContents);
int32 MakeDir(ExtensionString path, int32 mode);
int32 Rename(ExtensionString oldName, ExtensionString newName);
int32 GetFileInfo(ExtensionString filename, uint32& modtime, bool& isDir, double& size, ExtensionString& realPath);
int32 ReadFile(ExtensionString filename, ExtensionString encoding, std::string& contents);
int32 WriteFile(ExtensionString filename, std::string contents, ExtensionString encoding);
int32 SetPosixPermissions(ExtensionString filename, int32 mode);
int32 DeleteFileOrDirectory(ExtensionString filename);
void MoveFileOrDirectoryToTrash(ExtensionString filename, CefRefPtr<CefBrowser> browser, CefRefPtr<CefProcessMessage> response);
int32 CopyFile(ExtensionString src, ExtensionString dest);
int32 GetNodeState(int32& state);
void OnBeforeShutdown();
void CloseWindow(CefRefPtr<CefBrowser> browser);
void BringBrowserWindowToFront(CefRefPtr<CefBrowser> browser);
int32 ShowFolderInOSWindow(ExtensionString pathname);
int32 GetPendingFilesToOpen(ExtensionString& files);
int32 AddMenu(CefRefPtr<CefBrowser> browser, ExtensionString title, ExtensionString command,
ExtensionString position, ExtensionString relativeId);
int32 AddMenuItem(CefRefPtr<CefBrowser> browser, ExtensionString parentCommand, ExtensionString itemTitle,
ExtensionString command, ExtensionString key, ExtensionString displayStr,
ExtensionString position, ExtensionString relativeId);
int32 RemoveMenu(CefRefPtr<CefBrowser> browser, const ExtensionString& commandId);
int32 RemoveMenuItem(CefRefPtr<CefBrowser> browser, const ExtensionString& commandId);
int32 GetMenuItemState(CefRefPtr<CefBrowser> browser, ExtensionString commandId, bool& enabled, bool& checked, int& index);
int32 SetMenuTitle(CefRefPtr<CefBrowser> browser, ExtensionString commandId, ExtensionString menuTitle);
int32 GetMenuTitle(CefRefPtr<CefBrowser> browser, ExtensionString commandId, ExtensionString& menuTitle);
int32 SetMenuItemShortcut(CefRefPtr<CefBrowser> browser, ExtensionString commandId, ExtensionString shortcut, ExtensionString displayStr);
int32 GetMenuPosition(CefRefPtr<CefBrowser> browser, const ExtensionString& commandId, ExtensionString& parentId, int& index);
void DragWindow(CefRefPtr<CefBrowser> browser);