blob: 1e248e2198a681df59a42e48ce9e9bd2f8aaf11c [file] [log] [blame]
[email protected]e284e6d82010-01-29 19:49:451// Copyright (c) 2010 The Chromium Authors. All rights reserved.
license.botbf09a502008-08-24 00:55:552// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
initial.commit09911bf2008-07-26 23:55:294
5#include "chrome/browser/profile.h"
6
[email protected]1952c7d2010-03-04 23:48:347#include "app/resource_bundle.h"
[email protected]2735e3692009-09-25 18:19:398#include "app/theme_provider.h"
initial.commit09911bf2008-07-26 23:55:299#include "base/command_line.h"
[email protected]04fba9a92008-10-28 17:25:2510#include "base/file_path.h"
[email protected]405a64b2009-09-16 21:03:4411#include "base/file_util.h"
initial.commit09911bf2008-07-26 23:55:2912#include "base/path_service.h"
13#include "base/scoped_ptr.h"
14#include "base/string_util.h"
[email protected]0082d7e0d2010-02-27 14:34:1215#include "chrome/browser/appcache/chrome_appcache_service.h"
[email protected]def11712009-11-06 00:42:1516#include "chrome/browser/autofill/personal_data_manager.h"
[email protected]a9afddb2009-02-12 17:49:4217#include "chrome/browser/bookmarks/bookmark_model.h"
initial.commit09911bf2008-07-26 23:55:2918#include "chrome/browser/browser_list.h"
[email protected]9acc48602009-11-30 21:18:5119#include "chrome/browser/browser_prefs.h"
[email protected]8a4892d8d2009-11-23 20:40:5720#include "chrome/browser/browser_process.h"
[email protected]67a46b7f2009-06-16 21:41:0221#include "chrome/browser/browser_theme_provider.h"
[email protected]6fad2632009-11-02 05:59:3722#include "chrome/browser/chrome_thread.h"
[email protected]9c8dd902009-11-19 17:50:4223#include "chrome/browser/dom_ui/ntp_resource_cache.h"
[email protected]b7f05882009-02-22 01:21:5624#include "chrome/browser/download/download_manager.h"
[email protected]89ebc7e2009-08-24 22:11:0725#include "chrome/browser/extensions/extension_devtools_manager.h"
[email protected]7120f132009-07-20 21:05:3726#include "chrome/browser/extensions/extension_message_service.h"
[email protected]481e1a42009-05-06 20:56:0527#include "chrome/browser/extensions/extension_process_manager.h"
[email protected]6014d672008-12-05 00:38:2528#include "chrome/browser/extensions/extensions_service.h"
[email protected]0938d3c2009-01-09 20:37:3529#include "chrome/browser/extensions/user_script_master.h"
[email protected]0189bc722009-08-28 21:56:4830#include "chrome/browser/favicon_service.h"
[email protected]9c92d192009-12-02 08:03:1631#include "chrome/browser/spellcheck_host.h"
[email protected]326e6792009-12-11 21:04:4232#include "chrome/browser/transport_security_persister.h"
[email protected]a9afddb2009-02-12 17:49:4233#include "chrome/browser/history/history.h"
[email protected]e284e6d82010-01-29 19:49:4534#include "chrome/browser/host_content_settings_map.h"
[email protected]40bd6582009-12-04 23:49:5135#include "chrome/browser/host_zoom_map.h"
[email protected]3bf335a2009-06-26 20:46:0636#include "chrome/browser/in_process_webkit/webkit_context.h"
[email protected]6ab9b202008-12-23 22:34:5037#include "chrome/browser/net/chrome_url_request_context.h"
[email protected]db36938c2009-08-19 21:48:4238#include "chrome/browser/net/ssl_config_service_manager.h"
[email protected]4bb336302009-10-12 05:44:2639#include "chrome/browser/notifications/desktop_notification_service.h"
[email protected]e69d33952009-06-03 22:00:4140#include "chrome/browser/password_manager/password_store_default.h"
[email protected]8c6335d32010-01-20 09:21:5041#include "chrome/browser/privacy_blacklist/blacklist.h"
initial.commit09911bf2008-07-26 23:55:2942#include "chrome/browser/profile_manager.h"
[email protected]8c8657d62009-01-16 18:31:2643#include "chrome/browser/renderer_host/render_process_host.h"
[email protected]90085af02009-10-29 17:53:2144#include "chrome/browser/search_versus_navigate_classifier.h"
[email protected]1132436e2009-04-08 20:06:3345#include "chrome/browser/search_engines/template_url_fetcher.h"
[email protected]f63ae312009-02-04 17:58:4646#include "chrome/browser/search_engines/template_url_model.h"
[email protected]85e921fb82009-02-11 23:19:4447#include "chrome/browser/sessions/session_service.h"
[email protected]bd580a252009-02-12 01:16:3048#include "chrome/browser/sessions/tab_restore_service.h"
[email protected]1132436e2009-04-08 20:06:3349#include "chrome/browser/ssl/ssl_host_state.h"
[email protected]48352c12009-08-15 01:19:1150#include "chrome/browser/sync/profile_sync_service.h"
[email protected]4aea04a2010-02-10 20:13:4351#include "chrome/browser/sync/profile_sync_factory_impl.h"
[email protected]449478302009-06-09 20:04:2852#include "chrome/browser/thumbnail_store.h"
initial.commit09911bf2008-07-26 23:55:2953#include "chrome/browser/visitedlink_master.h"
[email protected]3e90d4a2009-07-03 17:38:3954#include "chrome/browser/visitedlink_event_listener.h"
initial.commit09911bf2008-07-26 23:55:2955#include "chrome/browser/webdata/web_data_service.h"
[email protected]b1748b1d82009-11-30 20:32:5656#include "chrome/browser/web_resource/web_resource_service.h"
initial.commit09911bf2008-07-26 23:55:2957#include "chrome/common/chrome_constants.h"
58#include "chrome/common/chrome_paths.h"
59#include "chrome/common/chrome_switches.h"
[email protected]5b1a0e22009-05-26 19:00:5860#include "chrome/common/extensions/extension_error_reporter.h"
initial.commit09911bf2008-07-26 23:55:2961#include "chrome/common/notification_service.h"
62#include "chrome/common/pref_names.h"
[email protected]f7011fcb2009-01-28 21:54:3263#include "chrome/common/render_messages.h"
[email protected]1952c7d2010-03-04 23:48:3464#include "grit/browser_resources.h"
[email protected]f90f5c512009-02-18 19:10:5865#include "grit/locale_settings.h"
[email protected]326e6792009-12-11 21:04:4266#include "net/base/transport_security_state.h"
[email protected]2f351cb2009-11-09 23:43:3467#include "webkit/database/database_tracker.h"
initial.commit09911bf2008-07-26 23:55:2968
[email protected]a5166af62009-07-03 00:42:2969#if defined(OS_LINUX)
70#include "chrome/browser/gtk/gtk_theme_provider.h"
71#endif
72
[email protected]e1acf6f2008-10-27 20:43:3373using base::Time;
74using base::TimeDelta;
75
[email protected]e5642992009-06-26 23:06:3176namespace {
77
initial.commit09911bf2008-07-26 23:55:2978// Delay, in milliseconds, before we explicitly create the SessionService.
79static const int kCreateSessionServiceDelayMS = 500;
80
[email protected]e5642992009-06-26 23:06:3181enum ContextType {
82 kNormalContext,
83 kMediaContext
84};
85
86// Gets the cache parameters from the command line. |type| is the type of
87// request context that we need, |cache_path| will be set to the user provided
88// path, or will not be touched if there is not an argument. |max_size| will
89// be the user provided value or zero by default.
90void GetCacheParameters(ContextType type, FilePath* cache_path,
91 int* max_size) {
92 DCHECK(cache_path);
93 DCHECK(max_size);
94
95 // Override the cache location if specified by the user.
96 std::wstring user_path(CommandLine::ForCurrentProcess()->GetSwitchValue(
97 switches::kDiskCacheDir));
98
99 if (!user_path.empty()) {
100 *cache_path = FilePath::FromWStringHack(user_path);
101 }
102
[email protected]b7e0a2a2009-10-13 02:07:25103 const char* arg = kNormalContext == type ? switches::kDiskCacheSize :
104 switches::kMediaCacheSize;
[email protected]e5642992009-06-26 23:06:31105 std::string value =
[email protected]b7e0a2a2009-10-13 02:07:25106 CommandLine::ForCurrentProcess()->GetSwitchValueASCII(arg);
[email protected]e5642992009-06-26 23:06:31107
108 // By default we let the cache determine the right size.
109 *max_size = 0;
110 if (!StringToInt(value, max_size)) {
111 *max_size = 0;
112 } else if (max_size < 0) {
113 *max_size = 0;
114 }
115}
116
[email protected]405a64b2009-09-16 21:03:44117FilePath GetCachePath(const FilePath& base) {
118 return base.Append(chrome::kCacheDirname);
119}
120
121FilePath GetMediaCachePath(const FilePath& base) {
122 return base.Append(chrome::kMediaCacheDirname);
123}
124
125bool HasACacheSubdir(const FilePath &dir) {
126 return file_util::PathExists(GetCachePath(dir)) ||
127 file_util::PathExists(GetMediaCachePath(dir));
128}
129
[email protected]e5642992009-06-26 23:06:31130} // namespace
131
initial.commit09911bf2008-07-26 23:55:29132// A pointer to the request context for the default profile. See comments on
133// Profile::GetDefaultRequestContext.
[email protected]be180c802009-10-23 06:33:31134URLRequestContextGetter* Profile::default_request_context_;
initial.commit09911bf2008-07-26 23:55:29135
[email protected]be180c802009-10-23 06:33:31136static void CleanupRequestContext(ChromeURLRequestContextGetter* context) {
[email protected]13c30922009-11-19 03:43:19137 if (context)
[email protected]47accfd62009-05-14 18:46:21138 context->CleanupOnUIThread();
[email protected]47accfd62009-05-14 18:46:21139}
140
[email protected]34cc84f2009-02-13 10:04:35141// static
[email protected]4bf6afd2009-10-08 14:00:11142const ProfileId Profile::InvalidProfileId = static_cast<ProfileId>(0);
143
144// static
initial.commit09911bf2008-07-26 23:55:29145void Profile::RegisterUserPrefs(PrefService* prefs) {
[email protected]430d3f72008-10-27 17:56:55146 prefs->RegisterBooleanPref(prefs::kSearchSuggestEnabled, true);
initial.commit09911bf2008-07-26 23:55:29147 prefs->RegisterBooleanPref(prefs::kSessionExitedCleanly, true);
148 prefs->RegisterBooleanPref(prefs::kSafeBrowsingEnabled, true);
[email protected]74c8b422009-03-11 00:34:12149 // TODO(estade): IDS_SPELLCHECK_DICTIONARY should be an ASCII string.
[email protected]e7244d82008-10-29 18:13:26150 prefs->RegisterLocalizedStringPref(prefs::kSpellCheckDictionary,
151 IDS_SPELLCHECK_DICTIONARY);
152 prefs->RegisterBooleanPref(prefs::kEnableSpellCheck, true);
[email protected]154a4332009-06-03 20:20:58153 prefs->RegisterBooleanPref(prefs::kEnableAutoSpellCorrect, true);
[email protected]a5166af62009-07-03 00:42:29154#if defined(OS_LINUX)
155 prefs->RegisterBooleanPref(prefs::kUsesSystemTheme, false);
156#endif
[email protected]f017cc92009-12-14 20:48:07157 prefs->RegisterFilePathPref(prefs::kCurrentThemePackFilename, FilePath());
[email protected]51c490b2009-08-03 16:34:34158 prefs->RegisterStringPref(prefs::kCurrentThemeID,
159 UTF8ToWide(BrowserThemeProvider::kDefaultThemeID));
[email protected]4a190632009-05-09 01:07:42160 prefs->RegisterDictionaryPref(prefs::kCurrentThemeImages);
161 prefs->RegisterDictionaryPref(prefs::kCurrentThemeColors);
162 prefs->RegisterDictionaryPref(prefs::kCurrentThemeTints);
[email protected]7895ea22009-06-02 20:53:50163 prefs->RegisterDictionaryPref(prefs::kCurrentThemeDisplayProperties);
[email protected]6d60703b2009-08-29 01:29:23164 prefs->RegisterBooleanPref(prefs::kDisableExtensions, false);
initial.commit09911bf2008-07-26 23:55:29165}
166
[email protected]34cc84f2009-02-13 10:04:35167// static
[email protected]f7011fcb2009-01-28 21:54:32168Profile* Profile::CreateProfile(const FilePath& path) {
initial.commit09911bf2008-07-26 23:55:29169 return new ProfileImpl(path);
170}
171
[email protected]34cc84f2009-02-13 10:04:35172// static
[email protected]be180c802009-10-23 06:33:31173URLRequestContextGetter* Profile::GetDefaultRequestContext() {
initial.commit09911bf2008-07-26 23:55:29174 return default_request_context_;
175}
176
[email protected]e69d33952009-06-03 22:00:41177#if defined(OS_LINUX)
178// Temporarily disabled while we figure some stuff out.
179// http://code.google.com/p/chromium/issues/detail?id=12351
180// #include "chrome/browser/password_manager/password_store_gnome.h"
181// #include "chrome/browser/password_manager/password_store_kwallet.h"
182#elif defined(OS_WIN)
183#include "chrome/browser/password_manager/password_store_win.h"
[email protected]034eba52009-06-03 22:50:56184#elif defined(OS_MACOSX)
185#include "chrome/browser/keychain_mac.h"
[email protected]e0411ae52009-06-30 23:59:17186#include "chrome/browser/password_manager/login_database_mac.h"
[email protected]034eba52009-06-03 22:50:56187#include "chrome/browser/password_manager/password_store_mac.h"
[email protected]e69d33952009-06-03 22:00:41188#endif
initial.commit09911bf2008-07-26 23:55:29189
initial.commit09911bf2008-07-26 23:55:29190////////////////////////////////////////////////////////////////////////////////
191//
192// OffTheRecordProfileImpl is a profile subclass that wraps an existing profile
[email protected]4a190632009-05-09 01:07:42193// to make it suitable for the off the record mode.
initial.commit09911bf2008-07-26 23:55:29194//
195////////////////////////////////////////////////////////////////////////////////
196class OffTheRecordProfileImpl : public Profile,
197 public NotificationObserver {
198 public:
199 explicit OffTheRecordProfileImpl(Profile* real_profile)
200 : profile_(real_profile),
201 start_time_(Time::Now()) {
[email protected]be180c802009-10-23 06:33:31202 request_context_ = ChromeURLRequestContextGetter::CreateOffTheRecord(this);
[email protected]481e1a42009-05-06 20:56:05203
initial.commit09911bf2008-07-26 23:55:29204 // Register for browser close notifications so we can detect when the last
205 // off-the-record window is closed, in which case we can clean our states
206 // (cookies, downloads...).
[email protected]88cf3292009-05-22 01:48:43207 registrar_.Add(this, NotificationType::BROWSER_CLOSED,
208 NotificationService::AllSources());
initial.commit09911bf2008-07-26 23:55:29209 }
210
211 virtual ~OffTheRecordProfileImpl() {
[email protected]47accfd62009-05-14 18:46:21212 CleanupRequestContext(request_context_);
initial.commit09911bf2008-07-26 23:55:29213 }
214
[email protected]4bf6afd2009-10-08 14:00:11215 virtual ProfileId GetRuntimeId() {
216 return reinterpret_cast<ProfileId>(this);
217 }
218
[email protected]a6d0f182010-01-12 08:01:44219 virtual FilePath GetPath() { return profile_->GetPath(); }
initial.commit09911bf2008-07-26 23:55:29220
221 virtual bool IsOffTheRecord() {
222 return true;
223 }
224
225 virtual Profile* GetOffTheRecordProfile() {
226 return this;
227 }
228
[email protected]860f55492009-03-27 19:50:59229 virtual void DestroyOffTheRecordProfile() {
230 // Suicide is bad!
231 NOTREACHED();
232 }
233
initial.commit09911bf2008-07-26 23:55:29234 virtual Profile* GetOriginalProfile() {
235 return profile_;
236 }
237
[email protected]2f351cb2009-11-09 23:43:34238 virtual webkit_database::DatabaseTracker* GetDatabaseTracker() {
239 if (!db_tracker_)
240 db_tracker_ = new webkit_database::DatabaseTracker(FilePath());
241 return db_tracker_;
242 }
243
initial.commit09911bf2008-07-26 23:55:29244 virtual VisitedLinkMaster* GetVisitedLinkMaster() {
[email protected]7fb6c862009-03-13 02:51:49245 // We don't provide access to the VisitedLinkMaster when we're OffTheRecord
246 // because we don't want to leak the sites that the user has visited before.
247 return NULL;
initial.commit09911bf2008-07-26 23:55:29248 }
249
[email protected]6014d672008-12-05 00:38:25250 virtual ExtensionsService* GetExtensionsService() {
[email protected]55a35692010-02-11 23:25:21251 return GetOriginalProfile()->GetExtensionsService();
[email protected]6014d672008-12-05 00:38:25252 }
253
[email protected]0938d3c2009-01-09 20:37:35254 virtual UserScriptMaster* GetUserScriptMaster() {
[email protected]55a35692010-02-11 23:25:21255 return GetOriginalProfile()->GetUserScriptMaster();
[email protected]04fba9a92008-10-28 17:25:25256 }
257
[email protected]89ebc7e2009-08-24 22:11:07258 virtual ExtensionDevToolsManager* GetExtensionDevToolsManager() {
[email protected]55a35692010-02-11 23:25:21259 // TODO(mpcomplete): figure out whether we should return the original
260 // profile's version.
[email protected]89ebc7e2009-08-24 22:11:07261 return NULL;
262 }
263
[email protected]481e1a42009-05-06 20:56:05264 virtual ExtensionProcessManager* GetExtensionProcessManager() {
[email protected]55a35692010-02-11 23:25:21265 return GetOriginalProfile()->GetExtensionProcessManager();
[email protected]481e1a42009-05-06 20:56:05266 }
267
[email protected]7120f132009-07-20 21:05:37268 virtual ExtensionMessageService* GetExtensionMessageService() {
[email protected]55a35692010-02-11 23:25:21269 return GetOriginalProfile()->GetExtensionMessageService();
[email protected]7120f132009-07-20 21:05:37270 }
271
[email protected]34cc84f2009-02-13 10:04:35272 virtual SSLHostState* GetSSLHostState() {
273 if (!ssl_host_state_.get())
274 ssl_host_state_.reset(new SSLHostState());
275
276 DCHECK(ssl_host_state_->CalledOnValidThread());
277 return ssl_host_state_.get();
278 }
279
[email protected]326e6792009-12-11 21:04:42280 virtual net::TransportSecurityState* GetTransportSecurityState() {
[email protected]7a1251842010-01-30 01:17:54281 if (!transport_security_state_.get())
282 transport_security_state_ = new net::TransportSecurityState();
[email protected]a9cea7542009-05-20 04:30:23283
[email protected]326e6792009-12-11 21:04:42284 return transport_security_state_.get();
[email protected]a9cea7542009-05-20 04:30:23285 }
286
initial.commit09911bf2008-07-26 23:55:29287 virtual HistoryService* GetHistoryService(ServiceAccessType sat) {
[email protected]7a1251842010-01-30 01:17:54288 if (sat == EXPLICIT_ACCESS)
initial.commit09911bf2008-07-26 23:55:29289 return profile_->GetHistoryService(sat);
[email protected]7a1251842010-01-30 01:17:54290
291 NOTREACHED() << "This profile is OffTheRecord";
292 return NULL;
initial.commit09911bf2008-07-26 23:55:29293 }
294
[email protected]0850fa62009-10-08 22:34:29295 virtual HistoryService* GetHistoryServiceWithoutCreating() {
296 return profile_->GetHistoryServiceWithoutCreating();
297 }
298
[email protected]0189bc722009-08-28 21:56:48299 virtual FaviconService* GetFaviconService(ServiceAccessType sat) {
[email protected]7a1251842010-01-30 01:17:54300 if (sat == EXPLICIT_ACCESS)
[email protected]0189bc722009-08-28 21:56:48301 return profile_->GetFaviconService(sat);
[email protected]7a1251842010-01-30 01:17:54302
303 NOTREACHED() << "This profile is OffTheRecord";
304 return NULL;
[email protected]0189bc722009-08-28 21:56:48305 }
306
[email protected]90085af02009-10-29 17:53:21307 virtual SearchVersusNavigateClassifier* GetSearchVersusNavigateClassifier() {
308 return profile_->GetSearchVersusNavigateClassifier();
309 }
310
initial.commit09911bf2008-07-26 23:55:29311 virtual WebDataService* GetWebDataService(ServiceAccessType sat) {
[email protected]7a1251842010-01-30 01:17:54312 if (sat == EXPLICIT_ACCESS)
initial.commit09911bf2008-07-26 23:55:29313 return profile_->GetWebDataService(sat);
[email protected]7a1251842010-01-30 01:17:54314
315 NOTREACHED() << "This profile is OffTheRecord";
316 return NULL;
initial.commit09911bf2008-07-26 23:55:29317 }
318
[email protected]9cddbe372009-10-23 21:23:53319 virtual WebDataService* GetWebDataServiceWithoutCreating() {
320 return profile_->GetWebDataServiceWithoutCreating();
321 }
322
[email protected]e69d33952009-06-03 22:00:41323 virtual PasswordStore* GetPasswordStore(ServiceAccessType sat) {
[email protected]7a1251842010-01-30 01:17:54324 if (sat == EXPLICIT_ACCESS)
[email protected]e69d33952009-06-03 22:00:41325 return profile_->GetPasswordStore(sat);
[email protected]7a1251842010-01-30 01:17:54326
327 NOTREACHED() << "This profile is OffTheRecord";
328 return NULL;
[email protected]e69d33952009-06-03 22:00:41329 }
330
initial.commit09911bf2008-07-26 23:55:29331 virtual PrefService* GetPrefs() {
332 return profile_->GetPrefs();
333 }
334
335 virtual TemplateURLModel* GetTemplateURLModel() {
336 return profile_->GetTemplateURLModel();
337 }
338
339 virtual TemplateURLFetcher* GetTemplateURLFetcher() {
340 return profile_->GetTemplateURLFetcher();
341 }
342
343 virtual DownloadManager* GetDownloadManager() {
344 if (!download_manager_.get()) {
345 scoped_refptr<DownloadManager> dlm(new DownloadManager);
346 dlm->Init(this);
347 download_manager_.swap(dlm);
348 }
349 return download_manager_.get();
350 }
351
352 virtual bool HasCreatedDownloadManager() const {
353 return (download_manager_.get() != NULL);
354 }
355
[email protected]def11712009-11-06 00:42:15356 virtual PersonalDataManager* GetPersonalDataManager() {
357 return NULL;
358 }
359
[email protected]4a190632009-05-09 01:07:42360 virtual void InitThemes() {
[email protected]7a1251842010-01-30 01:17:54361 profile_->InitThemes();
[email protected]4a190632009-05-09 01:07:42362 }
363
364 virtual void SetTheme(Extension* extension) {
[email protected]7a1251842010-01-30 01:17:54365 profile_->SetTheme(extension);
[email protected]4a190632009-05-09 01:07:42366 }
367
[email protected]a5166af62009-07-03 00:42:29368 virtual void SetNativeTheme() {
[email protected]7a1251842010-01-30 01:17:54369 profile_->SetNativeTheme();
[email protected]a5166af62009-07-03 00:42:29370 }
371
[email protected]4a190632009-05-09 01:07:42372 virtual void ClearTheme() {
[email protected]7a1251842010-01-30 01:17:54373 profile_->ClearTheme();
[email protected]4a190632009-05-09 01:07:42374 }
375
[email protected]51c490b2009-08-03 16:34:34376 virtual Extension* GetTheme() {
[email protected]7a1251842010-01-30 01:17:54377 return profile_->GetTheme();
[email protected]51c490b2009-08-03 16:34:34378 }
379
[email protected]5786d3d2009-12-18 00:18:44380 virtual BrowserThemeProvider* GetThemeProvider() {
[email protected]7a1251842010-01-30 01:17:54381 return profile_->GetThemeProvider();
[email protected]4a190632009-05-09 01:07:42382 }
383
[email protected]be180c802009-10-23 06:33:31384 virtual URLRequestContextGetter* GetRequestContext() {
initial.commit09911bf2008-07-26 23:55:29385 return request_context_;
386 }
387
[email protected]be180c802009-10-23 06:33:31388 virtual URLRequestContextGetter* GetRequestContextForMedia() {
[email protected]d14c7ac2009-05-29 20:38:11389 // In OTR mode, media request context is the same as the original one.
390 return request_context_;
[email protected]e7f29642009-03-02 22:53:18391 }
392
[email protected]be180c802009-10-23 06:33:31393 URLRequestContextGetter* GetRequestContextForExtensions() {
[email protected]55a35692010-02-11 23:25:21394 return GetOriginalProfile()->GetRequestContextForExtensions();
[email protected]47accfd62009-05-14 18:46:21395 }
396
[email protected]db36938c2009-08-19 21:48:42397 virtual net::SSLConfigService* GetSSLConfigService() {
[email protected]7a1251842010-01-30 01:17:54398 return profile_->GetSSLConfigService();
[email protected]db36938c2009-08-19 21:48:42399 }
400
[email protected]e284e6d82010-01-29 19:49:45401 virtual HostContentSettingsMap* GetHostContentSettingsMap() {
[email protected]08bc6302010-01-30 02:53:39402 return profile_->GetHostContentSettingsMap();
[email protected]e284e6d82010-01-29 19:49:45403 }
404
[email protected]40bd6582009-12-04 23:49:51405 virtual HostZoomMap* GetHostZoomMap() {
[email protected]779c3362010-01-30 01:09:33406 return profile_->GetHostZoomMap();
[email protected]40bd6582009-12-04 23:49:51407 }
408
[email protected]8c6335d32010-01-20 09:21:50409 virtual Blacklist* GetPrivacyBlacklist() {
[email protected]7a1251842010-01-30 01:17:54410 return profile_->GetPrivacyBlacklist();
[email protected]eaadd9052009-06-23 18:02:23411 }
412
initial.commit09911bf2008-07-26 23:55:29413 virtual SessionService* GetSessionService() {
414 // Don't save any sessions when off the record.
415 return NULL;
416 }
417
418 virtual void ShutdownSessionService() {
419 // We don't allow a session service, nothing to do.
420 }
421
422 virtual bool HasSessionService() const {
423 // We never have a session service.
424 return false;
425 }
426
initial.commit09911bf2008-07-26 23:55:29427 virtual bool DidLastSessionExitCleanly() {
428 return profile_->DidLastSessionExitCleanly();
429 }
430
[email protected]d8e41ed2008-09-11 15:22:32431 virtual BookmarkModel* GetBookmarkModel() {
432 return profile_->GetBookmarkModel();
initial.commit09911bf2008-07-26 23:55:29433 }
434
[email protected]4bb336302009-10-12 05:44:26435 virtual DesktopNotificationService* GetDesktopNotificationService() {
[email protected]7d7696c52009-12-01 20:54:58436 if (!desktop_notification_service_.get()) {
437 desktop_notification_service_.reset(new DesktopNotificationService(
438 this, g_browser_process->notification_ui_manager()));
439 }
440 return desktop_notification_service_.get();
[email protected]4bb336302009-10-12 05:44:26441 }
442
[email protected]48352c12009-08-15 01:19:11443 virtual ProfileSyncService* GetProfileSyncService() {
444 return NULL;
[email protected]3a453fa2008-08-15 18:46:34445 }
[email protected]3a453fa2008-08-15 18:46:34446
initial.commit09911bf2008-07-26 23:55:29447 virtual bool IsSameProfile(Profile* profile) {
[email protected]7a1251842010-01-30 01:17:54448 return (profile == this) || (profile == profile_);
initial.commit09911bf2008-07-26 23:55:29449 }
450
451 virtual Time GetStartTime() const {
452 return start_time_;
453 }
454
455 virtual TabRestoreService* GetTabRestoreService() {
456 return NULL;
457 }
458
[email protected]e7244d82008-10-29 18:13:26459 virtual void ResetTabRestoreService() {
[email protected]20930852008-10-15 19:30:41460 }
461
[email protected]85c55dc2009-11-06 03:05:46462 virtual SpellCheckHost* GetSpellCheckHost() {
463 return profile_->GetSpellCheckHost();
464 }
465
466 virtual void ReinitializeSpellCheckHost(bool force) {
467 profile_->ReinitializeSpellCheckHost(force);
468 }
[email protected]85c55dc2009-11-06 03:05:46469
[email protected]3bf335a2009-06-26 20:46:06470 virtual WebKitContext* GetWebKitContext() {
[email protected]c27324b2009-11-19 22:44:29471 if (!webkit_context_.get())
[email protected]cfe8a112009-11-25 22:52:21472 webkit_context_ = new WebKitContext(FilePath(), true);
[email protected]c27324b2009-11-19 22:44:29473 DCHECK(webkit_context_.get());
474 return webkit_context_.get();
475 }
[email protected]3bf335a2009-06-26 20:46:06476
[email protected]449478302009-06-09 20:04:28477 virtual ThumbnailStore* GetThumbnailStore() {
478 return NULL;
479 }
480
initial.commit09911bf2008-07-26 23:55:29481 virtual void MarkAsCleanShutdown() {
482 }
483
[email protected]bdbc87c2009-01-25 05:08:54484 virtual void InitExtensions() {
485 NOTREACHED();
486 }
487
[email protected]ea0c98cf2009-06-18 23:02:54488 virtual void InitWebResources() {
489 NOTREACHED();
490 }
491
[email protected]9c8dd902009-11-19 17:50:42492 virtual NTPResourceCache* GetNTPResourceCache() {
493 // Just return the real profile resource cache.
494 return profile_->GetNTPResourceCache();
495 }
496
initial.commit09911bf2008-07-26 23:55:29497 virtual void ExitedOffTheRecordMode() {
498 // Drop our download manager so we forget about all the downloads made
499 // in off-the-record mode.
500 download_manager_ = NULL;
501 }
502
503 virtual void Observe(NotificationType type,
504 const NotificationSource& source,
505 const NotificationDetails& details) {
[email protected]bfd04a62009-02-01 18:16:56506 DCHECK_EQ(NotificationType::BROWSER_CLOSED, type.value);
initial.commit09911bf2008-07-26 23:55:29507 // We are only interested in OTR browser closing.
508 if (Source<Browser>(source)->profile() != this)
509 return;
510
511 // Let's check if we still have an Off The Record window opened.
512 // Note that we check against 1 as this notification is sent before the
513 // browser window is actually removed from the list.
514 if (BrowserList::GetBrowserCount(this) <= 1)
515 ExitedOffTheRecordMode();
516 }
517
518 private:
[email protected]88cf3292009-05-22 01:48:43519 NotificationRegistrar registrar_;
520
initial.commit09911bf2008-07-26 23:55:29521 // The real underlying profile.
522 Profile* profile_;
523
[email protected]6ab9b202008-12-23 22:34:50524 // The context to use for requests made from this OTR session.
[email protected]13c30922009-11-19 03:43:19525 scoped_refptr<ChromeURLRequestContextGetter> request_context_;
initial.commit09911bf2008-07-26 23:55:29526
527 // The download manager that only stores downloaded items in memory.
528 scoped_refptr<DownloadManager> download_manager_;
529
[email protected]7d7696c52009-12-01 20:54:58530 // Use a separate desktop notification service for OTR.
531 scoped_ptr<DesktopNotificationService> desktop_notification_service_;
532
[email protected]3bf335a2009-06-26 20:46:06533 // Use a special WebKit context for OTR browsing.
534 scoped_refptr<WebKitContext> webkit_context_;
535
[email protected]34cc84f2009-02-13 10:04:35536 // We don't want SSLHostState from the OTR profile to leak back to the main
537 // profile because then the main profile would learn some of the host names
538 // the user visited while OTR.
539 scoped_ptr<SSLHostState> ssl_host_state_;
540
[email protected]326e6792009-12-11 21:04:42541 // The TransportSecurityState that only stores enabled sites in memory.
542 scoped_refptr<net::TransportSecurityState>
543 transport_security_state_;
[email protected]a9cea7542009-05-20 04:30:23544
initial.commit09911bf2008-07-26 23:55:29545 // Time we were started.
546 Time start_time_;
547
[email protected]2f351cb2009-11-09 23:43:34548 // The main database tracker for this profile.
549 // Should be used only on the file thread.
550 scoped_refptr<webkit_database::DatabaseTracker> db_tracker_;
551
[email protected]90085af02009-10-29 17:53:21552 DISALLOW_COPY_AND_ASSIGN(OffTheRecordProfileImpl);
initial.commit09911bf2008-07-26 23:55:29553};
554
[email protected]f7011fcb2009-01-28 21:54:32555ProfileImpl::ProfileImpl(const FilePath& path)
initial.commit09911bf2008-07-26 23:55:29556 : path_(path),
[email protected]a6d0f182010-01-12 08:01:44557 visited_link_event_listener_(new VisitedLinkEventListener()),
[email protected]89ebc7e2009-08-24 22:11:07558 extension_devtools_manager_(NULL),
[email protected]f7011fcb2009-01-28 21:54:32559 request_context_(NULL),
[email protected]363347b2009-03-13 20:06:57560 media_request_context_(NULL),
[email protected]47accfd62009-05-14 18:46:21561 extensions_request_context_(NULL),
[email protected]e284e6d82010-01-29 19:49:45562 host_content_settings_map_(NULL),
[email protected]40bd6582009-12-04 23:49:51563 host_zoom_map_(NULL),
[email protected]f7011fcb2009-01-28 21:54:32564 history_service_created_(false),
[email protected]0189bc722009-08-28 21:56:48565 favicon_service_created_(false),
[email protected]f7011fcb2009-01-28 21:54:32566 created_web_data_service_(false),
[email protected]e69d33952009-06-03 22:00:41567 created_password_store_(false),
[email protected]f7011fcb2009-01-28 21:54:32568 created_download_manager_(false),
[email protected]4a190632009-05-09 01:07:42569 created_theme_provider_(false),
[email protected]f7011fcb2009-01-28 21:54:32570 start_time_(Time::Now()),
[email protected]85c55dc2009-11-06 03:05:46571 spellcheck_host_(NULL),
572 spellcheck_host_ready_(false),
initial.commit09911bf2008-07-26 23:55:29573 shutdown_session_service_(false) {
574 DCHECK(!path.empty()) << "Using an empty path will attempt to write " <<
575 "profile files to the root directory!";
[email protected]2d316662008-09-03 18:18:14576 create_session_service_timer_.Start(
577 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this,
578 &ProfileImpl::EnsureSessionServiceCreated);
[email protected]bdbc87c2009-01-25 05:08:54579
[email protected]89ebc7e2009-08-24 22:11:07580 if (CommandLine::ForCurrentProcess()->HasSwitch(
581 switches::kEnableExtensionTimelineApi)) {
582 extension_devtools_manager_ = new ExtensionDevToolsManager(this);
583 }
584
[email protected]382a0702009-06-26 17:12:27585 extension_process_manager_.reset(new ExtensionProcessManager(this));
[email protected]7120f132009-07-20 21:05:37586 extension_message_service_ = new ExtensionMessageService(this);
[email protected]382a0702009-06-26 17:12:27587
[email protected]e7244d82008-10-29 18:13:26588 PrefService* prefs = GetPrefs();
589 prefs->AddPrefObserver(prefs::kSpellCheckDictionary, this);
590 prefs->AddPrefObserver(prefs::kEnableSpellCheck, this);
[email protected]154a4332009-06-03 20:20:58591 prefs->AddPrefObserver(prefs::kEnableAutoSpellCorrect, this);
[email protected]380ab462009-04-24 01:23:58592
[email protected]405a64b2009-09-16 21:03:44593#if defined(OS_MACOSX)
594 // If the profile directory doesn't already have a cache directory and it
595 // is under ~/Library/Application Support, use a suitable cache directory
596 // under ~/Library/Caches. For example, a profile directory of
597 // ~/Library/Application Support/Google/Chrome/MyProfileName that doesn't
598 // have a "Cache" or "MediaCache" subdirectory would use the cache directory
599 // ~/Library/Caches/Google/Chrome/MyProfileName.
600 //
601 // TODO(akalin): Come up with unit tests for this.
[email protected]405a64b2009-09-16 21:03:44602 if (!HasACacheSubdir(path_)) {
603 FilePath app_data_path, user_cache_path;
604 if (PathService::Get(base::DIR_APP_DATA, &app_data_path) &&
[email protected]b70454862009-12-03 01:07:12605 PathService::Get(base::DIR_USER_CACHE, &user_cache_path) &&
[email protected]405a64b2009-09-16 21:03:44606 app_data_path.AppendRelativePath(path_, &user_cache_path)) {
607 base_cache_path_ = user_cache_path;
608 }
609 }
[email protected]9e9b6e8e2009-12-02 08:45:01610#elif defined(OS_POSIX) // Posix minus Mac.
611 // See http://standards.freedesktop.org/basedir-spec/basedir-spec-latest.html
612 // for a spec on where cache files go. The net effect for most systems is we
613 // use ~/.cache/chromium/ for Chromium and ~/.cache/google-chrome/ for
614 // official builds.
615 if (!PathService::IsOverridden(chrome::DIR_USER_DATA)) {
616#if defined(GOOGLE_CHROME_BUILD)
617 const char kCacheDir[] = "google-chrome";
[email protected]405a64b2009-09-16 21:03:44618#else
[email protected]9e9b6e8e2009-12-02 08:45:01619 const char kCacheDir[] = "chromium";
620#endif
621 PathService::Get(base::DIR_USER_CACHE, &base_cache_path_);
622 base_cache_path_ = base_cache_path_.Append(kCacheDir);
623 if (!file_util::PathExists(base_cache_path_))
624 file_util::CreateDirectory(base_cache_path_);
625 }
[email protected]405a64b2009-09-16 21:03:44626#endif
[email protected]bc96d562009-08-11 18:45:13627 if (base_cache_path_.empty())
628 base_cache_path_ = path_;
629
[email protected]4a190632009-05-09 01:07:42630 // Listen for theme installation.
[email protected]88cf3292009-05-22 01:48:43631 registrar_.Add(this, NotificationType::THEME_INSTALLED,
632 NotificationService::AllSources());
[email protected]48352c12009-08-15 01:19:11633
634 // Listen for bookmark model load, to bootstrap the sync service.
635 registrar_.Add(this, NotificationType::BOOKMARK_MODEL_LOADED,
636 Source<Profile>(this));
[email protected]db36938c2009-08-19 21:48:42637
638 ssl_config_service_manager_.reset(
639 SSLConfigServiceManager::CreateDefaultManager(this));
[email protected]2627431b2009-09-15 20:21:53640
641#if defined(OS_CHROMEOS)
[email protected]fecc1522009-10-15 21:08:29642 chromeos_preferences_.Init(prefs);
[email protected]2627431b2009-09-15 20:21:53643#endif
initial.commit09911bf2008-07-26 23:55:29644}
645
[email protected]bdbc87c2009-01-25 05:08:54646void ProfileImpl::InitExtensions() {
[email protected]8c756ac2009-01-30 23:36:41647 if (user_script_master_ || extensions_service_)
648 return; // Already initialized.
649
[email protected]bdbc87c2009-01-25 05:08:54650 const CommandLine* command_line = CommandLine::ForCurrentProcess();
[email protected]bb28e062009-02-27 17:19:18651 ExtensionErrorReporter::Init(true); // allow noisy errors.
[email protected]faed6e12009-11-24 22:38:36652
653 FilePath script_dir; // Don't look for user scripts in any directory.
654 // TODO(aa): We should just remove this functionality,
655 // since it isn't used anymore.
[email protected]c931db62009-12-23 03:28:51656 user_script_master_ = new UserScriptMaster(script_dir, this);
[email protected]faed6e12009-11-24 22:38:36657
[email protected]894bb502009-05-21 22:39:57658 extensions_service_ = new ExtensionsService(
[email protected]a9b00ac2009-06-25 21:03:23659 this,
660 CommandLine::ForCurrentProcess(),
661 GetPrefs(),
662 GetPath().AppendASCII(ExtensionsService::kInstallDirectoryName),
[email protected]c8b437d2009-07-20 21:26:36663 true);
[email protected]bdbc87c2009-01-25 05:08:54664
[email protected]1952c7d2010-03-04 23:48:34665 // Register the bookmark manager extension.
666 if (CommandLine::ForCurrentProcess()->HasSwitch(
667 switches::kEnableTabbedBookmarkManager)) {
668 FilePath bookmark_manager_path;
669 if (PathService::Get(chrome::DIR_BOOKMARK_MANAGER,
670 &bookmark_manager_path)) {
671 std::string manifest =
672 ResourceBundle::GetSharedInstance().GetRawDataResource(
673 IDR_BOOKMARKS_MANIFEST).as_string();
674 extensions_service_->register_component_extension(
675 ExtensionsService::ComponentExtensionInfo(manifest,
676 bookmark_manager_path));
677 } else {
678 NOTREACHED();
679 }
680 }
681
[email protected]9197f3b2009-06-02 00:49:27682 extensions_service_->Init();
[email protected]919ddc82009-07-15 04:30:12683
684 // Load any extensions specified with --load-extension.
685 if (command_line->HasSwitch(switches::kLoadExtension)) {
[email protected]5d39e3142009-12-17 05:54:10686 FilePath path = command_line->GetSwitchValuePath(switches::kLoadExtension);
[email protected]919ddc82009-07-15 04:30:12687 extensions_service_->LoadExtension(path);
[email protected]919ddc82009-07-15 04:30:12688 }
[email protected]bdbc87c2009-01-25 05:08:54689}
690
[email protected]ea0c98cf2009-06-18 23:02:54691void ProfileImpl::InitWebResources() {
[email protected]0c274c202009-07-12 02:59:07692 if (web_resource_service_)
693 return; // Already initialized.
694
[email protected]6fad2632009-11-02 05:59:37695 web_resource_service_ = new WebResourceService(this);
[email protected]ea0c98cf2009-06-18 23:02:54696 web_resource_service_->StartAfterDelay();
697}
698
[email protected]9c8dd902009-11-19 17:50:42699NTPResourceCache* ProfileImpl::GetNTPResourceCache() {
700 if (!ntp_resource_cache_.get())
701 ntp_resource_cache_.reset(new NTPResourceCache(this));
702 return ntp_resource_cache_.get();
703}
704
initial.commit09911bf2008-07-26 23:55:29705ProfileImpl::~ProfileImpl() {
[email protected]d2879af2010-02-08 16:02:56706 NotificationService::current()->Notify(
707 NotificationType::PROFILE_DESTROYED,
708 Source<Profile>(this),
709 NotificationService::NoDetails());
710
[email protected]169627b2008-12-06 19:30:19711 tab_restore_service_ = NULL;
initial.commit09911bf2008-07-26 23:55:29712
713 StopCreateSessionServiceTimer();
714 // TemplateURLModel schedules a task on the WebDataService from its
715 // destructor. Delete it first to ensure the task gets scheduled before we
716 // shut down the database.
717 template_url_model_.reset();
718
719 // The download manager queries the history system and should be deleted
720 // before the history is shutdown so it can properly cancel all requests.
721 download_manager_ = NULL;
722
[email protected]4a190632009-05-09 01:07:42723 // The theme provider provides bitmaps to whoever wants them.
[email protected]761962c2009-09-25 00:18:15724 theme_provider_.reset();
[email protected]4a190632009-05-09 01:07:42725
[email protected]44961292009-07-20 20:03:09726 // The ThumbnailStore saves thumbnails used by the NTP. Call Shutdown to
727 // save any new thumbnails to disk and release its reference to the
728 // HistoryService.
729 if (thumbnail_store_.get())
730 thumbnail_store_->Shutdown();
731
[email protected]e7244d82008-10-29 18:13:26732 // Remove pref observers.
733 PrefService* prefs = GetPrefs();
734 prefs->RemovePrefObserver(prefs::kSpellCheckDictionary, this);
735 prefs->RemovePrefObserver(prefs::kEnableSpellCheck, this);
[email protected]154a4332009-06-03 20:20:58736 prefs->RemovePrefObserver(prefs::kEnableAutoSpellCorrect, this);
[email protected]e7244d82008-10-29 18:13:26737
[email protected]9c8dd902009-11-19 17:50:42738 // Delete the NTP resource cache so we can unregister pref observers.
739 ntp_resource_cache_.reset();
740
[email protected]48352c12009-08-15 01:19:11741 sync_service_.reset();
[email protected]3a453fa2008-08-15 18:46:34742
initial.commit09911bf2008-07-26 23:55:29743 // Both HistoryService and WebDataService maintain threads for background
744 // processing. Its possible each thread still has tasks on it that have
745 // increased the ref count of the service. In such a situation, when we
746 // decrement the refcount, it won't be 0, and the threads/databases aren't
747 // properly shut down. By explicitly calling Cleanup/Shutdown we ensure the
748 // databases are properly closed.
749 if (web_data_service_.get())
750 web_data_service_->Shutdown();
751
752 if (history_service_.get())
753 history_service_->Cleanup();
754
[email protected]85c55dc2009-11-06 03:05:46755 if (spellcheck_host_.get())
756 spellcheck_host_->UnsetObserver();
initial.commit09911bf2008-07-26 23:55:29757
[email protected]cfc06f122009-11-16 22:18:55758 if (default_request_context_ == request_context_)
[email protected]47accfd62009-05-14 18:46:21759 default_request_context_ = NULL;
[email protected]6ab9b202008-12-23 22:34:50760
[email protected]47accfd62009-05-14 18:46:21761 CleanupRequestContext(request_context_);
762 CleanupRequestContext(media_request_context_);
763 CleanupRequestContext(extensions_request_context_);
[email protected]1e744f22009-04-08 01:00:17764
[email protected]d8e41ed2008-09-11 15:22:32765 // HistoryService may call into the BookmarkModel, as such we need to
766 // delete HistoryService before the BookmarkModel. The destructor for
[email protected]90ef13132008-08-27 03:27:46767 // HistoryService will join with HistoryService's backend thread so that
768 // by the time the destructor has finished we're sure it will no longer call
[email protected]d8e41ed2008-09-11 15:22:32769 // into the BookmarkModel.
[email protected]90ef13132008-08-27 03:27:46770 history_service_ = NULL;
771 bookmark_bar_model_.reset();
772
[email protected]0189bc722009-08-28 21:56:48773 // FaviconService depends on HistoryServce so make sure we delete
774 // HistoryService first.
775 favicon_service_ = NULL;
776
[email protected]7120f132009-07-20 21:05:37777 extension_message_service_->ProfileDestroyed();
778
[email protected]6ef635e42009-07-26 06:16:12779 if (extensions_service_)
780 extensions_service_->ProfileDestroyed();
781
[email protected]66da08b2009-10-19 22:27:00782 // This causes the Preferences file to be written to disk.
initial.commit09911bf2008-07-26 23:55:29783 MarkAsCleanShutdown();
784}
785
[email protected]4bf6afd2009-10-08 14:00:11786ProfileId ProfileImpl::GetRuntimeId() {
787 return reinterpret_cast<ProfileId>(this);
788}
789
[email protected]f7011fcb2009-01-28 21:54:32790FilePath ProfileImpl::GetPath() {
initial.commit09911bf2008-07-26 23:55:29791 return path_;
792}
793
794bool ProfileImpl::IsOffTheRecord() {
795 return false;
796}
797
798Profile* ProfileImpl::GetOffTheRecordProfile() {
799 if (!off_the_record_profile_.get()) {
800 scoped_ptr<OffTheRecordProfileImpl> p(new OffTheRecordProfileImpl(this));
801 off_the_record_profile_.swap(p);
802 }
803 return off_the_record_profile_.get();
804}
805
[email protected]860f55492009-03-27 19:50:59806void ProfileImpl::DestroyOffTheRecordProfile() {
807 off_the_record_profile_.reset();
808}
809
initial.commit09911bf2008-07-26 23:55:29810Profile* ProfileImpl::GetOriginalProfile() {
811 return this;
812}
813
[email protected]2f351cb2009-11-09 23:43:34814webkit_database::DatabaseTracker* ProfileImpl::GetDatabaseTracker() {
815 if (!db_tracker_)
816 db_tracker_ = new webkit_database::DatabaseTracker(GetPath());
817 return db_tracker_;
818}
819
initial.commit09911bf2008-07-26 23:55:29820VisitedLinkMaster* ProfileImpl::GetVisitedLinkMaster() {
[email protected]a6d0f182010-01-12 08:01:44821 if (!visited_link_master_.get()) {
822 scoped_ptr<VisitedLinkMaster> visited_links(
823 new VisitedLinkMaster(visited_link_event_listener_.get(), this));
824 if (!visited_links->Init())
825 return NULL;
826 visited_link_master_.swap(visited_links);
[email protected]a5fb1c52010-01-12 03:39:53827 }
[email protected]a6d0f182010-01-12 08:01:44828
829 return visited_link_master_.get();
initial.commit09911bf2008-07-26 23:55:29830}
831
[email protected]6014d672008-12-05 00:38:25832ExtensionsService* ProfileImpl::GetExtensionsService() {
833 return extensions_service_.get();
834}
835
[email protected]0938d3c2009-01-09 20:37:35836UserScriptMaster* ProfileImpl::GetUserScriptMaster() {
[email protected]0938d3c2009-01-09 20:37:35837 return user_script_master_.get();
[email protected]04fba9a92008-10-28 17:25:25838}
839
[email protected]89ebc7e2009-08-24 22:11:07840ExtensionDevToolsManager* ProfileImpl::GetExtensionDevToolsManager() {
841 return extension_devtools_manager_.get();
842}
843
[email protected]481e1a42009-05-06 20:56:05844ExtensionProcessManager* ProfileImpl::GetExtensionProcessManager() {
[email protected]382a0702009-06-26 17:12:27845 return extension_process_manager_.get();
[email protected]481e1a42009-05-06 20:56:05846}
847
[email protected]7120f132009-07-20 21:05:37848ExtensionMessageService* ProfileImpl::GetExtensionMessageService() {
849 return extension_message_service_.get();
850}
851
[email protected]34cc84f2009-02-13 10:04:35852SSLHostState* ProfileImpl::GetSSLHostState() {
853 if (!ssl_host_state_.get())
854 ssl_host_state_.reset(new SSLHostState());
855
856 DCHECK(ssl_host_state_->CalledOnValidThread());
857 return ssl_host_state_.get();
858}
859
[email protected]326e6792009-12-11 21:04:42860net::TransportSecurityState*
861 ProfileImpl::GetTransportSecurityState() {
862 if (!transport_security_state_.get()) {
863 transport_security_state_ = new net::TransportSecurityState();
864 transport_security_persister_ =
865 new TransportSecurityPersister();
866 transport_security_persister_->Initialize(
867 transport_security_state_.get(), path_);
[email protected]887f80d2009-09-04 16:57:51868 }
[email protected]a9cea7542009-05-20 04:30:23869
[email protected]326e6792009-12-11 21:04:42870 return transport_security_state_.get();
[email protected]a9cea7542009-05-20 04:30:23871}
872
initial.commit09911bf2008-07-26 23:55:29873PrefService* ProfileImpl::GetPrefs() {
874 if (!prefs_.get()) {
[email protected]6fad2632009-11-02 05:59:37875 prefs_.reset(new PrefService(GetPrefFilePath()));
initial.commit09911bf2008-07-26 23:55:29876
877 // The Profile class and ProfileManager class may read some prefs so
878 // register known prefs as soon as possible.
879 Profile::RegisterUserPrefs(prefs_.get());
[email protected]9acc48602009-11-30 21:18:51880 browser::RegisterUserPrefs(prefs_.get());
initial.commit09911bf2008-07-26 23:55:29881
882 // The last session exited cleanly if there is no pref for
883 // kSessionExitedCleanly or the value for kSessionExitedCleanly is true.
884 last_session_exited_cleanly_ =
885 prefs_->GetBoolean(prefs::kSessionExitedCleanly);
886 // Mark the session as open.
887 prefs_->SetBoolean(prefs::kSessionExitedCleanly, false);
888 // Make sure we save to disk that the session has opened.
[email protected]6faa0e0d2009-04-28 06:50:36889 prefs_->ScheduleSavePersistentPrefs();
initial.commit09911bf2008-07-26 23:55:29890 }
891
892 return prefs_.get();
893}
894
[email protected]f7011fcb2009-01-28 21:54:32895FilePath ProfileImpl::GetPrefFilePath() {
896 FilePath pref_file_path = path_;
897 pref_file_path = pref_file_path.Append(chrome::kPreferencesFilename);
initial.commit09911bf2008-07-26 23:55:29898 return pref_file_path;
899}
900
[email protected]be180c802009-10-23 06:33:31901URLRequestContextGetter* ProfileImpl::GetRequestContext() {
initial.commit09911bf2008-07-26 23:55:29902 if (!request_context_) {
[email protected]f7011fcb2009-01-28 21:54:32903 FilePath cookie_path = GetPath();
904 cookie_path = cookie_path.Append(chrome::kCookieFilename);
[email protected]bc96d562009-08-11 18:45:13905 FilePath cache_path = base_cache_path_;
[email protected]e5642992009-06-26 23:06:31906 int max_size;
907 GetCacheParameters(kNormalContext, &cache_path, &max_size);
[email protected]2b2830a2009-02-07 01:58:42908
[email protected]405a64b2009-09-16 21:03:44909 cache_path = GetCachePath(cache_path);
[email protected]be180c802009-10-23 06:33:31910 request_context_ = ChromeURLRequestContextGetter::CreateOriginal(
911 this, cookie_path, cache_path, max_size);
initial.commit09911bf2008-07-26 23:55:29912
[email protected]6ab9b202008-12-23 22:34:50913 // The first request context is always a normal (non-OTR) request context.
914 // Even when Chromium is started in OTR mode, a normal profile is always
915 // created first.
916 if (!default_request_context_) {
917 default_request_context_ = request_context_;
[email protected]be180c802009-10-23 06:33:31918 // TODO(eroman): this isn't terribly useful anymore now that the
919 // URLRequestContext is constructed by the IO thread...
[email protected]6ab9b202008-12-23 22:34:50920 NotificationService::current()->Notify(
[email protected]bfd04a62009-02-01 18:16:56921 NotificationType::DEFAULT_REQUEST_CONTEXT_AVAILABLE,
[email protected]6ab9b202008-12-23 22:34:50922 NotificationService::AllSources(), NotificationService::NoDetails());
923 }
initial.commit09911bf2008-07-26 23:55:29924 }
925
926 return request_context_;
927}
928
[email protected]be180c802009-10-23 06:33:31929URLRequestContextGetter* ProfileImpl::GetRequestContextForMedia() {
[email protected]e7f29642009-03-02 22:53:18930 if (!media_request_context_) {
[email protected]bc96d562009-08-11 18:45:13931 FilePath cache_path = base_cache_path_;
[email protected]e5642992009-06-26 23:06:31932 int max_size;
933 GetCacheParameters(kMediaContext, &cache_path, &max_size);
[email protected]e3edeba2009-03-23 18:57:14934
[email protected]405a64b2009-09-16 21:03:44935 cache_path = GetMediaCachePath(cache_path);
[email protected]be180c802009-10-23 06:33:31936 media_request_context_ =
937 ChromeURLRequestContextGetter::CreateOriginalForMedia(
938 this, cache_path, max_size);
[email protected]e7f29642009-03-02 22:53:18939 }
940
941 return media_request_context_;
942}
943
[email protected]0189bc722009-08-28 21:56:48944FaviconService* ProfileImpl::GetFaviconService(ServiceAccessType sat) {
945 if (!favicon_service_created_) {
946 favicon_service_created_ = true;
947 scoped_refptr<FaviconService> service(new FaviconService(this));
948 favicon_service_.swap(service);
949 }
950 return favicon_service_.get();
951}
952
[email protected]be180c802009-10-23 06:33:31953URLRequestContextGetter* ProfileImpl::GetRequestContextForExtensions() {
[email protected]47accfd62009-05-14 18:46:21954 if (!extensions_request_context_) {
955 FilePath cookie_path = GetPath();
956 cookie_path = cookie_path.Append(chrome::kExtensionsCookieFilename);
957
958 extensions_request_context_ =
[email protected]be180c802009-10-23 06:33:31959 ChromeURLRequestContextGetter::CreateOriginalForExtensions(
960 this, cookie_path);
[email protected]47accfd62009-05-14 18:46:21961 }
962
963 return extensions_request_context_;
964}
965
[email protected]db36938c2009-08-19 21:48:42966net::SSLConfigService* ProfileImpl::GetSSLConfigService() {
967 return ssl_config_service_manager_->Get();
968}
969
[email protected]e284e6d82010-01-29 19:49:45970HostContentSettingsMap* ProfileImpl::GetHostContentSettingsMap() {
971 if (!host_content_settings_map_.get())
[email protected]08bc6302010-01-30 02:53:39972 host_content_settings_map_ = new HostContentSettingsMap(this);
[email protected]e284e6d82010-01-29 19:49:45973 return host_content_settings_map_.get();
974}
975
[email protected]40bd6582009-12-04 23:49:51976HostZoomMap* ProfileImpl::GetHostZoomMap() {
977 if (!host_zoom_map_)
978 host_zoom_map_ = new HostZoomMap(this);
979 return host_zoom_map_.get();
980}
981
[email protected]8c6335d32010-01-20 09:21:50982Blacklist* ProfileImpl::GetPrivacyBlacklist() {
[email protected]a307e31e2009-11-30 16:11:27983 if (!CommandLine::ForCurrentProcess()->HasSwitch(
[email protected]c37f8b42010-01-23 16:22:14984 switches::kEnablePrivacyBlacklists))
[email protected]a307e31e2009-11-30 16:11:27985 return NULL;
[email protected]c37f8b42010-01-23 16:22:14986 if (!privacy_blacklist_.get())
[email protected]7a1251842010-01-30 01:17:54987 privacy_blacklist_ = new Blacklist(GetPrefs());
[email protected]8c6335d32010-01-20 09:21:50988 return privacy_blacklist_.get();
[email protected]eaadd9052009-06-23 18:02:23989}
990
initial.commit09911bf2008-07-26 23:55:29991HistoryService* ProfileImpl::GetHistoryService(ServiceAccessType sat) {
992 if (!history_service_created_) {
[email protected]90ef13132008-08-27 03:27:46993 history_service_created_ = true;
initial.commit09911bf2008-07-26 23:55:29994 scoped_refptr<HistoryService> history(new HistoryService(this));
[email protected]d8e41ed2008-09-11 15:22:32995 if (!history->Init(GetPath(), GetBookmarkModel()))
initial.commit09911bf2008-07-26 23:55:29996 return NULL;
997 history_service_.swap(history);
initial.commit09911bf2008-07-26 23:55:29998
999 // Send out the notification that the history service was created.
1000 NotificationService::current()->
[email protected]bfd04a62009-02-01 18:16:561001 Notify(NotificationType::HISTORY_CREATED, Source<Profile>(this),
initial.commit09911bf2008-07-26 23:55:291002 Details<HistoryService>(history_service_.get()));
1003 }
1004 return history_service_.get();
1005}
1006
[email protected]0850fa62009-10-08 22:34:291007HistoryService* ProfileImpl::GetHistoryServiceWithoutCreating() {
1008 return history_service_.get();
1009}
1010
initial.commit09911bf2008-07-26 23:55:291011TemplateURLModel* ProfileImpl::GetTemplateURLModel() {
1012 if (!template_url_model_.get())
1013 template_url_model_.reset(new TemplateURLModel(this));
1014 return template_url_model_.get();
1015}
1016
1017TemplateURLFetcher* ProfileImpl::GetTemplateURLFetcher() {
1018 if (!template_url_fetcher_.get())
1019 template_url_fetcher_.reset(new TemplateURLFetcher(this));
1020 return template_url_fetcher_.get();
1021}
1022
[email protected]11f4857282009-11-13 19:56:171023SearchVersusNavigateClassifier*
1024ProfileImpl::GetSearchVersusNavigateClassifier() {
[email protected]90085af02009-10-29 17:53:211025 if (!search_versus_navigate_classifier_.get()) {
1026 search_versus_navigate_classifier_.reset(
1027 new SearchVersusNavigateClassifier(this));
1028 }
1029 return search_versus_navigate_classifier_.get();
1030}
1031
initial.commit09911bf2008-07-26 23:55:291032WebDataService* ProfileImpl::GetWebDataService(ServiceAccessType sat) {
1033 if (!created_web_data_service_)
1034 CreateWebDataService();
1035 return web_data_service_.get();
1036}
1037
[email protected]9cddbe372009-10-23 21:23:531038WebDataService* ProfileImpl::GetWebDataServiceWithoutCreating() {
1039 return web_data_service_.get();
1040}
1041
initial.commit09911bf2008-07-26 23:55:291042void ProfileImpl::CreateWebDataService() {
1043 DCHECK(!created_web_data_service_ && web_data_service_.get() == NULL);
1044 created_web_data_service_ = true;
1045 scoped_refptr<WebDataService> wds(new WebDataService());
1046 if (!wds->Init(GetPath()))
1047 return;
1048 web_data_service_.swap(wds);
1049}
1050
[email protected]e69d33952009-06-03 22:00:411051PasswordStore* ProfileImpl::GetPasswordStore(ServiceAccessType sat) {
1052 if (!created_password_store_)
1053 CreatePasswordStore();
1054 return password_store_.get();
1055}
1056
1057void ProfileImpl::CreatePasswordStore() {
1058 DCHECK(!created_password_store_ && password_store_.get() == NULL);
1059 created_password_store_ = true;
1060 scoped_refptr<PasswordStore> ps;
1061#if defined(OS_LINUX)
[email protected]d17634b2009-10-20 18:56:251062 // TODO(evanm): implement "native" password management.
1063 // This bug describes the issues.
1064 // http://code.google.com/p/chromium/issues/detail?id=12351
1065 ps = new PasswordStoreDefault(GetWebDataService(Profile::IMPLICIT_ACCESS));
1066 if (!ps->Init())
1067 return;
[email protected]e69d33952009-06-03 22:00:411068#elif defined(OS_WIN)
1069 ps = new PasswordStoreWin(GetWebDataService(Profile::IMPLICIT_ACCESS));
[email protected]034eba52009-06-03 22:50:561070#elif defined(OS_MACOSX)
[email protected]e0411ae52009-06-30 23:59:171071 FilePath login_db_file_path = GetPath();
1072 login_db_file_path = login_db_file_path.Append(chrome::kLoginDataFileName);
1073 LoginDatabaseMac* login_db = new LoginDatabaseMac();
1074 if (!login_db->Init(login_db_file_path)) {
1075 LOG(ERROR) << "Could not initialize login database.";
1076 delete login_db;
1077 return;
1078 }
1079 ps = new PasswordStoreMac(new MacKeychain(), login_db);
[email protected]e69d33952009-06-03 22:00:411080#else
1081 NOTIMPLEMENTED();
1082#endif
1083 if (!ps || !ps->Init()) {
1084 // Try falling back to the default password manager
1085 LOG(WARNING) << "Could not initialise native password manager - "
1086 "falling back to default";
1087 ps = new PasswordStoreDefault(GetWebDataService(Profile::IMPLICIT_ACCESS));
1088 if (!ps->Init())
1089 return;
1090 }
1091 password_store_.swap(ps);
1092}
1093
initial.commit09911bf2008-07-26 23:55:291094DownloadManager* ProfileImpl::GetDownloadManager() {
1095 if (!created_download_manager_) {
1096 scoped_refptr<DownloadManager> dlm(new DownloadManager);
1097 dlm->Init(this);
1098 created_download_manager_ = true;
1099 download_manager_.swap(dlm);
1100 }
1101 return download_manager_.get();
1102}
1103
1104bool ProfileImpl::HasCreatedDownloadManager() const {
1105 return created_download_manager_;
1106}
1107
[email protected]def11712009-11-06 00:42:151108PersonalDataManager* ProfileImpl::GetPersonalDataManager() {
1109 if (!personal_data_manager_.get()) {
[email protected]2609bc12010-01-24 08:32:551110 personal_data_manager_.reset(new PersonalDataManager(this));
[email protected]def11712009-11-06 00:42:151111 }
1112 return personal_data_manager_.get();
1113}
1114
[email protected]4a190632009-05-09 01:07:421115void ProfileImpl::InitThemes() {
1116 if (!created_theme_provider_) {
[email protected]0519e112009-09-29 15:49:571117#if defined(OS_LINUX)
[email protected]761962c2009-09-25 00:18:151118 theme_provider_.reset(new GtkThemeProvider);
[email protected]a5166af62009-07-03 00:42:291119#else
[email protected]761962c2009-09-25 00:18:151120 theme_provider_.reset(new BrowserThemeProvider);
[email protected]a5166af62009-07-03 00:42:291121#endif
[email protected]761962c2009-09-25 00:18:151122 theme_provider_->Init(this);
[email protected]4a190632009-05-09 01:07:421123 created_theme_provider_ = true;
[email protected]4a190632009-05-09 01:07:421124 }
1125}
1126
1127void ProfileImpl::SetTheme(Extension* extension) {
1128 InitThemes();
1129 theme_provider_.get()->SetTheme(extension);
1130}
1131
[email protected]a5166af62009-07-03 00:42:291132void ProfileImpl::SetNativeTheme() {
1133 InitThemes();
1134 theme_provider_.get()->SetNativeTheme();
1135}
1136
[email protected]4a190632009-05-09 01:07:421137void ProfileImpl::ClearTheme() {
1138 InitThemes();
1139 theme_provider_.get()->UseDefaultTheme();
1140}
1141
[email protected]51c490b2009-08-03 16:34:341142Extension* ProfileImpl::GetTheme() {
1143 InitThemes();
1144
1145 std::string id = theme_provider_.get()->GetThemeID();
1146 if (id == BrowserThemeProvider::kDefaultThemeID)
1147 return NULL;
1148
[email protected]61b411612009-11-10 23:17:411149 return extensions_service_->GetExtensionById(id, false);
[email protected]51c490b2009-08-03 16:34:341150}
1151
[email protected]5786d3d2009-12-18 00:18:441152BrowserThemeProvider* ProfileImpl::GetThemeProvider() {
[email protected]4a190632009-05-09 01:07:421153 InitThemes();
1154 return theme_provider_.get();
1155}
1156
initial.commit09911bf2008-07-26 23:55:291157SessionService* ProfileImpl::GetSessionService() {
1158 if (!session_service_.get() && !shutdown_session_service_) {
1159 session_service_ = new SessionService(this);
1160 session_service_->ResetFromCurrentBrowsers();
1161 }
1162 return session_service_.get();
1163}
1164
1165void ProfileImpl::ShutdownSessionService() {
1166 if (shutdown_session_service_)
1167 return;
1168
1169 // We're about to exit, force creation of the session service if it hasn't
1170 // been created yet. We do this to ensure session state matches the point in
1171 // time the user exited.
1172 GetSessionService();
1173 shutdown_session_service_ = true;
1174 session_service_ = NULL;
1175}
1176
1177bool ProfileImpl::HasSessionService() const {
1178 return (session_service_.get() != NULL);
1179}
1180
initial.commit09911bf2008-07-26 23:55:291181bool ProfileImpl::DidLastSessionExitCleanly() {
1182 // last_session_exited_cleanly_ is set when the preferences are loaded. Force
1183 // it to be set by asking for the prefs.
1184 GetPrefs();
1185 return last_session_exited_cleanly_;
1186}
1187
[email protected]d8e41ed2008-09-11 15:22:321188BookmarkModel* ProfileImpl::GetBookmarkModel() {
[email protected]90ef13132008-08-27 03:27:461189 if (!bookmark_bar_model_.get()) {
[email protected]d8e41ed2008-09-11 15:22:321190 bookmark_bar_model_.reset(new BookmarkModel(this));
[email protected]90ef13132008-08-27 03:27:461191 bookmark_bar_model_->Load();
1192 }
initial.commit09911bf2008-07-26 23:55:291193 return bookmark_bar_model_.get();
1194}
1195
1196bool ProfileImpl::IsSameProfile(Profile* profile) {
1197 if (profile == static_cast<Profile*>(this))
1198 return true;
1199 OffTheRecordProfileImpl* otr_profile = off_the_record_profile_.get();
1200 return otr_profile && profile == static_cast<Profile*>(otr_profile);
1201}
1202
1203Time ProfileImpl::GetStartTime() const {
1204 return start_time_;
1205}
1206
1207TabRestoreService* ProfileImpl::GetTabRestoreService() {
1208 if (!tab_restore_service_.get())
[email protected]169627b2008-12-06 19:30:191209 tab_restore_service_ = new TabRestoreService(this);
initial.commit09911bf2008-07-26 23:55:291210 return tab_restore_service_.get();
1211}
1212
[email protected]449478302009-06-09 20:04:281213ThumbnailStore* ProfileImpl::GetThumbnailStore() {
1214 if (!thumbnail_store_.get()) {
1215 thumbnail_store_ = new ThumbnailStore;
[email protected]daa82dc2009-07-28 01:22:251216 thumbnail_store_->Init(
1217 GetPath().Append(chrome::kNewTabThumbnailsFilename), this);
[email protected]449478302009-06-09 20:04:281218 }
1219 return thumbnail_store_.get();
1220}
1221
initial.commit09911bf2008-07-26 23:55:291222void ProfileImpl::ResetTabRestoreService() {
[email protected]169627b2008-12-06 19:30:191223 tab_restore_service_ = NULL;
initial.commit09911bf2008-07-26 23:55:291224}
1225
[email protected]85c55dc2009-11-06 03:05:461226SpellCheckHost* ProfileImpl::GetSpellCheckHost() {
1227 return spellcheck_host_ready_ ? spellcheck_host_.get() : NULL;
1228}
1229
1230void ProfileImpl::ReinitializeSpellCheckHost(bool force) {
1231 // If we are already loading the spellchecker, and this is just a hint to
1232 // load the spellchecker, do nothing.
1233 if (!force && spellcheck_host_.get())
1234 return;
1235
[email protected]f41301e2009-11-16 21:30:071236 spellcheck_host_ready_ = false;
1237
[email protected]85c55dc2009-11-06 03:05:461238 bool notify = false;
1239 if (spellcheck_host_.get()) {
1240 spellcheck_host_->UnsetObserver();
[email protected]71c012a2009-11-10 01:33:051241 spellcheck_host_ = NULL;
[email protected]85c55dc2009-11-06 03:05:461242 notify = true;
1243 }
1244
1245 PrefService* prefs = GetPrefs();
1246 if (prefs->GetBoolean(prefs::kEnableSpellCheck)) {
1247 // Retrieve the (perhaps updated recently) dictionary name from preferences.
1248 spellcheck_host_ = new SpellCheckHost(this,
1249 WideToASCII(prefs->GetString(prefs::kSpellCheckDictionary)),
1250 GetRequestContext());
[email protected]f41301e2009-11-16 21:30:071251 spellcheck_host_->Initialize();
[email protected]85c55dc2009-11-06 03:05:461252 } else if (notify) {
1253 // The spellchecker has been disabled.
1254 SpellCheckHostInitialized();
1255 }
1256}
1257
1258void ProfileImpl::SpellCheckHostInitialized() {
[email protected]cb6037d2009-11-16 22:55:171259 spellcheck_host_ready_ = spellcheck_host_ &&
[email protected]c27324b2009-11-19 22:44:291260 (spellcheck_host_->bdict_file() != base::kInvalidPlatformFileValue ||
1261 spellcheck_host_->use_platform_spellchecker());
[email protected]85c55dc2009-11-06 03:05:461262 NotificationService::current()->Notify(
1263 NotificationType::SPELLCHECK_HOST_REINITIALIZED,
1264 Source<Profile>(this), NotificationService::NoDetails());
1265}
initial.commit09911bf2008-07-26 23:55:291266
[email protected]3bf335a2009-06-26 20:46:061267WebKitContext* ProfileImpl::GetWebKitContext() {
1268 if (!webkit_context_.get())
1269 webkit_context_ = new WebKitContext(path_, false);
1270 DCHECK(webkit_context_.get());
1271 return webkit_context_.get();
1272}
1273
[email protected]4bb336302009-10-12 05:44:261274DesktopNotificationService* ProfileImpl::GetDesktopNotificationService() {
1275 DCHECK(ChromeThread::CurrentlyOn(ChromeThread::UI));
1276 if (!desktop_notification_service_.get()) {
[email protected]4bb336302009-10-12 05:44:261277 desktop_notification_service_.reset(new DesktopNotificationService(
[email protected]29672ab2009-10-30 03:44:031278 this, g_browser_process->notification_ui_manager()));
[email protected]4bb336302009-10-12 05:44:261279 }
[email protected]4bb336302009-10-12 05:44:261280 return desktop_notification_service_.get();
1281}
1282
initial.commit09911bf2008-07-26 23:55:291283void ProfileImpl::MarkAsCleanShutdown() {
1284 if (prefs_.get()) {
1285 // The session cleanly exited, set kSessionExitedCleanly appropriately.
1286 prefs_->SetBoolean(prefs::kSessionExitedCleanly, true);
1287
1288 // NOTE: If you change what thread this writes on, be sure and update
1289 // ChromeFrame::EndSession().
[email protected]6faa0e0d2009-04-28 06:50:361290 prefs_->SavePersistentPrefs();
initial.commit09911bf2008-07-26 23:55:291291 }
1292}
1293
[email protected]e7244d82008-10-29 18:13:261294void ProfileImpl::Observe(NotificationType type,
1295 const NotificationSource& source,
1296 const NotificationDetails& details) {
[email protected]bfd04a62009-02-01 18:16:561297 if (NotificationType::PREF_CHANGED == type) {
[email protected]e7244d82008-10-29 18:13:261298 std::wstring* pref_name_in = Details<std::wstring>(details).ptr();
1299 PrefService* prefs = Source<PrefService>(source).ptr();
1300 DCHECK(pref_name_in && prefs);
1301 if (*pref_name_in == prefs::kSpellCheckDictionary ||
[email protected]85c55dc2009-11-06 03:05:461302 *pref_name_in == prefs::kEnableSpellCheck) {
[email protected]85c55dc2009-11-06 03:05:461303 ReinitializeSpellCheckHost(true);
[email protected]c27324b2009-11-19 22:44:291304 } else if (*pref_name_in == prefs::kEnableAutoSpellCorrect) {
1305 NotificationService::current()->Notify(
1306 NotificationType::SPELLCHECK_AUTOSPELL_TOGGLED,
1307 Source<Profile>(this), NotificationService::NoDetails());
[email protected]e7244d82008-10-29 18:13:261308 }
[email protected]4a190632009-05-09 01:07:421309 } else if (NotificationType::THEME_INSTALLED == type) {
1310 Extension* extension = Details<Extension>(details).ptr();
1311 SetTheme(extension);
[email protected]48352c12009-08-15 01:19:111312 } else if (NotificationType::BOOKMARK_MODEL_LOADED == type) {
1313 GetProfileSyncService(); // Causes lazy-load if sync is enabled.
1314 registrar_.Remove(this, NotificationType::BOOKMARK_MODEL_LOADED,
1315 Source<Profile>(this));
[email protected]e7244d82008-10-29 18:13:261316 }
1317}
1318
initial.commit09911bf2008-07-26 23:55:291319void ProfileImpl::StopCreateSessionServiceTimer() {
[email protected]2d316662008-09-03 18:18:141320 create_session_service_timer_.Stop();
initial.commit09911bf2008-07-26 23:55:291321}
[email protected]3a453fa2008-08-15 18:46:341322
[email protected]48352c12009-08-15 01:19:111323ProfileSyncService* ProfileImpl::GetProfileSyncService() {
[email protected]eec3bcfa2009-11-12 17:23:431324 if (!ProfileSyncService::IsSyncEnabled()) {
1325 return NULL;
[email protected]7367f1a2009-10-10 01:09:441326 }
[email protected]eec3bcfa2009-11-12 17:23:431327 if (!sync_service_.get())
1328 InitSyncService();
1329 return sync_service_.get();
[email protected]48352c12009-08-15 01:19:111330}
1331
1332void ProfileImpl::InitSyncService() {
[email protected]4aea04a2010-02-10 20:13:431333 profile_sync_factory_.reset(
1334 new ProfileSyncFactoryImpl(this,
1335 CommandLine::ForCurrentProcess()));
1336 sync_service_.reset(
1337 profile_sync_factory_->CreateProfileSyncService());
[email protected]48352c12009-08-15 01:19:111338 sync_service_->Initialize();
[email protected]48352c12009-08-15 01:19:111339}