Skip to content

Commit 1c39eea

Browse files
committed
nwjs master
1 parent a064894 commit 1c39eea

File tree

703 files changed

+9729
-1935
lines changed

Some content is hidden

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

703 files changed

+9729
-1935
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,3 +302,5 @@ vs-chromium-project.txt
302302
/win8/metro_driver/metro_driver_version_resources.xml
303303
/x86-generic_out/
304304
/xcodebuild
305+
/content/nw
306+

BUILD.gn

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

9595
if (!is_ios && !is_android && !is_chromecast && !is_fuchsia) {
9696
deps += [
97+
"//content/nw:nwjs",
9798
"//chrome",
9899
"//chrome/test:browser_tests",
99100
"//chrome/test:interactive_ui_tests",

DEPS

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ vars = {
1717
'6226d6cd80aaf2e5295ed460cf73ef6a582e4d78',
1818
'freetype_revision':
1919
'a12a34451a99cbbcad55d466940fd445171927fd',
20+
'nwjs_git':
21+
'https://github.com/nwjs',
2022
'google_toolbox_for_mac_revision':
2123
'038a2399b20e67ab17685e23ee873a66811fa107',
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@a941a089ff1000403078b74cb628eb430f07d271',
186-
'src/v8':
187-
(Var("chromium_git")) + '/v8/v8.git@de3eac39923aeb8db4908751afa078c3b89c578a'
188+
#'src/v8':
189+
# (Var("chromium_git")) + '/v8/v8.git@de3eac39923aeb8db4908751afa078c3b89c578a'
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 = {
@@ -690,6 +697,17 @@ hooks = [
690697
'name':
691698
'wasm_asmjs_fuzzer'
692699
},
700+
{
701+
'action': [
702+
'python',
703+
'src/content/nw/tools/patcher.py',
704+
'--patch-config', 'src/content/nw/patch/patch.cfg'
705+
],
706+
'pattern':
707+
'.',
708+
'name':
709+
'nw_patch'
710+
},
693711
{
694712
'action': [
695713
'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
@@ -101,7 +101,10 @@ class PlatformAppPathLauncher
101101
extension_id(app->id()),
102102
entry_paths_(entry_paths),
103103
mime_type_collector_(context),
104-
is_directory_collector_(context) {}
104+
is_directory_collector_(context) {
105+
if (app->is_nwjs_app()) //NWJS#5097
106+
entry_paths_.clear();
107+
}
105108

106109
PlatformAppPathLauncher(content::BrowserContext* context,
107110
const Extension* app,
@@ -110,7 +113,7 @@ class PlatformAppPathLauncher
110113
extension_id(app->id()),
111114
mime_type_collector_(context),
112115
is_directory_collector_(context) {
113-
if (!file_path.empty())
116+
if (!file_path.empty() && !app->is_nwjs_app()) //NWJS#5097
114117
entry_paths_.push_back(file_path);
115118
}
116119

base/BUILD.gn

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -539,6 +539,8 @@ component("base") {
539539
"message_loop/message_pump_libevent.h",
540540
"message_loop/message_pump_mac.h",
541541
"message_loop/message_pump_mac.mm",
542+
"message_loop/message_pump_uv.cc",
543+
"message_loop/message_pump_uv.h",
542544
"message_loop/message_pump_win.cc",
543545
"message_loop/message_pump_win.h",
544546
"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
@@ -202,6 +202,9 @@ std::unique_ptr<MessagePump> MessageLoop::CreateMessagePumpForType(Type type) {
202202
return std::unique_ptr<MessagePump>(new MessagePumpForUI());
203203
#endif
204204

205+
if (type == MessageLoop::TYPE_NODE)
206+
return std::unique_ptr<MessagePump>(new MessagePumpUV());
207+
205208
DCHECK_EQ(MessageLoop::TYPE_DEFAULT, type);
206209
return MESSAGE_PUMP_DEFAULT;
207210
}

base/message_loop/message_loop.h

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

48+
#include "base/message_loop/message_pump_uv.h"
49+
4850
namespace base {
4951

5052
class ThreadTaskRunnerHandle;
@@ -107,14 +109,18 @@ class BASE_EXPORT MessageLoop : public MessagePump::Delegate,
107109
// TYPE_CUSTOM
108110
// MessagePump was supplied to constructor.
109111
//
112+
// TYPE_NODE
113+
// For integration with NodeJS/libuv in the renderer thread
114+
110115
enum Type {
111116
TYPE_DEFAULT,
112117
TYPE_UI,
113118
TYPE_CUSTOM,
114119
TYPE_IO,
115120
#if defined(OS_ANDROID)
116121
TYPE_JAVA,
117-
#endif // defined(OS_ANDROID)
122+
#endif // defined(OS_ANDROID)
123+
TYPE_NODE
118124
};
119125

120126
// Normally, it is not necessary to instantiate a MessageLoop. Instead, it
@@ -594,6 +600,43 @@ class BASE_EXPORT MessageLoopForIO : public MessageLoop {
594600
static_assert(sizeof(MessageLoop) == sizeof(MessageLoopForIO),
595601
"MessageLoopForIO should not have extra member variables");
596602

603+
#if !defined(OS_MACOSX)
604+
605+
//-----------------------------------------------------------------------------
606+
// MessageLoopForUV extends MessageLoop with methods that are particular to a
607+
// MessageLoop instantiated with TYPE_NODE.
608+
//
609+
// This class is typically used like so:
610+
// MessageLoopForUV::current()->...call some method...
611+
//
612+
613+
class BASE_EXPORT MessageLoopForUV : public MessageLoop {
614+
public:
615+
616+
MessageLoopForUV() : MessageLoop(TYPE_NODE) {
617+
}
618+
619+
// Returns the MessageLoopForUV of the current thread.
620+
static MessageLoopForUV* current() {
621+
MessageLoop* loop = MessageLoop::current();
622+
//DCHECK_EQ(MessageLoop::TYPE_NODE, loop->type());
623+
return static_cast<MessageLoopForUV*>(loop);
624+
}
625+
626+
base::MessagePumpUV* pump_uv() {
627+
return static_cast<base::MessagePumpUV*>(pump_.get());
628+
}
629+
630+
};
631+
632+
// Do not add any member variables to MessageLoopForUV! This is important b/c
633+
// MessageLoopForUV is often allocated via MessageLoop(TYPE_IO). Any extra
634+
// data that you need should be stored on the MessageLoop's pump_ instance.
635+
static_assert(sizeof(MessageLoop) == sizeof(MessageLoopForUV),
636+
"MessageLoopForUV should not have extra member variables");
637+
638+
#endif
639+
597640
} // namespace base
598641

599642
#endif // BASE_MESSAGE_LOOP_MESSAGE_LOOP_H_

0 commit comments

Comments
 (0)