summaryrefslogtreecommitdiffstats
path: root/chrome/browser/extensions/api
diff options
context:
space:
mode:
authortmdiep@chromium.org <tmdiep@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-06 12:58:32 +0000
committertmdiep@chromium.org <tmdiep@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2013-12-06 12:58:32 +0000
commitc89ab53ea88770cbbab3ec81a301089ac54276b8 (patch)
tree7f8dedba51edf94eaef4bf5a469f5665465f13f9 /chrome/browser/extensions/api
parentaee861165564fe84986e5fb895b82e93c19fa8c9 (diff)
downloadchromium_src-c89ab53ea88770cbbab3ec81a301089ac54276b8.zip
chromium_src-c89ab53ea88770cbbab3ec81a301089ac54276b8.tar.gz
chromium_src-c89ab53ea88770cbbab3ec81a301089ac54276b8.tar.bz2
Reinstate alwaysOnTopWindows permission
Reinstate the "alwaysOnTopWindows" permission. This feature is available only in the Dev channel, but is whitelisted for two first-party apps in Stable. Apps that wish to enable the alwaysOnTop property for app windows must now declare the "alwaysOnTopWindows" permission in their manifest. This permission does not generate a warning in install prompts. BUG=326361 TESTS=browser_tests (PlatformAppBrowserTest.WindowsApiAlwaysOnTop*) Manual test: Create an app which does not specify this permission and attempts to create a new window with the option enabled or calls setAlwaysOnTop(true) on an existing window. The window should not be always on top. The option should work for apps which do declare the permission. Review URL: https://codereview.chromium.org/61073004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@239180 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/extensions/api')
-rw-r--r--chrome/browser/extensions/api/app_current_window_internal/app_current_window_internal_api.cc9
-rw-r--r--chrome/browser/extensions/api/app_window/app_window_api.cc19
-rw-r--r--chrome/browser/extensions/api/app_window/app_window_api.h2
-rw-r--r--chrome/browser/extensions/api/app_window/app_window_apitest.cc22
4 files changed, 22 insertions, 30 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 4259d60c..a3db7bd 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
@@ -8,7 +8,6 @@
#include "apps/shell_window_registry.h"
#include "apps/ui/native_app_window.h"
#include "base/command_line.h"
-#include "chrome/browser/extensions/api/app_window/app_window_api.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/common/extensions/api/app_current_window_internal.h"
#include "chrome/common/extensions/api/app_window.h"
@@ -48,6 +47,9 @@ const char kDevChannelOnly[] =
const char kRequiresFramelessWindow[] =
"This function requires a frameless window (frame:none).";
+const char kAlwaysOnTopPermission[] =
+ "The \"alwaysOnTopWindows\" permission is required.";
+
const int kUnboundedSize = apps::ShellWindow::SizeConstraints::kUnboundedSize;
} // namespace
@@ -288,8 +290,9 @@ bool AppCurrentWindowInternalSetShapeFunction::RunWithWindow(
bool AppCurrentWindowInternalSetAlwaysOnTopFunction::RunWithWindow(
ShellWindow* window) {
- if (!AppWindowCreateFunction::AllowAlwaysOnTopWindows(GetExtension()->id())) {
- error_ = kDevChannelOnly;
+ if (!GetExtension()->HasAPIPermission(
+ extensions::APIPermission::kAlwaysOnTopWindows)) {
+ error_ = kAlwaysOnTopPermission;
return false;
}
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 59d3457..4cac570 100644
--- a/chrome/browser/extensions/api/app_window/app_window_api.cc
+++ b/chrome/browser/extensions/api/app_window/app_window_api.cc
@@ -18,7 +18,6 @@
#include "chrome/browser/ui/apps/chrome_shell_window_delegate.h"
#include "chrome/common/extensions/api/app_window.h"
#include "chrome/common/extensions/features/feature_channel.h"
-#include "chrome/common/extensions/features/simple_feature.h"
#include "content/public/browser/notification_registrar.h"
#include "content/public/browser/notification_types.h"
#include "content/public/browser/render_process_host.h"
@@ -121,22 +120,6 @@ void SetCreateResultFromShellWindow(ShellWindow* window,
} // namespace
-// static
-bool AppWindowCreateFunction::AllowAlwaysOnTopWindows(
- const std::string& extension_id) {
- if (GetCurrentChannel() <= chrome::VersionInfo::CHANNEL_DEV)
- return true;
-
- const char* kWhitelist[] = {
- "0F42756099D914A026DADFA182871C015735DD95",
- "2D22CDB6583FD0A13758AEBE8B15E45208B4E9A7"
- };
- return SimpleFeature::IsIdInWhitelist(
- extension_id,
- std::set<std::string>(kWhitelist,
- kWhitelist + arraysize(kWhitelist)));
-}
-
void AppWindowCreateFunction::SendDelayedResponse() {
SendResponse(true);
}
@@ -287,7 +270,7 @@ bool AppWindowCreateFunction::RunImpl() {
create_params.resizable = *options->resizable.get();
if (options->always_on_top.get() &&
- AllowAlwaysOnTopWindows(GetExtension()->id()))
+ GetExtension()->HasAPIPermission(APIPermission::kAlwaysOnTopWindows))
create_params.always_on_top = *options->always_on_top.get();
if (options->type != extensions::api::app_window::WINDOW_TYPE_PANEL) {
diff --git a/chrome/browser/extensions/api/app_window/app_window_api.h b/chrome/browser/extensions/api/app_window/app_window_api.h
index 7f17b05..8aaac544 100644
--- a/chrome/browser/extensions/api/app_window/app_window_api.h
+++ b/chrome/browser/extensions/api/app_window/app_window_api.h
@@ -13,8 +13,6 @@ class AppWindowCreateFunction : public ChromeAsyncExtensionFunction {
public:
DECLARE_EXTENSION_FUNCTION("app.window.create", APP_WINDOW_CREATE)
- static bool AllowAlwaysOnTopWindows(const std::string& extension_id);
-
void SendDelayedResponse();
protected:
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 1f7737c..b1d0185 100644
--- a/chrome/browser/extensions/api/app_window/app_window_apitest.cc
+++ b/chrome/browser/extensions/api/app_window/app_window_apitest.cc
@@ -138,16 +138,24 @@ IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, WindowsApiProperties) {
#endif // defined(TOOLKIT_VIEWS)
-IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, WindowsApiAlwaysOnTopDev) {
- EXPECT_TRUE(RunPlatformAppTest("platform_apps/windows_api_always_on_top"))
- << message_;
+IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest,
+ WindowsApiAlwaysOnTopWithPermissions) {
+ EXPECT_TRUE(RunPlatformAppTest(
+ "platform_apps/windows_api_always_on_top/has_permissions")) << message_;
}
-IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, WindowsApiAlwaysOnTopStable) {
+IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest,
+ WindowsApiAlwaysOnTopWithPermissionsStable) {
ScopedCurrentChannel channel(chrome::VersionInfo::CHANNEL_STABLE);
- EXPECT_TRUE(
- RunPlatformAppTest("platform_apps/windows_api_always_on_top_stable"))
- << message_;
+ EXPECT_TRUE(RunPlatformAppTestWithFlags(
+ "platform_apps/windows_api_always_on_top/has_permissions_stable",
+ ExtensionApiTest::kFlagIgnoreManifestWarnings)) << message_;
+}
+
+IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest,
+ WindowsApiAlwaysOnTopNoPermissions) {
+ EXPECT_TRUE(RunPlatformAppTest(
+ "platform_apps/windows_api_always_on_top/no_permissions")) << message_;
}
IN_PROC_BROWSER_TEST_F(PlatformAppBrowserTest, WindowsApiGet) {