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

Side by Side Diff: chrome/browser/extensions/api/management/management_api.cc

Issue 11366074: Coalesce event router Init calls into their constructors. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: aa Created 8 years, 1 month 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/api/management/management_api.h" 5 #include "chrome/browser/extensions/api/management/management_api.h"
6 6
7 #include <map> 7 #include <map>
8 #include <string> 8 #include <string>
9 #include <vector> 9 #include <vector>
10 10
(...skipping 565 matching lines...) Expand 10 before | Expand all | Expand 10 after
576 Finish(true); 576 Finish(true);
577 Release(); 577 Release();
578 } 578 }
579 579
580 void UninstallFunction::ExtensionUninstallCanceled() { 580 void UninstallFunction::ExtensionUninstallCanceled() {
581 Finish(false); 581 Finish(false);
582 Release(); 582 Release();
583 } 583 }
584 584
585 ExtensionManagementEventRouter::ExtensionManagementEventRouter(Profile* profile) 585 ExtensionManagementEventRouter::ExtensionManagementEventRouter(Profile* profile)
586 : profile_(profile) {} 586 : profile_(profile) {
587
588 ExtensionManagementEventRouter::~ExtensionManagementEventRouter() {}
589
590 void ExtensionManagementEventRouter::Init() {
591 int types[] = { 587 int types[] = {
592 chrome::NOTIFICATION_EXTENSION_INSTALLED, 588 chrome::NOTIFICATION_EXTENSION_INSTALLED,
593 chrome::NOTIFICATION_EXTENSION_UNINSTALLED, 589 chrome::NOTIFICATION_EXTENSION_UNINSTALLED,
594 chrome::NOTIFICATION_EXTENSION_LOADED, 590 chrome::NOTIFICATION_EXTENSION_LOADED,
595 chrome::NOTIFICATION_EXTENSION_UNLOADED 591 chrome::NOTIFICATION_EXTENSION_UNLOADED
596 }; 592 };
597 593
598 CHECK(registrar_.IsEmpty()); 594 CHECK(registrar_.IsEmpty());
599 for (size_t i = 0; i < arraysize(types); i++) { 595 for (size_t i = 0; i < arraysize(types); i++) {
600 registrar_.Add(this, 596 registrar_.Add(this,
601 types[i], 597 types[i],
602 content::Source<Profile>(profile_)); 598 content::Source<Profile>(profile_));
603 } 599 }
604 } 600 }
605 601
602 ExtensionManagementEventRouter::~ExtensionManagementEventRouter() {}
603
606 void ExtensionManagementEventRouter::Observe( 604 void ExtensionManagementEventRouter::Observe(
607 int type, 605 int type,
608 const content::NotificationSource& source, 606 const content::NotificationSource& source,
609 const content::NotificationDetails& details) { 607 const content::NotificationDetails& details) {
610 const char* event_name = NULL; 608 const char* event_name = NULL;
611 Profile* profile = content::Source<Profile>(source).ptr(); 609 Profile* profile = content::Source<Profile>(source).ptr();
612 CHECK(profile); 610 CHECK(profile);
613 CHECK(profile_->IsSameProfile(profile)); 611 CHECK(profile_->IsSameProfile(profile));
614 612
615 switch (type) { 613 switch (type) {
(...skipping 29 matching lines...) Expand all
645 CHECK(extension); 643 CHECK(extension);
646 scoped_ptr<management::ExtensionInfo> info = CreateExtensionInfo( 644 scoped_ptr<management::ExtensionInfo> info = CreateExtensionInfo(
647 *extension, ExtensionSystem::Get(profile)); 645 *extension, ExtensionSystem::Get(profile));
648 args->Append(info->ToValue().release()); 646 args->Append(info->ToValue().release());
649 } 647 }
650 648
651 extensions::ExtensionSystem::Get(profile)->event_router()-> 649 extensions::ExtensionSystem::Get(profile)->event_router()->
652 DispatchEventToRenderers(event_name, args.Pass(), NULL, GURL(), 650 DispatchEventToRenderers(event_name, args.Pass(), NULL, GURL(),
653 extensions::EventFilteringInfo()); 651 extensions::EventFilteringInfo());
654 } 652 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698