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

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: Fix permission check in code after rename 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: apps/app_window.cc
diff --git a/apps/app_window.cc b/apps/app_window.cc
index e2d837d4e3847cda39e2cf9954fccc150f5931b4..c221bcb855974d4fbc46473faf31fc68ba628bea 100644
--- a/apps/app_window.cc
+++ b/apps/app_window.cc
@@ -245,7 +245,8 @@ AppWindow::AppWindow(BrowserContext* context,
has_been_shown_(false),
can_send_events_(false),
is_hidden_(false),
- cached_always_on_top_(false) {
+ cached_always_on_top_(false),
+ cached_want_all_keys_(false) {
extensions::ExtensionsBrowserClient* client =
extensions::ExtensionsBrowserClient::Get();
CHECK(!client->IsGuestSession(context) || context->IsOffTheRecord())
@@ -514,6 +515,8 @@ void AppWindow::OnNativeWindowChanged() {
}
#endif
+ UpdateNativeInterceptAllKeys();
+
if (app_window_contents_ && native_app_window_)
app_window_contents_->NativeWindowChanged(native_app_window_.get());
}
@@ -737,6 +740,15 @@ 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) {
+ return;
+ }
+
+ cached_want_all_keys_ = want_all_keys;
+ UpdateNativeInterceptAllKeys();
+}
+
void AppWindow::WindowEventsReady() {
can_send_events_ = true;
SendOnWindowShownIfShown();
@@ -898,6 +910,16 @@ void AppWindow::UpdateNativeAlwaysOnTop() {
}
}
+void AppWindow::UpdateNativeInterceptAllKeys() {
+ // This function could be called from OnNativeWindowChanged() even before the
+ // object is initialized. So make sure that we have a valid object.
+ if (native_app_window_) {
+ bool should_intercept_all_keys =
+ cached_want_all_keys_ && native_app_window_->IsActive();
+ native_app_window_->SetInterceptAllKeys(should_intercept_all_keys);
benwells 2014/07/16 09:39:14 This is going to be called a lot - e.g. when the w
Sriram 2014/07/24 22:38:54 Done.
+ }
+}
+
void AppWindow::SendOnWindowShownIfShown() {
if (!can_send_events_ || !has_been_shown_)
return;

Powered by Google App Engine
This is Rietveld 408576698