2012-04-03 03:34:16 +02:00
|
|
|
// 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 "libcef/common/main_delegate.h"
|
|
|
|
#include "libcef/browser/content_browser_client.h"
|
|
|
|
#include "libcef/browser/context.h"
|
|
|
|
#include "libcef/common/cef_switches.h"
|
|
|
|
#include "libcef/common/command_line_impl.h"
|
2014-09-27 01:48:19 +02:00
|
|
|
#include "libcef/common/crash_reporter_client.h"
|
2015-07-16 23:40:01 +02:00
|
|
|
#include "libcef/common/extensions/extensions_util.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "libcef/renderer/content_renderer_client.h"
|
2014-07-03 20:34:58 +02:00
|
|
|
#include "libcef/utility/content_utility_client.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2013-11-21 23:43:36 +01:00
|
|
|
#include "base/base_switches.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "base/command_line.h"
|
2013-02-27 18:56:03 +01:00
|
|
|
#include "base/files/file_path.h"
|
2014-11-12 20:25:15 +01:00
|
|
|
#include "base/files/file_util.h"
|
2013-11-21 23:43:36 +01:00
|
|
|
#include "base/lazy_instance.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "base/path_service.h"
|
2013-06-22 04:06:32 +02:00
|
|
|
#include "base/strings/string_number_conversions.h"
|
|
|
|
#include "base/strings/string_util.h"
|
2012-04-11 20:00:55 +02:00
|
|
|
#include "base/synchronization/waitable_event.h"
|
|
|
|
#include "base/threading/thread.h"
|
2015-10-17 02:44:00 +02:00
|
|
|
#include "chrome/browser/browser_process.h"
|
2015-07-16 23:40:01 +02:00
|
|
|
#include "chrome/child/pdf_child_init.h"
|
2015-08-14 16:41:08 +02:00
|
|
|
#include "chrome/common/chrome_constants.h"
|
2014-07-08 00:17:33 +02:00
|
|
|
#include "chrome/common/chrome_paths.h"
|
2013-02-06 21:41:54 +01:00
|
|
|
#include "chrome/common/chrome_switches.h"
|
2015-09-09 16:05:39 +02:00
|
|
|
#include "components/content_settings/core/common/content_settings_pattern.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "content/public/browser/browser_main_runner.h"
|
|
|
|
#include "content/public/browser/render_process_host.h"
|
|
|
|
#include "content/public/common/content_switches.h"
|
2012-04-11 20:00:55 +02:00
|
|
|
#include "content/public/common/main_function_params.h"
|
2015-09-09 16:05:39 +02:00
|
|
|
#include "extensions/common/constants.h"
|
2015-07-16 23:40:01 +02:00
|
|
|
#include "pdf/pdf.h"
|
2014-07-08 00:17:33 +02:00
|
|
|
#include "ui/base/layout.h"
|
2016-05-25 01:35:43 +02:00
|
|
|
#include "ui/base/material_design/material_design_controller.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "ui/base/resource/resource_bundle.h"
|
|
|
|
#include "ui/base/ui_base_paths.h"
|
2012-10-22 22:56:38 +02:00
|
|
|
#include "ui/base/ui_base_switches.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2015-08-31 13:28:07 +02:00
|
|
|
#include "widevine_cdm_version.h" // In SHARED_INTERMEDIATE_DIR.
|
|
|
|
|
2015-06-12 19:54:42 +02:00
|
|
|
#include "ipc/ipc_message.h" // For IPC_MESSAGE_LOG_ENABLED.
|
|
|
|
|
|
|
|
#if defined(IPC_MESSAGE_LOG_ENABLED)
|
|
|
|
#define IPC_MESSAGE_MACROS_LOG_ENABLED
|
|
|
|
#include "content/public/common/content_ipc_logging.h"
|
|
|
|
#define IPC_LOG_TABLE_ADD_ENTRY(msg_id, logger) \
|
|
|
|
content::RegisterIPCLogger(msg_id, logger)
|
|
|
|
#include "libcef/common/cef_message_generator.h"
|
|
|
|
#endif
|
|
|
|
|
2012-04-11 20:00:55 +02:00
|
|
|
#if defined(OS_WIN)
|
|
|
|
#include <Objbase.h> // NOLINT(build/include_order)
|
2015-03-25 22:22:47 +01:00
|
|
|
#include "base/win/registry.h"
|
2015-10-09 17:23:12 +02:00
|
|
|
#include "components/crash/content/app/breakpad_win.h"
|
2012-04-11 20:00:55 +02:00
|
|
|
#endif
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
#if defined(OS_MACOSX)
|
2015-03-25 22:22:47 +01:00
|
|
|
#include "libcef/common/util_mac.h"
|
2013-11-21 23:43:36 +01:00
|
|
|
#include "base/mac/os_crash_dumps.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "base/mac/bundle_locations.h"
|
|
|
|
#include "base/mac/foundation_util.h"
|
2015-10-09 17:23:12 +02:00
|
|
|
#include "components/crash/content/app/breakpad_mac.h"
|
2012-04-03 03:34:16 +02:00
|
|
|
#include "content/public/common/content_paths.h"
|
2012-04-27 00:20:18 +02:00
|
|
|
#endif
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2013-11-21 23:43:36 +01:00
|
|
|
#if defined(OS_POSIX) && !defined(OS_MACOSX)
|
2015-10-09 17:23:12 +02:00
|
|
|
#include "components/crash/content/app/breakpad_linux.h"
|
2013-11-21 23:43:36 +01:00
|
|
|
#endif
|
|
|
|
|
2015-03-02 21:25:14 +01:00
|
|
|
#if defined(OS_LINUX)
|
|
|
|
#include "base/environment.h"
|
|
|
|
#include "base/nix/xdg_util.h"
|
|
|
|
#endif
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
namespace {
|
2012-04-11 20:00:55 +02:00
|
|
|
|
2014-09-27 01:48:19 +02:00
|
|
|
base::LazyInstance<CefCrashReporterClient>::Leaky g_crash_reporter_client =
|
2013-11-21 23:43:36 +01:00
|
|
|
LAZY_INSTANCE_INITIALIZER;
|
|
|
|
|
2012-04-27 00:20:18 +02:00
|
|
|
#if defined(OS_MACOSX)
|
|
|
|
|
2013-02-23 01:43:28 +01:00
|
|
|
base::FilePath GetFrameworksPath() {
|
2012-04-03 03:34:16 +02:00
|
|
|
// Start out with the path to the running executable.
|
2013-02-23 01:43:28 +01:00
|
|
|
base::FilePath execPath;
|
2012-04-27 00:20:18 +02:00
|
|
|
PathService::Get(base::FILE_EXE, &execPath);
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2012-04-27 00:20:18 +02:00
|
|
|
// Get the main bundle path.
|
2013-02-23 01:43:28 +01:00
|
|
|
base::FilePath bundlePath = base::mac::GetAppBundlePath(execPath);
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2012-04-27 00:20:18 +02:00
|
|
|
// Go into the Contents/Frameworks directory.
|
|
|
|
return bundlePath.Append(FILE_PATH_LITERAL("Contents"))
|
|
|
|
.Append(FILE_PATH_LITERAL("Frameworks"));
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
// The framework bundle path is used for loading resources, libraries, etc.
|
2013-02-23 01:43:28 +01:00
|
|
|
base::FilePath GetFrameworkBundlePath() {
|
2012-04-27 00:20:18 +02:00
|
|
|
return GetFrameworksPath().Append(
|
|
|
|
FILE_PATH_LITERAL("Chromium Embedded Framework.framework"));
|
|
|
|
}
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2013-02-23 01:43:28 +01:00
|
|
|
base::FilePath GetResourcesFilePath() {
|
2012-04-27 00:20:18 +02:00
|
|
|
return GetFrameworkBundlePath().Append(FILE_PATH_LITERAL("Resources"));
|
|
|
|
}
|
|
|
|
|
2015-10-23 18:58:33 +02:00
|
|
|
// Retrieve the name of the running executable.
|
|
|
|
std::string GetExecutableName() {
|
|
|
|
base::FilePath path;
|
|
|
|
PathService::Get(base::FILE_EXE, &path);
|
|
|
|
return path.BaseName().value();
|
|
|
|
}
|
|
|
|
|
|
|
|
// Use a "~/Library/Logs/<app name>_debug.log" file where <app name> is the name
|
|
|
|
// of the running executable.
|
|
|
|
base::FilePath GetDefaultLogFile() {
|
|
|
|
return base::mac::GetUserLibraryPath()
|
|
|
|
.Append(FILE_PATH_LITERAL("Logs"))
|
|
|
|
.Append(FILE_PATH_LITERAL(GetExecutableName() + "_debug.log"));
|
|
|
|
}
|
|
|
|
|
2012-04-27 00:20:18 +02:00
|
|
|
void OverrideFrameworkBundlePath() {
|
|
|
|
base::mac::SetOverrideFrameworkBundlePath(GetFrameworkBundlePath());
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void OverrideChildProcessPath() {
|
2015-10-23 18:58:33 +02:00
|
|
|
const std::string& exe_name = GetExecutableName();
|
2013-02-23 01:43:28 +01:00
|
|
|
base::FilePath helper_path = GetFrameworksPath()
|
2015-10-23 18:58:33 +02:00
|
|
|
.Append(FILE_PATH_LITERAL(exe_name + " Helper.app"))
|
2012-04-27 00:20:18 +02:00
|
|
|
.Append(FILE_PATH_LITERAL("Contents"))
|
|
|
|
.Append(FILE_PATH_LITERAL("MacOS"))
|
2015-10-23 18:58:33 +02:00
|
|
|
.Append(FILE_PATH_LITERAL(exe_name + " Helper"));
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
PathService::Override(content::CHILD_PROCESS_EXE, helper_path);
|
|
|
|
}
|
2012-04-11 20:00:55 +02:00
|
|
|
|
2012-04-27 00:20:18 +02:00
|
|
|
#else // !defined(OS_MACOSX)
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2013-02-23 01:43:28 +01:00
|
|
|
base::FilePath GetResourcesFilePath() {
|
|
|
|
base::FilePath pak_dir;
|
2012-04-27 00:20:18 +02:00
|
|
|
PathService::Get(base::DIR_MODULE, &pak_dir);
|
|
|
|
return pak_dir;
|
|
|
|
}
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2015-10-23 18:58:33 +02:00
|
|
|
// Use a "debug.log" file in the running executable's directory.
|
|
|
|
base::FilePath GetDefaultLogFile() {
|
|
|
|
base::FilePath log_path;
|
|
|
|
PathService::Get(base::DIR_EXE, &log_path);
|
|
|
|
return log_path.Append(FILE_PATH_LITERAL("debug.log"));
|
|
|
|
}
|
|
|
|
|
2012-04-27 00:20:18 +02:00
|
|
|
#endif // !defined(OS_MACOSX)
|
2012-04-11 20:00:55 +02:00
|
|
|
|
2015-03-25 22:22:47 +01:00
|
|
|
#if defined(OS_WIN)
|
|
|
|
|
|
|
|
// Gets the Flash path if installed on the system.
|
2015-08-14 16:41:08 +02:00
|
|
|
bool GetSystemFlashFilename(base::FilePath* out_path) {
|
|
|
|
const wchar_t kPepperFlashRegistryRoot[] =
|
|
|
|
L"SOFTWARE\\Macromedia\\FlashPlayerPepper";
|
|
|
|
const wchar_t kFlashPlayerPathValueName[] = L"PlayerPath";
|
|
|
|
|
|
|
|
base::win::RegKey path_key(
|
|
|
|
HKEY_LOCAL_MACHINE, kPepperFlashRegistryRoot, KEY_READ);
|
2015-03-25 22:22:47 +01:00
|
|
|
base::string16 path_str;
|
|
|
|
if (FAILED(path_key.ReadValue(kFlashPlayerPathValueName, &path_str)))
|
|
|
|
return false;
|
|
|
|
|
2015-08-14 16:41:08 +02:00
|
|
|
*out_path = base::FilePath(path_str);
|
2015-03-25 22:22:47 +01:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
#elif defined(OS_MACOSX)
|
|
|
|
|
|
|
|
const base::FilePath::CharType kPepperFlashSystemBaseDirectory[] =
|
|
|
|
FILE_PATH_LITERAL("Internet Plug-Ins/PepperFlashPlayer");
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void OverridePepperFlashSystemPluginPath() {
|
2015-08-14 16:41:08 +02:00
|
|
|
base::FilePath plugin_filename;
|
2015-03-25 22:22:47 +01:00
|
|
|
#if defined(OS_WIN)
|
2015-08-14 16:41:08 +02:00
|
|
|
if (!GetSystemFlashFilename(&plugin_filename))
|
2015-03-25 22:22:47 +01:00
|
|
|
return;
|
|
|
|
#elif defined(OS_MACOSX)
|
2015-08-14 16:41:08 +02:00
|
|
|
if (!util_mac::GetLocalLibraryDirectory(&plugin_filename))
|
2015-03-25 22:22:47 +01:00
|
|
|
return;
|
2015-08-14 16:41:08 +02:00
|
|
|
plugin_filename = plugin_filename.Append(kPepperFlashSystemBaseDirectory)
|
|
|
|
.Append(chrome::kPepperFlashPluginFilename);
|
2015-03-25 22:22:47 +01:00
|
|
|
#else
|
|
|
|
// A system plugin is not available on other platforms.
|
|
|
|
return;
|
|
|
|
#endif
|
|
|
|
|
2015-11-10 21:18:16 +01:00
|
|
|
if (!plugin_filename.empty()) {
|
|
|
|
PathService::Override(chrome::FILE_PEPPER_FLASH_SYSTEM_PLUGIN,
|
|
|
|
plugin_filename);
|
|
|
|
}
|
2015-03-25 22:22:47 +01:00
|
|
|
}
|
|
|
|
|
2015-03-02 21:25:14 +01:00
|
|
|
#if defined(OS_LINUX)
|
|
|
|
|
|
|
|
// Based on chrome/common/chrome_paths_linux.cc.
|
|
|
|
// See http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
|
|
|
|
// for a spec on where config files go. The net effect for most
|
|
|
|
// systems is we use ~/.config/chromium/ for Chromium and
|
|
|
|
// ~/.config/google-chrome/ for official builds.
|
|
|
|
// (This also helps us sidestep issues with other apps grabbing ~/.chromium .)
|
|
|
|
bool GetDefaultUserDataDirectory(base::FilePath* result) {
|
2016-04-27 22:38:52 +02:00
|
|
|
std::unique_ptr<base::Environment> env(base::Environment::Create());
|
2015-03-02 21:25:14 +01:00
|
|
|
base::FilePath config_dir(
|
|
|
|
base::nix::GetXDGDirectory(env.get(),
|
|
|
|
base::nix::kXdgConfigHomeEnvVar,
|
|
|
|
base::nix::kDotConfigDir));
|
|
|
|
*result = config_dir.Append(FILE_PATH_LITERAL("cef_user_data"));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
#elif defined(OS_MACOSX)
|
|
|
|
|
|
|
|
// Based on chrome/common/chrome_paths_mac.mm.
|
|
|
|
bool GetDefaultUserDataDirectory(base::FilePath* result) {
|
|
|
|
if (!PathService::Get(base::DIR_APP_DATA, result))
|
|
|
|
return false;
|
|
|
|
*result = result->Append(FILE_PATH_LITERAL("CEF"));
|
|
|
|
*result = result->Append(FILE_PATH_LITERAL("User Data"));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
#elif defined(OS_WIN)
|
|
|
|
|
|
|
|
// Based on chrome/common/chrome_paths_win.cc.
|
|
|
|
bool GetDefaultUserDataDirectory(base::FilePath* result) {
|
|
|
|
if (!PathService::Get(base::DIR_LOCAL_APP_DATA, result))
|
|
|
|
return false;
|
|
|
|
*result = result->Append(FILE_PATH_LITERAL("CEF"));
|
|
|
|
*result = result->Append(FILE_PATH_LITERAL("User Data"));
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
base::FilePath GetUserDataPath() {
|
|
|
|
const CefSettings& settings = CefContext::Get()->settings();
|
|
|
|
if (settings.user_data_path.length > 0)
|
|
|
|
return base::FilePath(CefString(&settings.user_data_path));
|
|
|
|
|
|
|
|
base::FilePath result;
|
|
|
|
if (GetDefaultUserDataDirectory(&result))
|
|
|
|
return result;
|
|
|
|
|
|
|
|
if (PathService::Get(base::DIR_TEMP, &result))
|
|
|
|
return result;
|
|
|
|
|
|
|
|
NOTREACHED();
|
|
|
|
return result;
|
|
|
|
}
|
|
|
|
|
2014-07-08 00:17:33 +02:00
|
|
|
// Returns true if |scale_factor| is supported by this platform.
|
|
|
|
// Same as ResourceBundle::IsScaleFactorSupported.
|
|
|
|
bool IsScaleFactorSupported(ui::ScaleFactor scale_factor) {
|
|
|
|
const std::vector<ui::ScaleFactor>& supported_scale_factors =
|
|
|
|
ui::GetSupportedScaleFactors();
|
|
|
|
return std::find(supported_scale_factors.begin(),
|
|
|
|
supported_scale_factors.end(),
|
|
|
|
scale_factor) != supported_scale_factors.end();
|
|
|
|
}
|
2014-07-03 20:34:58 +02:00
|
|
|
|
2012-04-11 20:00:55 +02:00
|
|
|
// Used to run the UI on a separate thread.
|
|
|
|
class CefUIThread : public base::Thread {
|
|
|
|
public:
|
|
|
|
explicit CefUIThread(const content::MainFunctionParams& main_function_params)
|
|
|
|
: base::Thread("CefUIThread"),
|
|
|
|
main_function_params_(main_function_params) {
|
|
|
|
}
|
|
|
|
|
2014-11-12 20:25:15 +01:00
|
|
|
void Init() override {
|
2012-04-11 20:00:55 +02:00
|
|
|
#if defined(OS_WIN)
|
|
|
|
// Initializes the COM library on the current thread.
|
|
|
|
CoInitialize(NULL);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Use our own browser process runner.
|
|
|
|
browser_runner_.reset(content::BrowserMainRunner::Create());
|
|
|
|
|
2012-06-19 18:29:49 +02:00
|
|
|
// Initialize browser process state. Uses the current thread's mesage loop.
|
2012-04-11 20:00:55 +02:00
|
|
|
int exit_code = browser_runner_->Initialize(main_function_params_);
|
|
|
|
CHECK_EQ(exit_code, -1);
|
|
|
|
}
|
|
|
|
|
2014-11-12 20:25:15 +01:00
|
|
|
void CleanUp() override {
|
2012-04-11 20:00:55 +02:00
|
|
|
browser_runner_->Shutdown();
|
|
|
|
browser_runner_.reset(NULL);
|
|
|
|
|
|
|
|
#if defined(OS_WIN)
|
|
|
|
// Closes the COM library on the current thread. CoInitialize must
|
|
|
|
// be balanced by a corresponding call to CoUninitialize.
|
|
|
|
CoUninitialize();
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
protected:
|
|
|
|
content::MainFunctionParams main_function_params_;
|
2016-04-27 22:38:52 +02:00
|
|
|
std::unique_ptr<content::BrowserMainRunner> browser_runner_;
|
2012-04-11 20:00:55 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
} // namespace
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
CefMainDelegate::CefMainDelegate(CefRefPtr<CefApp> application)
|
|
|
|
: content_client_(application) {
|
2014-07-11 22:10:05 +02:00
|
|
|
// Necessary so that exported functions from base_impl.cc will be included
|
|
|
|
// in the binary.
|
|
|
|
extern void base_impl_stub();
|
|
|
|
base_impl_stub();
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
CefMainDelegate::~CefMainDelegate() {
|
|
|
|
}
|
|
|
|
|
|
|
|
bool CefMainDelegate::BasicStartupComplete(int* exit_code) {
|
|
|
|
#if defined(OS_MACOSX)
|
|
|
|
OverrideFrameworkBundlePath();
|
|
|
|
#endif
|
2012-04-11 20:00:55 +02:00
|
|
|
|
2015-01-09 18:22:10 +01:00
|
|
|
base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
|
2012-04-03 03:34:16 +02:00
|
|
|
std::string process_type =
|
|
|
|
command_line->GetSwitchValueASCII(switches::kProcessType);
|
|
|
|
|
|
|
|
if (process_type.empty()) {
|
|
|
|
// In the browser process. Populate the global command-line object.
|
2013-09-03 20:06:25 +02:00
|
|
|
const CefSettings& settings = CefContext::Get()->settings();
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
if (settings.command_line_args_disabled) {
|
|
|
|
// Remove any existing command-line arguments.
|
2015-01-09 18:22:10 +01:00
|
|
|
base::CommandLine::StringVector argv;
|
2012-04-03 03:34:16 +02:00
|
|
|
argv.push_back(command_line->GetProgram().value());
|
|
|
|
command_line->InitFromArgv(argv);
|
|
|
|
|
2015-01-09 18:22:10 +01:00
|
|
|
const base::CommandLine::SwitchMap& map = command_line->GetSwitches();
|
|
|
|
const_cast<base::CommandLine::SwitchMap*>(&map)->clear();
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (settings.single_process)
|
|
|
|
command_line->AppendSwitch(switches::kSingleProcess);
|
|
|
|
|
2014-01-06 20:59:48 +01:00
|
|
|
bool no_sandbox = settings.no_sandbox ? true : false;
|
2013-11-15 19:47:02 +01:00
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
if (settings.browser_subprocess_path.length > 0) {
|
2013-02-23 01:43:28 +01:00
|
|
|
base::FilePath file_path =
|
|
|
|
base::FilePath(CefString(&settings.browser_subprocess_path));
|
2012-04-03 03:34:16 +02:00
|
|
|
if (!file_path.empty()) {
|
|
|
|
command_line->AppendSwitchPath(switches::kBrowserSubprocessPath,
|
|
|
|
file_path);
|
2013-11-15 19:47:02 +01:00
|
|
|
|
|
|
|
#if defined(OS_WIN)
|
|
|
|
// The sandbox is not supported when using a separate subprocess
|
|
|
|
// executable on Windows.
|
|
|
|
no_sandbox = true;
|
|
|
|
#endif
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-11-15 19:47:02 +01:00
|
|
|
if (no_sandbox)
|
|
|
|
command_line->AppendSwitch(switches::kNoSandbox);
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
if (settings.user_agent.length > 0) {
|
|
|
|
command_line->AppendSwitchASCII(switches::kUserAgent,
|
|
|
|
CefString(&settings.user_agent));
|
|
|
|
} else if (settings.product_version.length > 0) {
|
|
|
|
command_line->AppendSwitchASCII(switches::kProductVersion,
|
|
|
|
CefString(&settings.product_version));
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings.locale.length > 0) {
|
2012-10-22 22:56:38 +02:00
|
|
|
command_line->AppendSwitchASCII(switches::kLang,
|
2012-04-03 03:34:16 +02:00
|
|
|
CefString(&settings.locale));
|
2012-10-22 22:56:38 +02:00
|
|
|
} else if (!command_line->HasSwitch(switches::kLang)) {
|
|
|
|
command_line->AppendSwitchASCII(switches::kLang, "en-US");
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
2015-10-23 18:58:33 +02:00
|
|
|
base::FilePath log_file;
|
|
|
|
bool has_log_file_cmdline = false;
|
|
|
|
if (settings.log_file.length > 0)
|
|
|
|
log_file = base::FilePath(CefString(&settings.log_file));
|
|
|
|
if (log_file.empty() && command_line->HasSwitch(switches::kLogFile)) {
|
|
|
|
log_file = command_line->GetSwitchValuePath(switches::kLogFile);
|
|
|
|
if (!log_file.empty())
|
|
|
|
has_log_file_cmdline = true;
|
2012-06-25 19:52:54 +02:00
|
|
|
}
|
2015-10-23 18:58:33 +02:00
|
|
|
if (log_file.empty())
|
|
|
|
log_file = GetDefaultLogFile();
|
|
|
|
DCHECK(!log_file.empty());
|
|
|
|
if (!has_log_file_cmdline)
|
|
|
|
command_line->AppendSwitchPath(switches::kLogFile, log_file);
|
2012-06-25 19:52:54 +02:00
|
|
|
|
|
|
|
if (settings.log_severity != LOGSEVERITY_DEFAULT) {
|
|
|
|
std::string log_severity;
|
|
|
|
switch (settings.log_severity) {
|
|
|
|
case LOGSEVERITY_VERBOSE:
|
|
|
|
log_severity = switches::kLogSeverity_Verbose;
|
|
|
|
break;
|
|
|
|
case LOGSEVERITY_INFO:
|
|
|
|
log_severity = switches::kLogSeverity_Info;
|
|
|
|
break;
|
|
|
|
case LOGSEVERITY_WARNING:
|
|
|
|
log_severity = switches::kLogSeverity_Warning;
|
|
|
|
break;
|
|
|
|
case LOGSEVERITY_ERROR:
|
|
|
|
log_severity = switches::kLogSeverity_Error;
|
|
|
|
break;
|
|
|
|
case LOGSEVERITY_DISABLE:
|
|
|
|
log_severity = switches::kLogSeverity_Disable;
|
|
|
|
break;
|
2012-06-26 20:03:47 +02:00
|
|
|
default:
|
|
|
|
break;
|
2012-06-25 19:52:54 +02:00
|
|
|
}
|
|
|
|
if (!log_severity.empty())
|
|
|
|
command_line->AppendSwitchASCII(switches::kLogSeverity, log_severity);
|
|
|
|
}
|
|
|
|
|
2012-06-12 17:53:39 +02:00
|
|
|
if (settings.javascript_flags.length > 0) {
|
|
|
|
command_line->AppendSwitchASCII(switches::kJavaScriptFlags,
|
|
|
|
CefString(&settings.javascript_flags));
|
|
|
|
}
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
if (settings.pack_loading_disabled) {
|
2013-02-07 20:59:40 +01:00
|
|
|
command_line->AppendSwitch(switches::kDisablePackLoading);
|
2012-04-03 03:34:16 +02:00
|
|
|
} else {
|
2012-09-06 19:42:16 +02:00
|
|
|
if (settings.resources_dir_path.length > 0) {
|
2013-02-23 01:43:28 +01:00
|
|
|
base::FilePath file_path =
|
|
|
|
base::FilePath(CefString(&settings.resources_dir_path));
|
2012-09-06 19:42:16 +02:00
|
|
|
if (!file_path.empty()) {
|
|
|
|
command_line->AppendSwitchPath(switches::kResourcesDirPath,
|
|
|
|
file_path);
|
|
|
|
}
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (settings.locales_dir_path.length > 0) {
|
2013-02-23 01:43:28 +01:00
|
|
|
base::FilePath file_path =
|
|
|
|
base::FilePath(CefString(&settings.locales_dir_path));
|
2012-04-03 03:34:16 +02:00
|
|
|
if (!file_path.empty())
|
|
|
|
command_line->AppendSwitchPath(switches::kLocalesDirPath, file_path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-24 20:01:48 +02:00
|
|
|
if (settings.remote_debugging_port >= 1024 &&
|
|
|
|
settings.remote_debugging_port <= 65535) {
|
|
|
|
command_line->AppendSwitchASCII(switches::kRemoteDebuggingPort,
|
|
|
|
base::IntToString(settings.remote_debugging_port));
|
|
|
|
}
|
|
|
|
|
2012-11-02 19:16:28 +01:00
|
|
|
if (settings.uncaught_exception_stack_size > 0) {
|
|
|
|
command_line->AppendSwitchASCII(switches::kUncaughtExceptionStackSize,
|
|
|
|
base::IntToString(settings.uncaught_exception_stack_size));
|
|
|
|
}
|
|
|
|
|
2012-10-29 22:46:02 +01:00
|
|
|
if (settings.context_safety_implementation != 0) {
|
|
|
|
command_line->AppendSwitchASCII(switches::kContextSafetyImplementation,
|
|
|
|
base::IntToString(settings.context_safety_implementation));
|
|
|
|
}
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (content_client_.application().get()) {
|
|
|
|
// Give the application a chance to view/modify the command line.
|
|
|
|
CefRefPtr<CefCommandLineImpl> commandLinePtr(
|
|
|
|
new CefCommandLineImpl(command_line, false, false));
|
|
|
|
content_client_.application()->OnBeforeCommandLineProcessing(
|
|
|
|
CefString(process_type), commandLinePtr.get());
|
|
|
|
commandLinePtr->Detach(NULL);
|
|
|
|
}
|
|
|
|
|
2012-06-25 19:52:54 +02:00
|
|
|
// Initialize logging.
|
2013-07-19 00:37:02 +02:00
|
|
|
logging::LoggingSettings log_settings;
|
2015-10-23 18:58:33 +02:00
|
|
|
|
2013-08-28 17:26:01 +02:00
|
|
|
const base::FilePath& log_file =
|
|
|
|
command_line->GetSwitchValuePath(switches::kLogFile);
|
2015-10-23 18:58:33 +02:00
|
|
|
DCHECK(!log_file.empty());
|
2013-08-28 17:26:01 +02:00
|
|
|
log_settings.log_file = log_file.value().c_str();
|
2015-10-23 18:58:33 +02:00
|
|
|
|
2013-07-19 00:37:02 +02:00
|
|
|
log_settings.lock_log = logging::DONT_LOCK_LOG_FILE;
|
|
|
|
log_settings.delete_old = logging::APPEND_TO_OLD_LOG_FILE;
|
2012-06-25 19:52:54 +02:00
|
|
|
|
|
|
|
logging::LogSeverity log_severity = logging::LOG_INFO;
|
2013-07-19 00:37:02 +02:00
|
|
|
|
|
|
|
std::string log_severity_str =
|
|
|
|
command_line->GetSwitchValueASCII(switches::kLogSeverity);
|
2012-06-25 19:52:54 +02:00
|
|
|
if (!log_severity_str.empty()) {
|
2015-07-24 02:06:56 +02:00
|
|
|
if (base::LowerCaseEqualsASCII(log_severity_str,
|
|
|
|
switches::kLogSeverity_Verbose)) {
|
2012-06-25 19:52:54 +02:00
|
|
|
log_severity = logging::LOG_VERBOSE;
|
2015-07-24 02:06:56 +02:00
|
|
|
} else if (base::LowerCaseEqualsASCII(log_severity_str,
|
|
|
|
switches::kLogSeverity_Warning)) {
|
2012-06-25 19:52:54 +02:00
|
|
|
log_severity = logging::LOG_WARNING;
|
2015-07-24 02:06:56 +02:00
|
|
|
} else if (base::LowerCaseEqualsASCII(log_severity_str,
|
|
|
|
switches::kLogSeverity_Error)) {
|
2012-06-25 19:52:54 +02:00
|
|
|
log_severity = logging::LOG_ERROR;
|
2015-07-24 02:06:56 +02:00
|
|
|
} else if (base::LowerCaseEqualsASCII(log_severity_str,
|
|
|
|
switches::kLogSeverity_Disable)) {
|
2012-06-25 19:52:54 +02:00
|
|
|
log_severity = LOGSEVERITY_DISABLE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (log_severity == LOGSEVERITY_DISABLE) {
|
2013-07-19 00:37:02 +02:00
|
|
|
log_settings.logging_dest = logging::LOG_NONE;
|
2012-06-25 19:52:54 +02:00
|
|
|
} else {
|
2013-07-19 00:37:02 +02:00
|
|
|
log_settings.logging_dest = logging::LOG_TO_ALL;
|
2012-06-25 19:52:54 +02:00
|
|
|
logging::SetMinLogLevel(log_severity);
|
|
|
|
}
|
|
|
|
|
2013-07-19 00:37:02 +02:00
|
|
|
logging::InitLogging(log_settings);
|
2012-06-25 19:52:54 +02:00
|
|
|
|
2015-09-09 16:05:39 +02:00
|
|
|
ContentSettingsPattern::SetNonWildcardDomainNonPortScheme(
|
|
|
|
extensions::kExtensionScheme);
|
|
|
|
|
2012-04-24 20:01:48 +02:00
|
|
|
content::SetContentClient(&content_client_);
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
return false;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefMainDelegate::PreSandboxStartup() {
|
2015-01-09 18:22:10 +01:00
|
|
|
const base::CommandLine* command_line =
|
|
|
|
base::CommandLine::ForCurrentProcess();
|
2014-07-03 20:34:58 +02:00
|
|
|
const std::string& process_type =
|
2015-01-09 18:22:10 +01:00
|
|
|
command_line->GetSwitchValueASCII(switches::kProcessType);
|
2013-08-14 18:36:50 +02:00
|
|
|
|
2015-01-09 18:22:10 +01:00
|
|
|
if (command_line->HasSwitch(switches::kEnableCrashReporter)) {
|
2014-09-27 01:48:19 +02:00
|
|
|
crash_reporter::SetCrashReporterClient(g_crash_reporter_client.Pointer());
|
2013-11-21 23:43:36 +01:00
|
|
|
#if defined(OS_MACOSX)
|
|
|
|
base::mac::DisableOSCrashDumps();
|
2013-12-17 23:04:35 +01:00
|
|
|
breakpad::InitCrashReporter(process_type);
|
|
|
|
breakpad::InitCrashProcessInfo(process_type);
|
2013-11-21 23:43:36 +01:00
|
|
|
#elif defined(OS_POSIX) && !defined(OS_MACOSX)
|
|
|
|
if (process_type != switches::kZygoteProcess)
|
2013-12-17 23:04:35 +01:00
|
|
|
breakpad::InitCrashReporter(process_type);
|
2013-11-21 23:43:36 +01:00
|
|
|
#elif defined(OS_WIN)
|
|
|
|
UINT new_flags =
|
|
|
|
SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX;
|
|
|
|
UINT existing_flags = SetErrorMode(new_flags);
|
|
|
|
SetErrorMode(existing_flags | new_flags);
|
2013-12-17 23:04:35 +01:00
|
|
|
breakpad::InitCrashReporter(process_type);
|
2013-11-21 23:43:36 +01:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2015-01-09 18:22:10 +01:00
|
|
|
if (!command_line->HasSwitch(switches::kProcessType)) {
|
2015-03-25 22:22:47 +01:00
|
|
|
// Only override these paths when executing the main process.
|
2014-10-07 22:44:33 +02:00
|
|
|
#if defined(OS_MACOSX)
|
2013-08-14 18:36:50 +02:00
|
|
|
OverrideChildProcessPath();
|
2012-04-03 03:34:16 +02:00
|
|
|
#endif
|
|
|
|
|
2015-03-25 22:22:47 +01:00
|
|
|
OverridePepperFlashSystemPluginPath();
|
|
|
|
|
2014-10-07 22:44:33 +02:00
|
|
|
// Paths used to locate spell checking dictionary files.
|
2015-03-02 21:25:14 +01:00
|
|
|
const base::FilePath& user_data_path = GetUserDataPath();
|
|
|
|
PathService::Override(chrome::DIR_USER_DATA, user_data_path);
|
2014-10-07 22:44:33 +02:00
|
|
|
PathService::OverrideAndCreateIfNeeded(
|
|
|
|
chrome::DIR_APP_DICTIONARIES,
|
2015-03-02 21:25:14 +01:00
|
|
|
user_data_path.AppendASCII("Dictionaries"),
|
2014-10-07 22:44:33 +02:00
|
|
|
false, // May not be an absolute path.
|
|
|
|
true); // Create if necessary.
|
2015-08-31 13:28:07 +02:00
|
|
|
|
|
|
|
#if defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS)
|
2015-09-24 10:34:51 +02:00
|
|
|
const base::FilePath& widevine_plugin_path =
|
|
|
|
GetResourcesFilePath().AppendASCII(kWidevineCdmAdapterFileName);
|
|
|
|
if (base::PathExists(widevine_plugin_path)) {
|
|
|
|
PathService::Override(chrome::FILE_WIDEVINE_CDM_ADAPTER,
|
|
|
|
widevine_plugin_path);
|
|
|
|
}
|
2015-08-31 13:28:07 +02:00
|
|
|
#if defined(WIDEVINE_CDM_IS_COMPONENT)
|
2015-09-24 10:34:51 +02:00
|
|
|
if (command_line->HasSwitch(switches::kEnableWidevineCdm)) {
|
2015-11-10 21:18:16 +01:00
|
|
|
PathService::Override(
|
|
|
|
chrome::DIR_COMPONENT_WIDEVINE_CDM,
|
|
|
|
user_data_path.Append(FILE_PATH_LITERAL("WidevineCDM")));
|
2015-09-24 10:34:51 +02:00
|
|
|
}
|
2015-08-31 13:28:07 +02:00
|
|
|
#endif // defined(WIDEVINE_CDM_IS_COMPONENT)
|
|
|
|
#endif // defined(WIDEVINE_CDM_AVAILABLE) && defined(ENABLE_PEPPER_CDMS)
|
2014-10-07 22:44:33 +02:00
|
|
|
}
|
|
|
|
|
2015-01-09 18:22:10 +01:00
|
|
|
if (command_line->HasSwitch(switches::kDisablePackLoading))
|
2012-04-03 03:34:16 +02:00
|
|
|
content_client_.set_pack_loading_disabled(true);
|
2012-05-18 22:32:28 +02:00
|
|
|
|
|
|
|
InitializeResourceBundle();
|
2015-07-16 23:40:01 +02:00
|
|
|
chrome::InitializePDF();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefMainDelegate::SandboxInitialized(const std::string& process_type) {
|
|
|
|
CefContentClient::SetPDFEntryFunctions(
|
|
|
|
chrome_pdf::PPP_GetInterface,
|
|
|
|
chrome_pdf::PPP_InitializeModule,
|
|
|
|
chrome_pdf::PPP_ShutdownModule);
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
int CefMainDelegate::RunProcess(
|
|
|
|
const std::string& process_type,
|
|
|
|
const content::MainFunctionParams& main_function_params) {
|
|
|
|
if (process_type.empty()) {
|
2013-09-03 20:06:25 +02:00
|
|
|
const CefSettings& settings = CefContext::Get()->settings();
|
2012-04-11 20:00:55 +02:00
|
|
|
if (!settings.multi_threaded_message_loop) {
|
|
|
|
// Use our own browser process runner.
|
|
|
|
browser_runner_.reset(content::BrowserMainRunner::Create());
|
|
|
|
|
|
|
|
// Initialize browser process state. Results in a call to
|
2012-06-19 18:29:49 +02:00
|
|
|
// CefBrowserMain::PreMainMessageLoopStart() which creates the UI message
|
|
|
|
// loop.
|
2012-04-11 20:00:55 +02:00
|
|
|
int exit_code = browser_runner_->Initialize(main_function_params);
|
|
|
|
if (exit_code >= 0)
|
|
|
|
return exit_code;
|
|
|
|
} else {
|
|
|
|
// Run the UI on a separate thread.
|
2016-04-27 22:38:52 +02:00
|
|
|
std::unique_ptr<base::Thread> thread;
|
2012-04-11 20:00:55 +02:00
|
|
|
thread.reset(new CefUIThread(main_function_params));
|
|
|
|
base::Thread::Options options;
|
2013-04-16 00:16:01 +02:00
|
|
|
options.message_loop_type = base::MessageLoop::TYPE_UI;
|
2012-04-11 20:00:55 +02:00
|
|
|
if (!thread->StartWithOptions(options)) {
|
|
|
|
NOTREACHED() << "failed to start UI thread";
|
|
|
|
return 1;
|
|
|
|
}
|
2015-08-05 19:24:01 +02:00
|
|
|
thread->WaitUntilThreadStarted();
|
2012-04-11 20:00:55 +02:00
|
|
|
ui_thread_.swap(thread);
|
|
|
|
}
|
2012-04-03 03:34:16 +02:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
void CefMainDelegate::ProcessExiting(const std::string& process_type) {
|
2012-05-18 22:32:28 +02:00
|
|
|
ResourceBundle::CleanupSharedInstance();
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
2013-11-21 23:43:36 +01:00
|
|
|
#if defined(OS_POSIX) && !defined(OS_ANDROID) && !defined(OS_MACOSX)
|
|
|
|
void CefMainDelegate::ZygoteForked() {
|
2015-01-09 18:22:10 +01:00
|
|
|
const base::CommandLine* command_line =
|
|
|
|
base::CommandLine::ForCurrentProcess();
|
|
|
|
if (command_line->HasSwitch(switches::kEnableCrashReporter)) {
|
|
|
|
const std::string& process_type = command_line->GetSwitchValueASCII(
|
2013-12-17 23:04:35 +01:00
|
|
|
switches::kProcessType);
|
|
|
|
breakpad::InitCrashReporter(process_type);
|
2013-11-21 23:43:36 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
2012-06-22 00:50:34 +02:00
|
|
|
|
|
|
|
content::ContentBrowserClient* CefMainDelegate::CreateContentBrowserClient() {
|
|
|
|
browser_client_.reset(new CefContentBrowserClient);
|
|
|
|
return browser_client_.get();
|
|
|
|
}
|
|
|
|
|
|
|
|
content::ContentRendererClient*
|
|
|
|
CefMainDelegate::CreateContentRendererClient() {
|
|
|
|
renderer_client_.reset(new CefContentRendererClient);
|
|
|
|
return renderer_client_.get();
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
2014-07-03 20:34:58 +02:00
|
|
|
content::ContentUtilityClient* CefMainDelegate::CreateContentUtilityClient() {
|
|
|
|
utility_client_.reset(new CefContentUtilityClient);
|
|
|
|
return utility_client_.get();
|
|
|
|
}
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
void CefMainDelegate::ShutdownBrowser() {
|
|
|
|
if (browser_runner_.get()) {
|
|
|
|
browser_runner_->Shutdown();
|
|
|
|
browser_runner_.reset(NULL);
|
|
|
|
}
|
2012-04-11 20:00:55 +02:00
|
|
|
if (ui_thread_.get()) {
|
|
|
|
// Blocks until the thread has stopped.
|
|
|
|
ui_thread_->Stop();
|
|
|
|
ui_thread_.reset();
|
|
|
|
}
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void CefMainDelegate::InitializeResourceBundle() {
|
2015-01-09 18:22:10 +01:00
|
|
|
const base::CommandLine* command_line =
|
|
|
|
base::CommandLine::ForCurrentProcess();
|
2014-07-08 00:17:33 +02:00
|
|
|
base::FilePath cef_pak_file, cef_100_percent_pak_file,
|
2015-07-16 23:40:01 +02:00
|
|
|
cef_200_percent_pak_file, cef_extensions_pak_file,
|
|
|
|
devtools_pak_file, locales_dir;
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2015-07-16 23:40:01 +02:00
|
|
|
base::FilePath resources_dir;
|
|
|
|
if (command_line->HasSwitch(switches::kResourcesDirPath)) {
|
|
|
|
resources_dir =
|
|
|
|
command_line->GetSwitchValuePath(switches::kResourcesDirPath);
|
|
|
|
}
|
|
|
|
if (resources_dir.empty())
|
|
|
|
resources_dir = GetResourcesFilePath();
|
|
|
|
if (!resources_dir.empty())
|
|
|
|
PathService::Override(chrome::DIR_RESOURCES, resources_dir);
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2015-07-16 23:40:01 +02:00
|
|
|
if (!content_client_.pack_loading_disabled()) {
|
2012-09-06 19:42:16 +02:00
|
|
|
if (!resources_dir.empty()) {
|
2015-07-29 18:13:14 +02:00
|
|
|
CHECK(resources_dir.IsAbsolute());
|
2012-09-06 19:42:16 +02:00
|
|
|
cef_pak_file = resources_dir.Append(FILE_PATH_LITERAL("cef.pak"));
|
2014-07-08 00:17:33 +02:00
|
|
|
cef_100_percent_pak_file =
|
|
|
|
resources_dir.Append(FILE_PATH_LITERAL("cef_100_percent.pak"));
|
|
|
|
cef_200_percent_pak_file =
|
|
|
|
resources_dir.Append(FILE_PATH_LITERAL("cef_200_percent.pak"));
|
2015-07-16 23:40:01 +02:00
|
|
|
cef_extensions_pak_file =
|
|
|
|
resources_dir.Append(FILE_PATH_LITERAL("cef_extensions.pak"));
|
2012-09-06 19:42:16 +02:00
|
|
|
devtools_pak_file =
|
|
|
|
resources_dir.Append(FILE_PATH_LITERAL("devtools_resources.pak"));
|
|
|
|
}
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2015-01-09 18:22:10 +01:00
|
|
|
if (command_line->HasSwitch(switches::kLocalesDirPath))
|
|
|
|
locales_dir = command_line->GetSwitchValuePath(switches::kLocalesDirPath);
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2012-05-18 22:32:28 +02:00
|
|
|
if (!locales_dir.empty())
|
|
|
|
PathService::Override(ui::DIR_LOCALES, locales_dir);
|
|
|
|
}
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2015-01-09 18:22:10 +01:00
|
|
|
std::string locale = command_line->GetSwitchValueASCII(switches::kLang);
|
2012-10-22 22:56:38 +02:00
|
|
|
DCHECK(!locale.empty());
|
2012-04-03 03:34:16 +02:00
|
|
|
|
2016-05-25 01:35:43 +02:00
|
|
|
// Avoid DCHECK() in ResourceBundle::LoadChromeResources().
|
|
|
|
ui::MaterialDesignController::Initialize();
|
|
|
|
|
2012-04-03 03:34:16 +02:00
|
|
|
const std::string loaded_locale =
|
2014-09-04 19:53:40 +02:00
|
|
|
ui::ResourceBundle::InitSharedInstanceWithLocale(
|
|
|
|
locale,
|
|
|
|
&content_client_,
|
|
|
|
ui::ResourceBundle::LOAD_COMMON_RESOURCES);
|
2015-10-17 02:44:00 +02:00
|
|
|
if (!loaded_locale.empty() && g_browser_process)
|
|
|
|
g_browser_process->SetApplicationLocale(loaded_locale);
|
|
|
|
|
2014-07-08 00:17:33 +02:00
|
|
|
ResourceBundle& resource_bundle = ResourceBundle::GetSharedInstance();
|
|
|
|
|
2012-05-18 22:32:28 +02:00
|
|
|
if (!content_client_.pack_loading_disabled()) {
|
2014-07-08 00:17:33 +02:00
|
|
|
if (loaded_locale.empty())
|
|
|
|
LOG(ERROR) << "Could not load locale pak for " << locale;
|
2012-05-18 22:32:28 +02:00
|
|
|
|
2012-09-06 19:42:16 +02:00
|
|
|
content_client_.set_allow_pack_file_load(true);
|
|
|
|
|
2013-07-24 22:15:18 +02:00
|
|
|
if (base::PathExists(cef_pak_file)) {
|
2014-07-08 00:17:33 +02:00
|
|
|
resource_bundle.AddDataPackFromPath(cef_pak_file, ui::SCALE_FACTOR_NONE);
|
2012-05-18 22:32:28 +02:00
|
|
|
} else {
|
2014-07-08 00:17:33 +02:00
|
|
|
LOG(ERROR) << "Could not load cef.pak";
|
|
|
|
}
|
|
|
|
|
|
|
|
// On OS X and Linux/Aura always load the 1x data pack first as the 2x data
|
|
|
|
// pack contains both 1x and 2x images.
|
|
|
|
const bool load_100_percent =
|
|
|
|
#if defined(OS_WIN)
|
|
|
|
IsScaleFactorSupported(ui::SCALE_FACTOR_100P);
|
|
|
|
#else
|
|
|
|
true;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
if (load_100_percent) {
|
|
|
|
if (base::PathExists(cef_100_percent_pak_file)) {
|
|
|
|
resource_bundle.AddDataPackFromPath(
|
|
|
|
cef_100_percent_pak_file, ui::SCALE_FACTOR_100P);
|
|
|
|
} else {
|
|
|
|
LOG(ERROR) << "Could not load cef_100_percent.pak";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (IsScaleFactorSupported(ui::SCALE_FACTOR_200P)) {
|
|
|
|
if (base::PathExists(cef_200_percent_pak_file)) {
|
|
|
|
resource_bundle.AddDataPackFromPath(
|
|
|
|
cef_200_percent_pak_file, ui::SCALE_FACTOR_200P);
|
|
|
|
} else {
|
|
|
|
LOG(ERROR) << "Could not load cef_200_percent.pak";
|
|
|
|
}
|
2012-05-18 22:32:28 +02:00
|
|
|
}
|
2012-09-06 19:42:16 +02:00
|
|
|
|
2015-07-16 23:40:01 +02:00
|
|
|
if (extensions::ExtensionsEnabled()) {
|
|
|
|
if (base::PathExists(cef_extensions_pak_file)) {
|
|
|
|
resource_bundle.AddDataPackFromPath(
|
|
|
|
cef_extensions_pak_file, ui::SCALE_FACTOR_NONE);
|
|
|
|
} else {
|
|
|
|
LOG(ERROR) << "Could not load cef_extensions.pak";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-07-24 22:15:18 +02:00
|
|
|
if (base::PathExists(devtools_pak_file)) {
|
2014-07-08 00:17:33 +02:00
|
|
|
resource_bundle.AddDataPackFromPath(
|
2012-09-06 19:42:16 +02:00
|
|
|
devtools_pak_file, ui::SCALE_FACTOR_NONE);
|
|
|
|
}
|
|
|
|
|
|
|
|
content_client_.set_allow_pack_file_load(false);
|
2012-05-02 17:56:15 +02:00
|
|
|
}
|
2012-04-03 03:34:16 +02:00
|
|
|
}
|