| 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 264 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 275 WindowOpenDisposition disposition, | 275 WindowOpenDisposition disposition, |
| 276 const gfx::Rect& initial_pos, | 276 const gfx::Rect& initial_pos, |
| 277 bool user_gesture, | 277 bool user_gesture, |
| 278 bool* was_blocked) { | 278 bool* was_blocked) { |
| 279 DCHECK(Profile::FromBrowserContext(new_contents->GetBrowserContext()) == | 279 DCHECK(Profile::FromBrowserContext(new_contents->GetBrowserContext()) == |
| 280 profile_); | 280 profile_); |
| 281 delegate_->AddNewContents(profile_, new_contents, disposition, | 281 delegate_->AddNewContents(profile_, new_contents, disposition, |
| 282 initial_pos, user_gesture, was_blocked); | 282 initial_pos, user_gesture, was_blocked); |
| 283 } | 283 } |
| 284 | 284 |
| 285 bool ShellWindow::PreHandleKeyboardEvent( | |
| 286 content::WebContents* source, | |
| 287 const content::NativeWebKeyboardEvent& event, | |
| 288 bool* is_keyboard_shortcut) { | |
| 289 // Here, we can handle a key event before the content gets it. When we are | |
| 290 // fullscreen, we want to allow the user to leave when ESC is pressed. | |
| 291 // However, if the application has the "overrideEscFullscreen" permission, we | |
| 292 // should let it override that behavior. | |
| 293 // ::HandleKeyboardEvent() will only be called if the KeyEvent's default | |
| 294 // action is not prevented. | |
| 295 // Thus, we should handle the KeyEvent here only if the permission is not set. | |
| 296 if (event.windowsKeyCode == ui::VKEY_ESCAPE && | |
| 297 (fullscreen_types_ != FULLSCREEN_TYPE_NONE) && | |
| 298 !extension_->HasAPIPermission(APIPermission::kOverrideEscFullscreen)) { | |
| 299 Restore(); | |
| 300 return true; | |
| 301 } | |
| 302 | |
| 303 return false; | |
| 304 } | |
| 305 | |
| 306 void ShellWindow::HandleKeyboardEvent( | 285 void ShellWindow::HandleKeyboardEvent( |
| 307 WebContents* source, | 286 WebContents* source, |
| 308 const content::NativeWebKeyboardEvent& event) { | 287 const content::NativeWebKeyboardEvent& event) { |
| 309 // If the window is currently fullscreen, ESC should leave fullscreen. | |
| 310 // If this code is being called for ESC, that means that the KeyEvent's | |
| 311 // default behavior was not prevented by the content. | |
| 312 if (event.windowsKeyCode == ui::VKEY_ESCAPE && | |
| 313 (fullscreen_types_ != FULLSCREEN_TYPE_NONE)) { | |
| 314 Restore(); | |
| 315 return; | |
| 316 } | |
| 317 | |
| 318 native_app_window_->HandleKeyboardEvent(event); | 288 native_app_window_->HandleKeyboardEvent(event); |
| 319 } | 289 } |
| 320 | 290 |
| 321 void ShellWindow::RequestToLockMouse(WebContents* web_contents, | 291 void ShellWindow::RequestToLockMouse(WebContents* web_contents, |
| 322 bool user_gesture, | 292 bool user_gesture, |
| 323 bool last_unlocked_by_target) { | 293 bool last_unlocked_by_target) { |
| 324 bool has_permission = IsExtensionWithPermissionOrSuggestInConsole( | 294 bool has_permission = IsExtensionWithPermissionOrSuggestInConsole( |
| 325 APIPermission::kPointerLock, | 295 APIPermission::kPointerLock, |
| 326 extension_, | 296 extension_, |
| 327 web_contents->GetRenderViewHost()); | 297 web_contents->GetRenderViewHost()); |
| (...skipping 457 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 785 region.bounds.x(), | 755 region.bounds.x(), |
| 786 region.bounds.y(), | 756 region.bounds.y(), |
| 787 region.bounds.right(), | 757 region.bounds.right(), |
| 788 region.bounds.bottom(), | 758 region.bounds.bottom(), |
| 789 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); | 759 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); |
| 790 } | 760 } |
| 791 return sk_region; | 761 return sk_region; |
| 792 } | 762 } |
| 793 | 763 |
| 794 } // namespace apps | 764 } // namespace apps |
| OLD | NEW |