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

Side by Side Diff: chrome/test/testing_profile.cc

Issue 6803012: Profile shouldn't own DesktopNotificationService. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Lint Created 9 years, 8 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/test/testing_profile.h" 5 #include "chrome/test/testing_profile.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 8
9 #include "base/base_paths.h" 9 #include "base/base_paths.h"
10 #include "base/command_line.h" 10 #include "base/command_line.h"
11 #include "base/file_util.h" 11 #include "base/file_util.h"
12 #include "base/message_loop_proxy.h" 12 #include "base/message_loop_proxy.h"
13 #include "base/path_service.h" 13 #include "base/path_service.h"
14 #include "base/string_number_conversions.h" 14 #include "base/string_number_conversions.h"
15 #include "chrome/browser/autocomplete/autocomplete_classifier.h" 15 #include "chrome/browser/autocomplete/autocomplete_classifier.h"
16 #include "chrome/browser/bookmarks/bookmark_model.h" 16 #include "chrome/browser/bookmarks/bookmark_model.h"
17 #include "chrome/browser/content_settings/host_content_settings_map.h" 17 #include "chrome/browser/content_settings/host_content_settings_map.h"
18 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" 18 #include "chrome/browser/custom_handlers/protocol_handler_registry.h"
19 #include "chrome/browser/extensions/extension_pref_value_map.h" 19 #include "chrome/browser/extensions/extension_pref_value_map.h"
20 #include "chrome/browser/extensions/extension_service.h" 20 #include "chrome/browser/extensions/extension_service.h"
21 #include "chrome/browser/extensions/extension_special_storage_policy.h" 21 #include "chrome/browser/extensions/extension_special_storage_policy.h"
22 #include "chrome/browser/favicon_service.h" 22 #include "chrome/browser/favicon_service.h"
23 #include "chrome/browser/geolocation/geolocation_content_settings_map.h" 23 #include "chrome/browser/geolocation/geolocation_content_settings_map.h"
24 #include "chrome/browser/history/history.h" 24 #include "chrome/browser/history/history.h"
25 #include "chrome/browser/history/history_backend.h" 25 #include "chrome/browser/history/history_backend.h"
26 #include "chrome/browser/history/top_sites.h" 26 #include "chrome/browser/history/top_sites.h"
27 #include "chrome/browser/net/gaia/token_service.h" 27 #include "chrome/browser/net/gaia/token_service.h"
28 #include "chrome/browser/net/pref_proxy_config_service.h" 28 #include "chrome/browser/net/pref_proxy_config_service.h"
29 #include "chrome/browser/notifications/desktop_notification_service.h" 29 #include "chrome/browser/notifications/desktop_notification_service.h"
30 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
30 #include "chrome/browser/prefs/browser_prefs.h" 31 #include "chrome/browser/prefs/browser_prefs.h"
31 #include "chrome/browser/prefs/testing_pref_store.h" 32 #include "chrome/browser/prefs/testing_pref_store.h"
32 #include "chrome/browser/prerender/prerender_manager.h" 33 #include "chrome/browser/prerender/prerender_manager.h"
33 #include "chrome/browser/profiles/profile_dependency_manager.h" 34 #include "chrome/browser/profiles/profile_dependency_manager.h"
34 #include "chrome/browser/search_engines/template_url_fetcher.h" 35 #include "chrome/browser/search_engines/template_url_fetcher.h"
35 #include "chrome/browser/search_engines/template_url_model.h" 36 #include "chrome/browser/search_engines/template_url_model.h"
36 #include "chrome/browser/sessions/session_service.h" 37 #include "chrome/browser/sessions/session_service.h"
37 #include "chrome/browser/sync/profile_sync_service_mock.h" 38 #include "chrome/browser/sync/profile_sync_service_mock.h"
38 #include "chrome/browser/ui/find_bar/find_bar_state.h" 39 #include "chrome/browser/ui/find_bar/find_bar_state.h"
39 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 40 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after
134 return context_.get(); 135 return context_.get();
135 } 136 }
136 virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const { 137 virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const {
137 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); 138 return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO);
138 } 139 }
139 140
140 private: 141 private:
141 scoped_refptr<net::URLRequestContext> context_; 142 scoped_refptr<net::URLRequestContext> context_;
142 }; 143 };
143 144
145 ProfileKeyedService* CreateTestDesktopNotificationService(Profile* profile) {
146 return new DesktopNotificationService(profile, NULL);
147 }
148
144 } // namespace 149 } // namespace
145 150
146 TestingProfile::TestingProfile() 151 TestingProfile::TestingProfile()
147 : start_time_(Time::Now()), 152 : start_time_(Time::Now()),
148 testing_prefs_(NULL), 153 testing_prefs_(NULL),
149 incognito_(false), 154 incognito_(false),
150 last_session_exited_cleanly_(true), 155 last_session_exited_cleanly_(true),
151 profile_dependency_manager_(ProfileDependencyManager::GetInstance()) { 156 profile_dependency_manager_(ProfileDependencyManager::GetInstance()) {
152 if (!temp_dir_.CreateUniqueTempDir()) { 157 if (!temp_dir_.CreateUniqueTempDir()) {
153 LOG(ERROR) << "Failed to create unique temporary directory."; 158 LOG(ERROR) << "Failed to create unique temporary directory.";
(...skipping 11 matching lines...) Expand all
165 file_util::Delete(fallback_dir, true); 170 file_util::Delete(fallback_dir, true);
166 file_util::CreateDirectory(fallback_dir); 171 file_util::CreateDirectory(fallback_dir);
167 if (!temp_dir_.Set(fallback_dir)) { 172 if (!temp_dir_.Set(fallback_dir)) {
168 // That shouldn't happen, but if it does, try to recover. 173 // That shouldn't happen, but if it does, try to recover.
169 LOG(ERROR) << "Failed to use a fallback temporary directory."; 174 LOG(ERROR) << "Failed to use a fallback temporary directory.";
170 175
171 // We're screwed if this fails, see CHECK above. 176 // We're screwed if this fails, see CHECK above.
172 CHECK(temp_dir_.Set(system_tmp_dir)); 177 CHECK(temp_dir_.Set(system_tmp_dir));
173 } 178 }
174 } 179 }
180
181 // Install profile keyed service factory hooks for dummy/test services
182 DesktopNotificationServiceFactory::GetInstance()->set_factory_function(
183 &CreateTestDesktopNotificationService);
175 } 184 }
176 185
177 TestingProfile::~TestingProfile() { 186 TestingProfile::~TestingProfile() {
178 NotificationService::current()->Notify( 187 NotificationService::current()->Notify(
179 NotificationType::PROFILE_DESTROYED, 188 NotificationType::PROFILE_DESTROYED,
180 Source<Profile>(static_cast<Profile*>(this)), 189 Source<Profile>(static_cast<Profile*>(this)),
181 NotificationService::NoDetails()); 190 NotificationService::NoDetails());
182 191
183 profile_dependency_manager_->DestroyProfileServices(this); 192 profile_dependency_manager_->DestroyProfileServices(this);
184 193
(...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
686 WebKitContext* TestingProfile::GetOffTheRecordWebKitContext() { 695 WebKitContext* TestingProfile::GetOffTheRecordWebKitContext() {
687 return NULL; 696 return NULL;
688 } 697 }
689 698
690 NTPResourceCache* TestingProfile::GetNTPResourceCache() { 699 NTPResourceCache* TestingProfile::GetNTPResourceCache() {
691 if (!ntp_resource_cache_.get()) 700 if (!ntp_resource_cache_.get())
692 ntp_resource_cache_.reset(new NTPResourceCache(this)); 701 ntp_resource_cache_.reset(new NTPResourceCache(this));
693 return ntp_resource_cache_.get(); 702 return ntp_resource_cache_.get();
694 } 703 }
695 704
696 DesktopNotificationService* TestingProfile::GetDesktopNotificationService() {
697 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI));
698 if (!desktop_notification_service_.get()) {
699 desktop_notification_service_.reset(new DesktopNotificationService(
700 this, NULL));
701 }
702 return desktop_notification_service_.get();
703 }
704
705 BackgroundContentsService* 705 BackgroundContentsService*
706 TestingProfile::GetBackgroundContentsService() const { 706 TestingProfile::GetBackgroundContentsService() const {
707 return NULL; 707 return NULL;
708 } 708 }
709 709
710 StatusTray* TestingProfile::GetStatusTray() { 710 StatusTray* TestingProfile::GetStatusTray() {
711 return NULL; 711 return NULL;
712 } 712 }
713 713
714 FilePath TestingProfile::last_selected_directory() { 714 FilePath TestingProfile::last_selected_directory() {
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
808 } 808 }
809 809
810 DerivedTestingProfile::DerivedTestingProfile(Profile* profile) 810 DerivedTestingProfile::DerivedTestingProfile(Profile* profile)
811 : original_profile_(profile) {} 811 : original_profile_(profile) {}
812 812
813 DerivedTestingProfile::~DerivedTestingProfile() {} 813 DerivedTestingProfile::~DerivedTestingProfile() {}
814 814
815 ProfileId DerivedTestingProfile::GetRuntimeId() { 815 ProfileId DerivedTestingProfile::GetRuntimeId() {
816 return original_profile_->GetRuntimeId(); 816 return original_profile_->GetRuntimeId();
817 } 817 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698