MCPcopy Create free account
hub / github.com/cztomczak/cefpython / OpenInExternalBrowser

Function OpenInExternalBrowser

src/client_handler/context_menu_handler.cpp:125–157  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

123
124#if defined(OS_LINUX)
125void OpenInExternalBrowser(const std::string& url)
126{
127 // Linux equivalent of ShellExecute
128
129 if (url.empty()) {
130 LOG(ERROR) << "[Browser process] OpenInExternalBrowser():"
131 " url is empty";
132 return;
133 }
134 std::string msg = "[Browser process] OpenInExternalBrowser(): url=";
135 msg.append(url.c_str());
136 LOG(INFO) << msg.c_str();
137
138 // xdg-open is a desktop-independent tool for running
139 // default applications. Installed by default on Ubuntu.
140 // xdg-open process is running in the backround until
141 // cefpython app closes.
142 std::string prog = "xdg-open";
143
144 // Using system() opens up for bugs and exploits, not
145 // recommended.
146
147 // Fork yourself and run in parallel, do not block the
148 // current proces.
149 char *args[3];
150 args[0] = (char*) prog.c_str();
151 args[1] = (char*) url.c_str();
152 args[2] = 0;
153 pid_t pid = fork();
154 if (!pid) {
155 execvp(prog.c_str(), args);
156 }
157}
158#endif

Callers 1

OnContextMenuCommandMethod · 0.85

Calls 2

c_strMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected