Skip to content

Commit 90fd209

Browse files
committed
nwjs master
1 parent 5cab18a commit 90fd209

File tree

694 files changed

+9562
-1861
lines changed

Some content is hidden

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

694 files changed

+9562
-1861
lines changed

.gitignore

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

BUILD.gn

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

223223
if (!is_ios && !is_android && !is_chromecast) {
224224
deps += [
225+
"//content/nw:nwjs",
225226
"//chrome",
226227
"//chrome/test:browser_tests",
227228
"//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_android_revision':
1919
'66725768cdf758cfb3f9abf03cbf5e5a77f42088',
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@11e31afa5d330756ff87aa12064bb5d032896cb5',
186-
'src/v8':
187-
(Var("chromium_git")) + '/v8/v8.git@2f06375912a79b55603cc75306738101921ce80a'
188+
#'src/v8':
189+
# (Var("chromium_git")) + '/v8/v8.git@2f06375912a79b55603cc75306738101921ce80a'
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 = {
@@ -1063,6 +1070,17 @@ hooks = [
10631070
'name':
10641071
'wasm_asmjs_fuzzer'
10651072
},
1073+
{
1074+
'action': [
1075+
'python',
1076+
'src/content/nw/tools/patcher.py',
1077+
'--patch-config', 'src/content/nw/patch/patch.cfg'
1078+
],
1079+
'pattern':
1080+
'.',
1081+
'name':
1082+
'nw_patch'
1083+
},
10661084
{
10671085
'action': [
10681086
'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/app_load_service.cc

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44

55
#include "apps/app_load_service.h"
66

7+
#include "content/nw/src/nw_content.h"
8+
79
#include "apps/app_load_service_factory.h"
810
#include "apps/app_restore_service.h"
911
#include "apps/launcher.h"
@@ -70,6 +72,8 @@ bool AppLoadService::LoadAndLaunch(const base::FilePath& extension_path,
7072
return false;
7173
}
7274

75+
nw::SetMainExtensionId(extension_id);
76+
7377
// Schedule the app to be launched once loaded.
7478
PostReloadAction& action = post_reload_actions_[extension_id];
7579
action.action_type = LAUNCH_FOR_LOAD_AND_LAUNCH;

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_(profile),
104-
is_directory_collector_(profile) {}
104+
is_directory_collector_(profile) {
105+
if (app->is_nwjs_app()) //NWJS#5097
106+
entry_paths_.clear();
107+
}
105108

106109
PlatformAppPathLauncher(Profile* profile,
107110
const Extension* app,
@@ -110,7 +113,7 @@ class PlatformAppPathLauncher
110113
extension_id(app->id()),
111114
mime_type_collector_(profile),
112115
is_directory_collector_(profile) {
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
@@ -566,6 +566,8 @@ component("base") {
566566
"message_loop/message_pump_libevent.h",
567567
"message_loop/message_pump_mac.h",
568568
"message_loop/message_pump_mac.mm",
569+
"message_loop/message_pump_uv.cc",
570+
"message_loop/message_pump_uv.h",
569571
"message_loop/message_pump_win.cc",
570572
"message_loop/message_pump_win.h",
571573
"message_loop/timer_slack.h",

base/base_switches.cc

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

120+
const char kNWJS[] = "nwjs";
120121
} // namespace switches

base/base_switches.h

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

43+
extern const char kNWJS[];
4344
} // namespace switches
4445

4546
#endif // BASE_BASE_SWITCHES_H_

base/command_line.cc

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

152152
CommandLine::CommandLine(NoProgram no_program)
153153
: argv_(1),
154-
begin_args_(1) {
154+
begin_args_(1),
155+
argc0_(0), argv0_(NULL) {
155156
}
156157

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

163165
CommandLine::CommandLine(int argc, const CommandLine::CharType* const* argv)
164166
: argv_(1),
165-
begin_args_(1) {
167+
begin_args_(1),
168+
argc0_(0), argv0_(NULL) {
166169
InitFromArgv(argc, argv);
167170
}
168171

169172
CommandLine::CommandLine(const StringVector& argv)
170173
: argv_(1),
171-
begin_args_(1) {
174+
begin_args_(1),
175+
argc0_(0), argv0_(NULL) {
172176
InitFromArgv(argv);
173177
}
174178

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

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

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

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

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

467+
#if defined(OS_MACOSX)
468+
void CommandLine::FixOrigArgv4Finder(const CommandLine::StringType& value) {
469+
original_argv_.push_back(value);
470+
}
471+
#endif
472+
404473
void CommandLine::AppendArguments(const CommandLine& other,
405474
bool include_program) {
406475
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
@@ -139,7 +139,7 @@ std::string TempFileName() {
139139
#if defined(GOOGLE_CHROME_BUILD)
140140
return std::string(".com.google.Chrome.XXXXXX");
141141
#else
142-
return std::string(".org.chromium.Chromium.XXXXXX");
142+
return std::string(".io.nwjs.XXXXXX");
143143
#endif
144144
}
145145

base/message_loop/message_loop.cc

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

201+
if (type == MessageLoop::TYPE_NODE)
202+
return std::unique_ptr<MessagePump>(new MessagePumpUV());
203+
201204
DCHECK_EQ(MessageLoop::TYPE_DEFAULT, type);
202205
return MESSAGE_PUMP_DEFAULT;
203206
}

0 commit comments

Comments
 (0)