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

Commit c662e97

Browse files
narayani28g-217
authored andcommitted
Merge pull request #673 from jha-g/jha-g/moving-commandline-error-to-infobar2
moving command line error to infobar and fixing windows port range issues
1 parent 340be0e commit c662e97

File tree

2 files changed

+31
-19
lines changed

2 files changed

+31
-19
lines changed

appshell/appshell_extensions.cpp

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838

3939
extern std::vector<CefString> gDroppedFiles;
4040
extern int g_remote_debugging_port;
41+
extern std::string g_get_remote_debugging_port_error;
4142

4243
namespace appshell_extensions {
4344

@@ -57,6 +58,7 @@ class ProcessMessageDelegate : public ClientHandler::ProcessMessageDelegate {
5758
CefRefPtr<CefListValue> argList = message->GetArgumentList();
5859
int32 callbackId = -1;
5960
int32 error = NO_ERROR;
61+
std::string errInfo;
6062
CefRefPtr<CefProcessMessage> response =
6163
CefProcessMessage::Create("invokeCallback");
6264
CefRefPtr<CefListValue> responseArgs = response->GetArgumentList();
@@ -844,7 +846,13 @@ class ProcessMessageDelegate : public ClientHandler::ProcessMessageDelegate {
844846
uberDict->SetList(1, allStats);
845847
responseArgs->SetList(2, uberDict);
846848
} else if (message_name == "GetRemoteDebuggingPort") {
847-
responseArgs->SetInt(2, g_remote_debugging_port);
849+
if (g_get_remote_debugging_port_error.empty() && g_remote_debugging_port > 0) {
850+
responseArgs->SetInt(2, g_remote_debugging_port);
851+
}
852+
else {
853+
responseArgs->SetNull(2);
854+
errInfo = g_get_remote_debugging_port_error;
855+
}
848856
}
849857

850858
else {
@@ -853,8 +861,13 @@ class ProcessMessageDelegate : public ClientHandler::ProcessMessageDelegate {
853861
}
854862

855863
if (callbackId != -1) {
856-
responseArgs->SetInt(1, error);
857-
864+
if (errInfo.empty()) {
865+
responseArgs->SetInt(1, error);
866+
}
867+
else {
868+
responseArgs->SetString(1, errInfo);
869+
}
870+
858871
// Send response
859872
browser->SendProcessMessage(PID_RENDERER, response);
860873
}

appshell/cefclient.cpp

Lines changed: 15 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
CefRefPtr<ClientHandler> g_handler;
2323
int g_remote_debugging_port = 0;
24+
std::string g_get_remote_debugging_port_error;
2425

2526
#ifdef OS_WIN
2627
bool g_force_enable_acc = false;
@@ -99,24 +100,22 @@ void AppGetSettings(CefSettings& settings, CefRefPtr<CefCommandLine> command_lin
99100
// Enable dev tools
100101
CefString debugger_port = command_line->GetSwitchValue("remote-debugging-port");
101102
if (!debugger_port.empty()) {
102-
const long port = strtol(debugger_port.ToString().c_str(), NULL, 10);
103-
if (errno == ERANGE || port == 0) {
104-
LOG(ERROR) << "Could not enable remote debugging."
105-
<< " Error while parsing remote-debugging-port arg: "<< debugger_port.ToString();
106-
errno = 0;
103+
g_get_remote_debugging_port_error = debugger_port.ToString();
104+
long port = strtol(g_get_remote_debugging_port_error.c_str(), NULL, 10);
105+
if (errno == ERANGE) {
106+
errno = port = 0;
107+
}
108+
static const long max_port_num = 65535;
109+
static const long max_reserved_port_num = 1023;
110+
if (port > max_reserved_port_num && port < max_port_num) {
111+
g_remote_debugging_port = static_cast<int>(port);
112+
settings.remote_debugging_port = g_remote_debugging_port;
113+
g_get_remote_debugging_port_error.clear();
107114
}
108115
else {
109-
static const long max_port_num = 65534;
110-
static const long max_reserved_port_num = 1025;
111-
if (port >= max_reserved_port_num && port <= max_port_num) {
112-
g_remote_debugging_port = static_cast<int>(port);
113-
settings.remote_debugging_port = g_remote_debugging_port;
114-
}
115-
else {
116-
LOG(ERROR) << "Cannot enable remote debugging on port "<< port
117-
<< ". Port numbers should be between "<< max_reserved_port_num
118-
<< " and " << max_port_num << ".";
119-
}
116+
// Setting debugging port to highest number will disable remote debugging
117+
// As setting.remote_debugging_port has higher priority compared to command line option
118+
settings.remote_debugging_port = max_port_num;
120119
}
121120
}
122121

0 commit comments

Comments
 (0)