summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions
diff options
context:
space:
mode:
authortmdiep@chromium.org <tmdiep@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-11 11:27:22 +0000
committertmdiep@chromium.org <tmdiep@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-10-11 11:27:22 +0000
commit46d46055fa8fb752bcab72ed1476e81924f5a74d (patch)
treeba758f30c65170ebc42f220b5f5810addcd03c26 /chrome/browser/extensions
parent8321c5fa5df8d43f01937c2d7f00dafe1486b510 (diff)
downloadchromium_src-46d46055fa8fb752bcab72ed1476e81924f5a74d.zip
chromium_src-46d46055fa8fb752bcab72ed1476e81924f5a74d.tar.gz
chromium_src-46d46055fa8fb752bcab72ed1476e81924f5a74d.tar.bz2
Add always-on-top property to app windows
The chrome.app.window API has been extended to include: - A new alwaysOnTop option for the create() function. - An AppWindow.isAlwaysOnTop() function to query the state of this property. - An AppWindow.setAlwaysOnTop() function to change this property after creation of the window. Changes involving native app windows: - Added apps::NativeAppWindow::SetAlwaysOnTop(). - Implemented IsAlwaysOnTop(), a function inherited from ui::BaseWindow but was left unimplemented for native app windows. Changes involving views: - Added IsAlwaysOnTop(). SetAlwaysOnTop() already existed. BUG=171597 TEST=browser_tests (PlatformAppBrowserTest.WindowsApiAlwaysOnTop). Test manually by creating an app that enables the alwaysOnTop option on window creation and changes the property after creation. Test Windows, Mac, ChromeOS and Linux. Review URL: https://codereview.chromium.org/26427002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@228160 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions')
-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
5 files changed, 34 insertions, 0 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.
};