Chromium Code Reviews| 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; |