summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--base/base.gypi1
-rw-r--r--base/base_untrusted.gyp2
-rw-r--r--base/logging.cc12
-rw-r--r--chrome/browser/nacl_host/nacl_process_host.cc19
-rw-r--r--ppapi/ppapi_shared.gypi2
-rw-r--r--ppapi/proxy/plugin_main_nacl.cc28
-rw-r--r--ppapi/proxy/ppapi_messages.h16
-rw-r--r--ppapi/shared_impl/ppapi_nacl_channel_args.cc17
-rw-r--r--ppapi/shared_impl/ppapi_nacl_channel_args.h30
9 files changed, 109 insertions, 18 deletions
diff --git a/base/base.gypi b/base/base.gypi
index 164aa23..c8c5c37 100644
--- a/base/base.gypi
+++ b/base/base.gypi
@@ -620,7 +620,6 @@
'allocator/type_profiler_control.cc',
'allocator/type_profiler_control.h',
'base_paths.cc',
- 'command_line.cc',
'cpu.cc',
'debug/stack_trace_posix.cc',
'file_util.cc',
diff --git a/base/base_untrusted.gyp b/base/base_untrusted.gyp
index b63885b..a4c26b1 100644
--- a/base/base_untrusted.gyp
+++ b/base/base_untrusted.gyp
@@ -23,6 +23,8 @@
'build_glibc': 1,
'build_newlib': 1,
'sources': [
+ 'base_switches.cc',
+ 'base_switches.h',
'string16.cc',
'sync_socket_nacl.cc',
'time_posix.cc',
diff --git a/base/logging.cc b/base/logging.cc
index b5e4999..0c4a302 100644
--- a/base/logging.cc
+++ b/base/logging.cc
@@ -163,6 +163,8 @@ void CloseFile(FileHandle log) {
void DeleteFilePath(const PathString& log_name) {
#if defined(OS_WIN)
DeleteFile(log_name.c_str());
+#elif defined (OS_NACL)
+ // Do nothing; unlink() isn't supported on NaCl.
#else
unlink(log_name.c_str());
#endif
@@ -348,9 +350,11 @@ bool BaseInitLoggingImpl(const PathChar* new_log_file,
LogLockingState lock_log,
OldFileDeletionState delete_old,
DcheckState dcheck_state) {
+#if defined(OS_NACL)
+ CHECK(logging_dest == LOG_NONE ||
+ logging_dest == LOG_ONLY_TO_SYSTEM_DEBUG_LOG);
+#endif
g_dcheck_state = dcheck_state;
-// TODO(bbudge) Hook this up to NaCl logging.
-#if !defined(OS_NACL)
CommandLine* command_line = CommandLine::ForCurrentProcess();
// Don't bother initializing g_vlog_info unless we use one of the
// vlog switches.
@@ -393,10 +397,6 @@ bool BaseInitLoggingImpl(const PathChar* new_log_file,
DeleteFilePath(*log_file_name);
return InitializeLogFileHandle();
-#else
- (void) g_vlog_info_prev;
- return true;
-#endif // !defined(OS_NACL)
}
void SetMinLogLevel(int level) {
diff --git a/chrome/browser/nacl_host/nacl_process_host.cc b/chrome/browser/nacl_host/nacl_process_host.cc
index f91bd4e..5cda1b6 100644
--- a/chrome/browser/nacl_host/nacl_process_host.cc
+++ b/chrome/browser/nacl_host/nacl_process_host.cc
@@ -7,6 +7,7 @@
#include <string>
#include <vector>
+#include "base/base_switches.h"
#include "base/bind.h"
#include "base/command_line.h"
#include "base/message_loop.h"
@@ -48,6 +49,7 @@
#include "net/base/net_util.h"
#include "net/socket/tcp_listen_socket.h"
#include "ppapi/proxy/ppapi_messages.h"
+#include "ppapi/shared_impl/ppapi_nacl_channel_args.h"
#if defined(OS_POSIX)
#include <fcntl.h>
@@ -833,13 +835,26 @@ void NaClProcessHost::OnPpapiChannelCreated(
chrome_render_message_filter_->render_process_id(),
render_view_id_));
+ ppapi::PpapiNaClChannelArgs args;
+ args.off_the_record = chrome_render_message_filter_->off_the_record();
+ args.permissions = permissions_;
+ CommandLine* cmdline = CommandLine::ForCurrentProcess();
+ DCHECK(cmdline);
+ std::string flag_whitelist[] = {switches::kV, switches::kVModule};
+ for (size_t i = 0; i < arraysize(flag_whitelist); ++i) {
+ std::string value = cmdline->GetSwitchValueASCII(flag_whitelist[i]);
+ if (!value.empty()) {
+ args.switch_names.push_back(flag_whitelist[i]);
+ args.switch_values.push_back(value);
+ }
+ }
+
// Send a message to create the NaCl-Renderer channel. The handle is just
// a place holder.
ipc_proxy_channel_->Send(
new PpapiMsg_CreateNaClChannel(
chrome_render_message_filter_->render_process_id(),
- permissions_,
- chrome_render_message_filter_->off_the_record(),
+ args,
SerializedHandle(SerializedHandle::CHANNEL_HANDLE,
IPC::InvalidPlatformFileForTransit())));
} else if (reply_msg_) {
diff --git a/ppapi/ppapi_shared.gypi b/ppapi/ppapi_shared.gypi
index 880f5cd..6802d59 100644
--- a/ppapi/ppapi_shared.gypi
+++ b/ppapi/ppapi_shared.gypi
@@ -44,6 +44,8 @@
'shared_impl/platform_file.h',
'shared_impl/ppapi_globals.cc',
'shared_impl/ppapi_globals.h',
+ 'shared_impl/ppapi_nacl_channel_args.cc',
+ 'shared_impl/ppapi_nacl_channel_args.h',
'shared_impl/ppapi_permissions.cc',
'shared_impl/ppapi_permissions.h',
'shared_impl/ppapi_preferences.cc',
diff --git a/ppapi/proxy/plugin_main_nacl.cc b/ppapi/proxy/plugin_main_nacl.cc
index 8733b9c..5d43d3a 100644
--- a/ppapi/proxy/plugin_main_nacl.cc
+++ b/ppapi/proxy/plugin_main_nacl.cc
@@ -11,6 +11,7 @@
// IPC_MESSAGE_MACROS_LOG_ENABLED so ppapi_messages.h will generate the
// ViewMsgLog et al. functions.
+#include "base/command_line.h"
#include "base/message_loop.h"
#include "base/synchronization/waitable_event.h"
#include "base/threading/thread.h"
@@ -83,8 +84,7 @@ class PpapiDispatcher : public ProxyChannel,
private:
void OnMsgCreateNaClChannel(int renderer_id,
- const ppapi::PpapiPermissions& permissions,
- bool incognito,
+ const ppapi::PpapiNaClChannelArgs& args,
SerializedHandle handle);
void OnMsgResourceReply(
const ppapi::proxy::ResourceMessageReplyParams& reply_params,
@@ -181,16 +181,32 @@ bool PpapiDispatcher::OnMessageReceived(const IPC::Message& msg) {
void PpapiDispatcher::OnMsgCreateNaClChannel(
int renderer_id,
- const ppapi::PpapiPermissions& permissions,
- bool incognito,
+ const ppapi::PpapiNaClChannelArgs& args,
SerializedHandle handle) {
+ static bool command_line_and_logging_initialized = false;
+ if (!command_line_and_logging_initialized) {
+ CommandLine::Init(0, NULL);
+ for (size_t i = 0; i < args.switch_names.size(); ++i) {
+ DCHECK(i < args.switch_values.size());
+ CommandLine::ForCurrentProcess()->AppendSwitchASCII(
+ args.switch_names[i], args.switch_values[i]);
+ }
+ logging::InitLogging(
+ NULL,
+ logging::LOG_ONLY_TO_SYSTEM_DEBUG_LOG,
+ logging::DONT_LOCK_LOG_FILE,
+ logging::DELETE_OLD_LOG_FILE,
+ logging::DISABLE_DCHECK_FOR_NON_OFFICIAL_RELEASE_BUILDS);
+ command_line_and_logging_initialized = true;
+ }
// Tell the process-global GetInterface which interfaces it can return to the
// plugin.
ppapi::proxy::InterfaceList::SetProcessGlobalPermissions(
- permissions);
+ args.permissions);
PluginDispatcher* dispatcher =
- new PluginDispatcher(::PPP_GetInterface, permissions, incognito);
+ new PluginDispatcher(::PPP_GetInterface, args.permissions,
+ args.off_the_record);
// The channel handle's true name is not revealed here.
IPC::ChannelHandle channel_handle("nacl", handle.descriptor());
if (!dispatcher->InitPluginWithChannel(this, base::kNullProcessId,
diff --git a/ppapi/proxy/ppapi_messages.h b/ppapi/proxy/ppapi_messages.h
index 215791d..581d3f0 100644
--- a/ppapi/proxy/ppapi_messages.h
+++ b/ppapi/proxy/ppapi_messages.h
@@ -55,6 +55,7 @@
#include "ppapi/proxy/serialized_var.h"
#include "ppapi/shared_impl/dir_contents.h"
#include "ppapi/shared_impl/file_path.h"
+#include "ppapi/shared_impl/ppapi_nacl_channel_args.h"
#include "ppapi/shared_impl/ppapi_preferences.h"
#include "ppapi/shared_impl/ppb_device_ref_shared.h"
#include "ppapi/shared_impl/ppb_input_event_shared.h"
@@ -296,6 +297,16 @@ IPC_STRUCT_TRAITS_BEGIN(ppapi::NetworkInfo)
IPC_STRUCT_TRAITS_MEMBER(mtu)
IPC_STRUCT_TRAITS_END()
+// Only whitelisted switches passed through NaClChannelArgs.
+// The list of switches can be found in:
+// chrome/browser/nacl_host/nacl_process_host.cc
+IPC_STRUCT_TRAITS_BEGIN(ppapi::PpapiNaClChannelArgs)
+ IPC_STRUCT_TRAITS_MEMBER(off_the_record)
+ IPC_STRUCT_TRAITS_MEMBER(permissions)
+ IPC_STRUCT_TRAITS_MEMBER(switch_names)
+ IPC_STRUCT_TRAITS_MEMBER(switch_values)
+IPC_STRUCT_TRAITS_END()
+
#if !defined(OS_NACL) && !defined(NACL_WIN64)
IPC_STRUCT_TRAITS_BEGIN(ppapi::proxy::PPPDecryptor_Buffer)
@@ -322,10 +333,9 @@ IPC_MESSAGE_CONTROL3(PpapiMsg_CreateChannel,
// Creates a channel to talk to a renderer. This message is only used by the
// NaCl IPC proxy. It is intercepted by NaClIPCAdapter, which creates the
// actual channel and rewrites the message for the untrusted side.
-IPC_MESSAGE_CONTROL4(PpapiMsg_CreateNaClChannel,
+IPC_MESSAGE_CONTROL3(PpapiMsg_CreateNaClChannel,
int /* renderer_id */,
- ppapi::PpapiPermissions /* permissions */,
- bool /* incognito */,
+ ppapi::PpapiNaClChannelArgs /* args */,
ppapi::proxy::SerializedHandle /* channel_handle */)
// Instructs the plugin process to crash.
diff --git a/ppapi/shared_impl/ppapi_nacl_channel_args.cc b/ppapi/shared_impl/ppapi_nacl_channel_args.cc
new file mode 100644
index 0000000..7e20a53
--- /dev/null
+++ b/ppapi/shared_impl/ppapi_nacl_channel_args.cc
@@ -0,0 +1,17 @@
+// Copyright (c) 2012 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "ppapi/shared_impl/ppapi_nacl_channel_args.h"
+
+namespace ppapi {
+
+// We must provide explicit definitions of these functions for builds on
+// Windows.
+PpapiNaClChannelArgs::PpapiNaClChannelArgs() {
+}
+
+PpapiNaClChannelArgs::~PpapiNaClChannelArgs() {
+}
+
+} // namespace ppapi
diff --git a/ppapi/shared_impl/ppapi_nacl_channel_args.h b/ppapi/shared_impl/ppapi_nacl_channel_args.h
new file mode 100644
index 0000000..462a3a0
--- /dev/null
+++ b/ppapi/shared_impl/ppapi_nacl_channel_args.h
@@ -0,0 +1,30 @@
+// Copyright (c) 2013 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef PPAPI_SHARED_IMPL_PPAPI_CREATE_NACL_CHANNEL_ARGS_H
+#define PPAPI_SHARED_IMPL_PPAPI_CREATE_NACL_CHANNEL_ARGS_H
+
+#include <string>
+#include <vector>
+
+#include "ppapi/shared_impl/ppapi_permissions.h"
+
+namespace ppapi {
+
+struct PPAPI_SHARED_EXPORT PpapiNaClChannelArgs {
+ public:
+ PpapiNaClChannelArgs();
+ ~PpapiNaClChannelArgs();
+
+ bool off_the_record;
+ PpapiPermissions permissions;
+
+ // Switches from the command-line.
+ std::vector<std::string> switch_names;
+ std::vector<std::string> switch_values;
+};
+
+} // namespace ppapi
+
+#endif // PPAPI_SHARED_IMPL_PPAPI_CREATE_NACL_CHANNEL_ARGS_H