#include "atom/browser/atom_speech_recognition_manager_delegate.h"
#include "atom/browser/browser.h"
#include "atom/browser/native_window.h"
+#include "atom/browser/web_contents_preferences.h"
#include "atom/browser/web_view_manager.h"
#include "atom/browser/web_view_constants.h"
#include "atom/browser/window_list.h"
NativeWindow* window = NativeWindow::FromWebContents(web_contents);
if (window)
- window->OverrideWebkitPrefs(prefs);
+ WebContentsPreferences::OverrideWebkitPrefs(web_contents, prefs);
}
std::string AtomBrowserClient::GetApplicationLocale() {
if (owner == OWNER_NATIVE_WINDOW) {
window->AppendExtraCommandLineSwitches(command_line);
+ WebContentsPreferences::AppendExtraCommandLineSwitches(
+ window->web_contents(), command_line);
} else if (owner == OWNER_GUEST_WEB_CONTENTS) {
command_line->AppendSwitchASCII(
switches::kGuestInstanceID, base::IntToString(info.guest_instance_id));
#include "content/public/browser/render_view_host.h"
#include "content/public/browser/render_widget_host_view.h"
#include "content/public/common/content_switches.h"
-#include "content/public/common/renderer_preferences.h"
-#include "content/public/common/web_preferences.h"
#include "ipc/ipc_message_macros.h"
#include "native_mate/dictionary.h"
#include "ui/gfx/codec/png_codec.h"
base::DoubleToString(zoom_factor_));
}
-void NativeWindow::OverrideWebkitPrefs(content::WebPreferences* prefs) {
- if (web_preferences_.IsEmpty())
- return;
-
- bool b;
- if (web_preferences_.Get("javascript", &b))
- prefs->javascript_enabled = b;
- if (web_preferences_.Get("images", &b))
- prefs->images_enabled = b;
- if (web_preferences_.Get("java", &b))
- prefs->java_enabled = b;
- if (web_preferences_.Get("text-areas-are-resizable", &b))
- prefs->text_areas_are_resizable = b;
- if (web_preferences_.Get("webgl", &b))
- prefs->experimental_webgl_enabled = b;
- if (web_preferences_.Get("webaudio", &b))
- prefs->webaudio_enabled = b;
- if (web_preferences_.Get("web-security", &b)) {
- prefs->web_security_enabled = b;
- prefs->allow_displaying_insecure_content = !b;
- prefs->allow_running_insecure_content = !b;
- }
- if (web_preferences_.Get("allow-displaying-insecure-content", &b))
- prefs->allow_displaying_insecure_content = b;
- if (web_preferences_.Get("allow-running-insecure-content", &b))
- prefs->allow_running_insecure_content = b;
-}
-
void NativeWindow::NotifyWindowClosed() {
if (is_closed_)
return;
namespace content {
struct NativeWebKeyboardEvent;
-struct WebPreferences;
}
namespace gfx {
// Called when renderer process is going to be started.
void AppendExtraCommandLineSwitches(base::CommandLine* command_line);
- void OverrideWebkitPrefs(content::WebPreferences* prefs);
// Public API used by platform-dependent delegates and observers to send UI
// related notifications.
#include "atom/common/options_switches.h"
#include "base/command_line.h"
+#include "content/public/common/web_preferences.h"
#if defined(OS_WIN)
#include "ui/gfx/switches.h"
}
}
+void WebContentsPreferences::OverrideWebkitPrefs(
+ content::WebContents* web_contents, content::WebPreferences* prefs) {
+ WebContentsPreferences* self = From(web_contents);
+ CHECK(self);
+
+ bool b;
+ if (self->web_preferences_.GetBoolean("javascript", &b))
+ prefs->javascript_enabled = b;
+ if (self->web_preferences_.GetBoolean("images", &b))
+ prefs->images_enabled = b;
+ if (self->web_preferences_.GetBoolean("java", &b))
+ prefs->java_enabled = b;
+ if (self->web_preferences_.GetBoolean("text-areas-are-resizable", &b))
+ prefs->text_areas_are_resizable = b;
+ if (self->web_preferences_.GetBoolean("webgl", &b))
+ prefs->experimental_webgl_enabled = b;
+ if (self->web_preferences_.GetBoolean("webaudio", &b))
+ prefs->webaudio_enabled = b;
+ if (self->web_preferences_.GetBoolean("web-security", &b)) {
+ prefs->web_security_enabled = b;
+ prefs->allow_displaying_insecure_content = !b;
+ prefs->allow_running_insecure_content = !b;
+ }
+ if (self->web_preferences_.GetBoolean("allow-displaying-insecure-content",
+ &b))
+ prefs->allow_displaying_insecure_content = b;
+ if (self->web_preferences_.GetBoolean("allow-running-insecure-content", &b))
+ prefs->allow_running_insecure_content = b;
+}
+
} // namespace atom
class CommandLine;
}
+namespace content {
+struct WebPreferences;
+}
+
namespace atom {
// Stores and applies the preferences of WebContents.
// Get the preferences of |web_contents|.
static WebContentsPreferences* From(content::WebContents* web_contents);
- // Append command paramters appending to |web_contents|'s preferences.
+ // Append command paramters according to |web_contents|'s preferences.
static void AppendExtraCommandLineSwitches(
content::WebContents* web_contents, base::CommandLine* command_line);
+ // Modify the WebPreferences according to |web_contents|'s preferences.
+ static void OverrideWebkitPrefs(
+ content::WebContents* web_contents, content::WebPreferences* prefs);
+
WebContentsPreferences(content::WebContents* web_contents,
base::DictionaryValue&& web_preferences);
~WebContentsPreferences() override;