Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Nw15 mas #17

Open
wants to merge 10 commits into
base: nw15
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -471,3 +471,5 @@ vs-chromium-project.txt
/win8/metro_driver/metro_driver_version_resources.xml
/x86-generic_out/
/xcodebuild
/content/nw

1,363 changes: 633 additions & 730 deletions DEPS

Large diffs are not rendered by default.

2 changes: 2 additions & 0 deletions apps/app_lifetime_monitor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,10 @@ void AppLifetimeMonitor::OnAppWindowRemoved(AppWindow* app_window) {
}

void AppLifetimeMonitor::OnAppWindowHidden(AppWindow* app_window) {
#if 0
if (!HasOtherVisibleAppWindows(app_window))
NotifyAppDeactivated(app_window->extension_id());
#endif
}

void AppLifetimeMonitor::OnAppWindowShown(AppWindow* app_window,
Expand Down
4 changes: 4 additions & 0 deletions apps/app_load_service.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

#include "apps/app_load_service.h"

#include "content/nw/src/nw_content.h"

#include "apps/app_load_service_factory.h"
#include "apps/app_restore_service.h"
#include "apps/launcher.h"
Expand Down Expand Up @@ -69,6 +71,8 @@ bool AppLoadService::LoadAndLaunch(const base::FilePath& extension_path,
return false;
}

nw::SetMainExtensionId(extension_id);

// Schedule the app to be launched once loaded.
PostReloadAction& action = post_reload_actions_[extension_id];
action.action_type = LAUNCH_FOR_LOAD_AND_LAUNCH;
Expand Down
2 changes: 2 additions & 0 deletions base/base.gyp
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,8 @@
'message_loop/message_pump_libevent.h',
'message_loop/message_pump_mac.h',
'message_loop/message_pump_mac.mm',
#'message_loop/message_pump_uv.cc',
#'message_loop/message_pump_uv.h',
'metrics/field_trial.cc',
'metrics/field_trial.h',
'posix/file_descriptor_shuffle.cc',
Expand Down
1 change: 1 addition & 0 deletions base/base_switches.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,5 @@ const char kEnableCrashReporterForTesting[] =
"enable-crash-reporter-for-testing";
#endif

const char kNWJS[] = "nwjs";
} // namespace switches
1 change: 1 addition & 0 deletions base/base_switches.h
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ extern const char kDisableUsbKeyboardDetect[];
extern const char kEnableCrashReporterForTesting[];
#endif

extern const char kNWJS[];
} // namespace switches

