Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(6)

Unified Diff: extensions/browser/api/app_current_window_internal/app_current_window_internal_api.cc

Issue 297123002: API proposal for chrome.app.window to intercept all keys. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Use WidgetObserver instead of plumbing SetKeyboardIntercept through view::Widget Created 6 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: extensions/browser/api/app_current_window_internal/app_current_window_internal_api.cc
diff --git a/extensions/browser/api/app_current_window_internal/app_current_window_internal_api.cc b/extensions/browser/api/app_current_window_internal/app_current_window_internal_api.cc
index 29cf618a1f77fc114cc4145e36674b4a86fe1ef6..3e3de5d058eb644eba3db535f28146ded7e7c737 100644
--- a/extensions/browser/api/app_current_window_internal/app_current_window_internal_api.cc
+++ b/extensions/browser/api/app_current_window_internal/app_current_window_internal_api.cc
@@ -28,7 +28,8 @@ namespace SetShape = app_current_window_internal::SetShape;
namespace SetAlwaysOnTop = app_current_window_internal::SetAlwaysOnTop;
namespace SetVisibleOnAllWorkspaces =
app_current_window_internal::SetVisibleOnAllWorkspaces;
-
+namespace SetInterceptAllKeys =
+ app_current_window_internal::SetInterceptAllKeys;
using app_current_window_internal::Bounds;
using app_current_window_internal::Region;
using app_current_window_internal::RegionRect;
@@ -51,6 +52,11 @@ const char kRequiresFramelessWindow[] =
const char kAlwaysOnTopPermission[] =
"The \"app.window.alwaysOnTop\" permission is required.";
+const char kInterceptAllKeysPermission[] = "app.window.interceptAllKeys";
+
+const char kInterceptAllKeysPermissionError[] =
+ "The \"app.window.interceptAllKeys\" permission is required.";
+
const char kInvalidParameters[] = "Invalid parameters.";
const int kUnboundedSize = SizeConstraints::kUnboundedSize;
@@ -412,4 +418,19 @@ bool AppCurrentWindowInternalSetVisibleOnAllWorkspacesFunction::RunWithWindow(
return true;
}
+bool AppCurrentWindowInternalSetInterceptAllKeysFunction::RunWithWindow(
+ AppWindow* window) {
+ if (!extension()->permissions_data()->HasAPIPermission(
+ kInterceptAllKeysPermission)) {
+ error_ = kInterceptAllKeysPermissionError;
+ return false;
+ }
+
+ scoped_ptr<SetInterceptAllKeys::Params> params(
+ SetInterceptAllKeys::Params::Create(*args_));
+ CHECK(params.get());
+ window->SetInterceptAllKeys(params->want_all_keys);
+ return true;
+}
+
} // namespace extensions

Powered by Google App Engine
This is Rietveld 408576698