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

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

Issue 7243012: Change many extension event routers to not be singletons and to be more profile-aware. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: bookmark remove observer Created 9 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
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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_service.h" 5 #include "chrome/browser/extensions/extension_service.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <set> 8 #include <set>
9 9
10 #include "base/basictypes.h" 10 #include "base/basictypes.h"
(...skipping 625 matching lines...) Expand 10 before | Expand all | Expand 10 after
636 ExtensionService::~ExtensionService() { 636 ExtensionService::~ExtensionService() {
637 // No need to unload extensions here because they are profile-scoped, and the 637 // No need to unload extensions here because they are profile-scoped, and the
638 // profile is in the process of being deleted. 638 // profile is in the process of being deleted.
639 639
640 ProviderCollection::const_iterator i; 640 ProviderCollection::const_iterator i;
641 for (i = external_extension_providers_.begin(); 641 for (i = external_extension_providers_.begin();
642 i != external_extension_providers_.end(); ++i) { 642 i != external_extension_providers_.end(); ++i) {
643 ExternalExtensionProviderInterface* provider = i->get(); 643 ExternalExtensionProviderInterface* provider = i->get();
644 provider->ServiceShutdown(); 644 provider->ServiceShutdown();
645 } 645 }
646
647 #if defined(OS_CHROMEOS)
648 if (event_routers_initialized_) {
649 ExtensionFileBrowserEventRouter::GetInstance()->
650 StopObservingFileSystemEvents();
651 }
652 #endif
653 } 646 }
654 647
655 void ExtensionService::InitEventRouters() { 648 void ExtensionService::InitEventRouters() {
656 if (event_routers_initialized_) 649 if (event_routers_initialized_)
657 return; 650 return;
658 651
659 ExtensionHistoryEventRouter::GetInstance()->ObserveProfile(profile_); 652 history_event_router_.reset(new ExtensionHistoryEventRouter());
653 history_event_router_->ObserveProfile(profile_);
660 ExtensionAccessibilityEventRouter::GetInstance()->ObserveProfile(profile_); 654 ExtensionAccessibilityEventRouter::GetInstance()->ObserveProfile(profile_);
661 browser_event_router_.reset(new ExtensionBrowserEventRouter(profile_)); 655 browser_event_router_.reset(new ExtensionBrowserEventRouter(profile_));
662 browser_event_router_->Init(); 656 browser_event_router_->Init();
663 preference_event_router_.reset(new ExtensionPreferenceEventRouter(profile_)); 657 preference_event_router_.reset(new ExtensionPreferenceEventRouter(profile_));
664 ExtensionBookmarkEventRouter::GetInstance()->Observe( 658 bookmark_event_router_.reset(new ExtensionBookmarkEventRouter(
665 profile_->GetBookmarkModel()); 659 profile_->GetBookmarkModel()));
666 ExtensionCookiesEventRouter::GetInstance()->Init(); 660 bookmark_event_router_->Init();
667 ExtensionManagementEventRouter::GetInstance()->Init(); 661 cookies_event_router_.reset(new ExtensionCookiesEventRouter());
662 cookies_event_router_->ObserveProfile(profile_);
663 management_event_router_.reset(new ExtensionManagementEventRouter());
664 management_event_router_->ObserveProfile(profile_);
668 ExtensionProcessesEventRouter::GetInstance()->ObserveProfile(profile_); 665 ExtensionProcessesEventRouter::GetInstance()->ObserveProfile(profile_);
669 ExtensionWebNavigationEventRouter::GetInstance()->Init(); 666 web_navigation_event_router_.reset(
667 new ExtensionWebNavigationEventRouter(profile_));
668 web_navigation_event_router_->Init();
670 669
671 #if defined(OS_CHROMEOS) 670 #if defined(OS_CHROMEOS)
672 ExtensionFileBrowserEventRouter::GetInstance()->ObserveFileSystemEvents( 671 file_browser_event_router_.reset(
673 profile_); 672 new ExtensionFileBrowserEventRouter(profile_));
674 ExtensionMediaPlayerEventRouter::GetInstance()->Init(profile_); 673 file_browser_event_router_->Init();
675 #endif 674 #endif
676 675
677 #if defined(OS_CHROMEOS) && defined(TOUCH_UI) 676 #if defined(OS_CHROMEOS) && defined(TOUCH_UI)
678 ExtensionInputUiEventRouter::GetInstance()->Init(); 677 ExtensionInputUiEventRouter::GetInstance()->Init();
679 #endif 678 #endif
680 679
681 event_routers_initialized_ = true; 680 event_routers_initialized_ = true;
682 } 681 }
683 682
684 const Extension* ExtensionService::GetExtensionById( 683 const Extension* ExtensionService::GetExtensionById(
(...skipping 1725 matching lines...) Expand 10 before | Expand all | Expand 10 after
2410 2409
2411 ExtensionService::NaClModuleInfoList::iterator 2410 ExtensionService::NaClModuleInfoList::iterator
2412 ExtensionService::FindNaClModule(const GURL& url) { 2411 ExtensionService::FindNaClModule(const GURL& url) {
2413 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); 2412 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin();
2414 iter != nacl_module_list_.end(); ++iter) { 2413 iter != nacl_module_list_.end(); ++iter) {
2415 if (iter->url == url) 2414 if (iter->url == url)
2416 return iter; 2415 return iter;
2417 } 2416 }
2418 return nacl_module_list_.end(); 2417 return nacl_module_list_.end();
2419 } 2418 }
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_service.h ('k') | chrome/browser/extensions/extension_webnavigation_api.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698