mate::Dictionary web_preferences = mate::Dictionary::CreateEmpty(isolate);
options.Get(switches::kWebPreferences, &web_preferences);
+ // Be compatible with old options which are now in web_preferences.
+ std::string str;
+ double d;
+ if (options.Get(switches::kNodeIntegration, &str))
+ web_preferences.Set(switches::kNodeIntegration, str);
+ if (options.Get(switches::kPreloadScript, &str))
+ web_preferences.Set(switches::kPreloadScript, str);
+ if (options.Get(switches::kZoomFactor, &d))
+ web_preferences.Set(switches::kZoomFactor, d);
+
// Creates the WebContents used by BrowserWindow.
auto web_contents = WebContents::Create(isolate, web_preferences);
web_contents_.Reset(isolate, web_contents.ToV8());
#include "net/ssl/ssl_cert_request_info.h"
#include "ppapi/host/ppapi_host.h"
#include "ui/base/l10n/l10n_util.h"
+#include "v8/include/v8.h"
namespace atom {
ProcessOwner owner = GetProcessOwner(process_id, &window, &info);
if (owner == OWNER_NATIVE_WINDOW) {
- window->AppendExtraCommandLineSwitches(command_line);
WebContentsPreferences::AppendExtraCommandLineSwitches(
window->web_contents(), command_line);
} else if (owner == OWNER_GUEST_WEB_CONTENTS) {
#include "atom/common/native_mate_converters/image_converter.h"
#include "atom/common/native_mate_converters/file_path_converter.h"
#include "atom/common/options_switches.h"
-#include "base/command_line.h"
#include "base/files/file_util.h"
#include "base/json/json_writer.h"
#include "base/prefs/pref_service.h"
#include "base/message_loop/message_loop.h"
-#include "base/strings/string_number_conversions.h"
#include "base/strings/utf_string_conversions.h"
#include "brightray/browser/inspectable_web_contents.h"
#include "brightray/browser/inspectable_web_contents_view.h"
transparent_(false),
enable_larger_than_screen_(false),
is_closed_(false),
- node_integration_(true),
has_dialog_attached_(false),
- zoom_factor_(1.0),
aspect_ratio_(0.0),
inspectable_web_contents_(inspectable_web_contents),
weak_factory_(this) {
options.Get(switches::kFrame, &has_frame_);
options.Get(switches::kTransparent, &transparent_);
options.Get(switches::kEnableLargerThanScreen, &enable_larger_than_screen_);
- options.Get(switches::kNodeIntegration, &node_integration_);
// Tell the content module to initialize renderer widget with transparent
// mode.
// 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) &&
- old_string_token != "disable")
- node_integration_ = true;
-
- // Read the web preferences.
- options.Get(switches::kWebPreferences, &web_preferences_);
-
- // Read the zoom factor before any navigation.
- options.Get(switches::kZoomFactor, &zoom_factor_);
-
WindowList::AddWindow(this);
}
FOR_EACH_OBSERVER(NativeWindowObserver, observers_, OnRendererResponsive());
}
-void NativeWindow::AppendExtraCommandLineSwitches(
- base::CommandLine* command_line) {
- // Append --node-integration to renderer process.
- 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,
- base::DoubleToString(zoom_factor_));
-}
-
void NativeWindow::NotifyWindowClosed() {
if (is_closed_)
return;
#include "content/public/browser/readback_types.h"
#include "content/public/browser/web_contents_observer.h"
#include "content/public/browser/web_contents_user_data.h"
-#include "native_mate/persistent_dictionary.h"
#include "ui/gfx/image/image.h"
#include "ui/gfx/image/image_skia.h"
// The windows has been closed.
bool is_closed_;
- // Whether node integration is enabled.
- bool node_integration_;
-
// There is a dialog that has been attached to window.
bool has_dialog_attached_;
// it should be cancelled when we can prove that the window is responsive.
base::CancelableClosure window_unresposive_closure_;
- // Web preferences.
- mate::PersistentDictionary web_preferences_;
-
- // The script to load before page's JavaScript starts to run.
- base::FilePath preload_script_;
-
- // Page's default zoom factor.
- double zoom_factor_;
-
// Used to maintain the aspect ratio of a view which is inside of the
// content view.
double aspect_ratio_;
#include "atom/common/options_switches.h"
#include "base/command_line.h"
+#include "base/strings/string_number_conversions.h"
#include "content/public/common/web_preferences.h"
+#include "storage/common/fileapi/file_system_util.h" // IsAbsolute
#if defined(OS_WIN)
#include "ui/gfx/switches.h"
content::WebContents* web_contents, base::CommandLine* command_line) {
WebContentsPreferences* self = From(web_contents);
CHECK(self);
+ base::DictionaryValue& web_preferences = self->web_preferences_;
bool b;
#if defined(OS_WIN)
// Check if DirectWrite is disabled.
- if (self->web_preferences_.GetBoolean(switches::kDirectWrite, &b) && !b)
+ if (web_preferences.GetBoolean(switches::kDirectWrite, &b) && !b)
command_line->AppendSwitch(::switches::kDisableDirectWrite);
#endif
// Check if plugins are enabled.
- if (self->web_preferences_.GetBoolean("plugins", &b) && b)
+ if (web_preferences.GetBoolean("plugins", &b) && b)
command_line->AppendSwitch(switches::kEnablePlugins);
// This set of options are not availabe in WebPreferences, so we have to pass
// them via command line and enable them in renderer procss.
for (size_t i = 0; i < arraysize(kWebRuntimeFeatures); ++i) {
const char* feature = kWebRuntimeFeatures[i];
- if (self->web_preferences_.GetBoolean(feature, &b))
+ if (web_preferences.GetBoolean(feature, &b))
command_line->AppendSwitchASCII(feature, b ? "true" : "false");
}
+
+ // Check if we have node integration specified.
+ bool node_integration = true;
+ web_preferences.GetBoolean(switches::kNodeIntegration, &node_integration);
+ // Be compatible with old API of "node-integration" option.
+ std::string old_token;
+ if (web_preferences.GetString(switches::kNodeIntegration, &old_token) &&
+ old_token != "disable")
+ node_integration = true;
+ command_line->AppendSwitchASCII(switches::kNodeIntegration,
+ node_integration ? "true" : "false");
+
+ // The preload script.
+ base::FilePath::StringType preload;
+ if (web_preferences.GetString(switches::kPreloadScript, &preload) &&
+ !preload.empty() &&
+ base::FilePath(preload).IsAbsolute())
+ command_line->AppendSwitchNative(switches::kPreloadScript, preload);
+
+ // The zoom factor.
+ double zoom_factor = 1.0;
+ if (web_preferences.GetDouble(switches::kZoomFactor, &zoom_factor) &&
+ zoom_factor != 1.0)
+ command_line->AppendSwitchASCII(switches::kZoomFactor,
+ base::DoubleToString(zoom_factor));
}
void WebContentsPreferences::OverrideWebkitPrefs(