Skip to content

Commit 5db10ec

Browse files
committed
nwjs master
1 parent e1268ad commit 5db10ec

File tree

779 files changed

+10547
-1934
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

779 files changed

+10547
-1934
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -280,3 +280,5 @@ vs-chromium-project.txt
280280
/win8/metro_driver/metro_driver_version_resources.xml
281281
/x86-generic_out/
282282
/xcodebuild
283+
/content/nw
284+

BUILD.gn

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ group("gn_all") {
9797

9898
if (!is_ios && !is_android && !is_chromecast && !is_fuchsia) {
9999
deps += [
100+
"//content/nw:nwjs",
100101
"//chrome",
101102
"//chrome/test:browser_tests",
102103
"//chrome/test:interactive_ui_tests",

DEPS

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ vars = {
8585
'android_git': 'https://android.googlesource.com',
8686
'aomedia_git': 'https://aomedia.googlesource.com',
8787
'chromium_git': 'https://chromium.googlesource.com',
88+
'nwjs_git': 'https://github.com/nwjs',
8889
'swiftshader_git': 'https://swiftshader.googlesource.com',
8990
'pdfium_git': 'https://pdfium.googlesource.com',
9091
'boringssl_git': 'https://boringssl.googlesource.com',
@@ -1010,8 +1011,8 @@ deps = {
10101011
'src/tools/swarming_client':
10111012
Var('chromium_git') + '/infra/luci/client-py.git' + '@' + Var('swarming_revision'),
10121013

1013-
'src/v8':
1014-
Var('chromium_git') + '/v8/v8.git' + '@' + Var('v8_revision'),
1014+
#'src/v8':
1015+
# Var('chromium_git') + '/v8/v8.git' + '@' + Var('v8_revision'),
10151016

10161017
'src-internal': {
10171018
'url': 'https://chrome-internal.googlesource.com/chrome/src-internal.git@4f6d0d2338db72503be90be956306b6fe3f4f116',
@@ -1767,7 +1768,15 @@ hooks = [
17671768
'--no_auth',
17681769
'--bucket', 'chromium-nodejs/8.9.1',
17691770
'-s', 'src/third_party/node/linux/node-linux-x64.tar.gz.sha1',
1770-
],
1771+
],
1772+
},
1773+
{
1774+
'name': 'nw_patch',
1775+
'pattern': '.',
1776+
'action': [
1777+
'python',
1778+
'src/content/nw/tools/patcher.py'
1779+
],
17711780
},
17721781
{
17731782
'name': 'node_mac',

apps/app_lifetime_monitor.cc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,8 +77,10 @@ void AppLifetimeMonitor::OnAppWindowRemoved(AppWindow* app_window) {
7777
}
7878

7979
void AppLifetimeMonitor::OnAppWindowHidden(AppWindow* app_window) {
80+
#if 0
8081
if (!HasOtherVisibleAppWindows(app_window))
8182
NotifyAppDeactivated(app_window->extension_id());
83+
#endif
8284
}
8385

8486
void AppLifetimeMonitor::OnAppWindowShown(AppWindow* app_window,

apps/launcher.cc

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,10 @@ class PlatformAppPathLauncher
104104
extension_id(app->id()),
105105
entry_paths_(entry_paths),
106106
mime_type_collector_(context),
107-
is_directory_collector_(context) {}
107+
is_directory_collector_(context) {
108+
if (app->is_nwjs_app()) //NWJS#5097
109+
entry_paths_.clear();
110+
}
108111

109112
PlatformAppPathLauncher(content::BrowserContext* context,
110113
const Extension* app,
@@ -113,7 +116,7 @@ class PlatformAppPathLauncher
113116
extension_id(app->id()),
114117
mime_type_collector_(context),
115118
is_directory_collector_(context) {
116-
if (!file_path.empty())
119+
if (!file_path.empty() && !app->is_nwjs_app()) //NWJS#5097
117120
entry_paths_.push_back(file_path);
118121
}
119122

base/BUILD.gn

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -565,6 +565,8 @@ jumbo_component("base") {
565565
"message_loop/message_pump_io_ios.h",
566566
"message_loop/message_pump_mac.h",
567567
"message_loop/message_pump_mac.mm",
568+
"message_loop/message_pump_uv.cc",
569+
"message_loop/message_pump_uv.h",
568570
"message_loop/message_pump_win.cc",
569571
"message_loop/message_pump_win.h",
570572
"message_loop/timer_slack.h",

base/base_switches.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,4 +124,5 @@ const char kForceNativePrefetch[] = "force-native-prefetch";
124124
const char kNativePrefetchOrderedOnly[] = "native-prefetch-ordered-only";
125125
#endif
126126

127+
const char kNWJS[] = "nwjs";
127128
} // namespace switches

base/base_switches.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ extern const char kForceNativePrefetch[];
4848
extern const char kNativePrefetchOrderedOnly[];
4949
#endif
5050

51+
extern const char kNWJS[];
5152
} // namespace switches
5253

5354
#endif // BASE_BASE_SWITCHES_H_

base/command_line.cc

Lines changed: 86 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -155,32 +155,83 @@ string16 QuoteForCommandLineToArgvW(const string16& arg,
155155

156156
CommandLine::CommandLine(NoProgram no_program)
157157
: argv_(1),
158-
begin_args_(1) {
158+
begin_args_(1),
159+
argc0_(0), argv0_(NULL) {
159160
}
160161

161162
CommandLine::CommandLine(const FilePath& program)
162163
: argv_(1),
163-
begin_args_(1) {
164+
begin_args_(1),
165+
argc0_(0), argv0_(NULL) {
164166
SetProgram(program);
165167
}
166168

167169
CommandLine::CommandLine(int argc, const CommandLine::CharType* const* argv)
168170
: argv_(1),
169-
begin_args_(1) {
171+
begin_args_(1),
172+
argc0_(0), argv0_(NULL) {
170173
InitFromArgv(argc, argv);
171174
}
172175

173176
CommandLine::CommandLine(const StringVector& argv)
174177
: argv_(1),
175-
begin_args_(1) {
178+
begin_args_(1),
179+
argc0_(0), argv0_(NULL) {
176180
InitFromArgv(argv);
177181
}
178182

179-
CommandLine::CommandLine(const CommandLine& other) = default;
183+
CommandLine::CommandLine(const CommandLine& other)
184+
: argv_(other.argv_),
185+
original_argv_(other.original_argv_),
186+
switches_(other.switches_),
187+
begin_args_(other.begin_args_),
188+
argc0_(other.argc0_), argv0_(nullptr) {
180189

181-
CommandLine& CommandLine::operator=(const CommandLine& other) = default;
190+
#if defined(OS_WIN)
191+
if (other.argv0_) {
192+
argv0_ = new char*[argc0_ + 1];
193+
for (int i = 0; i < argc0_; ++i) {
194+
argv0_[i] = new char[strlen(other.argv0_[i]) + 1];
195+
strcpy(argv0_[i], other.argv0_[i]);
196+
}
197+
argv0_[argc0_] = NULL;
198+
}
199+
#else
200+
argv0_ = other.argv0_;
201+
#endif
202+
}
203+
204+
CommandLine& CommandLine::operator=(const CommandLine& other) {
205+
argv_ = other.argv_;
206+
original_argv_ = other.original_argv_;
207+
switches_ = other.switches_;
208+
begin_args_ = other.begin_args_;
209+
#if defined(OS_WIN)
210+
if (other.argv0_) {
211+
argc0_ = other.argc0_;
212+
argv0_ = new char*[argc0_ + 1];
213+
for (int i = 0; i < argc0_; ++i) {
214+
argv0_[i] = new char[strlen(other.argv0_[i]) + 1];
215+
strcpy(argv0_[i], other.argv0_[i]);
216+
}
217+
argv0_[argc0_] = NULL;
218+
}
219+
#else
220+
argv0_ = other.argv0_;
221+
#endif
222+
return *this;
223+
}
182224

183-
CommandLine::~CommandLine() = default;
225+
CommandLine::~CommandLine() {
226+
#if defined(OS_WIN)
227+
if (!argv0_)
228+
return;
229+
for (int i = 0; i < argc0_; i++) {
230+
delete[] argv0_[i];
231+
}
232+
delete[] argv0_;
233+
#endif
234+
}
184235

185236
#if defined(OS_WIN)
186237
// static
@@ -253,12 +304,34 @@ CommandLine CommandLine::FromString(const string16& command_line) {
253304
void CommandLine::InitFromArgv(int argc,
254305
const CommandLine::CharType* const* argv) {
255306
StringVector new_argv;
307+
argc0_ = argc;
308+
#if !defined(OS_WIN)
309+
argv0_ = (char**)argv;
310+
#else
311+
argv0_ = new char*[argc + 1];
312+
for (int i = 0; i < argc; ++i) {
313+
std::string str(base::WideToUTF8(argv[i]));
314+
argv0_[i] = new char[str.length() + 1];
315+
strcpy(argv0_[i], str.c_str());
316+
}
317+
argv0_[argc] = NULL;
318+
#endif
256319
for (int i = 0; i < argc; ++i)
257320
new_argv.push_back(argv[i]);
258321
InitFromArgv(new_argv);
259322
}
260323

261324
void CommandLine::InitFromArgv(const StringVector& argv) {
325+
#if !defined(OS_MACOSX)
326+
original_argv_ = argv;
327+
#else
328+
for (size_t index = 0; index < argv.size(); ++index) {
329+
if (argv[index].compare(0, strlen("--psn_"), "--psn_") != 0 &&
330+
argv[index].compare(0, strlen("-psn_"), "-psn_") != 0) {
331+
original_argv_.push_back(argv[index]);
332+
}
333+
}
334+
#endif
262335
argv_ = StringVector(1);
263336
switches_.clear();
264337
begin_args_ = 1;
@@ -397,6 +470,12 @@ void CommandLine::AppendArgNative(const CommandLine::StringType& value) {
397470
argv_.push_back(value);
398471
}
399472

473+
#if defined(OS_MACOSX)
474+
void CommandLine::FixOrigArgv4Finder(const CommandLine::StringType& value) {
475+
original_argv_.push_back(value);
476+
}
477+
#endif
478+
400479
void CommandLine::AppendArguments(const CommandLine& other,
401480
bool include_program) {
402481
if (include_program)

base/command_line.h

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,11 @@ class BASE_EXPORT CommandLine {
149149

150150
// Returns the original command line string as a vector of strings.
151151
const StringVector& argv() const { return argv_; }
152+
int argc0() { return argc0_; }
153+
char** argv0() { return argv0_; }
154+
155+
// Returns the original command line string as a vector of strings (keeps precedence).
156+
const StringVector& original_argv() const { return original_argv_; }
152157

153158
// Get and Set the program part of the command line string (the first item).
154159
FilePath GetProgram() const;
@@ -199,6 +204,10 @@ class BASE_EXPORT CommandLine {
199204
void AppendArgPath(const FilePath& value);
200205
void AppendArgNative(const StringType& value);
201206

207+
#if defined(OS_MACOSX)
208+
void FixOrigArgv4Finder(const StringType& value);
209+
#endif
210+
202211
// Append the switches and arguments from another command line to this one.
203212
// If |include_program| is true, include |other|'s program as well.
204213
void AppendArguments(const CommandLine& other, bool include_program);
@@ -235,11 +244,17 @@ class BASE_EXPORT CommandLine {
235244
// The argv array: { program, [(--|-|/)switch[=value]]*, [--], [argument]* }
236245
StringVector argv_;
237246

247+
// The argv array (precedence not messed).
248+
StringVector original_argv_;
249+
238250
// Parsed-out switch keys and values.
239251
SwitchMap switches_;
240252

241253
// The index after the program and switches, any arguments start here.
242254
size_t begin_args_;
255+
256+
int argc0_;
257+
char** argv0_;
243258
};
244259

245260
} // namespace base

base/files/file_util_posix.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ std::string TempFileName() {
134134
#if defined(GOOGLE_CHROME_BUILD)
135135
return std::string(".com.google.Chrome.XXXXXX");
136136
#else
137-
return std::string(".org.chromium.Chromium.XXXXXX");
137+
return std::string(".io.nwjs.XXXXXX");
138138
#endif
139139
}
140140

base/message_loop/message_loop.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,9 @@ std::unique_ptr<MessagePump> MessageLoop::CreateMessagePumpForType(Type type) {
143143
return std::unique_ptr<MessagePump>(new MessagePumpForUI());
144144
#endif
145145

146+
if (type == MessageLoop::TYPE_NODE)
147+
return std::unique_ptr<MessagePump>(new MessagePumpUV());
148+
146149
DCHECK_EQ(MessageLoop::TYPE_DEFAULT, type);
147150
#if defined(OS_IOS)
148151
// On iOS, a native runloop is always required to pump system work.

base/message_loop/message_loop.h

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@
2828
#include "base/time/time.h"
2929
#include "build/build_config.h"
3030

31+
#include "base/message_loop/message_pump_uv.h"
32+
3133
namespace base {
3234

3335
class ThreadTaskRunnerHandle;
@@ -109,14 +111,18 @@ class BASE_EXPORT MessageLoop : public MessagePump::Delegate,
109111
// TYPE_CUSTOM
110112
// MessagePump was supplied to constructor.
111113
//
114+
// TYPE_NODE
115+
// For integration with NodeJS/libuv in the renderer thread
116+
112117
enum Type {
113118
TYPE_DEFAULT,
114119
TYPE_UI,
115120
TYPE_CUSTOM,
116121
TYPE_IO,
117122
#if defined(OS_ANDROID)
118123
TYPE_JAVA,
119-
#endif // defined(OS_ANDROID)
124+
#endif // defined(OS_ANDROID)
125+
TYPE_NODE
120126
};
121127

122128
// Normally, it is not necessary to instantiate a MessageLoop. Instead, it
@@ -403,6 +409,43 @@ class BASE_EXPORT MessageLoopForIO : public MessageLoop {
403409
static_assert(sizeof(MessageLoop) == sizeof(MessageLoopForIO),
404410
"MessageLoopForIO should not have extra member variables");
405411

412+
#if !defined(OS_MACOSX)
413+
414+
//-----------------------------------------------------------------------------
415+
// MessageLoopForUV extends MessageLoop with methods that are particular to a
416+
// MessageLoop instantiated with TYPE_NODE.
417+
//
418+
// This class is typically used like so:
419+
// MessageLoopForUV::current()->...call some method...
420+
//
421+
422+
class BASE_EXPORT MessageLoopForUV : public MessageLoop {
423+
public:
424+
425+
MessageLoopForUV() : MessageLoop(TYPE_NODE) {
426+
}
427+
428+
// Returns the MessageLoopForUV of the current thread.
429+
static MessageLoopForUV* current() {
430+
MessageLoop* loop = MessageLoop::current();
431+
//DCHECK_EQ(MessageLoop::TYPE_NODE, loop->type());
432+
return static_cast<MessageLoopForUV*>(loop);
433+
}
434+
435+
base::MessagePumpUV* pump_uv() {
436+
return static_cast<base::MessagePumpUV*>(pump_.get());
437+
}
438+
439+
};
440+
441+
// Do not add any member variables to MessageLoopForUV! This is important b/c
442+
// MessageLoopForUV is often allocated via MessageLoop(TYPE_IO). Any extra
443+
// data that you need should be stored on the MessageLoop's pump_ instance.
444+
static_assert(sizeof(MessageLoop) == sizeof(MessageLoopForUV),
445+
"MessageLoopForUV should not have extra member variables");
446+
447+
#endif
448+
406449
} // namespace base
407450

408451
#endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_

0 commit comments

Comments
 (0)