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

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

Issue 777863002: Introduce new component webdata_services (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove unnecessary DEPS on //ui, sort dependencies Created 6 years 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
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 "base/base_paths.h" 7 #include "base/base_paths.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/message_loop/message_loop_proxy.h" 10 #include "base/message_loop/message_loop_proxy.h"
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
42 #include "chrome/browser/profiles/profile_manager.h" 42 #include "chrome/browser/profiles/profile_manager.h"
43 #include "chrome/browser/profiles/storage_partition_descriptor.h" 43 #include "chrome/browser/profiles/storage_partition_descriptor.h"
44 #include "chrome/browser/search_engines/template_url_fetcher_factory.h" 44 #include "chrome/browser/search_engines/template_url_fetcher_factory.h"
45 #include "chrome/browser/webdata/web_data_service_factory.h" 45 #include "chrome/browser/webdata/web_data_service_factory.h"
46 #include "chrome/common/chrome_constants.h" 46 #include "chrome/common/chrome_constants.h"
47 #include "chrome/common/chrome_switches.h" 47 #include "chrome/common/chrome_switches.h"
48 #include "chrome/common/pref_names.h" 48 #include "chrome/common/pref_names.h"
49 #include "chrome/common/url_constants.h" 49 #include "chrome/common/url_constants.h"
50 #include "chrome/test/base/history_index_restore_observer.h" 50 #include "chrome/test/base/history_index_restore_observer.h"
51 #include "chrome/test/base/testing_pref_service_syncable.h" 51 #include "chrome/test/base/testing_pref_service_syncable.h"
52 #include "components/autofill/core/browser/webdata/autofill_webdata_service.h"
52 #include "components/bookmarks/browser/bookmark_model.h" 53 #include "components/bookmarks/browser/bookmark_model.h"
53 #include "components/bookmarks/common/bookmark_constants.h" 54 #include "components/bookmarks/common/bookmark_constants.h"
54 #include "components/content_settings/core/browser/host_content_settings_map.h" 55 #include "components/content_settings/core/browser/host_content_settings_map.h"
55 #include "components/history/core/browser/history_constants.h" 56 #include "components/history/core/browser/history_constants.h"
56 #include "components/history/core/browser/top_sites_observer.h" 57 #include "components/history/core/browser/top_sites_observer.h"
57 #include "components/keyed_service/content/browser_context_dependency_manager.h" 58 #include "components/keyed_service/content/browser_context_dependency_manager.h"
58 #include "components/policy/core/common/policy_service.h" 59 #include "components/policy/core/common/policy_service.h"
59 #include "components/user_prefs/user_prefs.h" 60 #include "components/user_prefs/user_prefs.h"
61 #include "components/webdata_services/web_data_service_wrapper.h"
60 #include "content/public/browser/browser_thread.h" 62 #include "content/public/browser/browser_thread.h"
61 #include "content/public/browser/cookie_store_factory.h" 63 #include "content/public/browser/cookie_store_factory.h"
62 #include "content/public/browser/notification_service.h" 64 #include "content/public/browser/notification_service.h"
63 #include "content/public/browser/render_process_host.h" 65 #include "content/public/browser/render_process_host.h"
64 #include "content/public/browser/storage_partition.h" 66 #include "content/public/browser/storage_partition.h"
65 #include "content/public/test/mock_resource_context.h" 67 #include "content/public/test/mock_resource_context.h"
66 #include "content/public/test/test_utils.h" 68 #include "content/public/test/test_utils.h"
67 #include "extensions/common/constants.h" 69 #include "extensions/common/constants.h"
68 #include "net/cookies/cookie_monster.h" 70 #include "net/cookies/cookie_monster.h"
69 #include "net/url_request/url_request_context.h" 71 #include "net/url_request/url_request_context.h"
(...skipping 30 matching lines...) Expand all
100 #endif 102 #endif
101 103
102 using base::Time; 104 using base::Time;
103 using content::BrowserThread; 105 using content::BrowserThread;
104 using content::DownloadManagerDelegate; 106 using content::DownloadManagerDelegate;
105 using testing::NiceMock; 107 using testing::NiceMock;
106 using testing::Return; 108 using testing::Return;
107 109
108 namespace { 110 namespace {
109 111
112 // Use for WebDataServiceWrapper constructor.
113 void TestProfileErrorCallback(WebDataServiceWrapper::ErrorType error_type,
114 sql::InitStatus status) {
115 NOTREACHED();
116 }
117
110 // Used to make sure TopSites has finished loading 118 // Used to make sure TopSites has finished loading
111 class WaitTopSitesLoadedObserver : public history::TopSitesObserver { 119 class WaitTopSitesLoadedObserver : public history::TopSitesObserver {
112 public: 120 public:
113 explicit WaitTopSitesLoadedObserver(content::MessageLoopRunner* runner) 121 explicit WaitTopSitesLoadedObserver(content::MessageLoopRunner* runner)
114 : runner_(runner) {} 122 : runner_(runner) {}
115 void TopSitesLoaded(history::TopSites* top_sites) override { 123 void TopSitesLoaded(history::TopSites* top_sites) override {
116 runner_->Quit(); 124 runner_->Quit();
117 } 125 }
118 void TopSitesChanged(history::TopSites* top_sites) override {} 126 void TopSitesChanged(history::TopSites* top_sites) override {}
119 127
(...skipping 460 matching lines...) Expand 10 before | Expand all | Expand 10 after
580 } 588 }
581 ChromeHistoryClientFactory::GetInstance()->SetTestingFactory( 589 ChromeHistoryClientFactory::GetInstance()->SetTestingFactory(
582 this, BuildChromeHistoryClient); 590 this, BuildChromeHistoryClient);
583 ChromeBookmarkClientFactory::GetInstance()->SetTestingFactory( 591 ChromeBookmarkClientFactory::GetInstance()->SetTestingFactory(
584 this, BuildChromeBookmarkClient); 592 this, BuildChromeBookmarkClient);
585 // This creates the BookmarkModel. 593 // This creates the BookmarkModel.
586 ignore_result(BookmarkModelFactory::GetInstance()->SetTestingFactoryAndUse( 594 ignore_result(BookmarkModelFactory::GetInstance()->SetTestingFactoryAndUse(
587 this, BuildBookmarkModel)); 595 this, BuildBookmarkModel));
588 } 596 }
589 597
590 static KeyedService* BuildWebDataService(content::BrowserContext* profile) { 598 static KeyedService* BuildWebDataService(content::BrowserContext* profile) {
Peter Kasting 2014/12/05 21:47:56 Nit: While here: It's weird that this file has bot
sdefresne 2014/12/08 10:54:42 Done.
591 return new WebDataServiceWrapper(static_cast<Profile*>(profile)); 599 WebDataServiceWrapper* web_data_service_wrapper = new WebDataServiceWrapper(
600 static_cast<Profile*>(profile)->GetPath(),
601 g_browser_process->GetApplicationLocale(),
602 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::UI),
603 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::DB),
604 &TestProfileErrorCallback);
605 web_data_service_wrapper->GetAutofillWebData()->GetAutofillBackend(
606 base::Bind(&InitSyncableServicesOnDBThread,
607 web_data_service_wrapper->GetAutofillWebData(),
608 static_cast<Profile*>(profile)->GetPath(),
609 g_browser_process->GetApplicationLocale()));
610 return web_data_service_wrapper;
592 } 611 }
593 612
594 void TestingProfile::CreateWebDataService() { 613 void TestingProfile::CreateWebDataService() {
595 WebDataServiceFactory::GetInstance()->SetTestingFactory( 614 WebDataServiceFactory::GetInstance()->SetTestingFactory(
596 this, BuildWebDataService); 615 this, BuildWebDataService);
597 } 616 }
598 617
599 void TestingProfile::BlockUntilHistoryIndexIsRefreshed() { 618 void TestingProfile::BlockUntilHistoryIndexIsRefreshed() {
600 // Only get the history service if it actually exists since the caller of the 619 // Only get the history service if it actually exists since the caller of the
601 // test should explicitly call CreateHistoryService to build it. 620 // test should explicitly call CreateHistoryService to build it.
(...skipping 440 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 #if defined(ENABLE_EXTENSIONS) 1061 #if defined(ENABLE_EXTENSIONS)
1043 extension_policy_, 1062 extension_policy_,
1044 #endif 1063 #endif
1045 pref_service_.Pass(), 1064 pref_service_.Pass(),
1046 original_profile, 1065 original_profile,
1047 guest_session_, 1066 guest_session_,
1048 supervised_user_id_, 1067 supervised_user_id_,
1049 policy_service_.Pass(), 1068 policy_service_.Pass(),
1050 testing_factories_); 1069 testing_factories_);
1051 } 1070 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698