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

Unified Diff: apps/app_window.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: Added comments to explain logic behind posting instead of directly handling keyboard events. Created 6 years, 4 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: apps/app_window.cc
diff --git a/apps/app_window.cc b/apps/app_window.cc
index df6eac7fdbfefaada9a35d7f7f376e6985a7a368..7303cf457a5717d56ab4afce0d4c18383f83dc7c 100644
--- a/apps/app_window.cc
+++ b/apps/app_window.cc
@@ -244,7 +244,8 @@ AppWindow::AppWindow(BrowserContext* context,
can_send_events_(false),
is_hidden_(false),
cached_always_on_top_(false),
- requested_transparent_background_(false) {
+ requested_transparent_background_(false),
+ cached_want_all_keys_(false) {
extensions::ExtensionsBrowserClient* client =
extensions::ExtensionsBrowserClient::Get();
CHECK(!client->IsGuestSession(context) || context->IsOffTheRecord())
@@ -351,6 +352,11 @@ void AppWindow::Init(const GURL& url,
}
AppWindow::~AppWindow() {
+ if (cached_want_all_keys_) {
+ native_app_window_->SetInterceptAllKeys(false);
+ cached_want_all_keys_ = false;
+ }
+
// Unregister now to prevent getting NOTIFICATION_APP_TERMINATING if we're the
// last window open.
registrar_.RemoveAll();
@@ -757,6 +763,13 @@ void AppWindow::SetAlwaysOnTop(bool always_on_top) {
bool AppWindow::IsAlwaysOnTop() const { return cached_always_on_top_; }
+void AppWindow::SetInterceptAllKeys(bool want_all_keys) {
+ if (cached_want_all_keys_ != want_all_keys) {
+ native_app_window_->SetInterceptAllKeys(want_all_keys);
+ cached_want_all_keys_ = want_all_keys;
+ }
+}
+
void AppWindow::WindowEventsReady() {
can_send_events_ = true;
SendOnWindowShownIfShown();

Powered by Google App Engine
This is Rietveld 408576698