OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "extensions/browser/app_window/app_window.h" | 5 #include "extensions/browser/app_window/app_window.h" |
6 | 6 |
7 #include <stddef.h> | 7 #include <stddef.h> |
8 | 8 |
9 #include <algorithm> | 9 #include <algorithm> |
10 #include <string> | 10 #include <string> |
11 #include <utility> | 11 #include <utility> |
12 #include <vector> | 12 #include <vector> |
13 | 13 |
14 #include "base/callback_helpers.h" | 14 #include "base/callback_helpers.h" |
15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
16 #include "base/strings/string_util.h" | 16 #include "base/strings/string_util.h" |
17 #include "base/strings/utf_string_conversions.h" | 17 #include "base/strings/utf_string_conversions.h" |
18 #include "base/task_runner.h" | 18 #include "base/task_runner.h" |
19 #include "base/threading/thread_task_runner_handle.h" | 19 #include "base/threading/thread_task_runner_handle.h" |
20 #include "base/values.h" | 20 #include "base/values.h" |
21 #include "build/build_config.h" | 21 #include "build/build_config.h" |
22 #include "components/web_modal/web_contents_modal_dialog_manager.h" | 22 #include "components/web_modal/web_contents_modal_dialog_manager.h" |
23 #include "content/public/browser/browser_context.h" | 23 #include "content/public/browser/browser_context.h" |
24 #include "content/public/browser/invalidate_type.h" | 24 #include "content/public/browser/invalidate_type.h" |
| 25 #include "content/public/browser/keyboard_event_processing_result.h" |
25 #include "content/public/browser/navigation_entry.h" | 26 #include "content/public/browser/navigation_entry.h" |
26 #include "content/public/browser/render_view_host.h" | 27 #include "content/public/browser/render_view_host.h" |
27 #include "content/public/browser/render_widget_host.h" | 28 #include "content/public/browser/render_widget_host.h" |
28 #include "content/public/browser/resource_dispatcher_host.h" | 29 #include "content/public/browser/resource_dispatcher_host.h" |
29 #include "content/public/browser/web_contents.h" | 30 #include "content/public/browser/web_contents.h" |
30 #include "content/public/common/browser_side_navigation_policy.h" | 31 #include "content/public/common/browser_side_navigation_policy.h" |
31 #include "content/public/common/media_stream_request.h" | 32 #include "content/public/common/media_stream_request.h" |
32 #include "extensions/browser/app_window/app_delegate.h" | 33 #include "extensions/browser/app_window/app_delegate.h" |
33 #include "extensions/browser/app_window/app_web_contents_helper.h" | 34 #include "extensions/browser/app_window/app_web_contents_helper.h" |
34 #include "extensions/browser/app_window/app_window_client.h" | 35 #include "extensions/browser/app_window/app_window_client.h" |
(...skipping 337 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
372 bool* was_blocked) { | 373 bool* was_blocked) { |
373 DCHECK(new_contents->GetBrowserContext() == browser_context_); | 374 DCHECK(new_contents->GetBrowserContext() == browser_context_); |
374 app_delegate_->AddNewContents(browser_context_, | 375 app_delegate_->AddNewContents(browser_context_, |
375 new_contents, | 376 new_contents, |
376 disposition, | 377 disposition, |
377 initial_rect, | 378 initial_rect, |
378 user_gesture, | 379 user_gesture, |
379 was_blocked); | 380 was_blocked); |
380 } | 381 } |
381 | 382 |
382 bool AppWindow::PreHandleKeyboardEvent( | 383 content::KeyboardEventProcessingResult AppWindow::PreHandleKeyboardEvent( |
383 content::WebContents* source, | 384 content::WebContents* source, |
384 const content::NativeWebKeyboardEvent& event, | 385 const content::NativeWebKeyboardEvent& event) { |
385 bool* is_keyboard_shortcut) { | |
386 const Extension* extension = GetExtension(); | 386 const Extension* extension = GetExtension(); |
387 if (!extension) | 387 if (!extension) |
388 return false; | 388 return content::KeyboardEventProcessingResult::NOT_HANDLED; |
389 | 389 |
390 // Here, we can handle a key event before the content gets it. When we are | 390 // Here, we can handle a key event before the content gets it. When we are |
391 // fullscreen and it is not forced, we want to allow the user to leave | 391 // fullscreen and it is not forced, we want to allow the user to leave |
392 // when ESC is pressed. | 392 // when ESC is pressed. |
393 // However, if the application has the "overrideEscFullscreen" permission, we | 393 // However, if the application has the "overrideEscFullscreen" permission, we |
394 // should let it override that behavior. | 394 // should let it override that behavior. |
395 // ::HandleKeyboardEvent() will only be called if the KeyEvent's default | 395 // ::HandleKeyboardEvent() will only be called if the KeyEvent's default |
396 // action is not prevented. | 396 // action is not prevented. |
397 // Thus, we should handle the KeyEvent here only if the permission is not set. | 397 // Thus, we should handle the KeyEvent here only if the permission is not set. |
398 if (event.windowsKeyCode == ui::VKEY_ESCAPE && IsFullscreen() && | 398 if (event.windowsKeyCode == ui::VKEY_ESCAPE && IsFullscreen() && |
399 !IsForcedFullscreen() && | 399 !IsForcedFullscreen() && |
400 !extension->permissions_data()->HasAPIPermission( | 400 !extension->permissions_data()->HasAPIPermission( |
401 APIPermission::kOverrideEscFullscreen)) { | 401 APIPermission::kOverrideEscFullscreen)) { |
402 Restore(); | 402 Restore(); |
403 return true; | 403 return content::KeyboardEventProcessingResult::HANDLED; |
404 } | 404 } |
405 | 405 |
406 return false; | 406 return content::KeyboardEventProcessingResult::NOT_HANDLED; |
407 } | 407 } |
408 | 408 |
409 void AppWindow::HandleKeyboardEvent( | 409 void AppWindow::HandleKeyboardEvent( |
410 WebContents* source, | 410 WebContents* source, |
411 const content::NativeWebKeyboardEvent& event) { | 411 const content::NativeWebKeyboardEvent& event) { |
412 // If the window is currently fullscreen and not forced, ESC should leave | 412 // If the window is currently fullscreen and not forced, ESC should leave |
413 // fullscreen. If this code is being called for ESC, that means that the | 413 // fullscreen. If this code is being called for ESC, that means that the |
414 // KeyEvent's default behavior was not prevented by the content. | 414 // KeyEvent's default behavior was not prevented by the content. |
415 if (event.windowsKeyCode == ui::VKEY_ESCAPE && IsFullscreen() && | 415 if (event.windowsKeyCode == ui::VKEY_ESCAPE && IsFullscreen() && |
416 !IsForcedFullscreen()) { | 416 !IsForcedFullscreen()) { |
(...skipping 696 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1113 region.bounds.x(), | 1113 region.bounds.x(), |
1114 region.bounds.y(), | 1114 region.bounds.y(), |
1115 region.bounds.right(), | 1115 region.bounds.right(), |
1116 region.bounds.bottom(), | 1116 region.bounds.bottom(), |
1117 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); | 1117 region.draggable ? SkRegion::kUnion_Op : SkRegion::kDifference_Op); |
1118 } | 1118 } |
1119 return sk_region; | 1119 return sk_region; |
1120 } | 1120 } |
1121 | 1121 |
1122 } // namespace extensions | 1122 } // namespace extensions |
OLD | NEW |