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

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: 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 bookmark_event_router_->Observe(profile_->GetBookmarkModel());
666 ExtensionCookiesEventRouter::GetInstance()->Init(); 660 cookies_event_router_.reset(new ExtensionCookiesEventRouter());
667 ExtensionManagementEventRouter::GetInstance()->Init(); 661 cookies_event_router_->ObserveProfile(profile_);
662 management_event_router_.reset(new ExtensionManagementEventRouter());
663 management_event_router_->ObserveProfile(profile_);
668 ExtensionProcessesEventRouter::GetInstance()->ObserveProfile(profile_); 664 ExtensionProcessesEventRouter::GetInstance()->ObserveProfile(profile_);
669 ExtensionWebNavigationEventRouter::GetInstance()->Init(); 665 web_navigation_event_router_.reset(
666 new ExtensionWebNavigationEventRouter(profile_));
667 web_navigation_event_router_->Init();
670 668
671 #if defined(OS_CHROMEOS) 669 #if defined(OS_CHROMEOS)
672 ExtensionFileBrowserEventRouter::GetInstance()->ObserveFileSystemEvents( 670 file_browser_event_router_.reset(
673 profile_); 671 new ExtensionFileBrowserEventRouter(profile_));
674 ExtensionMediaPlayerEventRouter::GetInstance()->Init(profile_); 672 file_browser_event_router_->Init();
675 #endif 673 #endif
676 674
677 #if defined(OS_CHROMEOS) && defined(TOUCH_UI) 675 #if defined(OS_CHROMEOS) && defined(TOUCH_UI)
678 ExtensionInputUiEventRouter::GetInstance()->Init(); 676 ExtensionInputUiEventRouter::GetInstance()->Init();
679 #endif 677 #endif
680 678
681 event_routers_initialized_ = true; 679 event_routers_initialized_ = true;
682 } 680 }
683 681
684 const Extension* ExtensionService::GetExtensionById( 682 const Extension* ExtensionService::GetExtensionById(
(...skipping 1725 matching lines...) Expand 10 before | Expand all | Expand 10 after
2410 2408
2411 ExtensionService::NaClModuleInfoList::iterator 2409 ExtensionService::NaClModuleInfoList::iterator
2412 ExtensionService::FindNaClModule(const GURL& url) { 2410 ExtensionService::FindNaClModule(const GURL& url) {
2413 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin(); 2411 for (NaClModuleInfoList::iterator iter = nacl_module_list_.begin();
2414 iter != nacl_module_list_.end(); ++iter) { 2412 iter != nacl_module_list_.end(); ++iter) {
2415 if (iter->url == url) 2413 if (iter->url == url)
2416 return iter; 2414 return iter;
2417 } 2415 }
2418 return nacl_module_list_.end(); 2416 return nacl_module_list_.end();
2419 } 2417 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698