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

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

Issue 10114015: Fix bug where transient pages would miss events dispatched while it was (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 8 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"
11 #include "base/memory/weak_ptr.h" 11 #include "base/memory/weak_ptr.h"
12 #include "base/message_loop.h" 12 #include "base/message_loop.h"
13 #include "base/metrics/histogram.h" 13 #include "base/metrics/histogram.h"
14 #include "base/string_util.h" 14 #include "base/string_util.h"
15 #include "base/utf_string_conversions.h" 15 #include "base/utf_string_conversions.h"
16 #include "chrome/browser/browser_shutdown.h" 16 #include "chrome/browser/browser_shutdown.h"
17 #include "chrome/browser/extensions/extension_event_router.h"
17 #include "chrome/browser/extensions/extension_process_manager.h" 18 #include "chrome/browser/extensions/extension_process_manager.h"
18 #include "chrome/browser/extensions/extension_service.h" 19 #include "chrome/browser/extensions/extension_service.h"
19 #include "chrome/browser/extensions/extension_system.h" 20 #include "chrome/browser/extensions/extension_system.h"
20 #include "chrome/browser/extensions/extension_tab_util.h" 21 #include "chrome/browser/extensions/extension_tab_util.h"
21 #include "chrome/browser/profiles/profile.h" 22 #include "chrome/browser/profiles/profile.h"
22 #include "chrome/browser/ui/app_modal_dialogs/message_box_handler.h" 23 #include "chrome/browser/ui/app_modal_dialogs/message_box_handler.h"
23 #include "chrome/browser/ui/browser.h" 24 #include "chrome/browser/ui/browser.h"
24 #include "chrome/browser/ui/browser_list.h" 25 #include "chrome/browser/ui/browser_list.h"
25 #include "chrome/browser/ui/browser_window.h" 26 #include "chrome/browser/ui/browser_window.h"
26 #include "chrome/browser/ui/prefs/prefs_tab_helper.h" 27 #include "chrome/browser/ui/prefs/prefs_tab_helper.h"
(...skipping 443 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 return; 471 return;
471 } 472 }
472 } 473 }
473 UnhandledKeyboardEvent(event); 474 UnhandledKeyboardEvent(event);
474 } 475 }
475 476
476 bool ExtensionHost::OnMessageReceived(const IPC::Message& message) { 477 bool ExtensionHost::OnMessageReceived(const IPC::Message& message) {
477 bool handled = true; 478 bool handled = true;
478 IPC_BEGIN_MESSAGE_MAP(ExtensionHost, message) 479 IPC_BEGIN_MESSAGE_MAP(ExtensionHost, message)
479 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest) 480 IPC_MESSAGE_HANDLER(ExtensionHostMsg_Request, OnRequest)
481 IPC_MESSAGE_HANDLER(ExtensionHostMsg_EventAck, OnEventAck)
482 IPC_MESSAGE_HANDLER(ExtensionHostMsg_IncrementLazyKeepaliveCount,
483 OnIncrementLazyKeepaliveCount)
484 IPC_MESSAGE_HANDLER(ExtensionHostMsg_DecrementLazyKeepaliveCount,
485 OnDecrementLazyKeepaliveCount)
480 IPC_MESSAGE_UNHANDLED(handled = false) 486 IPC_MESSAGE_UNHANDLED(handled = false)
481 IPC_END_MESSAGE_MAP() 487 IPC_END_MESSAGE_MAP()
482 return handled; 488 return handled;
483 } 489 }
484 490
485 void ExtensionHost::OnRequest(const ExtensionHostMsg_Request_Params& params) { 491 void ExtensionHost::OnRequest(const ExtensionHostMsg_Request_Params& params) {
486 extension_function_dispatcher_.Dispatch(params, render_view_host()); 492 extension_function_dispatcher_.Dispatch(params, render_view_host());
487 } 493 }
488 494
495 void ExtensionHost::OnEventAck() {
496 ExtensionEventRouter* router = ExtensionSystem::Get(profile_)->event_router();
497 if (router)
498 router->OnEventAck(profile_, extension_id());
499 }
500
501 void ExtensionHost::OnIncrementLazyKeepaliveCount() {
502 ExtensionProcessManager* pm =
503 ExtensionSystem::Get(profile_)->process_manager();
504 if (pm)
505 pm->IncrementLazyKeepaliveCount(extension());
506 }
507
508 void ExtensionHost::OnDecrementLazyKeepaliveCount() {
509 ExtensionProcessManager* pm =
510 ExtensionSystem::Get(profile_)->process_manager();
511 if (pm)
512 pm->DecrementLazyKeepaliveCount(extension());
513 }
514
515
489 void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) { 516 void ExtensionHost::RenderViewCreated(RenderViewHost* render_view_host) {
490 render_view_host_ = render_view_host; 517 render_view_host_ = render_view_host;
491 518
492 if (view_.get()) 519 if (view_.get())
493 view_->RenderViewCreated(); 520 view_->RenderViewCreated();
494 521
495 // If the host is bound to a browser, then extract its window id. 522 // If the host is bound to a browser, then extract its window id.
496 // Extensions hosted in ExternalTabContainer objects may not have 523 // Extensions hosted in ExternalTabContainer objects may not have
497 // an associated browser. 524 // an associated browser.
498 const Browser* browser = GetBrowser(); 525 const Browser* browser = GetBrowser();
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
572 params.user_gesture = user_gesture; 599 params.user_gesture = user_gesture;
573 browser::Navigate(&params); 600 browser::Navigate(&params);
574 } 601 }
575 602
576 void ExtensionHost::RenderViewReady() { 603 void ExtensionHost::RenderViewReady() {
577 content::NotificationService::current()->Notify( 604 content::NotificationService::current()->Notify(
578 chrome::NOTIFICATION_EXTENSION_HOST_CREATED, 605 chrome::NOTIFICATION_EXTENSION_HOST_CREATED,
579 content::Source<Profile>(profile_), 606 content::Source<Profile>(profile_),
580 content::Details<ExtensionHost>(this)); 607 content::Details<ExtensionHost>(this));
581 } 608 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698