Add "preload" option for BrowserWindow

This commit is contained in:
Cheng Zhao 2014-11-12 15:04:03 +08:00
parent 14d01544d4
commit 9f29f66768
4 changed files with 16 additions and 2 deletions

View file

@ -101,6 +101,13 @@ NativeWindow::NativeWindow(content::WebContents* web_contents,
// Read icon before window is created.
options.Get(switches::kIcon, &icon_);
// The "preload" option must be absolute path.
if (options.Get(switches::kPreloadScript, &preload_script_) &&
!preload_script_.IsAbsolute()) {
LOG(ERROR) << "Path of \"preload\" script must be absolute.";
preload_script_.clear();
}
// Be compatible with old API of "node-integration" option.
std::string old_string_token;
if (options.Get(switches::kNodeIntegration, &old_string_token) &&
@ -349,6 +356,10 @@ void NativeWindow::AppendExtraCommandLineSwitches(
command_line->AppendSwitchASCII(switches::kNodeIntegration,
node_integration_ ? "true" : "false");
// Append --preload.
if (!preload_script_.empty())
command_line->AppendSwitchPath(switches::kPreloadScript, preload_script_);
// Append --zoom-factor.
if (zoom_factor_ != 1.0)
command_line->AppendSwitchASCII(switches::kZoomFactor,