[email protected] | aeb53f0 | 2011-01-15 00:21:34 | [diff] [blame] | 1 | // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 2 | // Use of this source code is governed by a BSD-style license that can be |
| 3 | // found in the LICENSE file. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 4 | |
| 5 | #include "chrome/test/testing_profile.h" |
| 6 | |
[email protected] | a42b559 | 2009-09-03 16:52:23 | [diff] [blame] | 7 | #include "build/build_config.h" |
[email protected] | dbbad7a | 2010-08-13 18:18:36 | [diff] [blame] | 8 | |
| 9 | #include "base/base_paths.h" |
[email protected] | e3e43d9 | 2010-02-26 22:02:38 | [diff] [blame] | 10 | #include "base/command_line.h" |
[email protected] | dbbad7a | 2010-08-13 18:18:36 | [diff] [blame] | 11 | #include "base/file_util.h" |
[email protected] | 83a7d2eb | 2010-05-03 21:46:19 | [diff] [blame] | 12 | #include "base/message_loop_proxy.h" |
[email protected] | dbbad7a | 2010-08-13 18:18:36 | [diff] [blame] | 13 | #include "base/path_service.h" |
[email protected] | e83326f | 2010-07-31 17:29:25 | [diff] [blame] | 14 | #include "base/string_number_conversions.h" |
[email protected] | dbbad7a | 2010-08-13 18:18:36 | [diff] [blame] | 15 | #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
[email protected] | a9afddb | 2009-02-12 17:49:42 | [diff] [blame] | 16 | #include "chrome/browser/bookmarks/bookmark_model.h" |
[email protected] | 8281e48e | 2010-10-12 18:54:49 | [diff] [blame] | 17 | #include "chrome/browser/browser_thread.h" |
[email protected] | 9d01a6a | 2010-11-30 12:03:33 | [diff] [blame] | 18 | #include "chrome/browser/content_settings/host_content_settings_map.h" |
[email protected] | 248ce19 | 2011-02-10 15:26:34 | [diff] [blame] | 19 | #include "chrome/browser/dom_ui/chrome_url_data_manager.h" |
[email protected] | 156ed27b | 2009-11-23 18:31:25 | [diff] [blame] | 20 | #include "chrome/browser/dom_ui/ntp_resource_cache.h" |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 21 | #include "chrome/browser/extensions/extension_service.h" |
[email protected] | 9a8c402 | 2011-01-25 14:25:33 | [diff] [blame] | 22 | #include "chrome/browser/extensions/extension_pref_value_map.h" |
[email protected] | dbbad7a | 2010-08-13 18:18:36 | [diff] [blame] | 23 | #include "chrome/browser/favicon_service.h" |
[email protected] | dbbad7a | 2010-08-13 18:18:36 | [diff] [blame] | 24 | #include "chrome/browser/geolocation/geolocation_content_settings_map.h" |
| 25 | #include "chrome/browser/geolocation/geolocation_permission_context.h" |
| 26 | #include "chrome/browser/history/history.h" |
[email protected] | 075ae73 | 2009-02-11 23:58:31 | [diff] [blame] | 27 | #include "chrome/browser/history/history_backend.h" |
[email protected] | dbbad7a | 2010-08-13 18:18:36 | [diff] [blame] | 28 | #include "chrome/browser/history/top_sites.h" |
[email protected] | b071b6c | 2010-08-25 20:28:03 | [diff] [blame] | 29 | #include "chrome/browser/in_process_webkit/webkit_context.h" |
[email protected] | 8e4c2961 | 2010-07-14 01:24:45 | [diff] [blame] | 30 | #include "chrome/browser/net/gaia/token_service.h" |
[email protected] | cc5bfd4 | 2010-11-24 14:44:02 | [diff] [blame] | 31 | #include "chrome/browser/net/pref_proxy_config_service.h" |
[email protected] | dbbad7a | 2010-08-13 18:18:36 | [diff] [blame] | 32 | #include "chrome/browser/notifications/desktop_notification_service.h" |
[email protected] | 37858e5 | 2010-08-26 00:22:02 | [diff] [blame] | 33 | #include "chrome/browser/prefs/browser_prefs.h" |
[email protected] | 9a8c402 | 2011-01-25 14:25:33 | [diff] [blame] | 34 | #include "chrome/browser/prefs/testing_pref_store.h" |
[email protected] | fb9d1f4 | 2010-10-06 23:17:59 | [diff] [blame] | 35 | #include "chrome/browser/search_engines/template_url_fetcher.h" |
[email protected] | dbbad7a | 2010-08-13 18:18:36 | [diff] [blame] | 36 | #include "chrome/browser/search_engines/template_url_model.h" |
[email protected] | 8cb5d5b | 2010-02-09 11:36:16 | [diff] [blame] | 37 | #include "chrome/browser/sessions/session_service.h" |
[email protected] | 4772b07 | 2010-03-30 17:45:46 | [diff] [blame] | 38 | #include "chrome/browser/sync/profile_sync_service_mock.h" |
[email protected] | b071b6c | 2010-08-25 20:28:03 | [diff] [blame] | 39 | #include "chrome/browser/themes/browser_theme_provider.h" |
[email protected] | 45300ad4 | 2010-12-02 15:51:14 | [diff] [blame] | 40 | #include "chrome/browser/ui/find_bar/find_bar_state.h" |
[email protected] | a9afddb | 2009-02-12 17:49:42 | [diff] [blame] | 41 | #include "chrome/common/chrome_constants.h" |
[email protected] | 68d2a05f | 2010-05-07 21:39:55 | [diff] [blame] | 42 | #include "chrome/common/net/url_request_context_getter.h" |
[email protected] | d2879af | 2010-02-08 16:02:56 | [diff] [blame] | 43 | #include "chrome/common/notification_service.h" |
[email protected] | dbbad7a | 2010-08-13 18:18:36 | [diff] [blame] | 44 | #include "chrome/common/url_constants.h" |
[email protected] | 5138bbff | 2010-12-08 09:41:44 | [diff] [blame] | 45 | #include "chrome/test/test_url_request_context_getter.h" |
[email protected] | 93270d00 | 2011-01-19 22:32:59 | [diff] [blame] | 46 | #include "chrome/test/testing_pref_service.h" |
[email protected] | 809cc4d | 2010-10-27 15:22:54 | [diff] [blame] | 47 | #include "chrome/test/ui_test_utils.h" |
[email protected] | dbbad7a | 2010-08-13 18:18:36 | [diff] [blame] | 48 | #include "net/base/cookie_monster.h" |
[email protected] | 812b3a3 | 2010-01-08 05:36:04 | [diff] [blame] | 49 | #include "net/url_request/url_request_context.h" |
[email protected] | d2db029 | 2011-01-26 20:23:44 | [diff] [blame] | 50 | #include "net/url_request/url_request_test_util.h" |
[email protected] | 4772b07 | 2010-03-30 17:45:46 | [diff] [blame] | 51 | #include "testing/gmock/include/gmock/gmock.h" |
[email protected] | 2f351cb | 2009-11-09 23:43:34 | [diff] [blame] | 52 | #include "webkit/database/database_tracker.h" |
[email protected] | 248ce19 | 2011-02-10 15:26:34 | [diff] [blame] | 53 | |
[email protected] | a42b559 | 2009-09-03 16:52:23 | [diff] [blame] | 54 | #if defined(OS_LINUX) && !defined(TOOLKIT_VIEWS) |
[email protected] | 93270d00 | 2011-01-19 22:32:59 | [diff] [blame] | 55 | #include "chrome/browser/ui/gtk/gtk_theme_provider.h" |
[email protected] | a42b559 | 2009-09-03 16:52:23 | [diff] [blame] | 56 | #endif |
| 57 | |
[email protected] | e1acf6f | 2008-10-27 20:43:33 | [diff] [blame] | 58 | using base::Time; |
[email protected] | 3c88741 | 2010-04-19 20:30:23 | [diff] [blame] | 59 | using testing::NiceMock; |
[email protected] | 4772b07 | 2010-03-30 17:45:46 | [diff] [blame] | 60 | using testing::Return; |
[email protected] | e1acf6f | 2008-10-27 20:43:33 | [diff] [blame] | 61 | |
[email protected] | d364c65 | 2008-08-29 19:46:56 | [diff] [blame] | 62 | namespace { |
| 63 | |
[email protected] | 0bfc29a | 2009-04-27 16:15:44 | [diff] [blame] | 64 | // Task used to make sure history has finished processing a request. Intended |
| 65 | // for use with BlockUntilHistoryProcessesPendingRequests. |
| 66 | |
| 67 | class QuittingHistoryDBTask : public HistoryDBTask { |
| 68 | public: |
| 69 | QuittingHistoryDBTask() {} |
| 70 | |
| 71 | virtual bool RunOnDBThread(history::HistoryBackend* backend, |
| 72 | history::HistoryDatabase* db) { |
| 73 | return true; |
| 74 | } |
| 75 | |
| 76 | virtual void DoneRunOnMainThread() { |
| 77 | MessageLoop::current()->Quit(); |
| 78 | } |
| 79 | |
| 80 | private: |
[email protected] | 7991a23 | 2009-11-06 01:55:48 | [diff] [blame] | 81 | ~QuittingHistoryDBTask() {} |
| 82 | |
[email protected] | 0bfc29a | 2009-04-27 16:15:44 | [diff] [blame] | 83 | DISALLOW_COPY_AND_ASSIGN(QuittingHistoryDBTask); |
| 84 | }; |
| 85 | |
[email protected] | d8e41ed | 2008-09-11 15:22:32 | [diff] [blame] | 86 | // BookmarkLoadObserver is used when blocking until the BookmarkModel |
| 87 | // finishes loading. As soon as the BookmarkModel finishes loading the message |
| 88 | // loop is quit. |
| 89 | class BookmarkLoadObserver : public BookmarkModelObserver { |
[email protected] | d364c65 | 2008-08-29 19:46:56 | [diff] [blame] | 90 | public: |
| 91 | BookmarkLoadObserver() {} |
[email protected] | d8e41ed | 2008-09-11 15:22:32 | [diff] [blame] | 92 | virtual void Loaded(BookmarkModel* model) { |
[email protected] | d364c65 | 2008-08-29 19:46:56 | [diff] [blame] | 93 | MessageLoop::current()->Quit(); |
| 94 | } |
| 95 | |
[email protected] | d8e41ed | 2008-09-11 15:22:32 | [diff] [blame] | 96 | virtual void BookmarkNodeMoved(BookmarkModel* model, |
[email protected] | b3c33d46 | 2009-06-26 22:29:20 | [diff] [blame] | 97 | const BookmarkNode* old_parent, |
[email protected] | d364c65 | 2008-08-29 19:46:56 | [diff] [blame] | 98 | int old_index, |
[email protected] | b3c33d46 | 2009-06-26 22:29:20 | [diff] [blame] | 99 | const BookmarkNode* new_parent, |
[email protected] | d364c65 | 2008-08-29 19:46:56 | [diff] [blame] | 100 | int new_index) {} |
[email protected] | d8e41ed | 2008-09-11 15:22:32 | [diff] [blame] | 101 | virtual void BookmarkNodeAdded(BookmarkModel* model, |
[email protected] | b3c33d46 | 2009-06-26 22:29:20 | [diff] [blame] | 102 | const BookmarkNode* parent, |
[email protected] | d364c65 | 2008-08-29 19:46:56 | [diff] [blame] | 103 | int index) {} |
[email protected] | d8e41ed | 2008-09-11 15:22:32 | [diff] [blame] | 104 | virtual void BookmarkNodeRemoved(BookmarkModel* model, |
[email protected] | b3c33d46 | 2009-06-26 22:29:20 | [diff] [blame] | 105 | const BookmarkNode* parent, |
[email protected] | 6696502 | 2009-07-15 17:20:01 | [diff] [blame] | 106 | int old_index, |
| 107 | const BookmarkNode* node) {} |
[email protected] | d8e41ed | 2008-09-11 15:22:32 | [diff] [blame] | 108 | virtual void BookmarkNodeChanged(BookmarkModel* model, |
[email protected] | b3c33d46 | 2009-06-26 22:29:20 | [diff] [blame] | 109 | const BookmarkNode* node) {} |
[email protected] | 58b359d | 2009-02-27 22:05:08 | [diff] [blame] | 110 | virtual void BookmarkNodeChildrenReordered(BookmarkModel* model, |
[email protected] | b3c33d46 | 2009-06-26 22:29:20 | [diff] [blame] | 111 | const BookmarkNode* node) {} |
[email protected] | d8e41ed | 2008-09-11 15:22:32 | [diff] [blame] | 112 | virtual void BookmarkNodeFavIconLoaded(BookmarkModel* model, |
[email protected] | b3c33d46 | 2009-06-26 22:29:20 | [diff] [blame] | 113 | const BookmarkNode* node) {} |
[email protected] | d364c65 | 2008-08-29 19:46:56 | [diff] [blame] | 114 | |
| 115 | private: |
| 116 | DISALLOW_COPY_AND_ASSIGN(BookmarkLoadObserver); |
| 117 | }; |
| 118 | |
[email protected] | aeb53f0 | 2011-01-15 00:21:34 | [diff] [blame] | 119 | class TestExtensionURLRequestContext : public net::URLRequestContext { |
[email protected] | c10da4b0 | 2010-03-25 14:38:32 | [diff] [blame] | 120 | public: |
| 121 | TestExtensionURLRequestContext() { |
| 122 | net::CookieMonster* cookie_monster = new net::CookieMonster(NULL, NULL); |
| 123 | const char* schemes[] = {chrome::kExtensionScheme}; |
| 124 | cookie_monster->SetCookieableSchemes(schemes, 1); |
[email protected] | 182fe2f | 2011-02-14 20:35:15 | [diff] [blame] | 125 | cookie_store_ = cookie_monster; |
[email protected] | c10da4b0 | 2010-03-25 14:38:32 | [diff] [blame] | 126 | } |
| 127 | }; |
| 128 | |
| 129 | class TestExtensionURLRequestContextGetter : public URLRequestContextGetter { |
| 130 | public: |
[email protected] | aeb53f0 | 2011-01-15 00:21:34 | [diff] [blame] | 131 | virtual net::URLRequestContext* GetURLRequestContext() { |
[email protected] | c10da4b0 | 2010-03-25 14:38:32 | [diff] [blame] | 132 | if (!context_) |
| 133 | context_ = new TestExtensionURLRequestContext(); |
| 134 | return context_.get(); |
| 135 | } |
[email protected] | 00ed48f | 2010-10-22 22:19:24 | [diff] [blame] | 136 | virtual scoped_refptr<base::MessageLoopProxy> GetIOMessageLoopProxy() const { |
[email protected] | 0c7d74f | 2010-10-11 11:55:26 | [diff] [blame] | 137 | return BrowserThread::GetMessageLoopProxyForThread(BrowserThread::IO); |
[email protected] | 83a7d2eb | 2010-05-03 21:46:19 | [diff] [blame] | 138 | } |
[email protected] | c10da4b0 | 2010-03-25 14:38:32 | [diff] [blame] | 139 | |
| 140 | private: |
[email protected] | aeb53f0 | 2011-01-15 00:21:34 | [diff] [blame] | 141 | scoped_refptr<net::URLRequestContext> context_; |
[email protected] | c10da4b0 | 2010-03-25 14:38:32 | [diff] [blame] | 142 | }; |
| 143 | |
[email protected] | d364c65 | 2008-08-29 19:46:56 | [diff] [blame] | 144 | } // namespace |
| 145 | |
[email protected] | f25387b | 2008-08-21 15:20:33 | [diff] [blame] | 146 | TestingProfile::TestingProfile() |
[email protected] | ea6f7657 | 2008-12-18 00:09:55 | [diff] [blame] | 147 | : start_time_(Time::Now()), |
[email protected] | 2fb7dc98 | 2010-09-29 12:24:28 | [diff] [blame] | 148 | testing_prefs_(NULL), |
[email protected] | a42b559 | 2009-09-03 16:52:23 | [diff] [blame] | 149 | created_theme_provider_(false), |
[email protected] | ea6f7657 | 2008-12-18 00:09:55 | [diff] [blame] | 150 | has_history_service_(false), |
| 151 | off_the_record_(false), |
| 152 | last_session_exited_cleanly_(true) { |
[email protected] | f9dec948 | 2010-08-20 20:42:19 | [diff] [blame] | 153 | if (!temp_dir_.CreateUniqueTempDir()) { |
| 154 | LOG(ERROR) << "Failed to create unique temporary directory."; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 155 | |
[email protected] | f9dec948 | 2010-08-20 20:42:19 | [diff] [blame] | 156 | // Fallback logic in case we fail to create unique temporary directory. |
| 157 | FilePath system_tmp_dir; |
| 158 | bool success = PathService::Get(base::DIR_TEMP, &system_tmp_dir); |
[email protected] | 848cd05e | 2008-09-19 18:33:48 | [diff] [blame] | 159 | |
[email protected] | f9dec948 | 2010-08-20 20:42:19 | [diff] [blame] | 160 | // We're severly screwed if we can't get the system temporary |
| 161 | // directory. Die now to avoid writing to the filesystem root |
| 162 | // or other bad places. |
| 163 | CHECK(success); |
| 164 | |
| 165 | FilePath fallback_dir(system_tmp_dir.AppendASCII("TestingProfilePath")); |
| 166 | file_util::Delete(fallback_dir, true); |
| 167 | file_util::CreateDirectory(fallback_dir); |
| 168 | if (!temp_dir_.Set(fallback_dir)) { |
| 169 | // That shouldn't happen, but if it does, try to recover. |
| 170 | LOG(ERROR) << "Failed to use a fallback temporary directory."; |
| 171 | |
| 172 | // We're screwed if this fails, see CHECK above. |
| 173 | CHECK(temp_dir_.Set(system_tmp_dir)); |
| 174 | } |
| 175 | } |
[email protected] | ab23dbe | 2010-08-12 02:10:46 | [diff] [blame] | 176 | } |
| 177 | |
[email protected] | f25387b | 2008-08-21 15:20:33 | [diff] [blame] | 178 | TestingProfile::~TestingProfile() { |
[email protected] | d2879af | 2010-02-08 16:02:56 | [diff] [blame] | 179 | NotificationService::current()->Notify( |
| 180 | NotificationType::PROFILE_DESTROYED, |
| 181 | Source<Profile>(this), |
| 182 | NotificationService::NoDetails()); |
[email protected] | 809cc4d | 2010-10-27 15:22:54 | [diff] [blame] | 183 | DestroyTopSites(); |
[email protected] | f25387b | 2008-08-21 15:20:33 | [diff] [blame] | 184 | DestroyHistoryService(); |
[email protected] | d2879af | 2010-02-08 16:02:56 | [diff] [blame] | 185 | // FaviconService depends on HistoryServce so destroying it later. |
| 186 | DestroyFaviconService(); |
[email protected] | 2609bc1 | 2010-01-24 08:32:55 | [diff] [blame] | 187 | DestroyWebDataService(); |
[email protected] | 2fb7dc98 | 2010-09-29 12:24:28 | [diff] [blame] | 188 | if (extensions_service_.get()) { |
| 189 | extensions_service_->DestroyingProfile(); |
| 190 | extensions_service_ = NULL; |
| 191 | } |
[email protected] | cc5bfd4 | 2010-11-24 14:44:02 | [diff] [blame] | 192 | if (pref_proxy_config_tracker_.get()) |
| 193 | pref_proxy_config_tracker_->DetachFromPrefService(); |
[email protected] | f25387b | 2008-08-21 15:20:33 | [diff] [blame] | 194 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 195 | |
[email protected] | d2879af | 2010-02-08 16:02:56 | [diff] [blame] | 196 | void TestingProfile::CreateFaviconService() { |
| 197 | favicon_service_ = NULL; |
| 198 | favicon_service_ = new FaviconService(this); |
| 199 | } |
| 200 | |
[email protected] | d486a085 | 2009-11-02 21:40:00 | [diff] [blame] | 201 | void TestingProfile::CreateHistoryService(bool delete_file, bool no_db) { |
[email protected] | 809cc4d | 2010-10-27 15:22:54 | [diff] [blame] | 202 | DestroyHistoryService(); |
[email protected] | f25387b | 2008-08-21 15:20:33 | [diff] [blame] | 203 | if (delete_file) { |
[email protected] | f7011fcb | 2009-01-28 21:54:32 | [diff] [blame] | 204 | FilePath path = GetPath(); |
| 205 | path = path.Append(chrome::kHistoryFilename); |
[email protected] | f25387b | 2008-08-21 15:20:33 | [diff] [blame] | 206 | file_util::Delete(path, false); |
| 207 | } |
[email protected] | 90ef1313 | 2008-08-27 03:27:46 | [diff] [blame] | 208 | history_service_ = new HistoryService(this); |
[email protected] | d486a085 | 2009-11-02 21:40:00 | [diff] [blame] | 209 | history_service_->Init(GetPath(), bookmark_bar_model_.get(), no_db); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 210 | } |
| 211 | |
| 212 | void TestingProfile::DestroyHistoryService() { |
| 213 | if (!history_service_.get()) |
| 214 | return; |
| 215 | |
| 216 | history_service_->NotifyRenderProcessHostDestruction(0); |
| 217 | history_service_->SetOnBackendDestroyTask(new MessageLoop::QuitTask); |
| 218 | history_service_->Cleanup(); |
| 219 | history_service_ = NULL; |
| 220 | |
| 221 | // Wait for the backend class to terminate before deleting the files and |
| 222 | // moving to the next test. Note: if this never terminates, somebody is |
| 223 | // probably leaking a reference to the history backend, so it never calls |
| 224 | // our destroy task. |
| 225 | MessageLoop::current()->Run(); |
| 226 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 227 | // Make sure we don't have any event pending that could disrupt the next |
| 228 | // test. |
| 229 | MessageLoop::current()->PostTask(FROM_HERE, new MessageLoop::QuitTask); |
| 230 | MessageLoop::current()->Run(); |
| 231 | } |
[email protected] | 4d0cd7ce | 2008-08-11 16:40:57 | [diff] [blame] | 232 | |
[email protected] | 809cc4d | 2010-10-27 15:22:54 | [diff] [blame] | 233 | void TestingProfile::CreateTopSites() { |
| 234 | DestroyTopSites(); |
| 235 | top_sites_ = new history::TopSites(this); |
[email protected] | 73c4793 | 2010-12-06 18:13:43 | [diff] [blame] | 236 | FilePath file_name = GetPath().Append(chrome::kTopSitesFilename); |
[email protected] | 809cc4d | 2010-10-27 15:22:54 | [diff] [blame] | 237 | top_sites_->Init(file_name); |
| 238 | } |
| 239 | |
| 240 | void TestingProfile::DestroyTopSites() { |
| 241 | if (top_sites_.get()) { |
| 242 | top_sites_->Shutdown(); |
| 243 | top_sites_ = NULL; |
| 244 | // TopSites::Shutdown schedules some tasks (from TopSitesBackend) that need |
| 245 | // to be run to properly shutdown. Run all pending tasks now. This is |
| 246 | // normally handled by browser_process shutdown. |
| 247 | if (MessageLoop::current()) |
| 248 | MessageLoop::current()->RunAllPending(); |
| 249 | } |
| 250 | } |
| 251 | |
| 252 | void TestingProfile::DestroyFaviconService() { |
| 253 | if (!favicon_service_.get()) |
| 254 | return; |
| 255 | favicon_service_ = NULL; |
| 256 | } |
| 257 | |
[email protected] | d8e41ed | 2008-09-11 15:22:32 | [diff] [blame] | 258 | void TestingProfile::CreateBookmarkModel(bool delete_file) { |
[email protected] | 90ef1313 | 2008-08-27 03:27:46 | [diff] [blame] | 259 | // Nuke the model first, that way we're sure it's done writing to disk. |
| 260 | bookmark_bar_model_.reset(NULL); |
| 261 | |
| 262 | if (delete_file) { |
[email protected] | f7011fcb | 2009-01-28 21:54:32 | [diff] [blame] | 263 | FilePath path = GetPath(); |
| 264 | path = path.Append(chrome::kBookmarksFileName); |
[email protected] | 90ef1313 | 2008-08-27 03:27:46 | [diff] [blame] | 265 | file_util::Delete(path, false); |
| 266 | } |
[email protected] | d8e41ed | 2008-09-11 15:22:32 | [diff] [blame] | 267 | bookmark_bar_model_.reset(new BookmarkModel(this)); |
[email protected] | 90ef1313 | 2008-08-27 03:27:46 | [diff] [blame] | 268 | if (history_service_.get()) { |
| 269 | history_service_->history_backend_->bookmark_service_ = |
| 270 | bookmark_bar_model_.get(); |
| 271 | history_service_->history_backend_->expirer_.bookmark_service_ = |
| 272 | bookmark_bar_model_.get(); |
| 273 | } |
| 274 | bookmark_bar_model_->Load(); |
[email protected] | 4d0cd7ce | 2008-08-11 16:40:57 | [diff] [blame] | 275 | } |
[email protected] | d2c017a | 2008-08-13 21:51:45 | [diff] [blame] | 276 | |
[email protected] | 69c579e | 2010-04-23 20:01:00 | [diff] [blame] | 277 | void TestingProfile::CreateAutocompleteClassifier() { |
| 278 | autocomplete_classifier_.reset(new AutocompleteClassifier(this)); |
| 279 | } |
| 280 | |
[email protected] | 2609bc1 | 2010-01-24 08:32:55 | [diff] [blame] | 281 | void TestingProfile::CreateWebDataService(bool delete_file) { |
| 282 | if (web_data_service_.get()) |
| 283 | web_data_service_->Shutdown(); |
| 284 | |
| 285 | if (delete_file) { |
| 286 | FilePath path = GetPath(); |
| 287 | path = path.Append(chrome::kWebDataFilename); |
| 288 | file_util::Delete(path, false); |
| 289 | } |
| 290 | |
| 291 | web_data_service_ = new WebDataService; |
| 292 | if (web_data_service_.get()) |
| 293 | web_data_service_->Init(GetPath()); |
| 294 | } |
| 295 | |
[email protected] | d364c65 | 2008-08-29 19:46:56 | [diff] [blame] | 296 | void TestingProfile::BlockUntilBookmarkModelLoaded() { |
| 297 | DCHECK(bookmark_bar_model_.get()); |
| 298 | if (bookmark_bar_model_->IsLoaded()) |
| 299 | return; |
| 300 | BookmarkLoadObserver observer; |
| 301 | bookmark_bar_model_->AddObserver(&observer); |
| 302 | MessageLoop::current()->Run(); |
| 303 | bookmark_bar_model_->RemoveObserver(&observer); |
| 304 | DCHECK(bookmark_bar_model_->IsLoaded()); |
| 305 | } |
| 306 | |
[email protected] | 809cc4d | 2010-10-27 15:22:54 | [diff] [blame] | 307 | void TestingProfile::BlockUntilTopSitesLoaded() { |
| 308 | if (!GetHistoryService(Profile::EXPLICIT_ACCESS)) |
| 309 | GetTopSites()->HistoryLoaded(); |
| 310 | ui_test_utils::WaitForNotification(NotificationType::TOP_SITES_LOADED); |
| 311 | } |
| 312 | |
[email protected] | fb9d1f4 | 2010-10-06 23:17:59 | [diff] [blame] | 313 | void TestingProfile::CreateTemplateURLFetcher() { |
| 314 | template_url_fetcher_.reset(new TemplateURLFetcher(this)); |
| 315 | } |
| 316 | |
[email protected] | d2c017a | 2008-08-13 21:51:45 | [diff] [blame] | 317 | void TestingProfile::CreateTemplateURLModel() { |
[email protected] | fb9d1f4 | 2010-10-06 23:17:59 | [diff] [blame] | 318 | SetTemplateURLModel(new TemplateURLModel(this)); |
| 319 | } |
| 320 | |
| 321 | void TestingProfile::SetTemplateURLModel(TemplateURLModel* model) { |
| 322 | template_url_model_.reset(model); |
[email protected] | d2c017a | 2008-08-13 21:51:45 | [diff] [blame] | 323 | } |
[email protected] | 0bfc29a | 2009-04-27 16:15:44 | [diff] [blame] | 324 | |
[email protected] | a42b559 | 2009-09-03 16:52:23 | [diff] [blame] | 325 | void TestingProfile::UseThemeProvider(BrowserThemeProvider* theme_provider) { |
| 326 | theme_provider->Init(this); |
| 327 | created_theme_provider_ = true; |
[email protected] | 761962c | 2009-09-25 00:18:15 | [diff] [blame] | 328 | theme_provider_.reset(theme_provider); |
[email protected] | a42b559 | 2009-09-03 16:52:23 | [diff] [blame] | 329 | } |
| 330 | |
[email protected] | 9a8c402 | 2011-01-25 14:25:33 | [diff] [blame] | 331 | ExtensionService* TestingProfile::CreateExtensionService( |
[email protected] | 2fb7dc98 | 2010-09-29 12:24:28 | [diff] [blame] | 332 | const CommandLine* command_line, |
| 333 | const FilePath& install_directory) { |
[email protected] | 9a8c402 | 2011-01-25 14:25:33 | [diff] [blame] | 334 | // Extension pref store, created for use by |extension_prefs_|. |
| 335 | |
| 336 | extension_pref_value_map_.reset(new ExtensionPrefValueMap); |
| 337 | // Note that the GetPrefs() creates a TestingPrefService, therefore |
| 338 | // the extension controlled pref values set in extension_prefs_ |
| 339 | // are not reflected in the pref service. One would need to |
| 340 | // inject a new ExtensionPrefStore(extension_pref_value_map_.get(), false). |
| 341 | extension_prefs_.reset( |
| 342 | new ExtensionPrefs(GetPrefs(), |
| 343 | install_directory, |
| 344 | extension_pref_value_map_.get())); |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 345 | extensions_service_ = new ExtensionService(this, |
[email protected] | 9a8c402 | 2011-01-25 14:25:33 | [diff] [blame] | 346 | command_line, |
| 347 | install_directory, |
| 348 | extension_prefs_.get(), |
| 349 | false); |
[email protected] | 2fb7dc98 | 2010-09-29 12:24:28 | [diff] [blame] | 350 | return extensions_service_; |
| 351 | } |
| 352 | |
[email protected] | f9dec948 | 2010-08-20 20:42:19 | [diff] [blame] | 353 | FilePath TestingProfile::GetPath() { |
| 354 | DCHECK(temp_dir_.IsValid()); // TODO(phajdan.jr): do it better. |
| 355 | return temp_dir_.path(); |
| 356 | } |
| 357 | |
[email protected] | dbbad7a | 2010-08-13 18:18:36 | [diff] [blame] | 358 | TestingPrefService* TestingProfile::GetTestingPrefService() { |
[email protected] | 2fb7dc98 | 2010-09-29 12:24:28 | [diff] [blame] | 359 | if (!prefs_.get()) |
| 360 | CreateTestingPrefService(); |
| 361 | DCHECK(testing_prefs_); |
| 362 | return testing_prefs_; |
[email protected] | dbbad7a | 2010-08-13 18:18:36 | [diff] [blame] | 363 | } |
| 364 | |
[email protected] | fadc607b6 | 2011-02-07 17:55:50 | [diff] [blame] | 365 | ProfileId TestingProfile::GetRuntimeId() { |
| 366 | return reinterpret_cast<ProfileId>(this); |
| 367 | } |
| 368 | |
| 369 | bool TestingProfile::IsOffTheRecord() { |
| 370 | return off_the_record_; |
| 371 | } |
| 372 | |
| 373 | Profile* TestingProfile::GetOffTheRecordProfile() { |
| 374 | return NULL; |
| 375 | } |
| 376 | |
| 377 | bool TestingProfile::HasOffTheRecordProfile() { |
| 378 | return false; |
| 379 | } |
| 380 | |
| 381 | Profile* TestingProfile::GetOriginalProfile() { |
| 382 | return this; |
| 383 | } |
| 384 | |
| 385 | ChromeAppCacheService* TestingProfile::GetAppCacheService() { |
| 386 | return NULL; |
| 387 | } |
| 388 | |
[email protected] | 2f351cb | 2009-11-09 23:43:34 | [diff] [blame] | 389 | webkit_database::DatabaseTracker* TestingProfile::GetDatabaseTracker() { |
| 390 | if (!db_tracker_) |
[email protected] | fe615f3 | 2010-06-13 09:08:41 | [diff] [blame] | 391 | db_tracker_ = new webkit_database::DatabaseTracker(GetPath(), false); |
[email protected] | 2f351cb | 2009-11-09 23:43:34 | [diff] [blame] | 392 | return db_tracker_; |
| 393 | } |
| 394 | |
[email protected] | fadc607b6 | 2011-02-07 17:55:50 | [diff] [blame] | 395 | VisitedLinkMaster* TestingProfile::GetVisitedLinkMaster() { |
| 396 | return NULL; |
| 397 | } |
| 398 | |
[email protected] | eaa7dd18 | 2010-12-14 11:09:00 | [diff] [blame] | 399 | ExtensionService* TestingProfile::GetExtensionService() { |
[email protected] | 2fb7dc98 | 2010-09-29 12:24:28 | [diff] [blame] | 400 | return extensions_service_.get(); |
| 401 | } |
| 402 | |
[email protected] | fadc607b6 | 2011-02-07 17:55:50 | [diff] [blame] | 403 | UserScriptMaster* TestingProfile::GetUserScriptMaster() { |
| 404 | return NULL; |
| 405 | } |
| 406 | |
| 407 | ExtensionDevToolsManager* TestingProfile::GetExtensionDevToolsManager() { |
| 408 | return NULL; |
| 409 | } |
| 410 | |
| 411 | ExtensionProcessManager* TestingProfile::GetExtensionProcessManager() { |
| 412 | return NULL; |
| 413 | } |
| 414 | |
| 415 | ExtensionMessageService* TestingProfile::GetExtensionMessageService() { |
| 416 | return NULL; |
| 417 | } |
| 418 | |
| 419 | ExtensionEventRouter* TestingProfile::GetExtensionEventRouter() { |
| 420 | return NULL; |
| 421 | } |
| 422 | |
| 423 | ExtensionIOEventRouter* TestingProfile::GetExtensionIOEventRouter() { |
| 424 | return NULL; |
| 425 | } |
| 426 | |
| 427 | SSLHostState* TestingProfile::GetSSLHostState() { |
| 428 | return NULL; |
| 429 | } |
| 430 | |
| 431 | net::TransportSecurityState* TestingProfile::GetTransportSecurityState() { |
| 432 | return NULL; |
| 433 | } |
| 434 | |
| 435 | FaviconService* TestingProfile::GetFaviconService(ServiceAccessType access) { |
| 436 | return favicon_service_.get(); |
| 437 | } |
| 438 | |
| 439 | HistoryService* TestingProfile::GetHistoryService(ServiceAccessType access) { |
| 440 | return history_service_.get(); |
| 441 | } |
| 442 | |
| 443 | HistoryService* TestingProfile::GetHistoryServiceWithoutCreating() { |
| 444 | return history_service_.get(); |
| 445 | } |
| 446 | |
[email protected] | dbbad7a | 2010-08-13 18:18:36 | [diff] [blame] | 447 | net::CookieMonster* TestingProfile::GetCookieMonster() { |
| 448 | if (!GetRequestContext()) |
| 449 | return NULL; |
| 450 | return GetRequestContext()->GetCookieStore()->GetCookieMonster(); |
| 451 | } |
| 452 | |
[email protected] | fadc607b6 | 2011-02-07 17:55:50 | [diff] [blame] | 453 | AutocompleteClassifier* TestingProfile::GetAutocompleteClassifier() { |
| 454 | return autocomplete_classifier_.get(); |
| 455 | } |
| 456 | |
| 457 | WebDataService* TestingProfile::GetWebDataService(ServiceAccessType access) { |
| 458 | return web_data_service_.get(); |
| 459 | } |
| 460 | |
| 461 | WebDataService* TestingProfile::GetWebDataServiceWithoutCreating() { |
| 462 | return web_data_service_.get(); |
| 463 | } |
| 464 | |
| 465 | PasswordStore* TestingProfile::GetPasswordStore(ServiceAccessType access) { |
| 466 | return NULL; |
| 467 | } |
| 468 | |
[email protected] | a42b559 | 2009-09-03 16:52:23 | [diff] [blame] | 469 | void TestingProfile::InitThemes() { |
| 470 | if (!created_theme_provider_) { |
| 471 | #if defined(OS_LINUX) && !defined(TOOLKIT_VIEWS) |
[email protected] | 761962c | 2009-09-25 00:18:15 | [diff] [blame] | 472 | theme_provider_.reset(new GtkThemeProvider); |
[email protected] | a42b559 | 2009-09-03 16:52:23 | [diff] [blame] | 473 | #else |
[email protected] | 761962c | 2009-09-25 00:18:15 | [diff] [blame] | 474 | theme_provider_.reset(new BrowserThemeProvider); |
[email protected] | a42b559 | 2009-09-03 16:52:23 | [diff] [blame] | 475 | #endif |
[email protected] | 761962c | 2009-09-25 00:18:15 | [diff] [blame] | 476 | theme_provider_->Init(this); |
[email protected] | a42b559 | 2009-09-03 16:52:23 | [diff] [blame] | 477 | created_theme_provider_ = true; |
[email protected] | a42b559 | 2009-09-03 16:52:23 | [diff] [blame] | 478 | } |
[email protected] | 7668808 | 2009-05-16 07:04:42 | [diff] [blame] | 479 | } |
| 480 | |
[email protected] | fadc607b6 | 2011-02-07 17:55:50 | [diff] [blame] | 481 | const Extension* TestingProfile::GetTheme() { |
| 482 | return NULL; |
| 483 | } |
| 484 | |
| 485 | BrowserThemeProvider* TestingProfile::GetThemeProvider() { |
| 486 | InitThemes(); |
| 487 | return theme_provider_.get(); |
| 488 | } |
| 489 | |
[email protected] | 2fb7dc98 | 2010-09-29 12:24:28 | [diff] [blame] | 490 | void TestingProfile::SetPrefService(PrefService* prefs) { |
| 491 | DCHECK(!prefs_.get()); |
| 492 | prefs_.reset(prefs); |
| 493 | } |
| 494 | |
| 495 | void TestingProfile::CreateTestingPrefService() { |
| 496 | DCHECK(!prefs_.get()); |
| 497 | testing_prefs_ = new TestingPrefService(); |
| 498 | prefs_.reset(testing_prefs_); |
| 499 | Profile::RegisterUserPrefs(prefs_.get()); |
| 500 | browser::RegisterAllPrefs(prefs_.get(), prefs_.get()); |
| 501 | } |
| 502 | |
[email protected] | dbbad7a | 2010-08-13 18:18:36 | [diff] [blame] | 503 | PrefService* TestingProfile::GetPrefs() { |
| 504 | if (!prefs_.get()) { |
[email protected] | 2fb7dc98 | 2010-09-29 12:24:28 | [diff] [blame] | 505 | CreateTestingPrefService(); |
[email protected] | dbbad7a | 2010-08-13 18:18:36 | [diff] [blame] | 506 | } |
| 507 | return prefs_.get(); |
| 508 | } |
| 509 | |
[email protected] | fadc607b6 | 2011-02-07 17:55:50 | [diff] [blame] | 510 | TemplateURLModel* TestingProfile::GetTemplateURLModel() { |
| 511 | return template_url_model_.get(); |
| 512 | } |
| 513 | |
| 514 | TemplateURLFetcher* TestingProfile::GetTemplateURLFetcher() { |
| 515 | return template_url_fetcher_.get(); |
| 516 | } |
| 517 | |
[email protected] | dbbad7a | 2010-08-13 18:18:36 | [diff] [blame] | 518 | history::TopSites* TestingProfile::GetTopSites() { |
[email protected] | 809cc4d | 2010-10-27 15:22:54 | [diff] [blame] | 519 | return top_sites_.get(); |
[email protected] | dbbad7a | 2010-08-13 18:18:36 | [diff] [blame] | 520 | } |
| 521 | |
[email protected] | fadc607b6 | 2011-02-07 17:55:50 | [diff] [blame] | 522 | history::TopSites* TestingProfile::GetTopSitesWithoutCreating() { |
| 523 | return top_sites_.get(); |
| 524 | } |
| 525 | |
| 526 | DownloadManager* TestingProfile::GetDownloadManager() { |
| 527 | return NULL; |
| 528 | } |
| 529 | |
| 530 | PersonalDataManager* TestingProfile::GetPersonalDataManager() { |
| 531 | return NULL; |
| 532 | } |
| 533 | |
[email protected] | 397281f | 2011-02-14 05:15:53 | [diff] [blame] | 534 | fileapi::FileSystemContext* TestingProfile::GetFileSystemContext() { |
[email protected] | fadc607b6 | 2011-02-07 17:55:50 | [diff] [blame] | 535 | return NULL; |
| 536 | } |
| 537 | |
| 538 | BrowserSignin* TestingProfile::GetBrowserSignin() { |
| 539 | return NULL; |
| 540 | } |
| 541 | |
| 542 | bool TestingProfile::HasCreatedDownloadManager() const { |
| 543 | return false; |
| 544 | } |
| 545 | |
[email protected] | 812b3a3 | 2010-01-08 05:36:04 | [diff] [blame] | 546 | URLRequestContextGetter* TestingProfile::GetRequestContext() { |
| 547 | return request_context_.get(); |
| 548 | } |
| 549 | |
| 550 | void TestingProfile::CreateRequestContext() { |
| 551 | if (!request_context_) |
| 552 | request_context_ = new TestURLRequestContextGetter(); |
| 553 | } |
| 554 | |
[email protected] | 7c89320 | 2010-10-07 20:18:02 | [diff] [blame] | 555 | void TestingProfile::ResetRequestContext() { |
| 556 | request_context_ = NULL; |
| 557 | } |
| 558 | |
[email protected] | fadc607b6 | 2011-02-07 17:55:50 | [diff] [blame] | 559 | URLRequestContextGetter* TestingProfile::GetRequestContextForMedia() { |
| 560 | return NULL; |
| 561 | } |
| 562 | |
[email protected] | c10da4b0 | 2010-03-25 14:38:32 | [diff] [blame] | 563 | URLRequestContextGetter* TestingProfile::GetRequestContextForExtensions() { |
| 564 | if (!extensions_request_context_) |
| 565 | extensions_request_context_ = new TestExtensionURLRequestContextGetter(); |
| 566 | return extensions_request_context_.get(); |
| 567 | } |
| 568 | |
[email protected] | fadc607b6 | 2011-02-07 17:55:50 | [diff] [blame] | 569 | net::SSLConfigService* TestingProfile::GetSSLConfigService() { |
| 570 | return NULL; |
| 571 | } |
| 572 | |
| 573 | UserStyleSheetWatcher* TestingProfile::GetUserStyleSheetWatcher() { |
| 574 | return NULL; |
| 575 | } |
| 576 | |
[email protected] | dbbad7a | 2010-08-13 18:18:36 | [diff] [blame] | 577 | FindBarState* TestingProfile::GetFindBarState() { |
| 578 | if (!find_bar_state_.get()) |
| 579 | find_bar_state_.reset(new FindBarState()); |
| 580 | return find_bar_state_.get(); |
| 581 | } |
| 582 | |
| 583 | HostContentSettingsMap* TestingProfile::GetHostContentSettingsMap() { |
| 584 | if (!host_content_settings_map_.get()) |
| 585 | host_content_settings_map_ = new HostContentSettingsMap(this); |
| 586 | return host_content_settings_map_.get(); |
| 587 | } |
| 588 | |
| 589 | GeolocationContentSettingsMap* |
| 590 | TestingProfile::GetGeolocationContentSettingsMap() { |
| 591 | if (!geolocation_content_settings_map_.get()) { |
| 592 | geolocation_content_settings_map_ = |
| 593 | new GeolocationContentSettingsMap(this); |
| 594 | } |
| 595 | return geolocation_content_settings_map_.get(); |
| 596 | } |
| 597 | |
| 598 | GeolocationPermissionContext* |
| 599 | TestingProfile::GetGeolocationPermissionContext() { |
| 600 | if (!geolocation_permission_context_.get()) { |
| 601 | geolocation_permission_context_ = |
| 602 | new GeolocationPermissionContext(this); |
| 603 | } |
| 604 | return geolocation_permission_context_.get(); |
| 605 | } |
| 606 | |
[email protected] | fadc607b6 | 2011-02-07 17:55:50 | [diff] [blame] | 607 | HostZoomMap* TestingProfile::GetHostZoomMap() { |
| 608 | return NULL; |
| 609 | } |
| 610 | |
| 611 | SessionService* TestingProfile::GetSessionService() { |
| 612 | return session_service_.get(); |
| 613 | } |
| 614 | |
| 615 | bool TestingProfile::HasSessionService() const { |
| 616 | return (session_service_.get() != NULL); |
| 617 | } |
| 618 | |
| 619 | bool TestingProfile::HasProfileSyncService() const { |
| 620 | return (profile_sync_service_.get() != NULL); |
| 621 | } |
| 622 | |
| 623 | std::wstring TestingProfile::GetName() { |
| 624 | return std::wstring(); |
| 625 | } |
| 626 | |
| 627 | std::wstring TestingProfile::GetID() { |
| 628 | return id_; |
| 629 | } |
| 630 | |
| 631 | void TestingProfile::SetID(const std::wstring& id) { |
| 632 | id_ = id; |
| 633 | } |
| 634 | |
| 635 | bool TestingProfile::DidLastSessionExitCleanly() { |
| 636 | return last_session_exited_cleanly_; |
| 637 | } |
| 638 | |
| 639 | BookmarkModel* TestingProfile::GetBookmarkModel() { |
| 640 | return bookmark_bar_model_.get(); |
| 641 | } |
| 642 | |
| 643 | bool TestingProfile::IsSameProfile(Profile *p) { |
| 644 | return this == p; |
| 645 | } |
| 646 | |
| 647 | base::Time TestingProfile::GetStartTime() const { |
| 648 | return start_time_; |
| 649 | } |
| 650 | |
| 651 | TabRestoreService* TestingProfile::GetTabRestoreService() { |
| 652 | return NULL; |
| 653 | } |
| 654 | |
| 655 | SpellCheckHost* TestingProfile::GetSpellCheckHost() { |
| 656 | return NULL; |
| 657 | } |
| 658 | |
[email protected] | 8cb5d5b | 2010-02-09 11:36:16 | [diff] [blame] | 659 | void TestingProfile::set_session_service(SessionService* session_service) { |
| 660 | session_service_ = session_service; |
| 661 | } |
| 662 | |
[email protected] | dbbad7a | 2010-08-13 18:18:36 | [diff] [blame] | 663 | WebKitContext* TestingProfile::GetWebKitContext() { |
| 664 | if (webkit_context_ == NULL) |
[email protected] | 5134417a | 2010-11-30 13:57:24 | [diff] [blame] | 665 | webkit_context_ = new WebKitContext(this, false); |
[email protected] | dbbad7a | 2010-08-13 18:18:36 | [diff] [blame] | 666 | return webkit_context_; |
| 667 | } |
| 668 | |
[email protected] | fadc607b6 | 2011-02-07 17:55:50 | [diff] [blame] | 669 | WebKitContext* TestingProfile::GetOffTheRecordWebKitContext() { |
| 670 | return NULL; |
| 671 | } |
| 672 | |
[email protected] | 156ed27b | 2009-11-23 18:31:25 | [diff] [blame] | 673 | NTPResourceCache* TestingProfile::GetNTPResourceCache() { |
| 674 | if (!ntp_resource_cache_.get()) |
| 675 | ntp_resource_cache_.reset(new NTPResourceCache(this)); |
| 676 | return ntp_resource_cache_.get(); |
| 677 | } |
| 678 | |
[email protected] | dbbad7a | 2010-08-13 18:18:36 | [diff] [blame] | 679 | DesktopNotificationService* TestingProfile::GetDesktopNotificationService() { |
[email protected] | 0c7d74f | 2010-10-11 11:55:26 | [diff] [blame] | 680 | DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
[email protected] | dbbad7a | 2010-08-13 18:18:36 | [diff] [blame] | 681 | if (!desktop_notification_service_.get()) { |
| 682 | desktop_notification_service_.reset(new DesktopNotificationService( |
| 683 | this, NULL)); |
| 684 | } |
| 685 | return desktop_notification_service_.get(); |
| 686 | } |
| 687 | |
[email protected] | fadc607b6 | 2011-02-07 17:55:50 | [diff] [blame] | 688 | BackgroundContentsService* |
| 689 | TestingProfile::GetBackgroundContentsService() const { |
| 690 | return NULL; |
| 691 | } |
| 692 | |
| 693 | StatusTray* TestingProfile::GetStatusTray() { |
| 694 | return NULL; |
| 695 | } |
| 696 | |
| 697 | FilePath TestingProfile::last_selected_directory() { |
| 698 | return last_selected_directory_; |
| 699 | } |
| 700 | |
| 701 | void TestingProfile::set_last_selected_directory(const FilePath& path) { |
| 702 | last_selected_directory_ = path; |
| 703 | } |
| 704 | |
[email protected] | cc5bfd4 | 2010-11-24 14:44:02 | [diff] [blame] | 705 | PrefProxyConfigTracker* TestingProfile::GetProxyConfigTracker() { |
| 706 | if (!pref_proxy_config_tracker_) |
| 707 | pref_proxy_config_tracker_ = new PrefProxyConfigTracker(GetPrefs()); |
| 708 | |
| 709 | return pref_proxy_config_tracker_; |
| 710 | } |
| 711 | |
[email protected] | 0bfc29a | 2009-04-27 16:15:44 | [diff] [blame] | 712 | void TestingProfile::BlockUntilHistoryProcessesPendingRequests() { |
| 713 | DCHECK(history_service_.get()); |
| 714 | DCHECK(MessageLoop::current()); |
| 715 | |
| 716 | CancelableRequestConsumer consumer; |
| 717 | history_service_->ScheduleDBTask(new QuittingHistoryDBTask(), &consumer); |
| 718 | MessageLoop::current()->Run(); |
| 719 | } |
[email protected] | 345a8b7 | 2009-09-29 09:11:44 | [diff] [blame] | 720 | |
[email protected] | 8e4c2961 | 2010-07-14 01:24:45 | [diff] [blame] | 721 | TokenService* TestingProfile::GetTokenService() { |
| 722 | if (!token_service_.get()) { |
| 723 | token_service_.reset(new TokenService()); |
| 724 | } |
| 725 | return token_service_.get(); |
| 726 | } |
| 727 | |
[email protected] | 345a8b7 | 2009-09-29 09:11:44 | [diff] [blame] | 728 | ProfileSyncService* TestingProfile::GetProfileSyncService() { |
[email protected] | e8234d3 | 2010-09-09 20:36:39 | [diff] [blame] | 729 | return GetProfileSyncService(""); |
| 730 | } |
| 731 | |
| 732 | ProfileSyncService* TestingProfile::GetProfileSyncService( |
| 733 | const std::string& cros_user) { |
[email protected] | 4772b07 | 2010-03-30 17:45:46 | [diff] [blame] | 734 | if (!profile_sync_service_.get()) { |
[email protected] | 3c88741 | 2010-04-19 20:30:23 | [diff] [blame] | 735 | // Use a NiceMock here since we are really using the mock as a |
| 736 | // fake. Test cases that want to set expectations on a |
| 737 | // ProfileSyncService should use the ProfileMock and have this |
| 738 | // method return their own mock instance. |
| 739 | profile_sync_service_.reset(new NiceMock<ProfileSyncServiceMock>()); |
[email protected] | 4772b07 | 2010-03-30 17:45:46 | [diff] [blame] | 740 | } |
[email protected] | 345a8b7 | 2009-09-29 09:11:44 | [diff] [blame] | 741 | return profile_sync_service_.get(); |
[email protected] | 345a8b7 | 2009-09-29 09:11:44 | [diff] [blame] | 742 | } |
[email protected] | 2609bc1 | 2010-01-24 08:32:55 | [diff] [blame] | 743 | |
[email protected] | fadc607b6 | 2011-02-07 17:55:50 | [diff] [blame] | 744 | CloudPrintProxyService* TestingProfile::GetCloudPrintProxyService() { |
| 745 | return NULL; |
| 746 | } |
| 747 | |
| 748 | ChromeBlobStorageContext* TestingProfile::GetBlobStorageContext() { |
| 749 | return NULL; |
| 750 | } |
| 751 | |
| 752 | ExtensionInfoMap* TestingProfile::GetExtensionInfoMap() { |
| 753 | return NULL; |
| 754 | } |
| 755 | |
| 756 | PromoCounter* TestingProfile::GetInstantPromoCounter() { |
| 757 | return NULL; |
| 758 | } |
| 759 | |
| 760 | policy::ProfilePolicyContext* TestingProfile::GetPolicyContext() { |
| 761 | return NULL; |
| 762 | } |
| 763 | |
[email protected] | 248ce19 | 2011-02-10 15:26:34 | [diff] [blame] | 764 | ChromeURLDataManager* TestingProfile::GetChromeURLDataManager() { |
| 765 | if (!chrome_url_data_manager_.get()) |
| 766 | chrome_url_data_manager_.reset(new ChromeURLDataManager(this)); |
| 767 | return chrome_url_data_manager_.get(); |
| 768 | } |
| 769 | |
[email protected] | 4c154ff8 | 2011-02-15 11:23:59 | [diff] [blame^] | 770 | prerender::PrerenderManager* TestingProfile::GetPrerenderManager() { |
[email protected] | fadc607b6 | 2011-02-07 17:55:50 | [diff] [blame] | 771 | return NULL; |
| 772 | } |
| 773 | |
| 774 | PrefService* TestingProfile::GetOffTheRecordPrefs() { |
| 775 | return NULL; |
| 776 | } |
| 777 | |
[email protected] | 2609bc1 | 2010-01-24 08:32:55 | [diff] [blame] | 778 | void TestingProfile::DestroyWebDataService() { |
| 779 | if (!web_data_service_.get()) |
| 780 | return; |
| 781 | |
| 782 | web_data_service_->Shutdown(); |
| 783 | } |
[email protected] | a5add2c | 2011-02-14 23:54:47 | [diff] [blame] | 784 | |
| 785 | DerivedTestingProfile::DerivedTestingProfile(Profile* profile) |
| 786 | : original_profile_(profile) {} |
| 787 | |
| 788 | DerivedTestingProfile::~DerivedTestingProfile() {} |
| 789 | |
| 790 | ProfileId DerivedTestingProfile::GetRuntimeId() { |
| 791 | return original_profile_->GetRuntimeId(); |
| 792 | } |