OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "apps/shell_window.h" | 5 #include "apps/shell_window.h" |
6 | 6 |
7 #include "apps/shell_window_geometry_cache.h" | 7 #include "apps/shell_window_geometry_cache.h" |
8 #include "apps/shell_window_registry.h" | 8 #include "apps/shell_window_registry.h" |
9 #include "apps/ui/native_app_window.h" | 9 #include "apps/ui/native_app_window.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
276 WindowOpenDisposition disposition, | 276 WindowOpenDisposition disposition, |
277 const gfx::Rect& initial_pos, | 277 const gfx::Rect& initial_pos, |
278 bool user_gesture, | 278 bool user_gesture, |
279 bool* was_blocked) { | 279 bool* was_blocked) { |
280 DCHECK(Profile::FromBrowserContext(new_contents->GetBrowserContext()) == | 280 DCHECK(Profile::FromBrowserContext(new_contents->GetBrowserContext()) == |
281 profile_); | 281 profile_); |
282 delegate_->AddNewContents(profile_, new_contents, disposition, | 282 delegate_->AddNewContents(profile_, new_contents, disposition, |
283 initial_pos, user_gesture, was_blocked); | 283 initial_pos, user_gesture, was_blocked); |
284 } | 284 } |
285 | 285 |
| 286 bool ShellWindow::PreHandleKeyboardEvent( |
| 287 content::WebContents* source, |
| 288 const content::NativeWebKeyboardEvent& event, |
| 289 bool* is_keyboard_shortcut) { |
| 290 // Here, we can handle a key event before the content gets it. When we are |
| 291 // fullscreen, we want to allow the user to leave when ESC is pressed. |
| 292 // However, if the application has the "overrideEscFullscreen" permission, we |
| 293 // should let it override that behavior. |
| 294 // ::HandleKeyboardEvent() will only be called if the KeyEvent's default |
| 295 // action is not prevented. |
| 296 // Thus, we should handle the KeyEvent here only if the permission is not set. |
| 297 if (event.windowsKeyCode == ui::VKEY_ESCAPE && |
| 298 (fullscreen_for_tab_ || fullscreen_for_window_api_) && |
| 299 !extension_->HasAPIPermission(APIPermission::kOverrideEscFullscreen)) { |
| 300 Restore(); |
| 301 return true; |
| 302 } |
| 303 |
| 304 return false; |
| 305 } |
| 306 |
286 void ShellWindow::HandleKeyboardEvent( | 307 void ShellWindow::HandleKeyboardEvent( |
287 WebContents* source, | 308 WebContents* source, |
288 const content::NativeWebKeyboardEvent& event) { | 309 const content::NativeWebKeyboardEvent& event) { |
| 310 // If the window is currently fullscreen, ESC should leave fullscreen. |
| 311 // If this code is being called for ESC, that means that the KeyEvent's |
| 312 // default behavior was not prevented by the content. |
| 313 if (event.windowsKeyCode == ui::VKEY_ESCAPE && |
| 314 (fullscreen_for_tab_ || fullscreen_for_window_api_)) { |
| 315 Restore(); |
| 316 return; |
| 317 } |
| 318 |
289 native_app_window_->HandleKeyboardEvent(event); | 319 native_app_window_->HandleKeyboardEvent(event); |
290 } | 320 } |
291 | 321 |
292 void ShellWindow::RequestToLockMouse(WebContents* web_contents, | 322 void ShellWindow::RequestToLockMouse(WebContents* web_contents, |
293 bool user_gesture, | 323 bool user_gesture, |
294 bool last_unlocked_by_target) { | 324 bool last_unlocked_by_target) { |
295 bool has_permission = IsExtensionWithPermissionOrSuggestInConsole( | 325 bool has_permission = IsExtensionWithPermissionOrSuggestInConsole( |
296 APIPermission::kPointerLock, | 326 APIPermission::kPointerLock, |
297 extension_, | 327 extension_, |
298 web_contents->GetRenderViewHost()); | 328 web_contents->GetRenderViewHost()); |
(...skipping 450 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
749 region.bounds.x(), | 779 region.bounds.x(), |
750 region.bounds.y(), | 780 region.bounds.y(), |
751 region.bounds.right(), | 781 region.bounds.right(), |
752 region.bounds.bottom(), | 782 region.bounds.bottom(), |
753 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); | 783 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); |
754 } | 784 } |
755 return sk_region; | 785 return sk_region; |
756 } | 786 } |
757 | 787 |
758 } // namespace apps | 788 } // namespace apps |
OLD | NEW |