#endif // BASE_BASE_SWITCHES_H_
78 changes: 73 additions & 5 deletions base/command_line.cc
Original file line number Diff line number Diff line change
Expand Up @@ -151,43 +151,83 @@ string16 QuoteForCommandLineToArgvW(const string16& arg,

CommandLine::CommandLine(NoProgram no_program)
: argv_(1),
begin_args_(1) {
begin_args_(1),
argc0_(0), argv0_(NULL) {
}

CommandLine::CommandLine(const FilePath& program)
: argv_(1),
begin_args_(1) {
begin_args_(1),
argc0_(0), argv0_(NULL) {
SetProgram(program);
}

CommandLine::CommandLine(int argc, const CommandLine::CharType* const* argv)
: argv_(1),
begin_args_(1) {
begin_args_(1),
argc0_(0), argv0_(NULL) {
InitFromArgv(argc, argv);
}

CommandLine::CommandLine(const StringVector& argv)
: argv_(1),
begin_args_(1) {
begin_args_(1),
argc0_(0), argv0_(NULL) {
InitFromArgv(argv);
}

CommandLine::CommandLine(const CommandLine& other)
: argv_(other.argv_),
original_argv_(other.original_argv_),
switches_(other.switches_),
begin_args_(other.begin_args_) {
begin_args_(other.begin_args_),
argc0_(other.argc0_), argv0_(NULL) {

#if defined(OS_WIN)
if (other.argv0_) {
argv0_ = new char*[argc0_ + 1];
for (int i = 0; i < argc0_; ++i) {
argv0_[i] = new char[strlen(other.argv0_[i]) + 1];
strcpy(argv0_[i], other.argv0_[i]);
}
argv0_[argc0_] = NULL;
}
#else
argv0_ = other.argv0_;
#endif
ResetStringPieces();
}

CommandLine& CommandLine::operator=(const CommandLine& other) {
argv_ = other.argv_;
original_argv_ = other.original_argv_;
switches_ = other.switches_;
begin_args_ = other.begin_args_;
#if defined(OS_WIN)
if (other.argv0_) {
argv0_ = new char*[argc0_ + 1];
for (int i = 0; i < argc0_; ++i) {
argv0_[i] = new char[strlen(other.argv0_[i]) + 1];
strcpy(argv0_[i], other.argv0_[i]);
}
argv0_[argc0_] = NULL;
}
#else
argv0_ = other.argv0_;
#endif
ResetStringPieces();
return *this;
}

CommandLine::~CommandLine() {
#if defined(OS_WIN)
if (!argv0_)
return;
for (int i = 0; i < argc0_; i++) {
delete[] argv0_[i];
}
delete[] argv0_;
#endif
}

#if defined(OS_WIN)
Expand Down Expand Up @@ -248,12 +288,34 @@ CommandLine CommandLine::FromString(const string16& command_line) {
void CommandLine::InitFromArgv(int argc,
const CommandLine::CharType* const* argv) {
StringVector new_argv;
argc0_ = argc;
#if !defined(OS_WIN)
argv0_ = (char**)argv;
#else
argv0_ = new char*[argc + 1];
for (int i = 0; i < argc; ++i) {
std::string str(base::WideToUTF8(argv[i]));
argv0_[i] = new char[str.length() + 1];
strcpy(argv0_[i], str.c_str());
}
argv0_[argc] = NULL;
#endif
for (int i = 0; i < argc; ++i)
new_argv.push_back(argv[i]);
InitFromArgv(new_argv);
}

void CommandLine::InitFromArgv(const StringVector& argv) {
#if !defined(OS_MACOSX)
original_argv_ = argv;
#else
for (size_t index = 0; index < argv.size(); ++index) {
if (argv[index].compare(0, strlen("--psn_"), "--psn_") != 0 &&
argv[index].compare(0, strlen("-psn_"), "-psn_") != 0) {
original_argv_.push_back(argv[index]);
}
}
#endif
argv_ = StringVector(1);
switches_.clear();
switches_by_stringpiece_.clear();
Expand Down Expand Up @@ -390,6 +452,12 @@ void CommandLine::AppendArgNative(const CommandLine::StringType& value) {
argv_.push_back(value);
}

#if defined(OS_MACOSX)
void CommandLine::FixOrigArgv4Finder(const CommandLine::StringType& value) {
original_argv_.push_back(value);
}
#endif

void CommandLine::AppendArguments(const CommandLine& other,
bool include_program) {
if (include_program)
Expand Down
15 changes: 15 additions & 0 deletions base/command_line.h
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,11 @@ class BASE_EXPORT CommandLine {

// Returns the original command line string as a vector of strings.
const StringVector& argv() const { return argv_; }
int argc0() { return argc0_; }
char** argv0() { return argv0_; }

// Returns the original command line string as a vector of strings (keeps precedence).
const StringVector& original_argv() const { return original_argv_; }

// Get and Set the program part of the command line string (the first item).
FilePath GetProgram() const;
Expand Down Expand Up @@ -192,6 +197,10 @@ class BASE_EXPORT CommandLine {
void AppendArgPath(const FilePath& value);
void AppendArgNative(const StringType& value);

#if defined(OS_MACOSX)
void FixOrigArgv4Finder(const StringType& value);
#endif

// Append the switches and arguments from another command line to this one.
// If |include_program| is true, include |other|'s program as well.
void AppendArguments(const CommandLine& other, bool include_program);
Expand Down Expand Up @@ -233,6 +242,9 @@ class BASE_EXPORT CommandLine {
// The argv array: { program, [(--|-|/)switch[=value]]*, [--], [argument]* }
StringVector argv_;

// The argv array (precedence not messed).
StringVector original_argv_;

// Parsed-out switch keys and values.
SwitchMap switches_;

Expand All @@ -244,6 +256,9 @@ class BASE_EXPORT CommandLine {

// The index after the program and switches, any arguments start here.
size_t begin_args_;

int argc0_;
char** argv0_;
};

} // namespace base
Expand Down
18 changes: 17 additions & 1 deletion base/files/file_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ BASE_EXPORT bool NormalizeToNativeFilePath(const FilePath& path,

// Given an existing file in |path|, returns whether this file is on a network
// drive or not. If |path| does not exist, this function returns false.
BASE_EXPORT bool IsOnNetworkDrive(const base::FilePath& path);
//BASE_EXPORT bool IsOnNetworkDrive(const base::FilePath& path);
#endif

// This function will return if the given file is a symlink or not.
Expand Down Expand Up @@ -420,6 +420,22 @@ BASE_EXPORT bool GetFileSystemType(const FilePath& path, FileSystemType* type);
BASE_EXPORT bool GetShmemTempDir(bool executable, FilePath* path);
#endif

#if defined(OS_MACOSX)
BASE_EXPORT class SanitizedSocketPath {
public:
explicit SanitizedSocketPath(const base::FilePath& socket_path);
~SanitizedSocketPath();
base::FilePath SocketPath() const;

private:
bool changed_directory_ = false;
base::FilePath socket_path_;
base::FilePath old_path_;

DISALLOW_COPY_AND_ASSIGN(SanitizedSocketPath);
};
#endif

// Internal --------------------------------------------------------------------

namespace internal {
Expand Down
25 changes: 25 additions & 0 deletions base/files/file_util_mac.mm
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
#include "base/files/file_util.h"

#include <copyfile.h>
#include <sys/un.h>
#import <Foundation/Foundation.h>

#include "base/files/file_path.h"
Expand Down Expand Up @@ -47,4 +48,28 @@ FilePath GetHomeDir() {
return FilePath("/tmp");
}

#if defined(OS_MACOSX)

SanitizedSocketPath::SanitizedSocketPath (const base::FilePath& socket_path)
: socket_path_(socket_path) {
if (socket_path.value().length() >= arraysize(sockaddr_un::sun_path)) {
bool found_current_dir = GetCurrentDirectory(&old_path_);
CHECK(found_current_dir) << "Failed to determine the current directory.";
changed_directory_ = SetCurrentDirectory(socket_path.DirName());
CHECK(changed_directory_) << "Failed to change directory: " <<
socket_path.DirName().value();
}
}

SanitizedSocketPath::~SanitizedSocketPath() {
if (changed_directory_)
SetCurrentDirectory(old_path_);
}

base::FilePath SanitizedSocketPath::SocketPath() const {
return changed_directory_ ? socket_path_.BaseName() : socket_path_;
}

#endif // NWJS_MAS

} // namespace base
2 changes: 1 addition & 1 deletion base/files/file_util_posix.cc
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ std::string TempFileName() {
#if defined(GOOGLE_CHROME_BUILD)
return std::string(".com.google.Chrome.XXXXXX");
#else
return std::string(".org.chromium.Chromium.XXXXXX");
return std::string(".io.nwjs.XXXXXX");
#endif
}

Expand Down
2 changes: 2 additions & 0 deletions base/files/file_util_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -559,6 +559,7 @@ bool NormalizeToNativeFilePath(const FilePath& path, FilePath* nt_path) {
return success;
}

#if 0
bool IsOnNetworkDrive(const base::FilePath& path) {
win::ScopedHandle handle(
::CreateFileW(path.value().c_str(),
Expand All @@ -578,6 +579,7 @@ bool IsOnNetworkDrive(const base::FilePath& path) {
&remote_proto_info,
sizeof(remote_proto_info));
}
#endif

// TODO(rkc): Work out if we want to handle NTFS junctions here or not, handle
// them if we do decide to.
Expand Down
5 changes: 5 additions & 0 deletions base/mac/mach_port_broker.mm
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,15 @@
// static
std::string MachPortBroker::GetMachPortName(const std::string& name,
bool is_child) {
#if defined(NWJS_MAS)
return base::StringPrintf(
"%s.%s", base::mac::BaseBundleID(), name.c_str());
#else
// In child processes, use the parent's pid.
const pid_t pid = is_child ? getppid() : getpid();
return base::StringPrintf(
"%s.%s.%d", base::mac::BaseBundleID(), name.c_str(), pid);
#endif
}

mach_port_t MachPortBroker::TaskForPid(base::ProcessHandle pid) const {
Expand Down
Loading