This source file includes following definitions.
- SkiaPreCacheFont
- PpapiPluginMain
#include "base/command_line.h"
#include "base/debug/debugger.h"
#include "base/i18n/rtl.h"
#include "base/message_loop/message_loop.h"
#include "base/threading/platform_thread.h"
#include "build/build_config.h"
#include "content/child/child_process.h"
#include "content/common/content_constants_internal.h"
#include "content/common/sandbox_linux/sandbox_linux.h"
#include "content/ppapi_plugin/ppapi_thread.h"
#include "content/public/common/content_client.h"
#include "content/public/common/content_switches.h"
#include "content/public/common/main_function_params.h"
#include "content/public/plugin/content_plugin_client.h"
#include "crypto/nss_util.h"
#include "ppapi/proxy/plugin_globals.h"
#include "ppapi/proxy/proxy_module.h"
#include "ui/base/ui_base_switches.h"
#if defined(OS_WIN)
#include "sandbox/win/src/sandbox.h"
#include "third_party/skia/include/ports/SkTypeface_win.h"
#endif
#if defined(OS_CHROMEOS)
#include "base/file_util.h"
#endif
#if defined(OS_LINUX)
#include "content/public/common/sandbox_init.h"
#endif
#if defined(OS_POSIX) && !defined(OS_ANDROID)
#include <stdlib.h>
#endif
#if defined(OS_WIN)
sandbox::TargetServices* g_target_services = NULL;
#else
void* g_target_services = 0;
#endif
namespace content {
namespace {
#if defined(OS_WIN)
void SkiaPreCacheFont(const LOGFONT& logfont) {
ppapi::proxy::PluginGlobals::Get()->PreCacheFontForFlash(
reinterpret_cast<const void*>(&logfont));
}
#endif
}
int PpapiPluginMain(const MainFunctionParams& parameters) {
const CommandLine& command_line = parameters.command_line;
#if defined(OS_WIN)
g_target_services = parameters.sandbox_info->target_services;
#endif
if (command_line.HasSwitch(switches::kPpapiStartupDialog)) {
if (g_target_services)
base::debug::WaitForDebugger(2*60, false);
else
ChildProcess::WaitForDebugger("Ppapi");
}
if (command_line.HasSwitch(switches::kLang)) {
std::string locale = command_line.GetSwitchValueASCII(switches::kLang);
base::i18n::SetICUDefaultLocale(locale);
#if defined(OS_POSIX) && !defined(OS_ANDROID)
std::replace(locale.begin(), locale.end(), '-', '_');
locale.append(".UTF-8");
setlocale(LC_ALL, locale.c_str());
setenv("LANG", locale.c_str(), 0);
#endif
}
#if defined(OS_CHROMEOS)
setenv("HOME", base::GetHomeDir().value().c_str(), 1);
#endif
base::MessageLoop main_message_loop;
base::PlatformThread::SetName("CrPPAPIMain");
base::debug::TraceLog::GetInstance()->SetProcessName("PPAPI Process");
base::debug::TraceLog::GetInstance()->SetProcessSortIndex(
kTraceEventPpapiProcessSortIndex);
#if defined(OS_LINUX) && defined(USE_NSS)
crypto::InitNSSSafely();
#endif
if (GetContentClient()->plugin())
GetContentClient()->plugin()->PreSandboxInitialization();
#if defined(OS_LINUX)
LinuxSandbox::InitializeSandbox();
#endif
ChildProcess ppapi_process;
ppapi_process.set_main_thread(
new PpapiThread(parameters.command_line, false));
#if defined(OS_WIN)
SkTypeface_SetEnsureLOGFONTAccessibleProc(SkiaPreCacheFont);
#endif
main_message_loop.Run();
return 0;
}
}