|
7 | 7 | #include <cstdlib> |
8 | 8 | #include <sstream> |
9 | 9 | #include <string> |
| 10 | +#include <errno.h> |
10 | 11 | #include "include/cef_app.h" |
11 | 12 | #include "include/cef_browser.h" |
12 | 13 | #include "include/cef_command_line.h" |
|
19 | 20 | #include "config.h" |
20 | 21 |
|
21 | 22 | CefRefPtr<ClientHandler> g_handler; |
| 23 | +int g_remote_debugging_port = 0; |
22 | 24 |
|
23 | 25 | #ifdef OS_WIN |
24 | 26 | bool g_force_enable_acc = false; |
@@ -95,7 +97,28 @@ void AppGetSettings(CefSettings& settings, CefRefPtr<CefCommandLine> command_lin |
95 | 97 | command_line->GetSwitchValue(client::switches::kJavascriptFlags); |
96 | 98 |
|
97 | 99 | // Enable dev tools |
98 | | - settings.remote_debugging_port = REMOTE_DEBUGGING_PORT; |
| 100 | + CefString debugger_port = command_line->GetSwitchValue("remote-debugging-port"); |
| 101 | + 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 | + LOG(ERROR) << "Error while parsing remote-debugging-port arg: "<< debugger_port.ToString(); |
| 106 | + errno = 0; |
| 107 | + } |
| 108 | + else { |
| 109 | + static const long max_port_num = 65535; |
| 110 | + static const long max_reserved_port_num = 1024; |
| 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) << "Could not enable Remote debugging on port: "<< port |
| 117 | + << ". Port number must be greater than "<< max_reserved_port_num |
| 118 | + << " and less than " << max_port_num << "."; |
| 119 | + } |
| 120 | + } |
| 121 | + } |
99 | 122 |
|
100 | 123 | std::wstring versionStr = appshell::AppGetProductVersionString(); |
101 | 124 |
|
|
0 commit comments