Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(977)

Side by Side Diff: chrome/browser/extensions/extension_host.cc

Issue 10459044: Fix inconsistency in browser shortcut handling when a BrowserAction popup is focused. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: review fix, rebase Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/extensions/extension_host.h ('k') | chrome/browser/ui/browser.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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/extensions/extension_host.h" 5 #include "chrome/browser/extensions/extension_host.h"
6 6
7 #include <list> 7 #include <list>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/memory/singleton.h" 10 #include "base/memory/singleton.h"
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
46 #include "content/public/browser/web_contents.h" 46 #include "content/public/browser/web_contents.h"
47 #include "content/public/browser/web_contents_view.h" 47 #include "content/public/browser/web_contents_view.h"
48 #include "grit/browser_resources.h" 48 #include "grit/browser_resources.h"
49 #include "grit/chromium_strings.h" 49 #include "grit/chromium_strings.h"
50 #include "grit/generated_resources.h" 50 #include "grit/generated_resources.h"
51 #include "ui/base/keycodes/keyboard_codes.h" 51 #include "ui/base/keycodes/keyboard_codes.h"
52 #include "ui/base/l10n/l10n_util.h" 52 #include "ui/base/l10n/l10n_util.h"
53 #include "ui/base/layout.h" 53 #include "ui/base/layout.h"
54 #include "ui/base/resource/resource_bundle.h" 54 #include "ui/base/resource/resource_bundle.h"
55 55
56 #if defined(TOOLKIT_VIEWS)
57 #include "ui/views/widget/widget.h"
58 #endif
59
60 using WebKit::WebDragOperation; 56 using WebKit::WebDragOperation;
61 using WebKit::WebDragOperationsMask; 57 using WebKit::WebDragOperationsMask;
62 using content::NativeWebKeyboardEvent; 58 using content::NativeWebKeyboardEvent;
63 using content::OpenURLParams; 59 using content::OpenURLParams;
64 using content::RenderViewHost; 60 using content::RenderViewHost;
65 using content::SiteInstance; 61 using content::SiteInstance;
66 using content::WebContents; 62 using content::WebContents;
67 63
68 // Helper class that rate-limits the creation of renderer processes for 64 // Helper class that rate-limits the creation of renderer processes for
69 // ExtensionHosts, to avoid blocking the UI. 65 // ExtensionHosts, to avoid blocking the UI.
(...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after
455 } 451 }
456 } 452 }
457 453
458 bool ExtensionHost::PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, 454 bool ExtensionHost::PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event,
459 bool* is_keyboard_shortcut) { 455 bool* is_keyboard_shortcut) {
460 if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_POPUP && 456 if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_POPUP &&
461 event.type == NativeWebKeyboardEvent::RawKeyDown && 457 event.type == NativeWebKeyboardEvent::RawKeyDown &&
462 event.windowsKeyCode == ui::VKEY_ESCAPE) { 458 event.windowsKeyCode == ui::VKEY_ESCAPE) {
463 DCHECK(is_keyboard_shortcut != NULL); 459 DCHECK(is_keyboard_shortcut != NULL);
464 *is_keyboard_shortcut = true; 460 *is_keyboard_shortcut = true;
461 return false;
465 } 462 }
463
464 // Handle higher priority browser shortcuts such as Ctrl-w.
465 Browser* browser = view() ? view()->browser() : NULL;
466 if (browser)
467 return browser->PreHandleKeyboardEvent(event, is_keyboard_shortcut);
468
469 *is_keyboard_shortcut = false;
466 return false; 470 return false;
467 } 471 }
468 472
469 void ExtensionHost::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { 473 void ExtensionHost::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) {
470 if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_POPUP) { 474 if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_POPUP) {
471 if (event.type == NativeWebKeyboardEvent::RawKeyDown && 475 if (event.type == NativeWebKeyboardEvent::RawKeyDown &&
472 event.windowsKeyCode == ui::VKEY_ESCAPE) { 476 event.windowsKeyCode == ui::VKEY_ESCAPE) {
473 Close(); 477 Close();
474 return; 478 return;
475 } 479 }
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
508 pm->IncrementLazyKeepaliveCount(extension()); 512 pm->IncrementLazyKeepaliveCount(extension());
509 } 513 }
510 514
511 void ExtensionHost::OnDecrementLazyKeepaliveCount() { 515 void ExtensionHost::OnDecrementLazyKeepaliveCount() {
512 ExtensionProcessManager* pm = 516 ExtensionProcessManager* pm =
513 ExtensionSystem::Get(profile_)->process_manager(); 517 ExtensionSystem::Get(profile_)->process_manager();
514 if (pm) 518 if (pm)
515 pm->DecrementLazyKeepaliveCount(extension()); 519 pm->DecrementLazyKeepaliveCount(extension());
516 } 520 }
517 521
522 void ExtensionHost::UnhandledKeyboardEvent(
523 const content::NativeWebKeyboardEvent& event) {
524 // Handle lower priority browser shortcuts such as Ctrl-f.
525 Browser* browser = view() ? view()->browser() : NULL;
526 if (browser)
527 return browser->HandleKeyboardEvent(event);
528 }
518 529
519 void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) { 530 void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) {
520 render_view_host_ = render_view_host; 531 render_view_host_ = render_view_host;
521 532
522 if (view()) 533 if (view())
523 view()->RenderViewCreated(); 534 view()->RenderViewCreated();
524 535
525 // If the host is bound to a window, then extract its id. Extensions hosted 536 // If the host is bound to a window, then extract its id. Extensions hosted
526 // in ExternalTabContainer objects may not have an associated window. 537 // in ExternalTabContainer objects may not have an associated window.
527 ExtensionWindowController* window = GetExtensionWindowController(); 538 ExtensionWindowController* window = GetExtensionWindowController();
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
600 params.user_gesture = user_gesture; 611 params.user_gesture = user_gesture;
601 browser::Navigate(&params); 612 browser::Navigate(&params);
602 } 613 }
603 614
604 void ExtensionHost::RenderViewReady() { 615 void ExtensionHost::RenderViewReady() {
605 content::NotificationService::current()->Notify( 616 content::NotificationService::current()->Notify(
606 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, 617 chrome::NOTIFICATION_EXTENSION_HOST_CREATED,
607 content::Source<Profile>(profile_), 618 content::Source<Profile>(profile_),
608 content::Details<ExtensionHost>(this)); 619 content::Details<ExtensionHost>(this));
609 } 620 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_host.h ('k') | chrome/browser/ui/browser.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698