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

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

Issue 10837112: Add WebContents* to some more WebContentsDelegate methods (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebased Created 8 years, 4 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
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 435 matching lines...) Expand 10 before | Expand all | Expand 10 after
446 // Only allow these from hosts that are bound to a browser (e.g. popups). 446 // Only allow these from hosts that are bound to a browser (e.g. popups).
447 // Otherwise they are not driven by a user gesture. 447 // Otherwise they are not driven by a user gesture.
448 Browser* browser = view() ? view()->browser() : NULL; 448 Browser* browser = view() ? view()->browser() : NULL;
449 return browser ? browser->OpenURL(params) : NULL; 449 return browser ? browser->OpenURL(params) : NULL;
450 } 450 }
451 default: 451 default:
452 return NULL; 452 return NULL;
453 } 453 }
454 } 454 }
455 455
456 bool ExtensionHost::PreHandleKeyboardEvent(const NativeWebKeyboardEvent& event, 456 bool ExtensionHost::PreHandleKeyboardEvent(WebContents* source,
457 const NativeWebKeyboardEvent& event,
457 bool* is_keyboard_shortcut) { 458 bool* is_keyboard_shortcut) {
458 if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_POPUP && 459 if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_POPUP &&
459 event.type == NativeWebKeyboardEvent::RawKeyDown && 460 event.type == NativeWebKeyboardEvent::RawKeyDown &&
460 event.windowsKeyCode == ui::VKEY_ESCAPE) { 461 event.windowsKeyCode == ui::VKEY_ESCAPE) {
461 DCHECK(is_keyboard_shortcut != NULL); 462 DCHECK(is_keyboard_shortcut != NULL);
462 *is_keyboard_shortcut = true; 463 *is_keyboard_shortcut = true;
463 return false; 464 return false;
464 } 465 }
465 466
466 // Handle higher priority browser shortcuts such as Ctrl-w. 467 // Handle higher priority browser shortcuts such as Ctrl-w.
467 Browser* browser = view() ? view()->browser() : NULL; 468 Browser* browser = view() ? view()->browser() : NULL;
468 if (browser) 469 if (browser)
469 return browser->PreHandleKeyboardEvent(event, is_keyboard_shortcut); 470 return browser->PreHandleKeyboardEvent(source, event, is_keyboard_shortcut);
470 471
471 *is_keyboard_shortcut = false; 472 *is_keyboard_shortcut = false;
472 return false; 473 return false;
473 } 474 }
474 475
475 void ExtensionHost::HandleKeyboardEvent(const NativeWebKeyboardEvent& event) { 476 void ExtensionHost::HandleKeyboardEvent(WebContents* source,
477 const NativeWebKeyboardEvent& event) {
476 if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_POPUP) { 478 if (extension_host_type_ == chrome::VIEW_TYPE_EXTENSION_POPUP) {
477 if (event.type == NativeWebKeyboardEvent::RawKeyDown && 479 if (event.type == NativeWebKeyboardEvent::RawKeyDown &&
478 event.windowsKeyCode == ui::VKEY_ESCAPE) { 480 event.windowsKeyCode == ui::VKEY_ESCAPE) {
479 Close(); 481 Close();
480 return; 482 return;
481 } 483 }
482 } 484 }
483 UnhandledKeyboardEvent(event); 485 UnhandledKeyboardEvent(source, event);
484 } 486 }
485 487
486 bool ExtensionHost::OnMessageReceived(const IPC::Message& message) { 488 bool ExtensionHost::OnMessageReceived(const IPC::Message& message) {
487 bool handled = true; 489 bool handled = true;
488 IPC_BEGIN_MESSAGE_MAP(ExtensionHost, message) 490 IPC_BEGIN_MESSAGE_MAP(ExtensionHost, message)
489 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) 491 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest)
490 IPC_MESSAGE_HANDLER(ExtensionHostMsg_EventAck, OnEventAck) 492 IPC_MESSAGE_HANDLER(ExtensionHostMsg_EventAck, OnEventAck)
491 IPC_MESSAGE_HANDLER(ExtensionHostMsg_IncrementLazyKeepaliveCount, 493 IPC_MESSAGE_HANDLER(ExtensionHostMsg_IncrementLazyKeepaliveCount,
492 OnIncrementLazyKeepaliveCount) 494 OnIncrementLazyKeepaliveCount)
493 IPC_MESSAGE_HANDLER(ExtensionHostMsg_DecrementLazyKeepaliveCount, 495 IPC_MESSAGE_HANDLER(ExtensionHostMsg_DecrementLazyKeepaliveCount,
(...skipping 22 matching lines...) Expand all
516 } 518 }
517 519
518 void ExtensionHost::OnDecrementLazyKeepaliveCount() { 520 void ExtensionHost::OnDecrementLazyKeepaliveCount() {
519 ExtensionProcessManager* pm = 521 ExtensionProcessManager* pm =
520 ExtensionSystem::Get(profile_)->process_manager(); 522 ExtensionSystem::Get(profile_)->process_manager();
521 if (pm) 523 if (pm)
522 pm->DecrementLazyKeepaliveCount(extension()); 524 pm->DecrementLazyKeepaliveCount(extension());
523 } 525 }
524 526
525 void ExtensionHost::UnhandledKeyboardEvent( 527 void ExtensionHost::UnhandledKeyboardEvent(
528 WebContents* source,
526 const content::NativeWebKeyboardEvent& event) { 529 const content::NativeWebKeyboardEvent& event) {
527 // Handle lower priority browser shortcuts such as Ctrl-f. 530 // Handle lower priority browser shortcuts such as Ctrl-f.
528 Browser* browser = view() ? view()->browser() : NULL; 531 Browser* browser = view() ? view()->browser() : NULL;
529 if (browser) 532 if (browser)
530 return browser->HandleKeyboardEvent(event); 533 return browser->HandleKeyboardEvent(source, event);
531 } 534 }
532 535
533 void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) { 536 void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) {
534 render_view_host_ = render_view_host; 537 render_view_host_ = render_view_host;
535 538
536 if (view()) 539 if (view())
537 view()->RenderViewCreated(); 540 view()->RenderViewCreated();
538 541
539 // If the host is bound to a window, then extract its id. Extensions hosted 542 // If the host is bound to a window, then extract its id. Extensions hosted
540 // in ExternalTabContainer objects may not have an associated window. 543 // in ExternalTabContainer objects may not have an associated window.
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
594 } 597 }
595 598
596 void ExtensionHost::RenderViewReady() { 599 void ExtensionHost::RenderViewReady() {
597 content::NotificationService::current()->Notify( 600 content::NotificationService::current()->Notify(
598 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, 601 chrome::NOTIFICATION_EXTENSION_HOST_CREATED,
599 content::Source<Profile>(profile_), 602 content::Source<Profile>(profile_),
600 content::Details<ExtensionHost>(this)); 603 content::Details<ExtensionHost>(this));
601 } 604 }
602 605
603 } // namespace extensions 606 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_host.h ('k') | chrome/browser/extensions/extension_host_mac.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698