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

Commit

Permalink
Merge pull request #654 from adobe/master
Browse files Browse the repository at this point in the history
Merging master to release for 1.13
  • Loading branch information
madanbn authored Jun 4, 2018
2 parents 67abaa3 + 66072d0 commit b858d45
Show file tree
Hide file tree
Showing 46 changed files with 1,611 additions and 70 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ xcodebuild/*
*.vcxproj
*.vcxproj.filters
*.vcxproj.user
*.sln

*.pbxuser
*.perspective
Expand Down
23 changes: 19 additions & 4 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ module.exports = function (grunt) {
var common = require("./tasks/common")(grunt),
platform = common.platform(),
staging,
cef_version = "3.2623.1397";
cef_version = "3.2623.1402";

if (platform === "mac") {
staging = "installer/mac/staging/<%= build.name %>.app/Contents";
Expand All @@ -37,8 +37,10 @@ module.exports = function (grunt) {
staging = "installer/linux/debian/package-root/opt/brackets";
}

if (platform === "linux") {
cef_version = "3.2785.1486";
if (platform === "mac") {
cef_version = "3.2704.1434";
} else if (platform === "linux") {
cef_version = "3.2785.1487";
}

grunt.initConfig({
Expand Down Expand Up @@ -192,6 +194,19 @@ module.exports = function (grunt) {
}
]
},
"winInstallerDLLs": {
"files": [
{
"flatten" : true,
"expand" : true,
"src" : [
"installer/win/LaunchBrackets/LaunchBrackets/bin/Release/LaunchBrackets.CA.dll",
"installer/win/BracketsConfigurator/BracketsConfigurator/bin/Release/BracketsConfigurator.CA.dll"
],
"dest" : "installer/win/"
}
]
},
"mac": {
"files": [
{
Expand Down Expand Up @@ -333,4 +348,4 @@ module.exports = function (grunt) {
grunt.loadNpmTasks("grunt-curl");

grunt.registerTask("default", ["setup", "build"]);
};
};
17 changes: 16 additions & 1 deletion appshell/appshell_extensions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
#endif

#include <algorithm>
#include "update.h"

extern std::vector<CefString> gDroppedFiles;

Expand Down Expand Up @@ -507,7 +508,21 @@ class ProcessMessageDelegate : public ClientHandler::ProcessMessageDelegate {
error = CopyFile(src, dest);
// No additional response args for this function
}
} else if (message_name == "GetDroppedFiles") {
} else if (message_name == "SetUpdateParams") {
// Parameters:
// 0: int32 - callback id
// 1: string - update parameters json object

size_t numArgs = argList->GetSize();
if (numArgs < 2 ||
argList->GetType(1) != VTYPE_STRING) {
error = ERR_INVALID_PARAMS;
}
if(error == NO_ERROR){
CefString updateJson = argList->GetString(1);
error = SetInstallerCommandLineArgs(updateJson);
}
} else if (message_name == "GetDroppedFiles") {
// Parameters:
// 0: int32 - callback id
if (argList->GetSize() != 1) {
Expand Down
15 changes: 14 additions & 1 deletion appshell/appshell_extensions.js
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,20 @@ if (!brackets) {
appshell.app.getRemoteDebuggingPort = function () {
return GetRemoteDebuggingPort();
};



/**
* Set the parameters for auto update, to be used by installer on Win/Update Script on Mac as command line arguments.
*
* @param {string} updateInfoObj - update info json object
* @param {function(err)=} callback Asynchronous callback function.
* @return None.
*/
native function SetUpdateParams();
appshell.app.setUpdateParams = function (updateInfoObj, callback) {
SetUpdateParams(callback || _dummyCallback, updateInfoObj);
}

