| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/extensions/extension_host.h" | 5 #include "chrome/browser/extensions/extension_host.h" |
| 6 | 6 |
| 7 #include <list> | 7 #include <list> |
| 8 | 8 |
| 9 #include "app/keyboard_codes.h" | |
| 10 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
| 11 #include "app/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
| 12 #include "base/message_loop.h" | 11 #include "base/message_loop.h" |
| 13 #include "base/singleton.h" | 12 #include "base/singleton.h" |
| 14 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 15 #include "base/string_util.h" | 14 #include "base/string_util.h" |
| 16 #include "chrome/browser/browser_list.h" | 15 #include "chrome/browser/browser_list.h" |
| 17 #include "chrome/browser/browser_shutdown.h" | 16 #include "chrome/browser/browser_shutdown.h" |
| 18 #include "chrome/browser/browser_window.h" | 17 #include "chrome/browser/browser_window.h" |
| 19 #include "chrome/browser/browsing_instance.h" | 18 #include "chrome/browser/browsing_instance.h" |
| (...skipping 23 matching lines...) Expand all Loading... |
| 43 #include "chrome/common/extensions/extension_constants.h" | 42 #include "chrome/common/extensions/extension_constants.h" |
| 44 #include "chrome/common/native_web_keyboard_event.h" | 43 #include "chrome/common/native_web_keyboard_event.h" |
| 45 #include "chrome/common/notification_service.h" | 44 #include "chrome/common/notification_service.h" |
| 46 #include "chrome/common/pref_names.h" | 45 #include "chrome/common/pref_names.h" |
| 47 #include "chrome/common/render_messages.h" | 46 #include "chrome/common/render_messages.h" |
| 48 #include "chrome/common/render_messages_params.h" | 47 #include "chrome/common/render_messages_params.h" |
| 49 #include "chrome/common/url_constants.h" | 48 #include "chrome/common/url_constants.h" |
| 50 #include "chrome/common/view_types.h" | 49 #include "chrome/common/view_types.h" |
| 51 #include "grit/browser_resources.h" | 50 #include "grit/browser_resources.h" |
| 52 #include "grit/generated_resources.h" | 51 #include "grit/generated_resources.h" |
| 52 #include "ui/base/keycodes/keyboard_codes.h" |
| 53 #include "webkit/glue/context_menu.h" | 53 #include "webkit/glue/context_menu.h" |
| 54 | 54 |
| 55 #if defined(TOOLKIT_VIEWS) | 55 #if defined(TOOLKIT_VIEWS) |
| 56 #include "views/widget/widget.h" | 56 #include "views/widget/widget.h" |
| 57 #endif | 57 #endif |
| 58 | 58 |
| 59 using WebKit::WebDragOperation; | 59 using WebKit::WebDragOperation; |
| 60 using WebKit::WebDragOperationsMask; | 60 using WebKit::WebDragOperationsMask; |
| 61 | 61 |
| 62 // static | 62 // static |
| (...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 701 void ExtensionHost::Activate() { | 701 void ExtensionHost::Activate() { |
| 702 } | 702 } |
| 703 | 703 |
| 704 void ExtensionHost::Deactivate() { | 704 void ExtensionHost::Deactivate() { |
| 705 } | 705 } |
| 706 | 706 |
| 707 bool ExtensionHost::PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, | 707 bool ExtensionHost::PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, |
| 708 bool* is_keyboard_shortcut) { | 708 bool* is_keyboard_shortcut) { |
| 709 if (extension_host_type_ == ViewType::EXTENSION_POPUP && | 709 if (extension_host_type_ == ViewType::EXTENSION_POPUP && |
| 710 event.type == NativeWebKeyboardEvent::RawKeyDown && | 710 event.type == NativeWebKeyboardEvent::RawKeyDown && |
| 711 event.windowsKeyCode == app::VKEY_ESCAPE) { | 711 event.windowsKeyCode == ui::VKEY_ESCAPE) { |
| 712 DCHECK(is_keyboard_shortcut != NULL); | 712 DCHECK(is_keyboard_shortcut != NULL); |
| 713 *is_keyboard_shortcut = true; | 713 *is_keyboard_shortcut = true; |
| 714 } | 714 } |
| 715 return false; | 715 return false; |
| 716 } | 716 } |
| 717 | 717 |
| 718 void ExtensionHost::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { | 718 void ExtensionHost::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { |
| 719 if (extension_host_type_ == ViewType::EXTENSION_POPUP) { | 719 if (extension_host_type_ == ViewType::EXTENSION_POPUP) { |
| 720 if (event.type == NativeWebKeyboardEvent::RawKeyDown && | 720 if (event.type == NativeWebKeyboardEvent::RawKeyDown && |
| 721 event.windowsKeyCode == app::VKEY_ESCAPE) { | 721 event.windowsKeyCode == ui::VKEY_ESCAPE) { |
| 722 NotificationService::current()->Notify( | 722 NotificationService::current()->Notify( |
| 723 NotificationType::EXTENSION_HOST_VIEW_SHOULD_CLOSE, | 723 NotificationType::EXTENSION_HOST_VIEW_SHOULD_CLOSE, |
| 724 Source<Profile>(profile_), | 724 Source<Profile>(profile_), |
| 725 Details<ExtensionHost>(this)); | 725 Details<ExtensionHost>(this)); |
| 726 return; | 726 return; |
| 727 } | 727 } |
| 728 } | 728 } |
| 729 UnhandledKeyboardEvent(event); | 729 UnhandledKeyboardEvent(event); |
| 730 } | 730 } |
| 731 | 731 |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 794 // Extensions hosted in ExternalTabContainer objects may not have | 794 // Extensions hosted in ExternalTabContainer objects may not have |
| 795 // an associated browser. | 795 // an associated browser. |
| 796 Browser* browser = GetBrowser(); | 796 Browser* browser = GetBrowser(); |
| 797 if (browser) | 797 if (browser) |
| 798 window_id = ExtensionTabUtil::GetWindowId(browser); | 798 window_id = ExtensionTabUtil::GetWindowId(browser); |
| 799 } else if (extension_host_type_ != ViewType::EXTENSION_BACKGROUND_PAGE) { | 799 } else if (extension_host_type_ != ViewType::EXTENSION_BACKGROUND_PAGE) { |
| 800 NOTREACHED(); | 800 NOTREACHED(); |
| 801 } | 801 } |
| 802 return window_id; | 802 return window_id; |
| 803 } | 803 } |
| OLD | NEW |