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

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

Issue 10006037: Moved WebDataService to ProfileKeyedService (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fixed compile Created 8 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
« no previous file with comments | « chrome/test/base/testing_profile.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/test/base/testing_profile.h" 5 #include "chrome/test/base/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"
(...skipping 21 matching lines...) Expand all
32 #include "chrome/browser/notifications/desktop_notification_service_factory.h" 32 #include "chrome/browser/notifications/desktop_notification_service_factory.h"
33 #include "chrome/browser/prefs/browser_prefs.h" 33 #include "chrome/browser/prefs/browser_prefs.h"
34 #include "chrome/browser/prefs/testing_pref_store.h" 34 #include "chrome/browser/prefs/testing_pref_store.h"
35 #include "chrome/browser/prerender/prerender_manager.h" 35 #include "chrome/browser/prerender/prerender_manager.h"
36 #include "chrome/browser/profiles/profile_dependency_manager.h" 36 #include "chrome/browser/profiles/profile_dependency_manager.h"
37 #include "chrome/browser/protector/protector_service_factory.h" 37 #include "chrome/browser/protector/protector_service_factory.h"
38 #include "chrome/browser/search_engines/template_url_fetcher_factory.h" 38 #include "chrome/browser/search_engines/template_url_fetcher_factory.h"
39 #include "chrome/browser/search_engines/template_url_service.h" 39 #include "chrome/browser/search_engines/template_url_service.h"
40 #include "chrome/browser/search_engines/template_url_service_factory.h" 40 #include "chrome/browser/search_engines/template_url_service_factory.h"
41 #include "chrome/browser/speech/chrome_speech_recognition_preferences.h" 41 #include "chrome/browser/speech/chrome_speech_recognition_preferences.h"
42 #include "chrome/browser/sync/profile_sync_service_mock.h"
43 #include "chrome/browser/ui/webui/chrome_url_data_manager.h" 42 #include "chrome/browser/ui/webui/chrome_url_data_manager.h"
44 #include "chrome/common/chrome_constants.h" 43 #include "chrome/common/chrome_constants.h"
45 #include "chrome/common/chrome_notification_types.h" 44 #include "chrome/common/chrome_notification_types.h"
46 #include "chrome/common/chrome_switches.h" 45 #include "chrome/common/chrome_switches.h"
47 #include "chrome/common/url_constants.h" 46 #include "chrome/common/url_constants.h"
48 #include "chrome/test/base/bookmark_load_observer.h" 47 #include "chrome/test/base/bookmark_load_observer.h"
49 #include "chrome/test/base/testing_pref_service.h" 48 #include "chrome/test/base/testing_pref_service.h"
50 #include "chrome/test/base/ui_test_utils.h" 49 #include "chrome/test/base/ui_test_utils.h"
51 #include "content/public/browser/browser_thread.h" 50 #include "content/public/browser/browser_thread.h"
52 #include "content/public/browser/notification_service.h" 51 #include "content/public/browser/notification_service.h"
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 226
228 profile_dependency_manager_->DestroyProfileServices(this); 227 profile_dependency_manager_->DestroyProfileServices(this);
229 228
230 if (host_content_settings_map_) 229 if (host_content_settings_map_)
231 host_content_settings_map_->ShutdownOnUIThread(); 230 host_content_settings_map_->ShutdownOnUIThread();
232 231
233 DestroyTopSites(); 232 DestroyTopSites();
234 DestroyHistoryService(); 233 DestroyHistoryService();
235 // FaviconService depends on HistoryServce so destroying it later. 234 // FaviconService depends on HistoryServce so destroying it later.
236 DestroyFaviconService(); 235 DestroyFaviconService();
237 DestroyWebDataService();
238 236
239 if (pref_proxy_config_tracker_.get()) 237 if (pref_proxy_config_tracker_.get())
240 pref_proxy_config_tracker_->DetachFromPrefService(); 238 pref_proxy_config_tracker_->DetachFromPrefService();
241 } 239 }
242 240
243 void TestingProfile::CreateFaviconService() { 241 void TestingProfile::CreateFaviconService() {
244 favicon_service_.reset(new FaviconService(this)); 242 favicon_service_.reset(new FaviconService(this));
245 } 243 }
246 244
247 void TestingProfile::CreateHistoryService(bool delete_file, bool no_db) { 245 void TestingProfile::CreateHistoryService(bool delete_file, bool no_db) {
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after
320 318
321 void TestingProfile::CreateAutocompleteClassifier() { 319 void TestingProfile::CreateAutocompleteClassifier() {
322 autocomplete_classifier_.reset(new AutocompleteClassifier(this)); 320 autocomplete_classifier_.reset(new AutocompleteClassifier(this));
323 } 321 }
324 322
325 void TestingProfile::CreateProtocolHandlerRegistry() { 323 void TestingProfile::CreateProtocolHandlerRegistry() {
326 protocol_handler_registry_ = new ProtocolHandlerRegistry(this, 324 protocol_handler_registry_ = new ProtocolHandlerRegistry(this,
327 new ProtocolHandlerRegistry::Delegate()); 325 new ProtocolHandlerRegistry::Delegate());
328 } 326 }
329 327
330 void TestingProfile::CreateWebDataService(bool delete_file) {
331 if (web_data_service_.get())
332 web_data_service_->Shutdown();
333
334 if (delete_file) {
335 FilePath path = GetPath();
336 path = path.Append(chrome::kWebDataFilename);
337 file_util::Delete(path, false);
338 }
339
340 web_data_service_ = new WebDataService;
341 if (web_data_service_.get())
342 web_data_service_->Init(GetPath());
343 }
344
345 void TestingProfile::BlockUntilBookmarkModelLoaded() { 328 void TestingProfile::BlockUntilBookmarkModelLoaded() {
346 DCHECK(bookmark_bar_model_.get()); 329 DCHECK(bookmark_bar_model_.get());
347 if (bookmark_bar_model_->IsLoaded()) 330 if (bookmark_bar_model_->IsLoaded())
348 return; 331 return;
349 BookmarkLoadObserver observer; 332 BookmarkLoadObserver observer;
350 bookmark_bar_model_->AddObserver(&observer); 333 bookmark_bar_model_->AddObserver(&observer);
351 MessageLoop::current()->Run(); 334 MessageLoop::current()->Run();
352 bookmark_bar_model_->RemoveObserver(&observer); 335 bookmark_bar_model_->RemoveObserver(&observer);
353 DCHECK(bookmark_bar_model_->IsLoaded()); 336 DCHECK(bookmark_bar_model_->IsLoaded());
354 } 337 }
(...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after
480 } 463 }
481 464
482 AutocompleteClassifier* TestingProfile::GetAutocompleteClassifier() { 465 AutocompleteClassifier* TestingProfile::GetAutocompleteClassifier() {
483 return autocomplete_classifier_.get(); 466 return autocomplete_classifier_.get();
484 } 467 }
485 468
486 history::ShortcutsBackend* TestingProfile::GetShortcutsBackend() { 469 history::ShortcutsBackend* TestingProfile::GetShortcutsBackend() {
487 return NULL; 470 return NULL;
488 } 471 }
489 472
490 WebDataService* TestingProfile::GetWebDataService(ServiceAccessType access) {
491 return web_data_service_.get();
492 }
493
494 WebDataService* TestingProfile::GetWebDataServiceWithoutCreating() {
495 return web_data_service_.get();
496 }
497
498 void TestingProfile::SetPrefService(PrefService* prefs) { 473 void TestingProfile::SetPrefService(PrefService* prefs) {
499 #if defined(ENABLE_PROTECTOR_SERVICE) 474 #if defined(ENABLE_PROTECTOR_SERVICE)
500 // ProtectorService binds itself very closely to the PrefService at the moment 475 // ProtectorService binds itself very closely to the PrefService at the moment
501 // of Profile creation and watches pref changes to update their backup. 476 // of Profile creation and watches pref changes to update their backup.
502 // For tests that replace the PrefService after TestingProfile creation, 477 // For tests that replace the PrefService after TestingProfile creation,
503 // ProtectorService is disabled to prevent further invalid memory accesses. 478 // ProtectorService is disabled to prevent further invalid memory accesses.
504 protector::ProtectorServiceFactory::GetInstance()-> 479 protector::ProtectorServiceFactory::GetInstance()->
505 SetTestingFactory(this, NULL); 480 SetTestingFactory(this, NULL);
506 #endif 481 #endif
507 prefs_.reset(prefs); 482 prefs_.reset(prefs);
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
701 } 676 }
702 677
703 PrefService* TestingProfile::GetOffTheRecordPrefs() { 678 PrefService* TestingProfile::GetOffTheRecordPrefs() {
704 return NULL; 679 return NULL;
705 } 680 }
706 681
707 quota::SpecialStoragePolicy* TestingProfile::GetSpecialStoragePolicy() { 682 quota::SpecialStoragePolicy* TestingProfile::GetSpecialStoragePolicy() {
708 return GetExtensionSpecialStoragePolicy(); 683 return GetExtensionSpecialStoragePolicy();
709 } 684 }
710 685
711 void TestingProfile::DestroyWebDataService() {
712 if (!web_data_service_.get())
713 return;
714
715 web_data_service_->Shutdown();
716 }
717
718 bool TestingProfile::WasCreatedByVersionOrLater(const std::string& version) { 686 bool TestingProfile::WasCreatedByVersionOrLater(const std::string& version) {
719 return true; 687 return true;
720 } 688 }
OLDNEW
« no previous file with comments | « chrome/test/base/testing_profile.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698