#include "ui/gfx/screen.h"
#include "ui/gl/gpu_switching_manager.h"
-#if defined(OS_WIN)
-#include "ui/gfx/switches.h"
-#endif
-
using content::NavigationEntry;
using content::RenderWidgetHostView;
using content::RenderWidgetHost;
namespace {
-// Array of available web runtime features.
-const char* kWebRuntimeFeatures[] = {
- switches::kExperimentalFeatures,
- switches::kExperimentalCanvasFeatures,
- switches::kSubpixelFontScaling,
- switches::kOverlayScrollbars,
- switches::kOverlayFullscreenVideo,
- switches::kSharedWorker,
- switches::kPageVisibility,
-};
-
// Convert draggable regions in raw format to SkRegion format. Caller is
// responsible for deleting the returned SkRegion instance.
scoped_ptr<SkRegion> DraggableRegionsToSkRegion(
if (zoom_factor_ != 1.0)
command_line->AppendSwitchASCII(switches::kZoomFactor,
base::DoubleToString(zoom_factor_));
-
- if (web_preferences_.IsEmpty())
- return;
-
- bool b;
-#if defined(OS_WIN)
- // Check if DirectWrite is disabled.
- if (web_preferences_.Get(switches::kDirectWrite, &b) && !b)
- command_line->AppendSwitch(::switches::kDisableDirectWrite);
-#endif
-
- // Check if plugins are enabled.
- if (web_preferences_.Get("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 (web_preferences_.Get(feature, &b))
- command_line->AppendSwitchASCII(feature, b ? "true" : "false");
- }
}
void NativeWindow::OverrideWebkitPrefs(content::WebPreferences* prefs) {
#include "atom/browser/web_contents_preferences.h"
+#include "atom/common/options_switches.h"
+#include "base/command_line.h"
+
+#if defined(OS_WIN)
+#include "ui/gfx/switches.h"
+#endif
+
namespace atom {
namespace {
+// Pointer as WebContents's user data key.
const char* kWebPreferencesKey = "WebContentsPreferences";
+// Array of available web runtime features.
+const char* kWebRuntimeFeatures[] = {
+ switches::kExperimentalFeatures,
+ switches::kExperimentalCanvasFeatures,
+ switches::kSubpixelFontScaling,
+ switches::kOverlayScrollbars,
+ switches::kOverlayFullscreenVideo,
+ switches::kSharedWorker,
+ switches::kPageVisibility,
+};
+
} // namespace
WebContentsPreferences::WebContentsPreferences(
web_contents->GetUserData(kWebPreferencesKey));
}
+// static
+void WebContentsPreferences::AppendExtraCommandLineSwitches(
+ content::WebContents* web_contents, base::CommandLine* command_line) {
+ WebContentsPreferences* self = From(web_contents);
+ CHECK(self);
+
+ bool b;
+#if defined(OS_WIN)
+ // Check if DirectWrite is disabled.
+ if (self->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)
+ 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))
+ command_line->AppendSwitchASCII(feature, b ? "true" : "false");
+ }
+}
+
} // namespace atom
#include "base/values.h"
#include "content/public/browser/web_contents_user_data.h"
+namespace base {
+class CommandLine;
+}
+
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.
+ static void AppendExtraCommandLineSwitches(
+ content::WebContents* web_contents, base::CommandLine* command_line);
+
WebContentsPreferences(content::WebContents* web_contents,
base::DictionaryValue&& web_preferences);
~WebContentsPreferences() override;