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

Unified Diff: chrome/browser/extensions/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: Update based on sky's comments Created 6 years, 5 months 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: chrome/browser/extensions/api/app_current_window_internal/app_current_window_internal_api.cc
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 7cde5b5c20cdc57c1bea63b380a0423e7b4f20e5..64fa45ab69b27c0604f10fbf1f5be7aae50964be 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
@@ -28,6 +28,8 @@ namespace SetIcon = app_current_window_internal::SetIcon;
namespace SetBadgeIcon = app_current_window_internal::SetBadgeIcon;
namespace SetShape = app_current_window_internal::SetShape;
namespace SetAlwaysOnTop = app_current_window_internal::SetAlwaysOnTop;
+namespace SetInterceptAllKeys =
+ app_current_window_internal::SetInterceptAllKeys;
using apps::AppWindow;
using app_current_window_internal::Bounds;
@@ -52,6 +54,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 = apps::SizeConstraints::kUnboundedSize;
@@ -399,4 +406,24 @@ bool AppCurrentWindowInternalSetAlwaysOnTopFunction::RunWithWindow(
return true;
}
+bool AppCurrentWindowInternalSetInterceptAllKeysFunction::RunWithWindow(
+ AppWindow* window) {
+ if (GetCurrentChannel() > chrome::VersionInfo::CHANNEL_DEV) {
benwells 2014/08/01 00:32:43 As mentioned I don't think this is needed as you a
Sriram 2014/08/11 21:01:28 Done.
+ error_ = kDevChannelOnly;
+ return false;
+ }
+
+ 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