summaryrefslogtreecommitdiffstats
path: root/chrome/browser
diff options
context:
space:
mode:
Diffstat (limited to 'chrome/browser')
-rw-r--r--chrome/browser/extensions/api/app_current_window_internal/app_current_window_internal_api.cc11
-rw-r--r--chrome/browser/extensions/api/app_current_window_internal/app_current_window_internal_api.h11
-rw-r--r--chrome/browser/extensions/api/app_window/app_window_api.cc6
-rw-r--r--chrome/browser/extensions/api/app_window/app_window_apitest.cc5
-rw-r--r--chrome/browser/extensions/extension_function_histogram_value.h1
-rw-r--r--chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h2
-rw-r--r--chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm17
-rw-r--r--chrome/browser/ui/cocoa/browser_window_cocoa.h1
-rw-r--r--chrome/browser/ui/cocoa/browser_window_cocoa.mm5
-rw-r--r--chrome/browser/ui/gtk/apps/native_app_window_gtk.cc16
-rw-r--r--chrome/browser/ui/gtk/apps/native_app_window_gtk.h5
-rw-r--r--chrome/browser/ui/gtk/browser_window_gtk.cc5
-rw-r--r--chrome/browser/ui/gtk/browser_window_gtk.h1
-rw-r--r--chrome/browser/ui/panels/panel.cc8
-rw-r--r--chrome/browser/ui/panels/panel.h4
-rw-r--r--chrome/browser/ui/views/apps/native_app_window_views.cc12
-rw-r--r--chrome/browser/ui/views/apps/native_app_window_views.h1
-rw-r--r--chrome/browser/ui/views/frame/browser_view.cc5
-rw-r--r--chrome/browser/ui/views/frame/browser_view.h1
19 files changed, 106 insertions, 11 deletions
diff --git a/chrome/browser/extensions/api/app_current_window_internal/app_current_window_internal_api.cc b/chrome/browser/extensions/api/app_current_window_internal/app_current_window_internal_api.cc
index f5cdf91..142d0d1 100644
--- a/chrome/browser/extensions/api/app_current_window_internal/app_current_window_internal_api.cc
+++ b/chrome/browser/extensions/api/app_current_window_internal/app_current_window_internal_api.cc
@@ -20,6 +20,8 @@ namespace SetBounds = extensions::api::app_current_window_internal::SetBounds;
namespace SetIcon = extensions::api::app_current_window_internal::SetIcon;
namespace SetInputRegion =
extensions::api::app_current_window_internal::SetInputRegion;
+namespace SetAlwaysOnTop =
+ extensions::api::app_current_window_internal::SetAlwaysOnTop;
using apps::ShellWindow;
using extensions::api::app_current_window_internal::Bounds;
@@ -202,4 +204,13 @@ bool AppCurrentWindowInternalSetInputRegionFunction::RunWithWindow(
return true;
}
+bool AppCurrentWindowInternalSetAlwaysOnTopFunction::RunWithWindow(
+ ShellWindow* window) {
+ scoped_ptr<SetAlwaysOnTop::Params> params(
+ SetAlwaysOnTop::Params::Create(*args_));
+ CHECK(params.get());
+ window->GetBaseWindow()->SetAlwaysOnTop(params->always_on_top);
+ return true;
+}
+
} // namespace extensions
diff --git a/chrome/browser/extensions/api/app_current_window_internal/app_current_window_internal_api.h b/chrome/browser/extensions/api/app_current_window_internal/app_current_window_internal_api.h
index 0bf5c4a..648724f 100644
--- a/chrome/browser/extensions/api/app_current_window_internal/app_current_window_internal_api.h
+++ b/chrome/browser/extensions/api/app_current_window_internal/app_current_window_internal_api.h
@@ -155,6 +155,17 @@ class AppCurrentWindowInternalSetInputRegionFunction
virtual bool RunWithWindow(apps::ShellWindow* window) OVERRIDE;
};
+class AppCurrentWindowInternalSetAlwaysOnTopFunction
+ : public AppCurrentWindowInternalExtensionFunction {
+ public:
+ DECLARE_EXTENSION_FUNCTION("app.currentWindowInternal.setAlwaysOnTop",
+ APP_CURRENTWINDOWINTERNAL_SETALWAYSONTOP)
+
+ protected:
+ virtual ~AppCurrentWindowInternalSetAlwaysOnTopFunction() {}
+ virtual bool RunWithWindow(apps::ShellWindow* window) OVERRIDE;
+};
+
} // namespace extensions
#endif // CHROME_BROWSER_EXTENSIONS_API_APP_CURRENT_WINDOW_INTERNAL_APP_CURRENT_WINDOW_INTERNAL_API_H_
diff --git a/chrome/browser/extensions/api/app_window/app_window_api.cc b/chrome/browser/extensions/api/app_window/app_window_api.cc
index b3bbeb9..34ab489 100644
--- a/chrome/browser/extensions/api/app_window/app_window_api.cc
+++ b/chrome/browser/extensions/api/app_window/app_window_api.cc
@@ -93,6 +93,7 @@ void SetCreateResultFromShellWindow(ShellWindow* window,
result->SetBoolean("fullscreen", window->GetBaseWindow()->IsFullscreen());
result->SetBoolean("minimized", window->GetBaseWindow()->IsMinimized());
result->SetBoolean("maximized", window->GetBaseWindow()->IsMaximized());
+ result->SetBoolean("alwaysOnTop", window->GetBaseWindow()->IsAlwaysOnTop());
base::DictionaryValue* boundsValue = new base::DictionaryValue();
gfx::Rect bounds = window->GetClientBounds();
boundsValue->SetInteger("left", bounds.x());
@@ -246,6 +247,11 @@ bool AppWindowCreateFunction::RunImpl() {
if (options->resizable.get())
create_params.resizable = *options->resizable.get();
+ if (GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV &&
+ options->always_on_top.get()) {
+ create_params.always_on_top = *options->always_on_top.get();
+ }
+
if (options->type != extensions::api::app_window::WINDOW_TYPE_PANEL) {
switch (options->state) {
case extensions::api::app_window::STATE_NONE:
diff --git a/chrome/browser/extensions/api/app_window/app_window_apitest.cc b/chrome/browser/extensions/api/app_window/app_window_apitest.cc
index 23d4945..f71f0c7 100644
--- a/chrome/browser/extensions/api/app_window/app_window_apitest.cc
+++ b/chrome/browser/extensions/api/app_window/app_window_apitest.cc
@@ -137,4 +137,9 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, WindowsApiProperties) {
#endif // defined(TOOLKIT_VIEWS)
+IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, WindowsApiAlwaysOnTop) {
+ EXPECT_TRUE(RunPlatformAppTest("platform_apps/windows_api_always_on_top"))
+ << message_;
+}
+
} // namespace extensions
diff --git a/chrome/browser/extensions/extension_function_histogram_value.h b/chrome/browser/extensions/extension_function_histogram_value.h
index 2b83e7d..ac9e45d 100644
--- a/chrome/browser/extensions/extension_function_histogram_value.h
+++ b/chrome/browser/extensions/extension_function_histogram_value.h
@@ -648,6 +648,7 @@ enum HistogramValue {
CAST_CHANNEL_CLOSE,
RUNTIME_RESTART,
DESKTOPCAPTURE_CANCELCHOOSEDESKTOPMEDIA,
+ APP_CURRENTWINDOWINTERNAL_SETALWAYSONTOP,
ENUM_BOUNDARY // Last entry: Add new entries above.
};
diff --git a/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h b/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h
index 106e398..835c460 100644
--- a/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h
+++ b/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.h
@@ -137,6 +137,8 @@ class NativeAppWindowCocoa : public apps::NativeAppWindow,
virtual void ShowWithApp() OVERRIDE;
virtual void HideWithApp() OVERRIDE;
+ virtual void SetAlwaysOnTop(bool always_on_top) OVERRIDE;
+
// WebContentsModalDialogHost implementation.
virtual gfx::NativeView GetHostView() const OVERRIDE;
virtual gfx::Point GetDialogPosition(const gfx::Size& size) OVERRIDE;
diff --git a/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm b/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm
index 5023194..fd18e0c 100644
--- a/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm
+++ b/chrome/browser/ui/cocoa/apps/native_app_window_cocoa.mm
@@ -265,6 +265,12 @@ void SetFullScreenCollectionBehavior(NSWindow* window, bool allow_fullscreen) {
- (void)setMouseDownCanMoveWindow:(BOOL)can_move;
@end
+namespace {
+
+const NSInteger kAlwaysOnTopWindowLevel = NSFloatingWindowLevel;
+
+} // namespace
+
NativeAppWindowCocoa::NativeAppWindowCocoa(
ShellWindow* shell_window,
const ShellWindow::CreateParams& params)
@@ -334,6 +340,9 @@ NativeAppWindowCocoa::NativeAppWindowCocoa(
[window respondsToSelector:@selector(setBottomCornerRounded:)])
[window setBottomCornerRounded:NO];
+ if (params.always_on_top)
+ [window setLevel:kAlwaysOnTopWindowLevel];
+
// Set the window to participate in Lion Fullscreen mode. Setting this flag
// has no effect on Snow Leopard or earlier. UI controls for fullscreen are
// only shown for apps that have unbounded size.
@@ -810,7 +819,7 @@ void NativeAppWindowCocoa::FlashFrame(bool flash) {
}
bool NativeAppWindowCocoa::IsAlwaysOnTop() const {
- return false;
+ return [window() level] == kAlwaysOnTopWindowLevel;
}
void NativeAppWindowCocoa::RenderViewHostChanged(
@@ -986,6 +995,12 @@ void NativeAppWindowCocoa::ShowWithApp() {
shell_window_->OnNativeWindowChanged();
}
+void NativeAppWindowCocoa::SetAlwaysOnTop(bool always_on_top) {
+ [window() setLevel:(always_on_top ? kAlwaysOnTopWindowLevel :
+ NSNormalWindowLevel)];
+ shell_window_->OnNativeWindowChanged();
+}
+
void NativeAppWindowCocoa::HideWithoutMarkingHidden() {
[window() orderOut:window_controller_];
}
diff --git a/chrome/browser/ui/cocoa/browser_window_cocoa.h b/chrome/browser/ui/cocoa/browser_window_cocoa.h
index efd9e94..e57eb8c 100644
--- a/chrome/browser/ui/cocoa/browser_window_cocoa.h
+++ b/chrome/browser/ui/cocoa/browser_window_cocoa.h
@@ -49,6 +49,7 @@ class BrowserWindowCocoa :
virtual bool IsActive() const OVERRIDE;
virtual void FlashFrame(bool flash) OVERRIDE;
virtual bool IsAlwaysOnTop() const OVERRIDE;
+ virtual void SetAlwaysOnTop(bool always_on_top) OVERRIDE;
virtual gfx::NativeWindow GetNativeWindow() OVERRIDE;
virtual BrowserWindowTesting* GetBrowserWindowTesting() OVERRIDE;
virtual StatusBubble* GetStatusBubble() OVERRIDE;
diff --git a/chrome/browser/ui/cocoa/browser_window_cocoa.mm b/chrome/browser/ui/cocoa/browser_window_cocoa.mm
index a26e674..a0f8056 100644
--- a/chrome/browser/ui/cocoa/browser_window_cocoa.mm
+++ b/chrome/browser/ui/cocoa/browser_window_cocoa.mm
@@ -259,6 +259,11 @@ bool BrowserWindowCocoa::IsAlwaysOnTop() const {
return false;
}
+void BrowserWindowCocoa::SetAlwaysOnTop(bool always_on_top) {
+ // Not implemented for browser windows.
+ NOTIMPLEMENTED();
+}
+
bool BrowserWindowCocoa::IsActive() const {
return [window() isKeyWindow];
}
diff --git a/chrome/browser/ui/gtk/apps/native_app_window_gtk.cc b/chrome/browser/ui/gtk/apps/native_app_window_gtk.cc
index d86e490..9560d66 100644
--- a/chrome/browser/ui/gtk/apps/native_app_window_gtk.cc
+++ b/chrome/browser/ui/gtk/apps/native_app_window_gtk.cc
@@ -48,6 +48,7 @@ NativeAppWindowGtk::NativeAppWindowGtk(ShellWindow* shell_window,
is_active_(false),
content_thinks_its_fullscreen_(false),
frameless_(params.frame == ShellWindow::FRAME_NONE),
+ always_on_top_(params.always_on_top),
frame_cursor_(NULL),
atom_cache_(base::MessagePumpGtk::GetDefaultXDisplay(), kAtomsToCache),
is_x_event_listened_(false) {
@@ -91,6 +92,9 @@ NativeAppWindowGtk::NativeAppWindowGtk(ShellWindow* shell_window,
if (frameless_)
gtk_window_set_decorated(window_, false);
+ if (always_on_top_)
+ gtk_window_set_keep_above(window_, TRUE);
+
int min_width = params.minimum_size.width();
int min_height = params.minimum_size.height();
int max_width = params.maximum_size.width();
@@ -339,7 +343,7 @@ void NativeAppWindowGtk::FlashFrame(bool flash) {
}
bool NativeAppWindowGtk::IsAlwaysOnTop() const {
- return false;
+ return always_on_top_;
}
void NativeAppWindowGtk::RenderViewHostChanged(
@@ -381,6 +385,16 @@ bool NativeAppWindowGtk::IsVisible() const {
void NativeAppWindowGtk::HideWithApp() {}
void NativeAppWindowGtk::ShowWithApp() {}
+void NativeAppWindowGtk::SetAlwaysOnTop(bool always_on_top) {
+ if (always_on_top_ != always_on_top) {
+ // gdk_window_get_state() does not give us the correct value for the
+ // GDK_WINDOW_STATE_ABOVE bit. Cache the current state.
+ always_on_top_ = always_on_top;
+ gtk_window_set_keep_above(window_, always_on_top_ ? TRUE : FALSE);
+ shell_window_->OnNativeWindowChanged();
+ }
+}
+
gfx::NativeView NativeAppWindowGtk::GetHostView() const {
NOTIMPLEMENTED();
return NULL;
diff --git a/chrome/browser/ui/gtk/apps/native_app_window_gtk.h b/chrome/browser/ui/gtk/apps/native_app_window_gtk.h
index 6cb9c9b..302da4e 100644
--- a/chrome/browser/ui/gtk/apps/native_app_window_gtk.h
+++ b/chrome/browser/ui/gtk/apps/native_app_window_gtk.h
@@ -80,6 +80,7 @@ class NativeAppWindowGtk : public apps::NativeAppWindow,
virtual bool IsVisible() const OVERRIDE;
virtual void HideWithApp() OVERRIDE;
virtual void ShowWithApp() OVERRIDE;
+ virtual void SetAlwaysOnTop(bool always_on_top) OVERRIDE;
// web_modal::WebContentsModalDialogHost implementation.
virtual gfx::NativeView GetHostView() const OVERRIDE;
@@ -154,6 +155,10 @@ class NativeAppWindowGtk : public apps::NativeAppWindow,
// True if the window should be resizable by the user.
bool resizable_;
+ // True if the window should be kept on top of other windows that do not have
+ // this flag enabled.
+ bool always_on_top_;
+
// The current window cursor. We set it to a resize cursor when over the
// custom frame border. We set it to NULL if we want the default cursor.
GdkCursor* frame_cursor_;
diff --git a/chrome/browser/ui/gtk/browser_window_gtk.cc b/chrome/browser/ui/gtk/browser_window_gtk.cc
index 60460ef..4494749 100644
--- a/chrome/browser/ui/gtk/browser_window_gtk.cc
+++ b/chrome/browser/ui/gtk/browser_window_gtk.cc
@@ -719,6 +719,11 @@ bool BrowserWindowGtk::IsAlwaysOnTop() const {
return false;
}
+void BrowserWindowGtk::SetAlwaysOnTop(bool always_on_top) {
+ // Not implemented for browser windows.
+ NOTIMPLEMENTED();
+}
+
gfx::NativeWindow BrowserWindowGtk::GetNativeWindow() {
return window_;
}
diff --git a/chrome/browser/ui/gtk/browser_window_gtk.h b/chrome/browser/ui/gtk/browser_window_gtk.h
index fc7e690..aa4dbbc 100644
--- a/chrome/browser/ui/gtk/browser_window_gtk.h
+++ b/chrome/browser/ui/gtk/browser_window_gtk.h
@@ -84,6 +84,7 @@ class BrowserWindowGtk
virtual bool IsActive() const OVERRIDE;
virtual void FlashFrame(bool flash) OVERRIDE;
virtual bool IsAlwaysOnTop() const OVERRIDE;
+ virtual void SetAlwaysOnTop(bool always_on_top) OVERRIDE;
virtual gfx::NativeWindow GetNativeWindow() OVERRIDE;
virtual BrowserWindowTesting* GetBrowserWindowTesting() OVERRIDE;
virtual StatusBubble* GetStatusBubble() OVERRIDE;
diff --git a/chrome/browser/ui/panels/panel.cc b/chrome/browser/ui/panels/panel.cc
index 2b21bc7..bef02b1 100644
--- a/chrome/browser/ui/panels/panel.cc
+++ b/chrome/browser/ui/panels/panel.cc
@@ -350,6 +350,10 @@ bool Panel::IsAlwaysOnTop() const {
return native_panel_->IsPanelAlwaysOnTop();
}
+void Panel::SetAlwaysOnTop(bool on_top) {
+ native_panel_->SetPanelAlwaysOnTop(on_top);
+}
+
void Panel::ExecuteCommandWithDisposition(int id,
WindowOpenDisposition disposition) {
DCHECK(command_updater_.IsCommandEnabled(id)) << "Invalid/disabled command "
@@ -658,10 +662,6 @@ void Panel::HandleKeyboardEvent(const content::NativeWebKeyboardEvent& event) {
native_panel_->HandlePanelKeyboardEvent(event);
}
-void Panel::SetAlwaysOnTop(bool on_top) {
- native_panel_->SetPanelAlwaysOnTop(on_top);
-}
-
void Panel::SetPreviewMode(bool in_preview) {
DCHECK_NE(in_preview_mode_, in_preview);
in_preview_mode_ = in_preview;
diff --git a/chrome/browser/ui/panels/panel.h b/chrome/browser/ui/panels/panel.h
index 8ce650b..3e5bde5 100644
--- a/chrome/browser/ui/panels/panel.h
+++ b/chrome/browser/ui/panels/panel.h
@@ -133,6 +133,7 @@ class Panel : public ui::BaseWindow,
virtual void SetBounds(const gfx::Rect& bounds) OVERRIDE;
virtual void FlashFrame(bool flash) OVERRIDE;
virtual bool IsAlwaysOnTop() const OVERRIDE;
+ virtual void SetAlwaysOnTop(bool on_top) OVERRIDE;
// Overridden from CommandUpdaterDelegate:
virtual void ExecuteCommandWithDisposition(
@@ -245,9 +246,6 @@ class Panel : public ui::BaseWindow,
// Handles keyboard events coming back from the renderer.
void HandleKeyboardEvent(const content::NativeWebKeyboardEvent& event);
- // Whether the panel window is always on top.
- void SetAlwaysOnTop(bool on_top);
-
// Sets whether the panel is shown in preview mode. When the panel is
// being dragged, it is in preview mode.
void SetPreviewMode(bool in_preview_mode);
diff --git a/chrome/browser/ui/views/apps/native_app_window_views.cc b/chrome/browser/ui/views/apps/native_app_window_views.cc
index 5c18710..e321c775 100644
--- a/chrome/browser/ui/views/apps/native_app_window_views.cc
+++ b/chrome/browser/ui/views/apps/native_app_window_views.cc
@@ -169,6 +169,7 @@ void NativeAppWindowViews::InitializeDefaultWindow(
// TODO(erg): Conceptually, these are toplevel windows, but we theoretically
// could plumb context through to here in some cases.
init_params.top_level = true;
+ init_params.keep_on_top = create_params.always_on_top;
gfx::Rect window_bounds = create_params.bounds;
bool position_specified =
window_bounds.x() != INT_MIN && window_bounds.y() != INT_MIN;
@@ -410,14 +411,16 @@ void NativeAppWindowViews::FlashFrame(bool flash) {
}
bool NativeAppWindowViews::IsAlwaysOnTop() const {
- if (!shell_window_->window_type_is_panel())
- return false;
+ if (shell_window_->window_type_is_panel()) {
#if defined(USE_ASH)
return ash::wm::GetWindowState(window_->GetNativeWindow())->
panel_attached();
#else
return true;
#endif
+ } else {
+ return window_->IsAlwaysOnTop();
+ }
}
gfx::Insets NativeAppWindowViews::GetFrameInsets() const {
@@ -443,6 +446,11 @@ bool NativeAppWindowViews::IsVisible() const {
void NativeAppWindowViews::HideWithApp() {}
void NativeAppWindowViews::ShowWithApp() {}
+void NativeAppWindowViews::SetAlwaysOnTop(bool always_on_top) {
+ window_->SetAlwaysOnTop(always_on_top);
+ shell_window_->OnNativeWindowChanged();
+}
+
gfx::NativeView NativeAppWindowViews::GetHostView() const {
return window_->GetNativeView();
}
diff --git a/chrome/browser/ui/views/apps/native_app_window_views.h b/chrome/browser/ui/views/apps/native_app_window_views.h
index 704d028..833393c 100644
--- a/chrome/browser/ui/views/apps/native_app_window_views.h
+++ b/chrome/browser/ui/views/apps/native_app_window_views.h
@@ -147,6 +147,7 @@ class NativeAppWindowViews : public apps::NativeAppWindow,
virtual bool IsVisible() const OVERRIDE;
virtual void HideWithApp() OVERRIDE;
virtual void ShowWithApp() OVERRIDE;
+ virtual void SetAlwaysOnTop(bool always_on_top) OVERRIDE;
// web_modal::WebContentsModalDialogHost implementation.
virtual gfx::NativeView GetHostView() const OVERRIDE;
diff --git a/chrome/browser/ui/views/frame/browser_view.cc b/chrome/browser/ui/views/frame/browser_view.cc
index 851c741..429c7e8 100644
--- a/chrome/browser/ui/views/frame/browser_view.cc
+++ b/chrome/browser/ui/views/frame/browser_view.cc
@@ -700,6 +700,11 @@ bool BrowserView::IsAlwaysOnTop() const {
return false;
}
+void BrowserView::SetAlwaysOnTop(bool always_on_top) {
+ // Not implemented for browser windows.
+ NOTIMPLEMENTED();
+}
+
gfx::NativeWindow BrowserView::GetNativeWindow() {
// While the browser destruction is going on, the widget can already be gone,
// but utility functions like FindBrowserWithWindow will come here and crash.
diff --git a/chrome/browser/ui/views/frame/browser_view.h b/chrome/browser/ui/views/frame/browser_view.h
index a7a3421..9edd602 100644
--- a/chrome/browser/ui/views/frame/browser_view.h
+++ b/chrome/browser/ui/views/frame/browser_view.h
@@ -263,6 +263,7 @@ class BrowserView : public BrowserWindow,
virtual bool IsActive() const OVERRIDE;
virtual void FlashFrame(bool flash) OVERRIDE;
virtual bool IsAlwaysOnTop() const OVERRIDE;
+ virtual void SetAlwaysOnTop(bool always_on_top) OVERRIDE;
virtual gfx::NativeWindow GetNativeWindow() OVERRIDE;
virtual BrowserWindowTesting* GetBrowserWindowTesting() OVERRIDE;
virtual StatusBubble* GetStatusBubble() OVERRIDE;