#include "atom/browser/atom_browser_context.h"
#include "atom/browser/atom_browser_main_parts.h"
#include "atom/browser/native_window.h"
+#include "atom/browser/web_contents_preferences.h"
#include "atom/browser/web_view_guest_delegate.h"
#include "atom/common/api/api_messages.h"
#include "atom/common/api/event_emitter_caller.h"
web_contents->SetUserAgentOverride(GetBrowserContext()->GetUserAgent());
}
-WebContents::WebContents(const mate::Dictionary& options) {
+WebContents::WebContents(v8::Isolate* isolate,
+ const mate::Dictionary& options) {
bool is_guest = false;
options.Get("isGuest", &is_guest);
AttachAsUserData(web_contents);
InitWithWebContents(web_contents);
+ // Save the preferences.
+ base::DictionaryValue web_preferences;
+ mate::ConvertFromV8(isolate, options.GetHandle(), &web_preferences);
+ new WebContentsPreferences(web_contents, std::move(web_preferences));
+
web_contents->SetUserAgentOverride(GetBrowserContext()->GetUserAgent());
if (is_guest) {
// static
mate::Handle<WebContents> WebContents::Create(
v8::Isolate* isolate, const mate::Dictionary& options) {
- auto handle = mate::CreateHandle(isolate, new WebContents(options));
+ auto handle = mate::CreateHandle(isolate, new WebContents(isolate, options));
g_wrap_web_contents.Run(handle.ToV8());
return handle;
}
protected:
explicit WebContents(content::WebContents* web_contents);
- explicit WebContents(const mate::Dictionary& options);
+ WebContents(v8::Isolate* isolate, const mate::Dictionary& options);
~WebContents();
// mate::Wrappable:
--- /dev/null
+// Copyright (c) 2015 GitHub, Inc.
+// Use of this source code is governed by the MIT license that can be
+// found in the LICENSE file.
+
+#include "atom/browser/web_contents_preferences.h"
+
+namespace atom {
+
+namespace {
+
+const char* kWebPreferencesKey = "WebContentsPreferences";
+
+} // namespace
+
+WebContentsPreferences::WebContentsPreferences(
+ content::WebContents* web_contents,
+ base::DictionaryValue&& web_preferences) {
+ web_preferences_.Swap(&web_preferences);
+ web_contents->SetUserData(kWebPreferencesKey, this);
+}
+
+WebContentsPreferences::~WebContentsPreferences() {
+}
+
+} // namespace atom
--- /dev/null
+// Copyright (c) 2015 GitHub, Inc.
+// Use of this source code is governed by the MIT license that can be
+// found in the LICENSE file.
+
+#ifndef ATOM_BROWSER_WEB_CONTENTS_PREFERENCES_H_
+#define ATOM_BROWSER_WEB_CONTENTS_PREFERENCES_H_
+
+#include "base/values.h"
+#include "content/public/browser/web_contents_user_data.h"
+
+namespace atom {
+
+class WebContentsPreferences
+ : public content::WebContentsUserData<WebContentsPreferences> {
+ public:
+ WebContentsPreferences(content::WebContents* web_contents,
+ base::DictionaryValue&& web_preferences);
+ ~WebContentsPreferences() override;
+
+ private:
+ friend class content::WebContentsUserData<WebContentsPreferences>;
+
+ base::DictionaryValue web_preferences_;
+
+ DISALLOW_COPY_AND_ASSIGN(WebContentsPreferences);
+};
+
+} // namespace atom
+
+#endif // ATOM_BROWSER_WEB_CONTENTS_PREFERENCES_H_
'atom/browser/ui/x/window_state_watcher.h',
'atom/browser/ui/x/x_window_utils.cc',
'atom/browser/ui/x/x_window_utils.h',
+ 'atom/browser/web_contents_preferences.cc',
+ 'atom/browser/web_contents_preferences.h',
+ 'atom/browser/web_dialog_helper.cc',
+ 'atom/browser/web_dialog_helper.h',
'atom/browser/web_view_constants.cc',
'atom/browser/web_view_constants.h',
'atom/browser/web_view_guest_delegate.cc',
'atom/browser/web_view_guest_delegate.h',
'atom/browser/web_view_manager.cc',
'atom/browser/web_view_manager.h',
- 'atom/browser/web_dialog_helper.cc',
- 'atom/browser/web_dialog_helper.h',
'atom/browser/window_list.cc',
'atom/browser/window_list.h',
'atom/browser/window_list_observer.h',