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

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

Issue 166053003: Move ProfileKeyedAPI implementations to take BrowserContext in the constructor (part 2). (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: | Created 6 years, 10 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/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 692 matching lines...) Expand 10 before | Expand all | Expand 10 after
703 } else { 703 } else {
704 scoped_ptr<management::ExtensionInfo> info = CreateExtensionInfo( 704 scoped_ptr<management::ExtensionInfo> info = CreateExtensionInfo(
705 *extension, ExtensionSystem::Get(profile)); 705 *extension, ExtensionSystem::Get(profile));
706 args->Append(info->ToValue().release()); 706 args->Append(info->ToValue().release());
707 } 707 }
708 708
709 scoped_ptr<Event> event(new Event(event_name, args.Pass())); 709 scoped_ptr<Event> event(new Event(event_name, args.Pass()));
710 ExtensionSystem::Get(profile)->event_router()->BroadcastEvent(event.Pass()); 710 ExtensionSystem::Get(profile)->event_router()->BroadcastEvent(event.Pass());
711 } 711 }
712 712
713 ManagementAPI::ManagementAPI(Profile* profile) 713 ManagementAPI::ManagementAPI(content::BrowserContext* context)
714 : profile_(profile) { 714 : browser_context_(context) {
715 ExtensionSystem::Get(profile_)->event_router()->RegisterObserver( 715 EventRouter* event_router =
716 this, management::OnInstalled::kEventName); 716 ExtensionSystem::Get(browser_context_)->event_router();
717 ExtensionSystem::Get(profile_)->event_router()->RegisterObserver( 717 event_router->RegisterObserver(this, management::OnInstalled::kEventName);
718 this, management::OnUninstalled::kEventName); 718 event_router->RegisterObserver(this, management::OnUninstalled::kEventName);
719 ExtensionSystem::Get(profile_)->event_router()->RegisterObserver( 719 event_router->RegisterObserver(this, management::OnEnabled::kEventName);
720 this, management::OnEnabled::kEventName); 720 event_router->RegisterObserver(this, management::OnDisabled::kEventName);
721 ExtensionSystem::Get(profile_)->event_router()->RegisterObserver(
722 this, management::OnDisabled::kEventName);
723 } 721 }
724 722
725 ManagementAPI::~ManagementAPI() { 723 ManagementAPI::~ManagementAPI() {
726 } 724 }
727 725
728 void ManagementAPI::Shutdown() { 726 void ManagementAPI::Shutdown() {
729 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); 727 ExtensionSystem::Get(browser_context_)->event_router()->UnregisterObserver(
728 this);
730 } 729 }
731 730
732 static base::LazyInstance<ProfileKeyedAPIFactory<ManagementAPI> > 731 static base::LazyInstance<ProfileKeyedAPIFactory<ManagementAPI> >
733 g_factory = LAZY_INSTANCE_INITIALIZER; 732 g_factory = LAZY_INSTANCE_INITIALIZER;
734 733
735 // static 734 // static
736 ProfileKeyedAPIFactory<ManagementAPI>* ManagementAPI::GetFactoryInstance() { 735 ProfileKeyedAPIFactory<ManagementAPI>* ManagementAPI::GetFactoryInstance() {
737 return g_factory.Pointer(); 736 return g_factory.Pointer();
738 } 737 }
739 738
740 void ManagementAPI::OnListenerAdded(const EventListenerInfo& details) { 739 void ManagementAPI::OnListenerAdded(const EventListenerInfo& details) {
741 management_event_router_.reset(new ManagementEventRouter(profile_)); 740 management_event_router_.reset(
742 ExtensionSystem::Get(profile_)->event_router()->UnregisterObserver(this); 741 new ManagementEventRouter(Profile::FromBrowserContext(browser_context_)));
742 ExtensionSystem::Get(browser_context_)->event_router()->UnregisterObserver(
743 this);
743 } 744 }
744 745
745 } // namespace extensions 746 } // namespace extensions
OLDNEW
« no previous file with comments | « chrome/browser/extensions/api/management/management_api.h ('k') | chrome/browser/extensions/api/mdns/mdns_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698