This repository was archived by the owner on Sep 2, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 601
Expand file tree
/
Copy pathappshell_extensions_platform.h
More file actions
146 lines (107 loc) · 5.84 KB
/
appshell_extensions_platform.h
File metadata and controls
146 lines (107 loc) · 5.84 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
/*
* Copyright (c) 2012 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>
// 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;
#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;
}
#elif defined(OS_MACOSX)
typedef std::string ExtensionString;
inline void* getMenuParent(CefRefPtr<CefBrowser>browser) {return NULL;} // Mac uses a shared menu bar
#else
typedef std::string ExtensionString;
inline void* getMenuParent(CefRefPtr<CefBrowser>browser) {
gtk_widget_get_ancestor(
GTK_WIDGET(browser->GetHost()->GetWindowHandle()),
GTK_TYPE_WINDOW);
}
#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);
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);
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 GetFileModificationTime(ExtensionString filename, uint32& modtime, bool& isDir);
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);
void RegisterAsDefaultEditorForCommonFileTypes();