| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/browser/ui/cocoa/browser_window_cocoa.h" | 5 #include "chrome/browser/ui/cocoa/browser_window_cocoa.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/debug/stack_trace.h" |
| 9 #include "base/logging.h" | 10 #include "base/logging.h" |
| 10 #import "base/mac/sdk_forward_declarations.h" | 11 #import "base/mac/sdk_forward_declarations.h" |
| 11 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
| 12 #include "base/strings/string_util.h" | 13 #include "base/strings/string_util.h" |
| 13 #include "base/strings/sys_string_conversions.h" | 14 #include "base/strings/sys_string_conversions.h" |
| 14 #include "chrome/app/chrome_command_ids.h" | 15 #include "chrome/app/chrome_command_ids.h" |
| 15 #include "chrome/browser/chrome_notification_types.h" | 16 #include "chrome/browser/chrome_notification_types.h" |
| 16 #include "chrome/browser/download/download_shelf.h" | 17 #include "chrome/browser/download/download_shelf.h" |
| 17 #include "chrome/browser/extensions/tab_helper.h" | 18 #include "chrome/browser/extensions/tab_helper.h" |
| 18 #include "chrome/browser/metrics/browser_window_histogram_helper.h" | 19 #include "chrome/browser/metrics/browser_window_histogram_helper.h" |
| (...skipping 556 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 575 security_info); | 576 security_info); |
| 576 } | 577 } |
| 577 | 578 |
| 578 void BrowserWindowCocoa::ShowAppMenu() { | 579 void BrowserWindowCocoa::ShowAppMenu() { |
| 579 // No-op. Mac doesn't support showing the menus via alt keys. | 580 // No-op. Mac doesn't support showing the menus via alt keys. |
| 580 } | 581 } |
| 581 | 582 |
| 582 content::KeyboardEventProcessingResult | 583 content::KeyboardEventProcessingResult |
| 583 BrowserWindowCocoa::PreHandleKeyboardEvent( | 584 BrowserWindowCocoa::PreHandleKeyboardEvent( |
| 584 const NativeWebKeyboardEvent& event) { | 585 const NativeWebKeyboardEvent& event) { |
| 586 base::debug::StackTrace s; |
| 587 LOG(ERROR) << "BrowserWindowCocoa::PreHandleKeyboardEvent\n" << s.ToString(); |
| 585 // Handle ESC to dismiss permission bubbles, but still forward it | 588 // Handle ESC to dismiss permission bubbles, but still forward it |
| 586 // to the window afterwards. | 589 // to the window afterwards. |
| 587 if (event.windows_key_code == ui::VKEY_ESCAPE) | 590 if (event.windows_key_code == ui::VKEY_ESCAPE) |
| 588 [controller_ dismissPermissionBubble]; | 591 [controller_ dismissPermissionBubble]; |
| 589 | 592 |
| 590 if (![BrowserWindowUtils shouldHandleKeyboardEvent:event]) | 593 if (![BrowserWindowUtils shouldHandleKeyboardEvent:event]) { |
| 594 LOG(ERROR) << " > early exit; shouldn't handle event"; |
| 591 return content::KeyboardEventProcessingResult::NOT_HANDLED; | 595 return content::KeyboardEventProcessingResult::NOT_HANDLED; |
| 596 } |
| 592 | 597 |
| 593 if (event.GetType() == blink::WebInputEvent::kRawKeyDown && | 598 if (event.GetType() == blink::WebInputEvent::kRawKeyDown && |
| 594 [controller_ | 599 [controller_ |
| 595 handledByExtensionCommand:event.os_event | 600 handledByExtensionCommand:event.os_event |
| 596 priority:ui::AcceleratorManager::kHighPriority]) | 601 priority:ui::AcceleratorManager::kHighPriority]) { |
| 602 LOG(ERROR) << " > handled by extension command"; |
| 597 return content::KeyboardEventProcessingResult::HANDLED; | 603 return content::KeyboardEventProcessingResult::HANDLED; |
| 604 } |
| 598 | 605 |
| 599 int id = [BrowserWindowUtils getCommandId:event]; | 606 int id = [BrowserWindowUtils getCommandId:event]; |
| 600 if (id == -1) | 607 if (id == -1) { |
| 608 LOG(ERROR) << " > not handled; no command id"; |
| 601 return content::KeyboardEventProcessingResult::NOT_HANDLED; | 609 return content::KeyboardEventProcessingResult::NOT_HANDLED; |
| 610 } |
| 602 | 611 |
| 603 if (browser_->command_controller()->IsReservedCommandOrKey(id, event)) { | 612 if (browser_->command_controller()->IsReservedCommandOrKey(id, event)) { |
| 604 using Result = content::KeyboardEventProcessingResult; | 613 using Result = content::KeyboardEventProcessingResult; |
| 605 return [BrowserWindowUtils handleKeyboardEvent:event.os_event | 614 bool result = [BrowserWindowUtils handleKeyboardEvent:event.os_event |
| 606 inWindow:window()] | 615 inWindow:window()]; |
| 607 ? Result::HANDLED | 616 LOG(ERROR) << " > handleKeyboardEvent: returned " << result; |
| 608 : Result::NOT_HANDLED; | 617 return result ? Result::HANDLED : Result::NOT_HANDLED; |
| 609 } | 618 } |
| 610 | 619 |
| 620 LOG(ERROR) << " > returning default"; |
| 611 return content::KeyboardEventProcessingResult::NOT_HANDLED_IS_SHORTCUT; | 621 return content::KeyboardEventProcessingResult::NOT_HANDLED_IS_SHORTCUT; |
| 612 } | 622 } |
| 613 | 623 |
| 614 void BrowserWindowCocoa::HandleKeyboardEvent( | 624 void BrowserWindowCocoa::HandleKeyboardEvent( |
| 615 const NativeWebKeyboardEvent& event) { | 625 const NativeWebKeyboardEvent& event) { |
| 616 if ([BrowserWindowUtils shouldHandleKeyboardEvent:event]) { | 626 if ([BrowserWindowUtils shouldHandleKeyboardEvent:event]) { |
| 617 if (![BrowserWindowUtils handleKeyboardEvent:event.os_event | 627 if (![BrowserWindowUtils handleKeyboardEvent:event.os_event |
| 618 inWindow:window()]) { | 628 inWindow:window()]) { |
| 619 | 629 |
| 620 // TODO(spqchan): This is a temporary fix for exit extension fullscreen. | 630 // TODO(spqchan): This is a temporary fix for exit extension fullscreen. |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 724 ExclusiveAccessContext* BrowserWindowCocoa::GetExclusiveAccessContext() { | 734 ExclusiveAccessContext* BrowserWindowCocoa::GetExclusiveAccessContext() { |
| 725 return [controller_ exclusiveAccessController]; | 735 return [controller_ exclusiveAccessController]; |
| 726 } | 736 } |
| 727 | 737 |
| 728 void BrowserWindowCocoa::ShowImeWarningBubble( | 738 void BrowserWindowCocoa::ShowImeWarningBubble( |
| 729 const extensions::Extension* extension, | 739 const extensions::Extension* extension, |
| 730 const base::Callback<void(ImeWarningBubblePermissionStatus status)>& | 740 const base::Callback<void(ImeWarningBubblePermissionStatus status)>& |
| 731 callback) { | 741 callback) { |
| 732 NOTREACHED() << "The IME warning bubble is unsupported on this platform."; | 742 NOTREACHED() << "The IME warning bubble is unsupported on this platform."; |
| 733 } | 743 } |
| OLD | NEW |