]> khamidou — GitHub mirrors - electron.git/commitdiff
renderer: option to override page visiblity state
authordeepak1556 <hop2deep@gmail.com>
Mon, 1 Jun 2015 07:28:20 +0000 (12:58 +0530)
committerdeepak1556 <hop2deep@gmail.com>
Thu, 4 Jun 2015 09:10:13 +0000 (14:40 +0530)
atom/browser/native_window.cc
atom/common/options_switches.cc
atom/common/options_switches.h
atom/renderer/atom_renderer_client.cc
atom/renderer/atom_renderer_client.h
docs/api/browser-window.md

index 3698d8b94594c7d5bb29400c4f2b601d86fdee76..c2326debc99ba2dbcc917195210380acc98dec18 100644 (file)
@@ -78,6 +78,7 @@ const char* kWebRuntimeFeatures[] = {
   switches::kOverlayScrollbars,
   switches::kOverlayFullscreenVideo,
   switches::kSharedWorker,
+  switches::kPageVisibility,
 };
 
 std::string RemoveWhitespace(const std::string& str) {
index 7f642ecbbabdd896baaffc2d5650a647a0199105..c9997996fed8ccc6373bb0a291894848479af6da 100644 (file)
@@ -95,6 +95,9 @@ const char kOverlayScrollbars[]          = "overlay-scrollbars";
 const char kOverlayFullscreenVideo[]     = "overlay-fullscreen-video";
 const char kSharedWorker[]               = "shared-worker";
 
+// Set page visiblity to always visible.
+const char kPageVisibility[] = "page-visibility";
+
 // Disable HTTP cache.
 const char kDisableHttpCache[] = "disable-http-cache";
 
index aaaa86addb1574432224b7cb09f4430e2d8c76ce..071459afac73d6cda013de74bbb023e595ff5e55 100644 (file)
@@ -52,6 +52,7 @@ extern const char kSubpixelFontScaling[];
 extern const char kOverlayScrollbars[];
 extern const char kOverlayFullscreenVideo[];
 extern const char kSharedWorker[];
+extern const char kPageVisibility[];
 
 extern const char kDisableHttpCache[];
 
index 1dc4e45b03d7d123fbaa6240ecff25930005de4d..e2a114af01411f5869c9ff0724a00253768c8065 100644 (file)
@@ -191,6 +191,21 @@ content::BrowserPluginDelegate* AtomRendererClient::CreateBrowserPluginDelegate(
   }
 }
 
+bool AtomRendererClient::ShouldOverridePageVisibilityState(
+    const content::RenderFrame* render_frame,
+    blink::WebPageVisibilityState* override_state) {
+  base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
+  bool b;
+
+  if (IsSwitchEnabled(command_line, switches::kPageVisibility, &b)
+      && b) {
+    *override_state = blink::WebPageVisibilityStateVisible;
+    return true;
+  }
+
+  return false;
+}
+
 void AtomRendererClient::EnableWebRuntimeFeatures() {
   base::CommandLine* command_line = base::CommandLine::ForCurrentProcess();
   bool b;
index af264d59792d8c78368894aa059bb174eb4fe401..68201f3cd435733425655367973f2232dd7d32ff 100644 (file)
@@ -55,6 +55,9 @@ class AtomRendererClient : public content::ContentRendererClient,
       content::RenderFrame* render_frame,
       const std::string& mime_type,
       const GURL& original_url) override;
+  bool ShouldOverridePageVisibilityState(
+      const content::RenderFrame* render_frame,
+      blink::WebPageVisibilityState* override_state) override;
 
   void EnableWebRuntimeFeatures();
 
index 30055dccb0afddb1fdd499d3728f7d3d2ee3ce87..c97bec0ebbb15b1a6a6a32758a03aeb398f1862d 100644 (file)
@@ -97,6 +97,8 @@ You can also create a window without chrome by using
     * `shared-worker` Boolean
     * `direct-write` Boolean - Whether the DirectWrite font rendering system on
        Windows is enabled
+    * `page-visibility` Boolean - Sets the page visibility state
+       to visible, prevents throttling of DOM timers.
 
 Creates a new `BrowserWindow` with native properties set by the `options`.
 Usually you only need to set the `width` and `height`, other properties will