2015-01-23 00:11:30 +01:00
|
|
|
// Copyright (c) 2015 The Chromium Embedded Framework 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 "cefclient/main_context_impl.h"
|
|
|
|
|
|
|
|
#include "cefclient/client_switches.h"
|
|
|
|
|
2015-01-27 01:03:25 +01:00
|
|
|
#if defined(OS_WIN)
|
|
|
|
#include "cefclient/root_window_manager.h"
|
|
|
|
#endif
|
2015-01-23 00:11:30 +01:00
|
|
|
namespace client {
|
|
|
|
|
|
|
|
namespace {
|
|
|
|
|
|
|
|
// The default URL to load in a browser window.
|
|
|
|
const char kDefaultUrl[] = "http://www.google.com";
|
|
|
|
|
|
|
|
} // namespace
|
|
|
|
|
|
|
|
MainContextImpl::MainContextImpl(int argc,
|
2015-01-27 01:03:25 +01:00
|
|
|
const char* const* argv
|
|
|
|
#if defined(OS_WIN)
|
|
|
|
, bool terminate_when_all_windows_closed
|
|
|
|
#endif
|
|
|
|
) {
|
2015-01-23 00:11:30 +01:00
|
|
|
// Parse the command line.
|
|
|
|
command_line_ = CefCommandLine::CreateCommandLine();
|
|
|
|
#if defined(OS_WIN)
|
|
|
|
command_line_->InitFromString(::GetCommandLineW());
|
|
|
|
#else
|
|
|
|
command_line_->InitFromArgv(argc, argv);
|
|
|
|
#endif
|
|
|
|
|
|
|
|
// Set the main URL.
|
2015-01-23 20:09:34 +01:00
|
|
|
if (command_line_->HasSwitch(switches::kUrl))
|
|
|
|
main_url_ = command_line_->GetSwitchValue(switches::kUrl);
|
2015-01-23 00:11:30 +01:00
|
|
|
if (main_url_.empty())
|
|
|
|
main_url_ = kDefaultUrl;
|
2015-01-27 01:03:25 +01:00
|
|
|
|
|
|
|
#if defined(OS_WIN)
|
|
|
|
root_window_manager_.reset(
|
|
|
|
new RootWindowManager(terminate_when_all_windows_closed));
|
|
|
|
#endif
|
2015-01-23 00:11:30 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
std::string MainContextImpl::GetConsoleLogPath() {
|
|
|
|
return GetAppWorkingDirectory() + "console.log";
|
|
|
|
}
|
|
|
|
|
|
|
|
std::string MainContextImpl::GetMainURL() {
|
|
|
|
return main_url_;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainContextImpl::PopulateSettings(CefSettings* settings) {
|
|
|
|
#if defined(OS_WIN)
|
|
|
|
settings->multi_threaded_message_loop =
|
2015-01-23 20:09:34 +01:00
|
|
|
command_line_->HasSwitch(switches::kMultiThreadedMessageLoop);
|
2015-01-23 00:11:30 +01:00
|
|
|
#endif
|
|
|
|
|
|
|
|
CefString(&settings->cache_path) =
|
2015-01-23 20:09:34 +01:00
|
|
|
command_line_->GetSwitchValue(switches::kCachePath);
|
2015-01-23 00:11:30 +01:00
|
|
|
|
2015-01-23 20:09:34 +01:00
|
|
|
if (command_line_->HasSwitch(switches::kOffScreenRenderingEnabled))
|
2015-01-23 00:11:30 +01:00
|
|
|
settings->windowless_rendering_enabled = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
void MainContextImpl::PopulateBrowserSettings(CefBrowserSettings* settings) {
|
2015-01-23 20:09:34 +01:00
|
|
|
if (command_line_->HasSwitch(switches::kOffScreenFrameRate)) {
|
2015-01-23 00:11:30 +01:00
|
|
|
settings->windowless_frame_rate = atoi(command_line_->
|
2015-01-23 20:09:34 +01:00
|
|
|
GetSwitchValue(switches::kOffScreenFrameRate).ToString().c_str());
|
2015-01-23 00:11:30 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2015-01-27 01:03:25 +01:00
|
|
|
#if defined(OS_WIN)
|
|
|
|
RootWindowManager* MainContextImpl::GetRootWindowManager() {
|
|
|
|
return root_window_manager_.get();
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2015-01-23 00:11:30 +01:00
|
|
|
} // namespace client
|