Skip to content

Commit dcf9601

Browse files
committed
nwjs master
1 parent 83f1cf4 commit dcf9601

File tree

707 files changed

+9694
-1848
lines changed

Some content is hidden

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

707 files changed

+9694
-1848
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -306,3 +306,5 @@ vs-chromium-project.txt
306306
/win8/metro_driver/metro_driver_version_resources.xml
307307
/x86-generic_out/
308308
/xcodebuild
309+
/content/nw
310+

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/installer/zucchini:zucchini",
102103
"//chrome/installer/zucchini:zucchini_unittests",

DEPS

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ vars = {
1717
'6226d6cd80aaf2e5295ed460cf73ef6a582e4d78',
1818
'freetype_revision':
1919
'38bdf22bfe68432aebdd33c198a0bd11b4ebb96f',
20+
'nwjs_git':
21+
'https://github.com/nwjs',
2022
'google_toolbox_for_mac_revision':
2123
'ec72a2bc500a716369c383837bffdc7d2a22855b',
2224
'libfuzzer_revision':
@@ -183,8 +185,13 @@ deps = {
183185
(Var("chromium_git")) + '/chromium/deps/acid3.git@6be0a66a1ebd7ebc5abc1b2f405a945f6d871521',
184186
'src/tools/swarming_client':
185187
(Var("chromium_git")) + '/external/swarming.client.git@a56c2b39ca23bdf41458421a7f825ddbf3f43f28',
186-
'src/v8':
187-
(Var("chromium_git")) + '/v8/v8.git@eadc807ddf76e55da321630860f1fff74c149f09'
188+
#'src/v8':
189+
# (Var("chromium_git")) + '/v8/v8.git@eadc807ddf76e55da321630860f1fff74c149f09'
190+
# (Var("nwjs_git")) + '/v8.git@origin/nw16',
191+
#'src/content/nw':
192+
# (Var("nwjs_git")) + '/nw.js.git@origin/nw16',
193+
#'src/third_party/node':
194+
# (Var("nwjs_git")) + '/node.git@origin/nw16',
188195
}
189196

190197
deps_os = {
@@ -704,6 +711,16 @@ hooks = [
704711
'name':
705712
'wasm_fuzzer'
706713
},
714+
{
715+
'action': [
716+
'python',
717+
'src/content/nw/tools/patcher.py'
718+
],
719+
'pattern':
720+
'.',
721+
'name':
722+
'nw_patch'
723+
},
707724
{
708725
'action': [
709726
'python',

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
@@ -103,7 +103,10 @@ class PlatformAppPathLauncher
103103
extension_id(app->id()),
104104
entry_paths_(entry_paths),
105105
mime_type_collector_(context),
106-
is_directory_collector_(context) {}
106+
is_directory_collector_(context) {
107+
if (app->is_nwjs_app()) //NWJS#5097
108+
entry_paths_.clear();
109+
}
107110

108111
PlatformAppPathLauncher(content::BrowserContext* context,
109112
const Extension* app,
@@ -112,7 +115,7 @@ class PlatformAppPathLauncher
112115
extension_id(app->id()),
113116
mime_type_collector_(context),
114117
is_directory_collector_(context) {
115-
if (!file_path.empty())
118+
if (!file_path.empty() && !app->is_nwjs_app()) //NWJS#5097
116119
entry_paths_.push_back(file_path);
117120
}
118121

base/BUILD.gn

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -522,6 +522,8 @@ component("base") {
522522
"message_loop/message_pump_libevent.h",
523523
"message_loop/message_pump_mac.h",
524524
"message_loop/message_pump_mac.mm",
525+
"message_loop/message_pump_uv.cc",
526+
"message_loop/message_pump_uv.h",
525527
"message_loop/message_pump_win.cc",
526528
"message_loop/message_pump_win.h",
527529
"message_loop/timer_slack.h",

base/base_switches.cc

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,4 +121,5 @@ const char kEnableCrashReporterForTesting[] =
121121
"enable-crash-reporter-for-testing";
122122
#endif
123123

124+
const char kNWJS[] = "nwjs";
124125
} // namespace switches

base/base_switches.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ extern const char kDisableUsbKeyboardDetect[];
4141
extern const char kEnableCrashReporterForTesting[];
4242
#endif
4343

44+
extern const char kNWJS[];
4445
} // namespace switches
4546

4647
#endif // BASE_BASE_SWITCHES_H_

base/command_line.cc

Lines changed: 74 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -152,43 +152,84 @@ string16 QuoteForCommandLineToArgvW(const string16& arg,
152152

153153
CommandLine::CommandLine(NoProgram no_program)
154154
: argv_(1),
155-
begin_args_(1) {
155+
begin_args_(1),
156+
argc0_(0), argv0_(NULL) {
156157
}
157158

158159
CommandLine::CommandLine(const FilePath& program)
159160
: argv_(1),
160-
begin_args_(1) {
161+
begin_args_(1),
162+
argc0_(0), argv0_(NULL) {
161163
SetProgram(program);
162164
}
163165

164166
CommandLine::CommandLine(int argc, const CommandLine::CharType* const* argv)
165167
: argv_(1),
166-
begin_args_(1) {
168+
begin_args_(1),
169+
argc0_(0), argv0_(NULL) {
167170
InitFromArgv(argc, argv);
168171
}
169172

170173
CommandLine::CommandLine(const StringVector& argv)
171174
: argv_(1),
172-
begin_args_(1) {
175+
begin_args_(1),
176+
argc0_(0), argv0_(NULL) {
173177
InitFromArgv(argv);
174178
}
175179

176180
CommandLine::CommandLine(const CommandLine& other)
177181
: argv_(other.argv_),
182+
original_argv_(other.original_argv_),
178183
switches_(other.switches_),
179-
begin_args_(other.begin_args_) {
184+
begin_args_(other.begin_args_),
185+
argc0_(other.argc0_), argv0_(NULL) {
186+
187+
#if defined(OS_WIN)
188+
if (other.argv0_) {
189+
argv0_ = new char*[argc0_ + 1];
190+
for (int i = 0; i < argc0_; ++i) {
191+
argv0_[i] = new char[strlen(other.argv0_[i]) + 1];
192+
strcpy(argv0_[i], other.argv0_[i]);
193+
}
194+
argv0_[argc0_] = NULL;
195+
}
196+
#else
197+
argv0_ = other.argv0_;
198+
#endif
180199
ResetStringPieces();
181200
}
182201

183202
CommandLine& CommandLine::operator=(const CommandLine& other) {
184203
argv_ = other.argv_;
204+
original_argv_ = other.original_argv_;
185205
switches_ = other.switches_;
186206
begin_args_ = other.begin_args_;
207+
#if defined(OS_WIN)
208+
if (other.argv0_) {
209+
argc0_ = other.argc0_;
210+
argv0_ = new char*[argc0_ + 1];
211+
for (int i = 0; i < argc0_; ++i) {
212+
argv0_[i] = new char[strlen(other.argv0_[i]) + 1];
213+
strcpy(argv0_[i], other.argv0_[i]);
214+
}
215+
argv0_[argc0_] = NULL;
216+
}
217+
#else
218+
argv0_ = other.argv0_;
219+
#endif
187220
ResetStringPieces();
188221
return *this;
189222
}
190223

191224
CommandLine::~CommandLine() {
225+
#if defined(OS_WIN)
226+
if (!argv0_)
227+
return;
228+
for (int i = 0; i < argc0_; i++) {
229+
delete[] argv0_[i];
230+
}
231+
delete[] argv0_;
232+
#endif
192233
}
193234

194235
#if defined(OS_WIN)
@@ -260,12 +301,34 @@ CommandLine CommandLine::FromString(const string16& command_line) {
260301
void CommandLine::InitFromArgv(int argc,
261302
const CommandLine::CharType* const* argv) {
262303
StringVector new_argv;
304+
argc0_ = argc;
305+
#if !defined(OS_WIN)
306+
argv0_ = (char**)argv;
307+
#else
308+
argv0_ = new char*[argc + 1];
309+
for (int i = 0; i < argc; ++i) {
310+
std::string str(base::WideToUTF8(argv[i]));
311+
argv0_[i] = new char[str.length() + 1];
312+
strcpy(argv0_[i], str.c_str());
313+
}
314+
argv0_[argc] = NULL;
315+
#endif
263316
for (int i = 0; i < argc; ++i)
264317
new_argv.push_back(argv[i]);
265318
InitFromArgv(new_argv);
266319
}
267320

268321
void CommandLine::InitFromArgv(const StringVector& argv) {
322+
#if !defined(OS_MACOSX)
323+
original_argv_ = argv;
324+
#else
325+
for (size_t index = 0; index < argv.size(); ++index) {
326+
if (argv[index].compare(0, strlen("--psn_"), "--psn_") != 0 &&
327+
argv[index].compare(0, strlen("-psn_"), "-psn_") != 0) {
328+
original_argv_.push_back(argv[index]);
329+
}
330+
}
331+
#endif
269332
argv_ = StringVector(1);
270333
switches_.clear();
271334
switches_by_stringpiece_.clear();
@@ -402,6 +465,12 @@ void CommandLine::AppendArgNative(const CommandLine::StringType& value) {
402465
argv_.push_back(value);
403466
}
404467

468+
#if defined(OS_MACOSX)
469+
void CommandLine::FixOrigArgv4Finder(const CommandLine::StringType& value) {
470+
original_argv_.push_back(value);
471+
}
472+
#endif
473+
405474
void CommandLine::AppendArguments(const CommandLine& other,
406475
bool include_program) {
407476
if (include_program)

base/command_line.h

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

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

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

208+
#if defined(OS_MACOSX)
209+
void FixOrigArgv4Finder(const StringType& value);
210+
#endif
211+
203212
// Append the switches and arguments from another command line to this one.
204213
// If |include_program| is true, include |other|'s program as well.
205214
void AppendArguments(const CommandLine& other, bool include_program);
@@ -241,6 +250,9 @@ class BASE_EXPORT CommandLine {
241250
// The argv array: { program, [(--|-|/)switch[=value]]*, [--], [argument]* }
242251
StringVector argv_;
243252

253+
// The argv array (precedence not messed).
254+
StringVector original_argv_;
255+
244256
// Parsed-out switch keys and values.
245257
SwitchMap switches_;
246258

@@ -252,6 +264,9 @@ class BASE_EXPORT CommandLine {
252264

253265
// The index after the program and switches, any arguments start here.
254266
size_t begin_args_;
267+
268+
int argc0_;
269+
char** argv0_;
255270
};
256271

257272
} // namespace base

base/files/file_util_posix.cc

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

base/message_loop/message_loop.cc

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

210+
if (type == MessageLoop::TYPE_NODE)
211+
return std::unique_ptr<MessagePump>(new MessagePumpUV());
212+
210213
DCHECK_EQ(MessageLoop::TYPE_DEFAULT, type);
211214
return MESSAGE_PUMP_DEFAULT;
212215
}

base/message_loop/message_loop.h

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,8 @@ class JavaMessageHandlerFactory;
4848
} // namespace base
4949
#endif // defined(OS_ANDROID)
5050

51+
#include "base/message_loop/message_pump_uv.h"
52+
5153
namespace base {
5254

5355
class ThreadTaskRunnerHandle;
@@ -110,14 +112,18 @@ class BASE_EXPORT MessageLoop : public MessagePump::Delegate,
110112
// TYPE_CUSTOM
111113
// MessagePump was supplied to constructor.
112114
//
115+
// TYPE_NODE
116+
// For integration with NodeJS/libuv in the renderer thread
117+
113118
enum Type {
114119
TYPE_DEFAULT,
115120
TYPE_UI,
116121
TYPE_CUSTOM,
117122
TYPE_IO,
118123
#if defined(OS_ANDROID)
119124
TYPE_JAVA,
120-
#endif // defined(OS_ANDROID)
125+
#endif // defined(OS_ANDROID)
126+
TYPE_NODE
121127
};
122128

123129
// Normally, it is not necessary to instantiate a MessageLoop. Instead, it
@@ -620,6 +626,43 @@ class BASE_EXPORT MessageLoopForIO : public MessageLoop {
620626
static_assert(sizeof(MessageLoop) == sizeof(MessageLoopForIO),
621627
"MessageLoopForIO should not have extra member variables");
622628

629+
#if !defined(OS_MACOSX)
630+
631+
//-----------------------------------------------------------------------------
632+
// MessageLoopForUV extends MessageLoop with methods that are particular to a
633+
// MessageLoop instantiated with TYPE_NODE.
634+
//
635+
// This class is typically used like so:
636+
// MessageLoopForUV::current()->...call some method...
637+
//
638+
639+
class BASE_EXPORT MessageLoopForUV : public MessageLoop {
640+
public:
641+
642+
MessageLoopForUV() : MessageLoop(TYPE_NODE) {
643+
}
644+
645+
// Returns the MessageLoopForUV of the current thread.
646+
static MessageLoopForUV* current() {
647+
MessageLoop* loop = MessageLoop::current();
648+
//DCHECK_EQ(MessageLoop::TYPE_NODE, loop->type());
649+
return static_cast<MessageLoopForUV*>(loop);
650+
}
651+
652+
base::MessagePumpUV* pump_uv() {
653+
return static_cast<base::MessagePumpUV*>(pump_.get());
654+
}
655+
656+
};
657+
658+
// Do not add any member variables to MessageLoopForUV! This is important b/c
659+
// MessageLoopForUV is often allocated via MessageLoop(TYPE_IO). Any extra
660+
// data that you need should be stored on the MessageLoop's pump_ instance.
661+
static_assert(sizeof(MessageLoop) == sizeof(MessageLoopForUV),
662+
"MessageLoopForUV should not have extra member variables");
663+
664+
#endif
665+
623666
} // namespace base
624667

625668
#endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_

0 commit comments

Comments
 (0)