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

Side by Side Diff: chrome/browser/ui/app_list/start_page_service.cc

Issue 148083014: ExtensionSystem cleanup part 3 (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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/ui/app_list/start_page_service.h" 5 #include "chrome/browser/ui/app_list/start_page_service.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/memory/singleton.h" 10 #include "base/memory/singleton.h"
11 #include "chrome/browser/chrome_notification_types.h" 11 #include "chrome/browser/chrome_notification_types.h"
12 #include "chrome/browser/extensions/extension_system_factory.h"
13 #include "chrome/browser/extensions/install_tracker_factory.h" 12 #include "chrome/browser/extensions/install_tracker_factory.h"
14 #include "chrome/browser/media/media_stream_infobar_delegate.h" 13 #include "chrome/browser/media/media_stream_infobar_delegate.h"
15 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
16 #include "chrome/browser/ui/app_list/recommended_apps.h" 15 #include "chrome/browser/ui/app_list/recommended_apps.h"
17 #include "chrome/browser/ui/app_list/start_page_observer.h" 16 #include "chrome/browser/ui/app_list/start_page_observer.h"
18 #include "chrome/common/chrome_switches.h" 17 #include "chrome/common/chrome_switches.h"
19 #include "chrome/common/url_constants.h" 18 #include "chrome/common/url_constants.h"
20 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h" 19 #include "components/browser_context_keyed_service/browser_context_dependency_ma nager.h"
21 #include "components/browser_context_keyed_service/browser_context_keyed_service _factory.h" 20 #include "components/browser_context_keyed_service/browser_context_keyed_service _factory.h"
22 #include "content/public/browser/notification_details.h" 21 #include "content/public/browser/notification_details.h"
23 #include "content/public/browser/notification_observer.h" 22 #include "content/public/browser/notification_observer.h"
24 #include "content/public/browser/notification_registrar.h" 23 #include "content/public/browser/notification_registrar.h"
25 #include "content/public/browser/notification_service.h" 24 #include "content/public/browser/notification_service.h"
26 #include "content/public/browser/notification_source.h" 25 #include "content/public/browser/notification_source.h"
27 #include "content/public/browser/web_contents.h" 26 #include "content/public/browser/web_contents.h"
28 #include "content/public/browser/web_contents_delegate.h" 27 #include "content/public/browser/web_contents_delegate.h"
28 #include "extensions/browser/extension_system_provider.h"
29 #include "extensions/browser/extensions_browser_client.h"
29 #include "extensions/common/extension.h" 30 #include "extensions/common/extension.h"
30 #include "ui/app_list/app_list_switches.h" 31 #include "ui/app_list/app_list_switches.h"
31 32
32 namespace app_list { 33 namespace app_list {
33 34
34 class StartPageService::Factory : public BrowserContextKeyedServiceFactory { 35 class StartPageService::Factory : public BrowserContextKeyedServiceFactory {
35 public: 36 public:
36 static StartPageService* GetForProfile(Profile* profile) { 37 static StartPageService* GetForProfile(Profile* profile) {
37 if (!CommandLine::ForCurrentProcess()->HasSwitch( 38 if (!CommandLine::ForCurrentProcess()->HasSwitch(
38 ::switches::kShowAppListStartPage) && 39 ::switches::kShowAppListStartPage) &&
39 !app_list::switches::IsVoiceSearchEnabled()) { 40 !app_list::switches::IsVoiceSearchEnabled()) {
40 return NULL; 41 return NULL;
41 } 42 }
42 43
43 return static_cast<StartPageService*>( 44 return static_cast<StartPageService*>(
44 GetInstance()->GetServiceForBrowserContext(profile, true)); 45 GetInstance()->GetServiceForBrowserContext(profile, true));
45 } 46 }
46 47
47 static Factory* GetInstance() { 48 static Factory* GetInstance() {
48 return Singleton<Factory>::get(); 49 return Singleton<Factory>::get();
49 } 50 }
50 51
51 private: 52 private:
52 friend struct DefaultSingletonTraits<Factory>; 53 friend struct DefaultSingletonTraits<Factory>;
53 54
54 Factory() 55 Factory()
55 : BrowserContextKeyedServiceFactory( 56 : BrowserContextKeyedServiceFactory(
56 "AppListStartPageService", 57 "AppListStartPageService",
57 BrowserContextDependencyManager::GetInstance()) { 58 BrowserContextDependencyManager::GetInstance()) {
58 DependsOn(extensions::ExtensionSystemFactory::GetInstance()); 59 DependsOn(extensions::ExtensionsBrowserClient::Get()
60 ->GetExtensionSystemFactory());
59 DependsOn(extensions::InstallTrackerFactory::GetInstance()); 61 DependsOn(extensions::InstallTrackerFactory::GetInstance());
60 } 62 }
61 63
62 virtual ~Factory() {} 64 virtual ~Factory() {}
63 65
64 // BrowserContextKeyedServiceFactory overrides: 66 // BrowserContextKeyedServiceFactory overrides:
65 virtual BrowserContextKeyedService* BuildServiceInstanceFor( 67 virtual BrowserContextKeyedService* BuildServiceInstanceFor(
66 content::BrowserContext* context) const OVERRIDE { 68 content::BrowserContext* context) const OVERRIDE {
67 Profile* profile = static_cast<Profile*>(context); 69 Profile* profile = static_cast<Profile*>(context);
68 return new StartPageService(profile); 70 return new StartPageService(profile);
(...skipping 117 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 FOR_EACH_OBSERVER(StartPageObserver, 188 FOR_EACH_OBSERVER(StartPageObserver,
187 observers_, 189 observers_,
188 OnSpeechRecognitionStateChanged(new_state)); 190 OnSpeechRecognitionStateChanged(new_state));
189 } 191 }
190 192
191 void StartPageService::Shutdown() { 193 void StartPageService::Shutdown() {
192 contents_.reset(); 194 contents_.reset();
193 } 195 }
194 196
195 } // namespace app_list 197 } // namespace app_list
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698