Skip to content

Commit 8adf1c9

Browse files
committed
nwjs master
1 parent 8a67263 commit 8adf1c9

File tree

691 files changed

+9526
-1881
lines changed

Some content is hidden

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

691 files changed

+9526
-1881
lines changed

.gitignore

+2
Original file line numberDiff line numberDiff line change
@@ -520,3 +520,5 @@ vs-chromium-project.txt
520520
/win8/metro_driver/metro_driver_version_resources.xml
521521
/x86-generic_out/
522522
/xcodebuild
523+
/content/nw
524+

BUILD.gn

+1
Original file line numberDiff line numberDiff line change
@@ -223,6 +223,7 @@ group("both_gn_and_gyp") {
223223

224224
if (!is_ios && !is_android && !is_chromecast) {
225225
deps += [
226+
"//content/nw:nwjs",
226227
"//chrome",
227228
"//chrome/test:browser_tests",
228229
"//chrome/test:interactive_ui_tests",

DEPS

+22-4
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ vars = {
1717
'6226d6cd80aaf2e5295ed460cf73ef6a582e4d78',
1818
'freetype_android_revision':
1919
'c38be52bf8de3b1699d74932b849bf150265819e',
20+
'nwjs_git':
21+
'https://github.com/nwjs',
2022
'google_toolbox_for_mac_revision':
2123
'038a2399b20e67ab17685e23ee873a66811fa107',
2224
'libfuzzer_revision':
@@ -179,8 +181,13 @@ deps = {
179181
(Var("chromium_git")) + '/chromium/deps/acid3.git@6be0a66a1ebd7ebc5abc1b2f405a945f6d871521',
180182
'src/tools/swarming_client':
181183
(Var("chromium_git")) + '/external/swarming.client.git@ebc8dab6f8b8d79ec221c94de39a921145abd404',
182-
'src/v8':
183-
(Var("chromium_git")) + '/v8/v8.git@3f1306cec18aae9f565f4e718444a468ee8dfd2a'
184+
#'src/v8':
185+
# (Var("chromium_git")) + '/v8/v8.git@3f1306cec18aae9f565f4e718444a468ee8dfd2a'
186+
# (Var("nwjs_git")) + '/v8.git@origin/nw16',
187+
#'src/content/nw':
188+
# (Var("nwjs_git")) + '/nw.js.git@origin/nw16',
189+
#'src/third_party/node':
190+
# (Var("nwjs_git")) + '/node.git@origin/nw16',
184191
}
185192

186193
deps_os = {
@@ -1037,6 +1044,17 @@ hooks = [
10371044
'name':
10381045
'wasm_asmjs_fuzzer'
10391046
},
1047+
{
1048+
'action': [
1049+
'python',
1050+
'src/content/nw/tools/patcher.py',
1051+
'--patch-config', 'src/content/nw/patch/patch.cfg'
1052+
],
1053+
'pattern':
1054+
'.',
1055+
'name':
1056+
'nw_patch'
1057+
},
10401058
{
10411059
'action': [
10421060
'python',
@@ -1140,8 +1158,8 @@ recursedeps = [
11401158
'src/buildtools',
11411159
'src/third_party/android_tools',
11421160
[
1143-
'DEPS.chromium',
1144-
'src/third_party/angle'
1161+
'src/third_party/angle',
1162+
'DEPS.chromium'
11451163
]
11461164
]
11471165

apps/app_lifetime_monitor.cc

+2
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

+4
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

+5-2
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,10 @@ class PlatformAppPathLauncher
102102
extension_id(app->id()),
103103
entry_paths_(entry_paths),
104104
mime_type_collector_(profile),
105-
is_directory_collector_(profile) {}
105+
is_directory_collector_(profile) {
106+
if (app->is_nwjs_app()) //NWJS#5097
107+
entry_paths_.clear();
108+
}
106109

107110
PlatformAppPathLauncher(Profile* profile,
108111
const Extension* app,
@@ -111,7 +114,7 @@ class PlatformAppPathLauncher
111114
extension_id(app->id()),
112115
mime_type_collector_(profile),
113116
is_directory_collector_(profile) {
114-
if (!file_path.empty())
117+
if (!file_path.empty() && !app->is_nwjs_app()) //NWJS#5097
115118
entry_paths_.push_back(file_path);
116119
}
117120

base/BUILD.gn

+2
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,8 @@ component("base") {
550550
"message_loop/message_pump_libevent.h",
551551
"message_loop/message_pump_mac.h",
552552
"message_loop/message_pump_mac.mm",
553+
"message_loop/message_pump_uv.cc",
554+
"message_loop/message_pump_uv.h",
553555
"message_loop/message_pump_win.cc",
554556
"message_loop/message_pump_win.h",
555557
"message_loop/timer_slack.h",

base/base_switches.cc

+1
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,5 @@ const char kEnableCrashReporterForTesting[] =
111111
"enable-crash-reporter-for-testing";
112112
#endif
113113

114+
const char kNWJS[] = "nwjs";
114115
} // namespace switches

base/base_switches.h

+1
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ extern const char kDisableUsbKeyboardDetect[];
3939
extern const char kEnableCrashReporterForTesting[];
4040
#endif
4141

42+
extern const char kNWJS[];
4243
} // namespace switches
4344

4445
#endif // BASE_BASE_SWITCHES_H_

base/command_line.cc

+74-5
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

+15
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

+1-1
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

+3
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)