/**
* Set menu enabled/checked state.
* @param {string} command ID of the menu item.
Expand Down
65 changes: 59 additions & 6 deletions appshell/appshell_extensions_gtk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,8 @@

typedef char s8;

bool StMenuCommandSkipper::sSkipMenuCommand = false;

extern CefRefPtr<ClientHandler> g_handler;

// Supported browsers (order matters):
Expand Down Expand Up @@ -721,6 +723,12 @@ int ShowFolderInOSWindow(ExtensionString pathname)
GError *gerror = NULL;
gchar *uri = NULL, *parentdir = NULL;

// Check if file exist in OS
struct stat fileStat;
if (stat(pathname.c_str(), &fileStat) != 0) {
return ERR_NOT_FOUND;
}

if (g_file_test(pathname.c_str(), G_FILE_TEST_IS_DIR)) {
uri = g_filename_to_uri(pathname.c_str(), NULL, NULL);
if (!gtk_show_uri(NULL, uri, GDK_CURRENT_TIME, &gerror)) {
Expand Down Expand Up @@ -1062,6 +1070,7 @@ int32 AddMenuItem(CefRefPtr<CefBrowser> browser, ExtensionString parentCommand,

ExtensionString commandId = model.getCommandId(tag);
model.setOsItem(tag, entry);
model.setKey(tag, key);
ParseShortcut(browser, entry, key, commandId);
GtkWidget* menuHeader = (GtkWidget*) model.getOsItem(parentTag);
GtkWidget* menuWidget = gtk_menu_item_get_submenu(GTK_MENU_ITEM(menuHeader));
Expand Down Expand Up @@ -1098,16 +1107,60 @@ int32 GetMenuItemState(CefRefPtr<CefBrowser> browser, ExtensionString commandId,
return NO_ERROR;
}

int _getMenuItemPosition(GtkWidget* parent, GtkWidget* menuItem)
{
GList* children = gtk_container_get_children(GTK_CONTAINER(parent));
int index = 0;
do {
GtkWidget* widget = (GtkWidget*) children->data;
if (widget == menuItem) {
return index;
}
index++;
} while ((children = g_list_next(children)) != NULL);

return -1;
}

int32 SetMenuItemState(CefRefPtr<CefBrowser> browser, ExtensionString command, bool& enabled, bool& checked)
{
// TODO: Implement functionality for checked
NativeMenuModel& model = NativeMenuModel::getInstance(getMenuParent(browser));
int tag = model.getTag(command);
if (tag == kTagNotFound) {
return ERR_NOT_FOUND;
}
GtkWidget* menuItem = (GtkWidget*) model.getOsItem(tag);
gtk_widget_set_sensitive(menuItem, enabled);
if (menuItem == NULL) {
return ERR_UNKNOWN;
}
GtkWidget* parent = gtk_widget_get_parent(menuItem);
if (parent == NULL) {
return ERR_UNKNOWN;
}
int position = _getMenuItemPosition(parent, menuItem);
if (position < 0) {
return ERR_UNKNOWN;
}
const gchar* label = gtk_menu_item_get_label(GTK_MENU_ITEM(menuItem));

GtkWidget* newMenuItem;
if (checked == true) {
newMenuItem = gtk_check_menu_item_new_with_label(label);
gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(newMenuItem), true);
} else {
newMenuItem = gtk_menu_item_new_with_label(label);
}
gtk_widget_destroy(menuItem);

InstallMenuHandler(newMenuItem, browser, tag);

model.setOsItem(tag, newMenuItem);
ExtensionString key = model.getKey(tag);
ParseShortcut(browser, newMenuItem, key, command);
gtk_menu_shell_insert(GTK_MENU_SHELL(parent), newMenuItem, position);
gtk_widget_set_sensitive(newMenuItem, enabled);
gtk_widget_show(newMenuItem);

return NO_ERROR;
}

Expand Down Expand Up @@ -1148,13 +1201,15 @@ int32 GetMenuTitle(CefRefPtr<CefBrowser> browser, ExtensionString commandId, Ext

int32 SetMenuItemShortcut(CefRefPtr<CefBrowser> browser, ExtensionString commandId, ExtensionString shortcut, ExtensionString displayStr)
{
NativeMenuModel model = NativeMenuModel::getInstance(getMenuParent(browser));
int32 tag = model.getTag(commandId);
NativeMenuModel& model = NativeMenuModel::getInstance(getMenuParent(browser));
int tag = model.getTag(commandId);
if (tag == kTagNotFound) {
return ERR_NOT_FOUND;
}
GtkWidget* entry = (GtkWidget*) model.getOsItem(tag);
model.setKey(tag, shortcut);
ParseShortcut(browser, entry, shortcut, commandId);

return NO_ERROR;
}

Expand Down Expand Up @@ -1353,5 +1408,3 @@ std::string GetSystemUniqueID()

return buf;
}


1 change: 1 addition & 0 deletions appshell/appshell_extensions_platform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "appshell/browser/main_context.h"
#include "appshell/browser/root_window_manager.h"
#include "appshell/browser/root_window_gtk.h"
#include <unicode/unistr.h>
#endif

#define UTF8_BOM "\xEF\xBB\xBF"
Expand Down
18 changes: 18 additions & 0 deletions appshell/appshell_extensions_platform.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@

#ifdef OS_LINUX
#include <gtk/gtk.h>
#include <unicode/ucnv_err.h>
#include <unicode/uenum.h>
#include <unicode/localpointer.h>
#endif

// Extension error codes. These MUST be in sync with the error
Expand Down Expand Up @@ -60,6 +63,7 @@ static const int ERR_CL_TOOLS_NOTSUPPORTED = 17;
static const int ERR_ENCODE_FILE_FAILED = 18;
static const int ERR_DECODE_FILE_FAILED = 19;
static const int ERR_UNSUPPORTED_UTF16_ENCODING = 20;
static const int ERR_UPDATE_ARGS_INIT_FAILED = 21;

static const int ERR_PID_NOT_FOUND = -9999; // negative int to avoid confusion with real PIDs

Expand Down Expand Up @@ -108,6 +112,20 @@ class CharSetEncode
void operator()(std::string &contents);
};

#if defined(OS_LINUX)
class StMenuCommandSkipper {
public:

StMenuCommandSkipper() { sSkipMenuCommand = true; }
~StMenuCommandSkipper() { sSkipMenuCommand = false;}

static bool GetMenuCmdSkipFlag () { return sSkipMenuCommand;}

private:
static bool sSkipMenuCommand;
};
#endif

#if defined(OS_MACOSX) || defined(OS_LINUX)
void DecodeContents(std::string &contents, const std::string& encoding);
#endif
Expand Down
29 changes: 7 additions & 22 deletions appshell/appshell_extensions_win.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -913,26 +913,6 @@ std::wstring StringToWString(const std::string& str)
return converterX.from_bytes(str);
}

class ReadFileHandle {
HANDLE hFile;
public:
ReadFileHandle(const std::wstring& filename) {
hFile = CreateFile(filename.c_str(), GENERIC_READ,
FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
if (INVALID_HANDLE_VALUE == hFile)
throw "Could not initialize read handle";
}
~ReadFileHandle() {
if (hFile)
CloseHandle(hFile);
}
operator HANDLE() {
return hFile;
}
};



int32 ReadFile(ExtensionString filename, ExtensionString& encoding, std::string& contents, bool& preserveBOM)
{
if (encoding == L"utf8") {
Expand All @@ -946,10 +926,13 @@ int32 ReadFile(ExtensionString filename, ExtensionString& encoding, std::string&
if (dwAttr & FILE_ATTRIBUTE_DIRECTORY)
return ERR_CANT_READ;

ReadFileHandle readFileHandle(filename);
HANDLE hFile = readFileHandle;
HANDLE hFile = CreateFile(filename.c_str(), GENERIC_READ,
FILE_SHARE_READ, NULL, OPEN_EXISTING, FILE_ATTRIBUTE_NORMAL, NULL);
int32 error = NO_ERROR;

if (INVALID_HANDLE_VALUE == hFile)
return ConvertWinErrorCode(GetLastError());

DWORD dwFileSize = GetFileSize(hFile, NULL);

if (dwFileSize == 0) {
Expand Down Expand Up @@ -986,6 +969,7 @@ int32 ReadFile(ExtensionString filename, ExtensionString& encoding, std::string&
detectedCharSet = conv.to_bytes(encoding);
}
if (detectedCharSet == "UTF-16LE" || detectedCharSet == "UTF-16BE") {
CloseHandle(hFile);
return ERR_UNSUPPORTED_UTF16_ENCODING;
}
std::transform(detectedCharSet.begin(), detectedCharSet.end(), detectedCharSet.begin(), ::toupper);
Expand Down Expand Up @@ -1027,6 +1011,7 @@ int32 ReadFile(ExtensionString filename, ExtensionString& encoding, std::string&
}
}
}
CloseHandle(hFile);
return error;
}

Expand Down
6 changes: 6 additions & 0 deletions appshell/browser/client_handler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -323,6 +323,7 @@ void ClientHandler::OnDownloadUpdated(
}
}

#ifndef OS_LINUX
bool ClientHandler::OnDragEnter(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDragData> dragData,
CefDragHandler::DragOperationsMask mask) {
Expand All @@ -334,14 +335,19 @@ bool ClientHandler::OnDragEnter(CefRefPtr<CefBrowser> browser,

return false;
}
#endif

#ifndef OS_LINUX
//We do not plan to add any feature to parent class(::ClientHandler) implementation of this function.
//So override is useless, modern compilers will complain about this.
void ClientHandler::OnDraggableRegionsChanged(
CefRefPtr<CefBrowser> browser,
const std::vector<CefDraggableRegion>& regions) {
CEF_REQUIRE_UI_THREAD();

NotifyDraggableRegions(regions);
}
#endif

bool ClientHandler::OnRequestGeolocationPermission(
CefRefPtr<CefBrowser> browser,
Expand Down
9 changes: 9 additions & 0 deletions appshell/browser/client_handler.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,9 +105,12 @@ class ClientHandler :
CefRefPtr<CefDownloadHandler> GetDownloadHandler() OVERRIDE {
return this;
}
#ifndef OS_LINUX
CefRefPtr<CefDragHandler> GetDragHandler() OVERRIDE {
return this;
}
#endif

CefRefPtr<CefGeolocationHandler> GetGeolocationHandler() OVERRIDE {
return this;
}
Expand Down Expand Up @@ -173,13 +176,19 @@ class ClientHandler :
CefRefPtr<CefDownloadItemCallback> callback) OVERRIDE;

// CefDragHandler methods
#ifndef OS_LINUX
bool OnDragEnter(CefRefPtr<CefBrowser> browser,
CefRefPtr<CefDragData> dragData,
CefDragHandler::DragOperationsMask mask) OVERRIDE;
#endif

#ifndef OS_LINUX
//We do not plan to add any feature to parent class(::ClientHandler) implementation of this function.
//So override is useless, modern compilers will complain about this.
void OnDraggableRegionsChanged(
CefRefPtr<CefBrowser> browser,
const std::vector<CefDraggableRegion>& regions) OVERRIDE;
#endif

// CefGeolocationHandler methods
bool OnRequestGeolocationPermission(
Expand Down
Loading

0 comments on commit b858d45

Please sign in to comment.