diff --git a/src/api/window/window.cc b/src/api/window/window.cc index 9765f51905..cb6f3d9fd1 100644 --- a/src/api/window/window.cc +++ b/src/api/window/window.cc @@ -255,6 +255,10 @@ void Window::Call(const std::string& method, bool show; if (arguments.GetBoolean(0, &show)) shell_->window()->SetShowInTaskbar(show); + } else if (method == "SetVisibleOnAllWorkspaces") { + bool all_workspaces; + if (arguments.GetBoolean(0, &all_workspaces)) + shell_->window()->SetVisibleOnAllWorkspaces(all_workspaces); } else if (method == "MoveTo") { int x, y; if (arguments.GetInteger(0, &x) && diff --git a/src/api/window_bindings.js b/src/api/window_bindings.js index ae11ec9ad9..49ec508675 100644 --- a/src/api/window_bindings.js +++ b/src/api/window_bindings.js @@ -412,6 +412,10 @@ Window.prototype.setShowInTaskbar = function(flag) { CallObjectMethod(this, 'SetShowInTaskbar', [ flag ]); } +Window.prototype.setVisibleOnAllWorkspaces = function(flag) { + CallObjectMethod(this, 'SetVisibleOnAllWorkspaces', [ Boolean(flag) ]); +} + Window.prototype.requestAttention = function(flash) { if (typeof flash == 'boolean') { // boolean true is redirected as -1 value diff --git a/src/browser/native_window.cc b/src/browser/native_window.cc index 6de6268641..f0b430e30b 100644 --- a/src/browser/native_window.cc +++ b/src/browser/native_window.cc @@ -130,6 +130,11 @@ void NativeWindow::InitFromManifest(base::DictionaryValue* manifest) { !showInTaskbar) { SetShowInTaskbar(false); } + bool all_workspaces; + if (manifest->GetBoolean(switches::kmVisibleOnAllWorkspaces, &all_workspaces) + && all_workspaces) { + SetVisibleOnAllWorkspaces(true); + } bool fullscreen; if (manifest->GetBoolean(switches::kmFullscreen, &fullscreen) && fullscreen) { SetFullscreen(true); diff --git a/src/browser/native_window.h b/src/browser/native_window.h index da72f275a1..1e904fea8b 100644 --- a/src/browser/native_window.h +++ b/src/browser/native_window.h @@ -96,6 +96,7 @@ class NativeWindow { virtual void SetResizable(bool resizable) = 0; virtual void SetAlwaysOnTop(bool top) = 0; virtual void SetShowInTaskbar(bool show = true) = 0; + virtual void SetVisibleOnAllWorkspaces(bool all_workspaces) = 0; virtual void SetPosition(const std::string& position) = 0; virtual void SetPosition(const gfx::Point& position) = 0; virtual gfx::Point GetPosition() = 0; diff --git a/src/browser/native_window_aura.cc b/src/browser/native_window_aura.cc index b8da0ebe72..776eb55f0b 100644 --- a/src/browser/native_window_aura.cc +++ b/src/browser/native_window_aura.cc @@ -565,6 +565,10 @@ void NativeWindowAura::SetAlwaysOnTop(bool top) { window_->SetAlwaysOnTop(top); } +void NativeWindowAura::SetVisibleOnAllWorkspaces(bool all_workspaces) { + window_->SetVisibleOnAllWorkspaces(all_workspaces); +} + void NativeWindowAura::OnWidgetActivationChanged(views::Widget* widget, bool active) { if (active) { if (shell()) diff --git a/src/browser/native_window_aura.h b/src/browser/native_window_aura.h index 861e540356..a4b575cf57 100644 --- a/src/browser/native_window_aura.h +++ b/src/browser/native_window_aura.h @@ -86,6 +86,7 @@ class NativeWindowAura : public NativeWindow, virtual void SetResizable(bool resizable) OVERRIDE; virtual void SetAlwaysOnTop(bool top) OVERRIDE; virtual void SetShowInTaskbar(bool show = true) OVERRIDE; + virtual void SetVisibleOnAllWorkspaces(bool all_workspaces) OVERRIDE; virtual void SetPosition(const std::string& position) OVERRIDE; virtual void SetPosition(const gfx::Point& position) OVERRIDE; virtual gfx::Point GetPosition() OVERRIDE; diff --git a/src/browser/native_window_mac.h b/src/browser/native_window_mac.h index 7283c1a97c..01b7b3713a 100644 --- a/src/browser/native_window_mac.h +++ b/src/browser/native_window_mac.h @@ -60,6 +60,7 @@ class NativeWindowCocoa : public NativeWindow { virtual void SetResizable(bool resizable) OVERRIDE; virtual void SetAlwaysOnTop(bool top) OVERRIDE; virtual void SetShowInTaskbar(bool show = true) OVERRIDE; + virtual void SetVisibleOnAllWorkspaces(bool all_workspaces) OVERRIDE; virtual void SetPosition(const std::string& position) OVERRIDE; virtual void SetPosition(const gfx::Point& position) OVERRIDE; virtual gfx::Point GetPosition() OVERRIDE; diff --git a/src/browser/native_window_mac.mm b/src/browser/native_window_mac.mm index e7572fd0bb..5d5f1fd94b 100644 --- a/src/browser/native_window_mac.mm +++ b/src/browser/native_window_mac.mm @@ -665,6 +665,16 @@ - (void)drawRect:(NSRect)dirtyRect { [window() setLevel:(top ? NSFloatingWindowLevel : NSNormalWindowLevel)]; } +void NativeWindowCocoa::SetVisibleOnAllWorkspaces(bool all_workspaces) { + NSUInteger collectionBehavior = [window() collectionBehavior]; + if (all_workspaces) { + collectionBehavior |= NSWindowCollectionBehaviorCanJoinAllSpaces; + } else { + collectionBehavior &= ~NSWindowCollectionBehaviorCanJoinAllSpaces; + } + [window() setCollectionBehavior:collectionBehavior]; +} + void NativeWindowCocoa::SetShowInTaskbar(bool show) { ProcessSerialNumber psn = { 0, kCurrentProcess }; if (!show) { diff --git a/src/common/shell_switches.cc b/src/common/shell_switches.cc index 6a8aff14ca..9ffbdef8e8 100644 --- a/src/common/shell_switches.cc +++ b/src/common/shell_switches.cc @@ -85,6 +85,9 @@ const char kmKiosk[] = "kiosk"; // Make windows stays on the top of all other windows. const char kmAlwaysOnTop[] = "always-on-top"; +// Make window visible on all workspaces. +const char kmVisibleOnAllWorkspaces[] = "visible-on-all-workspaces"; + // Whether we should support WebGL. const char kmWebgl[] = "webgl"; diff --git a/src/common/shell_switches.h b/src/common/shell_switches.h index 203fb328cc..4e0b532cbc 100644 --- a/src/common/shell_switches.h +++ b/src/common/shell_switches.h @@ -53,6 +53,7 @@ extern const char kmFullscreen[]; extern const char kmShowInTaskbar[]; extern const char kmKiosk[]; extern const char kmAlwaysOnTop[]; +extern const char kmVisibleOnAllWorkspaces[]; extern const char kmInitialFocus[]; extern const char kmTransparent[]; extern const char kmDisableTransparency[]; diff --git a/tests/manual_tests/always_on_visible_workspace/index.html b/tests/manual_tests/always_on_visible_workspace/index.html new file mode 100644 index 0000000000..e80e587d6b --- /dev/null +++ b/tests/manual_tests/always_on_visible_workspace/index.html @@ -0,0 +1,66 @@ + +
+This window is visible on all workspaces
+Makes the window visible on all workspaces simultaneously.
+Makes the window visible only on this workspace.
+This window is visible on all workspaces
+Makes the window visible on all workspaces simultaneously.
+Makes the window visible only on this workspace.
+