license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 1 | // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. |
| 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/browser/profile.h" |
| 6 | |
| 7 | #include "base/command_line.h" |
[email protected] | 04fba9a9 | 2008-10-28 17:25:25 | [diff] [blame] | 8 | #include "base/file_path.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 9 | #include "base/file_util.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 10 | #include "base/path_service.h" |
| 11 | #include "base/scoped_ptr.h" |
| 12 | #include "base/string_util.h" |
[email protected] | a9afddb | 2009-02-12 17:49:42 | [diff] [blame] | 13 | #include "chrome/browser/bookmarks/bookmark_model.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 14 | #include "chrome/browser/browser_list.h" |
| 15 | #include "chrome/browser/browser_process.h" |
[email protected] | 67a46b7f | 2009-06-16 21:41:02 | [diff] [blame^] | 16 | #include "chrome/browser/browser_theme_provider.h" |
[email protected] | b7f0588 | 2009-02-22 01:21:56 | [diff] [blame] | 17 | #include "chrome/browser/download/download_manager.h" |
[email protected] | 481e1a4 | 2009-05-06 20:56:05 | [diff] [blame] | 18 | #include "chrome/browser/extensions/extension_process_manager.h" |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 19 | #include "chrome/browser/extensions/extensions_service.h" |
[email protected] | 0938d3c | 2009-01-09 20:37:35 | [diff] [blame] | 20 | #include "chrome/browser/extensions/user_script_master.h" |
[email protected] | a9afddb | 2009-02-12 17:49:42 | [diff] [blame] | 21 | #include "chrome/browser/history/history.h" |
[email protected] | 6ab9b20 | 2008-12-23 22:34:50 | [diff] [blame] | 22 | #include "chrome/browser/net/chrome_url_request_context.h" |
[email protected] | e69d3395 | 2009-06-03 22:00:41 | [diff] [blame] | 23 | #include "chrome/browser/password_manager/password_store_default.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 24 | #include "chrome/browser/profile_manager.h" |
[email protected] | 8c8657d6 | 2009-01-16 18:31:26 | [diff] [blame] | 25 | #include "chrome/browser/renderer_host/render_process_host.h" |
[email protected] | 1132436e | 2009-04-08 20:06:33 | [diff] [blame] | 26 | #include "chrome/browser/search_engines/template_url_fetcher.h" |
[email protected] | f63ae31 | 2009-02-04 17:58:46 | [diff] [blame] | 27 | #include "chrome/browser/search_engines/template_url_model.h" |
[email protected] | 85e921fb8 | 2009-02-11 23:19:44 | [diff] [blame] | 28 | #include "chrome/browser/sessions/session_service.h" |
[email protected] | bd580a25 | 2009-02-12 01:16:30 | [diff] [blame] | 29 | #include "chrome/browser/sessions/tab_restore_service.h" |
[email protected] | f0a64429 | 2009-02-25 23:32:47 | [diff] [blame] | 30 | #include "chrome/browser/spellchecker.h" |
[email protected] | 1132436e | 2009-04-08 20:06:33 | [diff] [blame] | 31 | #include "chrome/browser/ssl/ssl_host_state.h" |
[email protected] | 44947830 | 2009-06-09 20:04:28 | [diff] [blame] | 32 | #include "chrome/browser/thumbnail_store.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 33 | #include "chrome/browser/visitedlink_master.h" |
| 34 | #include "chrome/browser/webdata/web_data_service.h" |
| 35 | #include "chrome/common/chrome_constants.h" |
| 36 | #include "chrome/common/chrome_paths.h" |
| 37 | #include "chrome/common/chrome_switches.h" |
[email protected] | 5b1a0e2 | 2009-05-26 19:00:58 | [diff] [blame] | 38 | #include "chrome/common/extensions/extension_error_reporter.h" |
[email protected] | 47accfd6 | 2009-05-14 18:46:21 | [diff] [blame] | 39 | #include "chrome/common/net/cookie_monster_sqlite.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 40 | #include "chrome/common/notification_service.h" |
| 41 | #include "chrome/common/pref_names.h" |
[email protected] | f7011fcb | 2009-01-28 21:54:32 | [diff] [blame] | 42 | #include "chrome/common/render_messages.h" |
[email protected] | f90f5c51 | 2009-02-18 19:10:58 | [diff] [blame] | 43 | #include "grit/locale_settings.h" |
[email protected] | a9cea754 | 2009-05-20 04:30:23 | [diff] [blame] | 44 | #include "net/base/force_tls_state.h" |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 45 | |
[email protected] | e1acf6f | 2008-10-27 20:43:33 | [diff] [blame] | 46 | using base::Time; |
| 47 | using base::TimeDelta; |
| 48 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 49 | // Delay, in milliseconds, before we explicitly create the SessionService. |
| 50 | static const int kCreateSessionServiceDelayMS = 500; |
| 51 | |
| 52 | // A pointer to the request context for the default profile. See comments on |
| 53 | // Profile::GetDefaultRequestContext. |
| 54 | URLRequestContext* Profile::default_request_context_; |
| 55 | |
[email protected] | 47accfd6 | 2009-05-14 18:46:21 | [diff] [blame] | 56 | static void CleanupRequestContext(ChromeURLRequestContext* context) { |
| 57 | if (context) { |
| 58 | context->CleanupOnUIThread(); |
| 59 | |
| 60 | // Clean up request context on IO thread. |
| 61 | g_browser_process->io_thread()->message_loop()->ReleaseSoon(FROM_HERE, |
| 62 | context); |
| 63 | } |
| 64 | } |
| 65 | |
[email protected] | 34cc84f | 2009-02-13 10:04:35 | [diff] [blame] | 66 | // static |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 67 | void Profile::RegisterUserPrefs(PrefService* prefs) { |
[email protected] | 430d3f7 | 2008-10-27 17:56:55 | [diff] [blame] | 68 | prefs->RegisterBooleanPref(prefs::kSearchSuggestEnabled, true); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 69 | prefs->RegisterBooleanPref(prefs::kSessionExitedCleanly, true); |
| 70 | prefs->RegisterBooleanPref(prefs::kSafeBrowsingEnabled, true); |
[email protected] | 74c8b42 | 2009-03-11 00:34:12 | [diff] [blame] | 71 | // TODO(estade): IDS_SPELLCHECK_DICTIONARY should be an ASCII string. |
[email protected] | e7244d8 | 2008-10-29 18:13:26 | [diff] [blame] | 72 | prefs->RegisterLocalizedStringPref(prefs::kSpellCheckDictionary, |
| 73 | IDS_SPELLCHECK_DICTIONARY); |
| 74 | prefs->RegisterBooleanPref(prefs::kEnableSpellCheck, true); |
[email protected] | 154a433 | 2009-06-03 20:20:58 | [diff] [blame] | 75 | prefs->RegisterBooleanPref(prefs::kEnableAutoSpellCorrect, true); |
[email protected] | f93fe78 | 2009-02-19 01:26:13 | [diff] [blame] | 76 | prefs->RegisterBooleanPref(prefs::kEnableUserScripts, false); |
[email protected] | 4a19063 | 2009-05-09 01:07:42 | [diff] [blame] | 77 | prefs->RegisterStringPref(prefs::kCurrentThemeID, L""); |
| 78 | prefs->RegisterDictionaryPref(prefs::kCurrentThemeImages); |
| 79 | prefs->RegisterDictionaryPref(prefs::kCurrentThemeColors); |
| 80 | prefs->RegisterDictionaryPref(prefs::kCurrentThemeTints); |
[email protected] | 7895ea2 | 2009-06-02 20:53:50 | [diff] [blame] | 81 | prefs->RegisterDictionaryPref(prefs::kCurrentThemeDisplayProperties); |
[email protected] | f93fe78 | 2009-02-19 01:26:13 | [diff] [blame] | 82 | prefs->RegisterBooleanPref(prefs::kEnableExtensions, false); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 83 | } |
| 84 | |
[email protected] | 34cc84f | 2009-02-13 10:04:35 | [diff] [blame] | 85 | // static |
[email protected] | f7011fcb | 2009-01-28 21:54:32 | [diff] [blame] | 86 | Profile* Profile::CreateProfile(const FilePath& path) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 87 | return new ProfileImpl(path); |
| 88 | } |
| 89 | |
[email protected] | 34cc84f | 2009-02-13 10:04:35 | [diff] [blame] | 90 | // static |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 91 | URLRequestContext* Profile::GetDefaultRequestContext() { |
| 92 | return default_request_context_; |
| 93 | } |
| 94 | |
[email protected] | e69d3395 | 2009-06-03 22:00:41 | [diff] [blame] | 95 | #if defined(OS_LINUX) |
| 96 | // Temporarily disabled while we figure some stuff out. |
| 97 | // http://code.google.com/p/chromium/issues/detail?id=12351 |
| 98 | // #include "chrome/browser/password_manager/password_store_gnome.h" |
| 99 | // #include "chrome/browser/password_manager/password_store_kwallet.h" |
| 100 | #elif defined(OS_WIN) |
| 101 | #include "chrome/browser/password_manager/password_store_win.h" |
[email protected] | 034eba5 | 2009-06-03 22:50:56 | [diff] [blame] | 102 | #elif defined(OS_MACOSX) |
| 103 | #include "chrome/browser/keychain_mac.h" |
| 104 | #include "chrome/browser/password_manager/password_store_mac.h" |
[email protected] | e69d3395 | 2009-06-03 22:00:41 | [diff] [blame] | 105 | #endif |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 106 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 107 | //////////////////////////////////////////////////////////////////////////////// |
| 108 | // |
| 109 | // OffTheRecordProfileImpl is a profile subclass that wraps an existing profile |
[email protected] | 4a19063 | 2009-05-09 01:07:42 | [diff] [blame] | 110 | // to make it suitable for the off the record mode. |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 111 | // |
| 112 | //////////////////////////////////////////////////////////////////////////////// |
| 113 | class OffTheRecordProfileImpl : public Profile, |
| 114 | public NotificationObserver { |
| 115 | public: |
| 116 | explicit OffTheRecordProfileImpl(Profile* real_profile) |
| 117 | : profile_(real_profile), |
[email protected] | 47accfd6 | 2009-05-14 18:46:21 | [diff] [blame] | 118 | extensions_request_context_(NULL), |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 119 | start_time_(Time::Now()) { |
[email protected] | 6ab9b20 | 2008-12-23 22:34:50 | [diff] [blame] | 120 | request_context_ = ChromeURLRequestContext::CreateOffTheRecord(this); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 121 | request_context_->AddRef(); |
[email protected] | 481e1a4 | 2009-05-06 20:56:05 | [diff] [blame] | 122 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 123 | // Register for browser close notifications so we can detect when the last |
| 124 | // off-the-record window is closed, in which case we can clean our states |
| 125 | // (cookies, downloads...). |
[email protected] | 88cf329 | 2009-05-22 01:48:43 | [diff] [blame] | 126 | registrar_.Add(this, NotificationType::BROWSER_CLOSED, |
| 127 | NotificationService::AllSources()); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 128 | } |
| 129 | |
| 130 | virtual ~OffTheRecordProfileImpl() { |
[email protected] | 47accfd6 | 2009-05-14 18:46:21 | [diff] [blame] | 131 | CleanupRequestContext(request_context_); |
[email protected] | 47accfd6 | 2009-05-14 18:46:21 | [diff] [blame] | 132 | CleanupRequestContext(extensions_request_context_); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 133 | } |
| 134 | |
[email protected] | f7011fcb | 2009-01-28 21:54:32 | [diff] [blame] | 135 | virtual FilePath GetPath() { return profile_->GetPath(); } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 136 | |
| 137 | virtual bool IsOffTheRecord() { |
| 138 | return true; |
| 139 | } |
| 140 | |
| 141 | virtual Profile* GetOffTheRecordProfile() { |
| 142 | return this; |
| 143 | } |
| 144 | |
[email protected] | 860f5549 | 2009-03-27 19:50:59 | [diff] [blame] | 145 | virtual void DestroyOffTheRecordProfile() { |
| 146 | // Suicide is bad! |
| 147 | NOTREACHED(); |
| 148 | } |
| 149 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 150 | virtual Profile* GetOriginalProfile() { |
| 151 | return profile_; |
| 152 | } |
| 153 | |
| 154 | virtual VisitedLinkMaster* GetVisitedLinkMaster() { |
[email protected] | 7fb6c86 | 2009-03-13 02:51:49 | [diff] [blame] | 155 | // We don't provide access to the VisitedLinkMaster when we're OffTheRecord |
| 156 | // because we don't want to leak the sites that the user has visited before. |
| 157 | return NULL; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 158 | } |
| 159 | |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 160 | virtual ExtensionsService* GetExtensionsService() { |
[email protected] | 1bd5413 | 2009-06-11 00:05:34 | [diff] [blame] | 161 | return NULL; |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 162 | } |
| 163 | |
[email protected] | 0938d3c | 2009-01-09 20:37:35 | [diff] [blame] | 164 | virtual UserScriptMaster* GetUserScriptMaster() { |
| 165 | return profile_->GetUserScriptMaster(); |
[email protected] | 04fba9a9 | 2008-10-28 17:25:25 | [diff] [blame] | 166 | } |
| 167 | |
[email protected] | 481e1a4 | 2009-05-06 20:56:05 | [diff] [blame] | 168 | virtual ExtensionProcessManager* GetExtensionProcessManager() { |
[email protected] | 1bd5413 | 2009-06-11 00:05:34 | [diff] [blame] | 169 | return NULL; |
[email protected] | 481e1a4 | 2009-05-06 20:56:05 | [diff] [blame] | 170 | } |
| 171 | |
[email protected] | 34cc84f | 2009-02-13 10:04:35 | [diff] [blame] | 172 | virtual SSLHostState* GetSSLHostState() { |
| 173 | if (!ssl_host_state_.get()) |
| 174 | ssl_host_state_.reset(new SSLHostState()); |
| 175 | |
| 176 | DCHECK(ssl_host_state_->CalledOnValidThread()); |
| 177 | return ssl_host_state_.get(); |
| 178 | } |
| 179 | |
[email protected] | a9cea754 | 2009-05-20 04:30:23 | [diff] [blame] | 180 | virtual net::ForceTLSState* GetForceTLSState() { |
| 181 | if (!force_tls_state_.get()) |
| 182 | force_tls_state_.reset(new net::ForceTLSState()); |
| 183 | |
| 184 | return force_tls_state_.get(); |
| 185 | } |
| 186 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 187 | virtual HistoryService* GetHistoryService(ServiceAccessType sat) { |
| 188 | if (sat == EXPLICIT_ACCESS) { |
| 189 | return profile_->GetHistoryService(sat); |
| 190 | } else { |
| 191 | NOTREACHED() << "This profile is OffTheRecord"; |
| 192 | return NULL; |
| 193 | } |
| 194 | } |
| 195 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 196 | virtual WebDataService* GetWebDataService(ServiceAccessType sat) { |
| 197 | if (sat == EXPLICIT_ACCESS) { |
| 198 | return profile_->GetWebDataService(sat); |
| 199 | } else { |
| 200 | NOTREACHED() << "This profile is OffTheRecord"; |
| 201 | return NULL; |
| 202 | } |
| 203 | } |
| 204 | |
[email protected] | e69d3395 | 2009-06-03 22:00:41 | [diff] [blame] | 205 | virtual PasswordStore* GetPasswordStore(ServiceAccessType sat) { |
| 206 | if (sat == EXPLICIT_ACCESS) { |
| 207 | return profile_->GetPasswordStore(sat); |
| 208 | } else { |
| 209 | NOTREACHED() << "This profile is OffTheRecord"; |
| 210 | return NULL; |
| 211 | } |
| 212 | } |
| 213 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 214 | virtual PrefService* GetPrefs() { |
| 215 | return profile_->GetPrefs(); |
| 216 | } |
| 217 | |
| 218 | virtual TemplateURLModel* GetTemplateURLModel() { |
| 219 | return profile_->GetTemplateURLModel(); |
| 220 | } |
| 221 | |
| 222 | virtual TemplateURLFetcher* GetTemplateURLFetcher() { |
| 223 | return profile_->GetTemplateURLFetcher(); |
| 224 | } |
| 225 | |
| 226 | virtual DownloadManager* GetDownloadManager() { |
| 227 | if (!download_manager_.get()) { |
| 228 | scoped_refptr<DownloadManager> dlm(new DownloadManager); |
| 229 | dlm->Init(this); |
| 230 | download_manager_.swap(dlm); |
| 231 | } |
| 232 | return download_manager_.get(); |
| 233 | } |
| 234 | |
| 235 | virtual bool HasCreatedDownloadManager() const { |
| 236 | return (download_manager_.get() != NULL); |
| 237 | } |
| 238 | |
[email protected] | 4a19063 | 2009-05-09 01:07:42 | [diff] [blame] | 239 | virtual void InitThemes() { |
| 240 | GetOriginalProfile()->InitThemes(); |
| 241 | } |
| 242 | |
| 243 | virtual void SetTheme(Extension* extension) { |
| 244 | GetOriginalProfile()->SetTheme(extension); |
| 245 | } |
| 246 | |
| 247 | virtual void ClearTheme() { |
| 248 | GetOriginalProfile()->ClearTheme(); |
| 249 | } |
| 250 | |
| 251 | virtual ThemeProvider* GetThemeProvider() { |
| 252 | return GetOriginalProfile()->GetThemeProvider(); |
| 253 | } |
| 254 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 255 | virtual URLRequestContext* GetRequestContext() { |
| 256 | return request_context_; |
| 257 | } |
| 258 | |
[email protected] | e7f2964 | 2009-03-02 22:53:18 | [diff] [blame] | 259 | virtual URLRequestContext* GetRequestContextForMedia() { |
[email protected] | d14c7ac | 2009-05-29 20:38:11 | [diff] [blame] | 260 | // In OTR mode, media request context is the same as the original one. |
| 261 | return request_context_; |
[email protected] | e7f2964 | 2009-03-02 22:53:18 | [diff] [blame] | 262 | } |
| 263 | |
[email protected] | 47accfd6 | 2009-05-14 18:46:21 | [diff] [blame] | 264 | URLRequestContext* GetRequestContextForExtensions() { |
| 265 | if (!extensions_request_context_) { |
| 266 | extensions_request_context_ = |
| 267 | ChromeURLRequestContext::CreateOffTheRecordForExtensions(this); |
| 268 | extensions_request_context_->AddRef(); |
| 269 | |
| 270 | DCHECK(extensions_request_context_->cookie_store()); |
| 271 | } |
| 272 | |
| 273 | return extensions_request_context_; |
| 274 | } |
| 275 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 276 | virtual SessionService* GetSessionService() { |
| 277 | // Don't save any sessions when off the record. |
| 278 | return NULL; |
| 279 | } |
| 280 | |
| 281 | virtual void ShutdownSessionService() { |
| 282 | // We don't allow a session service, nothing to do. |
| 283 | } |
| 284 | |
| 285 | virtual bool HasSessionService() const { |
| 286 | // We never have a session service. |
| 287 | return false; |
| 288 | } |
| 289 | |
| 290 | virtual std::wstring GetName() { |
| 291 | return profile_->GetName(); |
| 292 | } |
| 293 | |
| 294 | virtual void SetName(const std::wstring& name) { |
| 295 | profile_->SetName(name); |
| 296 | } |
| 297 | |
| 298 | virtual std::wstring GetID() { |
| 299 | return profile_->GetID(); |
| 300 | } |
| 301 | |
| 302 | virtual void SetID(const std::wstring& id) { |
| 303 | profile_->SetID(id); |
| 304 | } |
| 305 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 306 | virtual bool DidLastSessionExitCleanly() { |
| 307 | return profile_->DidLastSessionExitCleanly(); |
| 308 | } |
| 309 | |
[email protected] | d8e41ed | 2008-09-11 15:22:32 | [diff] [blame] | 310 | virtual BookmarkModel* GetBookmarkModel() { |
| 311 | return profile_->GetBookmarkModel(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 312 | } |
| 313 | |
[email protected] | 3a453fa | 2008-08-15 18:46:34 | [diff] [blame] | 314 | #ifdef CHROME_PERSONALIZATION |
[email protected] | 57d3d0a | 2008-09-24 00:50:07 | [diff] [blame] | 315 | virtual ProfilePersonalization* GetProfilePersonalization() { |
[email protected] | 3a453fa | 2008-08-15 18:46:34 | [diff] [blame] | 316 | return profile_->GetProfilePersonalization(); |
| 317 | } |
| 318 | #endif |
| 319 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 320 | virtual bool IsSameProfile(Profile* profile) { |
| 321 | if (profile == static_cast<Profile*>(this)) |
| 322 | return true; |
| 323 | return profile == profile_; |
| 324 | } |
| 325 | |
| 326 | virtual Time GetStartTime() const { |
| 327 | return start_time_; |
| 328 | } |
| 329 | |
| 330 | virtual TabRestoreService* GetTabRestoreService() { |
| 331 | return NULL; |
| 332 | } |
| 333 | |
[email protected] | e7244d8 | 2008-10-29 18:13:26 | [diff] [blame] | 334 | virtual void ResetTabRestoreService() { |
[email protected] | 2093085 | 2008-10-15 19:30:41 | [diff] [blame] | 335 | } |
| 336 | |
[email protected] | e7244d8 | 2008-10-29 18:13:26 | [diff] [blame] | 337 | virtual void ReinitializeSpellChecker() { |
| 338 | profile_->ReinitializeSpellChecker(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 339 | } |
| 340 | |
| 341 | virtual SpellChecker* GetSpellChecker() { |
| 342 | return profile_->GetSpellChecker(); |
| 343 | } |
| 344 | |
[email protected] | 44947830 | 2009-06-09 20:04:28 | [diff] [blame] | 345 | virtual ThumbnailStore* GetThumbnailStore() { |
| 346 | return NULL; |
| 347 | } |
| 348 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 349 | virtual void MarkAsCleanShutdown() { |
| 350 | } |
| 351 | |
[email protected] | bdbc87c | 2009-01-25 05:08:54 | [diff] [blame] | 352 | virtual void InitExtensions() { |
| 353 | NOTREACHED(); |
| 354 | } |
| 355 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 356 | virtual void ExitedOffTheRecordMode() { |
| 357 | // Drop our download manager so we forget about all the downloads made |
| 358 | // in off-the-record mode. |
| 359 | download_manager_ = NULL; |
| 360 | } |
| 361 | |
| 362 | virtual void Observe(NotificationType type, |
| 363 | const NotificationSource& source, |
| 364 | const NotificationDetails& details) { |
[email protected] | bfd04a6 | 2009-02-01 18:16:56 | [diff] [blame] | 365 | DCHECK_EQ(NotificationType::BROWSER_CLOSED, type.value); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 366 | // We are only interested in OTR browser closing. |
| 367 | if (Source<Browser>(source)->profile() != this) |
| 368 | return; |
| 369 | |
| 370 | // Let's check if we still have an Off The Record window opened. |
| 371 | // Note that we check against 1 as this notification is sent before the |
| 372 | // browser window is actually removed from the list. |
| 373 | if (BrowserList::GetBrowserCount(this) <= 1) |
| 374 | ExitedOffTheRecordMode(); |
| 375 | } |
| 376 | |
| 377 | private: |
[email protected] | 88cf329 | 2009-05-22 01:48:43 | [diff] [blame] | 378 | NotificationRegistrar registrar_; |
| 379 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 380 | // The real underlying profile. |
| 381 | Profile* profile_; |
| 382 | |
[email protected] | 6ab9b20 | 2008-12-23 22:34:50 | [diff] [blame] | 383 | // The context to use for requests made from this OTR session. |
| 384 | ChromeURLRequestContext* request_context_; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 385 | |
[email protected] | 47accfd6 | 2009-05-14 18:46:21 | [diff] [blame] | 386 | ChromeURLRequestContext* extensions_request_context_; |
| 387 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 388 | // The download manager that only stores downloaded items in memory. |
| 389 | scoped_refptr<DownloadManager> download_manager_; |
| 390 | |
[email protected] | 4a19063 | 2009-05-09 01:07:42 | [diff] [blame] | 391 | // The download manager that only stores downloaded items in memory. |
| 392 | scoped_refptr<BrowserThemeProvider> theme_provider_; |
| 393 | |
[email protected] | 34cc84f | 2009-02-13 10:04:35 | [diff] [blame] | 394 | // We don't want SSLHostState from the OTR profile to leak back to the main |
| 395 | // profile because then the main profile would learn some of the host names |
| 396 | // the user visited while OTR. |
| 397 | scoped_ptr<SSLHostState> ssl_host_state_; |
| 398 | |
[email protected] | a9cea754 | 2009-05-20 04:30:23 | [diff] [blame] | 399 | // The ForceTLSState that only stores enabled sites in memory. |
| 400 | scoped_ptr<net::ForceTLSState> force_tls_state_; |
| 401 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 402 | // Time we were started. |
| 403 | Time start_time_; |
| 404 | |
| 405 | DISALLOW_EVIL_CONSTRUCTORS(OffTheRecordProfileImpl); |
| 406 | }; |
| 407 | |
[email protected] | f7011fcb | 2009-01-28 21:54:32 | [diff] [blame] | 408 | ProfileImpl::ProfileImpl(const FilePath& path) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 409 | : path_(path), |
[email protected] | f7011fcb | 2009-01-28 21:54:32 | [diff] [blame] | 410 | request_context_(NULL), |
[email protected] | 363347b | 2009-03-13 20:06:57 | [diff] [blame] | 411 | media_request_context_(NULL), |
[email protected] | 47accfd6 | 2009-05-14 18:46:21 | [diff] [blame] | 412 | extensions_request_context_(NULL), |
[email protected] | f7011fcb | 2009-01-28 21:54:32 | [diff] [blame] | 413 | history_service_created_(false), |
| 414 | created_web_data_service_(false), |
[email protected] | e69d3395 | 2009-06-03 22:00:41 | [diff] [blame] | 415 | created_password_store_(false), |
[email protected] | f7011fcb | 2009-01-28 21:54:32 | [diff] [blame] | 416 | created_download_manager_(false), |
[email protected] | 4a19063 | 2009-05-09 01:07:42 | [diff] [blame] | 417 | created_theme_provider_(false), |
[email protected] | f7011fcb | 2009-01-28 21:54:32 | [diff] [blame] | 418 | start_time_(Time::Now()), |
| 419 | spellchecker_(NULL), |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 420 | shutdown_session_service_(false) { |
| 421 | DCHECK(!path.empty()) << "Using an empty path will attempt to write " << |
| 422 | "profile files to the root directory!"; |
[email protected] | 2d31666 | 2008-09-03 18:18:14 | [diff] [blame] | 423 | create_session_service_timer_.Start( |
| 424 | TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this, |
| 425 | &ProfileImpl::EnsureSessionServiceCreated); |
[email protected] | bdbc87c | 2009-01-25 05:08:54 | [diff] [blame] | 426 | |
[email protected] | 481e1a4 | 2009-05-06 20:56:05 | [diff] [blame] | 427 | extension_process_manager_.reset(new ExtensionProcessManager(this)); |
| 428 | |
[email protected] | e7244d8 | 2008-10-29 18:13:26 | [diff] [blame] | 429 | PrefService* prefs = GetPrefs(); |
| 430 | prefs->AddPrefObserver(prefs::kSpellCheckDictionary, this); |
| 431 | prefs->AddPrefObserver(prefs::kEnableSpellCheck, this); |
[email protected] | 154a433 | 2009-06-03 20:20:58 | [diff] [blame] | 432 | prefs->AddPrefObserver(prefs::kEnableAutoSpellCorrect, this); |
[email protected] | 380ab46 | 2009-04-24 01:23:58 | [diff] [blame] | 433 | |
| 434 | #ifdef CHROME_PERSONALIZATION |
| 435 | if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kDisableP13n)) |
| 436 | personalization_.reset(Personalization::CreateProfilePersonalization(this)); |
| 437 | #endif |
| 438 | |
[email protected] | 1351b6a | 2009-04-09 20:13:22 | [diff] [blame] | 439 | #if defined(OS_LINUX) |
| 440 | // TODO(port): Remove ifdef when the Linux splash page is not needed. |
| 441 | prefs->transient()->SetString(prefs::kHomePage, "about:linux-splash"); |
| 442 | prefs->transient()->SetBoolean(prefs::kHomePageIsNewTabPage, false); |
| 443 | #endif |
[email protected] | 4a19063 | 2009-05-09 01:07:42 | [diff] [blame] | 444 | |
| 445 | // Listen for theme installation. |
[email protected] | 88cf329 | 2009-05-22 01:48:43 | [diff] [blame] | 446 | registrar_.Add(this, NotificationType::THEME_INSTALLED, |
| 447 | NotificationService::AllSources()); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 448 | } |
| 449 | |
[email protected] | bdbc87c | 2009-01-25 05:08:54 | [diff] [blame] | 450 | void ProfileImpl::InitExtensions() { |
[email protected] | 8c756ac | 2009-01-30 23:36:41 | [diff] [blame] | 451 | if (user_script_master_ || extensions_service_) |
| 452 | return; // Already initialized. |
| 453 | |
[email protected] | bdbc87c | 2009-01-25 05:08:54 | [diff] [blame] | 454 | const CommandLine* command_line = CommandLine::ForCurrentProcess(); |
[email protected] | f93fe78 | 2009-02-19 01:26:13 | [diff] [blame] | 455 | PrefService* prefs = GetPrefs(); |
[email protected] | bdbc87c | 2009-01-25 05:08:54 | [diff] [blame] | 456 | bool user_scripts_enabled = |
[email protected] | f0a51fb5 | 2009-03-05 12:46:38 | [diff] [blame] | 457 | command_line->HasSwitch(switches::kEnableUserScripts) || |
[email protected] | f93fe78 | 2009-02-19 01:26:13 | [diff] [blame] | 458 | prefs->GetBoolean(prefs::kEnableUserScripts); |
[email protected] | bdbc87c | 2009-01-25 05:08:54 | [diff] [blame] | 459 | |
[email protected] | f7011fcb | 2009-01-28 21:54:32 | [diff] [blame] | 460 | FilePath script_dir; |
[email protected] | bdbc87c | 2009-01-25 05:08:54 | [diff] [blame] | 461 | if (user_scripts_enabled) { |
[email protected] | 0cd957b | 2009-03-06 20:13:23 | [diff] [blame] | 462 | if (command_line->HasSwitch(switches::kUserScriptsDir)) { |
| 463 | std::wstring path_string = |
| 464 | command_line->GetSwitchValue(switches::kUserScriptsDir); |
| 465 | script_dir = FilePath::FromWStringHack(path_string); |
| 466 | } else { |
| 467 | script_dir = GetPath(); |
| 468 | script_dir = script_dir.Append(chrome::kUserScriptsDirname); |
| 469 | } |
[email protected] | bdbc87c | 2009-01-25 05:08:54 | [diff] [blame] | 470 | } |
| 471 | |
[email protected] | bb28e06 | 2009-02-27 17:19:18 | [diff] [blame] | 472 | ExtensionErrorReporter::Init(true); // allow noisy errors. |
[email protected] | bdbc87c | 2009-01-25 05:08:54 | [diff] [blame] | 473 | user_script_master_ = new UserScriptMaster( |
[email protected] | 9197f3b | 2009-06-02 00:49:27 | [diff] [blame] | 474 | g_browser_process->file_thread()->message_loop(), |
| 475 | script_dir); |
[email protected] | 894bb50 | 2009-05-21 22:39:57 | [diff] [blame] | 476 | extensions_service_ = new ExtensionsService( |
| 477 | this, MessageLoop::current(), |
[email protected] | a1257b1 | 2009-06-12 02:51:34 | [diff] [blame] | 478 | g_browser_process->file_thread()->message_loop()); |
[email protected] | bdbc87c | 2009-01-25 05:08:54 | [diff] [blame] | 479 | |
[email protected] | 9197f3b | 2009-06-02 00:49:27 | [diff] [blame] | 480 | extensions_service_->Init(); |
[email protected] | bdbc87c | 2009-01-25 05:08:54 | [diff] [blame] | 481 | } |
| 482 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 483 | ProfileImpl::~ProfileImpl() { |
[email protected] | 169627b | 2008-12-06 19:30:19 | [diff] [blame] | 484 | tab_restore_service_ = NULL; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 485 | |
| 486 | StopCreateSessionServiceTimer(); |
| 487 | // TemplateURLModel schedules a task on the WebDataService from its |
| 488 | // destructor. Delete it first to ensure the task gets scheduled before we |
| 489 | // shut down the database. |
| 490 | template_url_model_.reset(); |
| 491 | |
| 492 | // The download manager queries the history system and should be deleted |
| 493 | // before the history is shutdown so it can properly cancel all requests. |
| 494 | download_manager_ = NULL; |
| 495 | |
[email protected] | 4a19063 | 2009-05-09 01:07:42 | [diff] [blame] | 496 | // The theme provider provides bitmaps to whoever wants them. |
| 497 | theme_provider_ = NULL; |
| 498 | |
[email protected] | e7244d8 | 2008-10-29 18:13:26 | [diff] [blame] | 499 | // Remove pref observers. |
| 500 | PrefService* prefs = GetPrefs(); |
| 501 | prefs->RemovePrefObserver(prefs::kSpellCheckDictionary, this); |
| 502 | prefs->RemovePrefObserver(prefs::kEnableSpellCheck, this); |
[email protected] | 154a433 | 2009-06-03 20:20:58 | [diff] [blame] | 503 | prefs->RemovePrefObserver(prefs::kEnableAutoSpellCorrect, this); |
[email protected] | e7244d8 | 2008-10-29 18:13:26 | [diff] [blame] | 504 | |
[email protected] | 3a453fa | 2008-08-15 18:46:34 | [diff] [blame] | 505 | #ifdef CHROME_PERSONALIZATION |
[email protected] | 57d3d0a | 2008-09-24 00:50:07 | [diff] [blame] | 506 | personalization_.reset(); |
[email protected] | 3a453fa | 2008-08-15 18:46:34 | [diff] [blame] | 507 | #endif |
| 508 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 509 | // Both HistoryService and WebDataService maintain threads for background |
| 510 | // processing. Its possible each thread still has tasks on it that have |
| 511 | // increased the ref count of the service. In such a situation, when we |
| 512 | // decrement the refcount, it won't be 0, and the threads/databases aren't |
| 513 | // properly shut down. By explicitly calling Cleanup/Shutdown we ensure the |
| 514 | // databases are properly closed. |
| 515 | if (web_data_service_.get()) |
| 516 | web_data_service_->Shutdown(); |
| 517 | |
| 518 | if (history_service_.get()) |
| 519 | history_service_->Cleanup(); |
| 520 | |
| 521 | // The I/O thread may be NULL during testing. |
[email protected] | ab820df | 2008-08-26 05:55:10 | [diff] [blame] | 522 | base::Thread* io_thread = g_browser_process->io_thread(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 523 | |
| 524 | if (spellchecker_) { |
| 525 | // The spellchecker must be deleted on the I/O thread. During testing, we |
| 526 | // don't have an I/O thread. |
| 527 | if (io_thread) |
| 528 | io_thread->message_loop()->ReleaseSoon(FROM_HERE, spellchecker_); |
| 529 | else |
| 530 | spellchecker_->Release(); |
| 531 | } |
| 532 | |
[email protected] | 47accfd6 | 2009-05-14 18:46:21 | [diff] [blame] | 533 | if (default_request_context_ == request_context_) |
| 534 | default_request_context_ = NULL; |
[email protected] | 6ab9b20 | 2008-12-23 22:34:50 | [diff] [blame] | 535 | |
[email protected] | 47accfd6 | 2009-05-14 18:46:21 | [diff] [blame] | 536 | CleanupRequestContext(request_context_); |
| 537 | CleanupRequestContext(media_request_context_); |
| 538 | CleanupRequestContext(extensions_request_context_); |
[email protected] | 1e744f2 | 2009-04-08 01:00:17 | [diff] [blame] | 539 | |
[email protected] | d8e41ed | 2008-09-11 15:22:32 | [diff] [blame] | 540 | // HistoryService may call into the BookmarkModel, as such we need to |
| 541 | // delete HistoryService before the BookmarkModel. The destructor for |
[email protected] | 90ef1313 | 2008-08-27 03:27:46 | [diff] [blame] | 542 | // HistoryService will join with HistoryService's backend thread so that |
| 543 | // by the time the destructor has finished we're sure it will no longer call |
[email protected] | d8e41ed | 2008-09-11 15:22:32 | [diff] [blame] | 544 | // into the BookmarkModel. |
[email protected] | 90ef1313 | 2008-08-27 03:27:46 | [diff] [blame] | 545 | history_service_ = NULL; |
| 546 | bookmark_bar_model_.reset(); |
| 547 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 548 | MarkAsCleanShutdown(); |
| 549 | } |
| 550 | |
[email protected] | f7011fcb | 2009-01-28 21:54:32 | [diff] [blame] | 551 | FilePath ProfileImpl::GetPath() { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 552 | return path_; |
| 553 | } |
| 554 | |
| 555 | bool ProfileImpl::IsOffTheRecord() { |
| 556 | return false; |
| 557 | } |
| 558 | |
| 559 | Profile* ProfileImpl::GetOffTheRecordProfile() { |
| 560 | if (!off_the_record_profile_.get()) { |
| 561 | scoped_ptr<OffTheRecordProfileImpl> p(new OffTheRecordProfileImpl(this)); |
| 562 | off_the_record_profile_.swap(p); |
| 563 | } |
| 564 | return off_the_record_profile_.get(); |
| 565 | } |
| 566 | |
[email protected] | 860f5549 | 2009-03-27 19:50:59 | [diff] [blame] | 567 | void ProfileImpl::DestroyOffTheRecordProfile() { |
| 568 | off_the_record_profile_.reset(); |
| 569 | } |
| 570 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 571 | Profile* ProfileImpl::GetOriginalProfile() { |
| 572 | return this; |
| 573 | } |
| 574 | |
[email protected] | 176aa48 | 2008-11-14 03:25:15 | [diff] [blame] | 575 | static void BroadcastNewHistoryTable(base::SharedMemory* table_memory) { |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 576 | if (!table_memory) |
| 577 | return; |
| 578 | |
| 579 | // send to all RenderProcessHosts |
| 580 | for (RenderProcessHost::iterator i = RenderProcessHost::begin(); |
| 581 | i != RenderProcessHost::end(); i++) { |
| 582 | if (!i->second->channel()) |
| 583 | continue; |
| 584 | |
[email protected] | 176aa48 | 2008-11-14 03:25:15 | [diff] [blame] | 585 | base::SharedMemoryHandle new_table; |
[email protected] | f7011fcb | 2009-01-28 21:54:32 | [diff] [blame] | 586 | base::ProcessHandle process = i->second->process().handle(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 587 | if (!process) { |
| 588 | // process can be null if it's started with the --single-process flag. |
[email protected] | f7011fcb | 2009-01-28 21:54:32 | [diff] [blame] | 589 | process = base::Process::Current().handle(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 590 | } |
| 591 | |
| 592 | table_memory->ShareToProcess(process, &new_table); |
| 593 | IPC::Message* msg = new ViewMsg_VisitedLink_NewTable(new_table); |
| 594 | i->second->channel()->Send(msg); |
| 595 | } |
| 596 | } |
| 597 | |
| 598 | VisitedLinkMaster* ProfileImpl::GetVisitedLinkMaster() { |
| 599 | if (!visited_link_master_.get()) { |
| 600 | scoped_ptr<VisitedLinkMaster> visited_links( |
| 601 | new VisitedLinkMaster(g_browser_process->file_thread(), |
| 602 | BroadcastNewHistoryTable, this)); |
| 603 | if (!visited_links->Init()) |
| 604 | return NULL; |
| 605 | visited_link_master_.swap(visited_links); |
| 606 | } |
| 607 | |
| 608 | return visited_link_master_.get(); |
| 609 | } |
| 610 | |
[email protected] | 6014d67 | 2008-12-05 00:38:25 | [diff] [blame] | 611 | ExtensionsService* ProfileImpl::GetExtensionsService() { |
| 612 | return extensions_service_.get(); |
| 613 | } |
| 614 | |
[email protected] | 0938d3c | 2009-01-09 20:37:35 | [diff] [blame] | 615 | UserScriptMaster* ProfileImpl::GetUserScriptMaster() { |
[email protected] | 0938d3c | 2009-01-09 20:37:35 | [diff] [blame] | 616 | return user_script_master_.get(); |
[email protected] | 04fba9a9 | 2008-10-28 17:25:25 | [diff] [blame] | 617 | } |
| 618 | |
[email protected] | 481e1a4 | 2009-05-06 20:56:05 | [diff] [blame] | 619 | ExtensionProcessManager* ProfileImpl::GetExtensionProcessManager() { |
| 620 | return extension_process_manager_.get(); |
| 621 | } |
| 622 | |
[email protected] | 34cc84f | 2009-02-13 10:04:35 | [diff] [blame] | 623 | SSLHostState* ProfileImpl::GetSSLHostState() { |
| 624 | if (!ssl_host_state_.get()) |
| 625 | ssl_host_state_.reset(new SSLHostState()); |
| 626 | |
| 627 | DCHECK(ssl_host_state_->CalledOnValidThread()); |
| 628 | return ssl_host_state_.get(); |
| 629 | } |
| 630 | |
[email protected] | a9cea754 | 2009-05-20 04:30:23 | [diff] [blame] | 631 | net::ForceTLSState* ProfileImpl::GetForceTLSState() { |
| 632 | if (!force_tls_state_.get()) |
| 633 | force_tls_state_.reset(new net::ForceTLSState()); |
| 634 | |
| 635 | return force_tls_state_.get(); |
| 636 | } |
| 637 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 638 | PrefService* ProfileImpl::GetPrefs() { |
| 639 | if (!prefs_.get()) { |
[email protected] | 6faa0e0d | 2009-04-28 06:50:36 | [diff] [blame] | 640 | prefs_.reset(new PrefService(GetPrefFilePath(), |
| 641 | g_browser_process->file_thread())); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 642 | |
| 643 | // The Profile class and ProfileManager class may read some prefs so |
| 644 | // register known prefs as soon as possible. |
| 645 | Profile::RegisterUserPrefs(prefs_.get()); |
| 646 | ProfileManager::RegisterUserPrefs(prefs_.get()); |
| 647 | |
| 648 | // The last session exited cleanly if there is no pref for |
| 649 | // kSessionExitedCleanly or the value for kSessionExitedCleanly is true. |
| 650 | last_session_exited_cleanly_ = |
| 651 | prefs_->GetBoolean(prefs::kSessionExitedCleanly); |
| 652 | // Mark the session as open. |
| 653 | prefs_->SetBoolean(prefs::kSessionExitedCleanly, false); |
| 654 | // Make sure we save to disk that the session has opened. |
[email protected] | 6faa0e0d | 2009-04-28 06:50:36 | [diff] [blame] | 655 | prefs_->ScheduleSavePersistentPrefs(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 656 | } |
| 657 | |
| 658 | return prefs_.get(); |
| 659 | } |
| 660 | |
[email protected] | f7011fcb | 2009-01-28 21:54:32 | [diff] [blame] | 661 | FilePath ProfileImpl::GetPrefFilePath() { |
| 662 | FilePath pref_file_path = path_; |
| 663 | pref_file_path = pref_file_path.Append(chrome::kPreferencesFilename); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 664 | return pref_file_path; |
| 665 | } |
| 666 | |
| 667 | URLRequestContext* ProfileImpl::GetRequestContext() { |
| 668 | if (!request_context_) { |
[email protected] | f7011fcb | 2009-01-28 21:54:32 | [diff] [blame] | 669 | FilePath cookie_path = GetPath(); |
| 670 | cookie_path = cookie_path.Append(chrome::kCookieFilename); |
| 671 | FilePath cache_path = GetPath(); |
[email protected] | 2b2830a | 2009-02-07 01:58:42 | [diff] [blame] | 672 | |
| 673 | // Override the cache location if specified by the user. |
| 674 | const std::wstring user_cache_dir( |
| 675 | CommandLine::ForCurrentProcess()->GetSwitchValue( |
| 676 | switches::kDiskCacheDir)); |
| 677 | if (!user_cache_dir.empty()) { |
| 678 | cache_path = FilePath::FromWStringHack(user_cache_dir); |
| 679 | } |
| 680 | |
[email protected] | f7011fcb | 2009-01-28 21:54:32 | [diff] [blame] | 681 | cache_path = cache_path.Append(chrome::kCacheDirname); |
[email protected] | 6ab9b20 | 2008-12-23 22:34:50 | [diff] [blame] | 682 | request_context_ = ChromeURLRequestContext::CreateOriginal( |
| 683 | this, cookie_path, cache_path); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 684 | request_context_->AddRef(); |
| 685 | |
[email protected] | 6ab9b20 | 2008-12-23 22:34:50 | [diff] [blame] | 686 | // The first request context is always a normal (non-OTR) request context. |
| 687 | // Even when Chromium is started in OTR mode, a normal profile is always |
| 688 | // created first. |
| 689 | if (!default_request_context_) { |
| 690 | default_request_context_ = request_context_; |
| 691 | NotificationService::current()->Notify( |
[email protected] | bfd04a6 | 2009-02-01 18:16:56 | [diff] [blame] | 692 | NotificationType::DEFAULT_REQUEST_CONTEXT_AVAILABLE, |
[email protected] | 6ab9b20 | 2008-12-23 22:34:50 | [diff] [blame] | 693 | NotificationService::AllSources(), NotificationService::NoDetails()); |
| 694 | } |
| 695 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 696 | DCHECK(request_context_->cookie_store()); |
| 697 | } |
| 698 | |
| 699 | return request_context_; |
| 700 | } |
| 701 | |
[email protected] | e7f2964 | 2009-03-02 22:53:18 | [diff] [blame] | 702 | URLRequestContext* ProfileImpl::GetRequestContextForMedia() { |
| 703 | if (!media_request_context_) { |
| 704 | FilePath cache_path = GetPath(); |
[email protected] | e3edeba | 2009-03-23 18:57:14 | [diff] [blame] | 705 | |
| 706 | // Override the cache location if specified by the user. |
| 707 | const std::wstring user_cache_dir( |
| 708 | CommandLine::ForCurrentProcess()->GetSwitchValue( |
| 709 | switches::kDiskCacheDir)); |
| 710 | if (!user_cache_dir.empty()) { |
| 711 | cache_path = FilePath::FromWStringHack(user_cache_dir); |
| 712 | } |
| 713 | |
[email protected] | 4e7b5dbb | 2009-03-25 00:09:23 | [diff] [blame] | 714 | cache_path = cache_path.Append(chrome::kMediaCacheDirname); |
[email protected] | e7f2964 | 2009-03-02 22:53:18 | [diff] [blame] | 715 | media_request_context_ = ChromeURLRequestContext::CreateOriginalForMedia( |
| 716 | this, cache_path); |
| 717 | media_request_context_->AddRef(); |
| 718 | |
| 719 | DCHECK(media_request_context_->cookie_store()); |
| 720 | } |
| 721 | |
| 722 | return media_request_context_; |
| 723 | } |
| 724 | |
[email protected] | 47accfd6 | 2009-05-14 18:46:21 | [diff] [blame] | 725 | URLRequestContext* ProfileImpl::GetRequestContextForExtensions() { |
| 726 | if (!extensions_request_context_) { |
| 727 | FilePath cookie_path = GetPath(); |
| 728 | cookie_path = cookie_path.Append(chrome::kExtensionsCookieFilename); |
| 729 | |
| 730 | extensions_request_context_ = |
| 731 | ChromeURLRequestContext::CreateOriginalForExtensions(this, cookie_path); |
| 732 | extensions_request_context_->AddRef(); |
| 733 | |
| 734 | DCHECK(extensions_request_context_->cookie_store()); |
| 735 | } |
| 736 | |
| 737 | return extensions_request_context_; |
| 738 | } |
| 739 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 740 | HistoryService* ProfileImpl::GetHistoryService(ServiceAccessType sat) { |
| 741 | if (!history_service_created_) { |
[email protected] | 90ef1313 | 2008-08-27 03:27:46 | [diff] [blame] | 742 | history_service_created_ = true; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 743 | scoped_refptr<HistoryService> history(new HistoryService(this)); |
[email protected] | d8e41ed | 2008-09-11 15:22:32 | [diff] [blame] | 744 | if (!history->Init(GetPath(), GetBookmarkModel())) |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 745 | return NULL; |
| 746 | history_service_.swap(history); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 747 | |
| 748 | // Send out the notification that the history service was created. |
| 749 | NotificationService::current()-> |
[email protected] | bfd04a6 | 2009-02-01 18:16:56 | [diff] [blame] | 750 | Notify(NotificationType::HISTORY_CREATED, Source<Profile>(this), |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 751 | Details<HistoryService>(history_service_.get())); |
| 752 | } |
| 753 | return history_service_.get(); |
| 754 | } |
| 755 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 756 | TemplateURLModel* ProfileImpl::GetTemplateURLModel() { |
| 757 | if (!template_url_model_.get()) |
| 758 | template_url_model_.reset(new TemplateURLModel(this)); |
| 759 | return template_url_model_.get(); |
| 760 | } |
| 761 | |
| 762 | TemplateURLFetcher* ProfileImpl::GetTemplateURLFetcher() { |
| 763 | if (!template_url_fetcher_.get()) |
| 764 | template_url_fetcher_.reset(new TemplateURLFetcher(this)); |
| 765 | return template_url_fetcher_.get(); |
| 766 | } |
| 767 | |
| 768 | WebDataService* ProfileImpl::GetWebDataService(ServiceAccessType sat) { |
| 769 | if (!created_web_data_service_) |
| 770 | CreateWebDataService(); |
| 771 | return web_data_service_.get(); |
| 772 | } |
| 773 | |
| 774 | void ProfileImpl::CreateWebDataService() { |
| 775 | DCHECK(!created_web_data_service_ && web_data_service_.get() == NULL); |
| 776 | created_web_data_service_ = true; |
| 777 | scoped_refptr<WebDataService> wds(new WebDataService()); |
| 778 | if (!wds->Init(GetPath())) |
| 779 | return; |
| 780 | web_data_service_.swap(wds); |
| 781 | } |
| 782 | |
[email protected] | e69d3395 | 2009-06-03 22:00:41 | [diff] [blame] | 783 | PasswordStore* ProfileImpl::GetPasswordStore(ServiceAccessType sat) { |
| 784 | if (!created_password_store_) |
| 785 | CreatePasswordStore(); |
| 786 | return password_store_.get(); |
| 787 | } |
| 788 | |
| 789 | void ProfileImpl::CreatePasswordStore() { |
| 790 | DCHECK(!created_password_store_ && password_store_.get() == NULL); |
| 791 | created_password_store_ = true; |
| 792 | scoped_refptr<PasswordStore> ps; |
| 793 | #if defined(OS_LINUX) |
| 794 | // Temporarily disabled while we figure some stuff out. |
| 795 | // http://code.google.com/p/chromium/issues/detail?id=12351 |
| 796 | // if (getenv("KDE_FULL_SESSION")) { |
| 797 | // ps = new PasswordStoreKWallet(); |
| 798 | // } else { |
| 799 | // ps = new PasswordStoreGnome(); |
| 800 | // } |
| 801 | NOTIMPLEMENTED(); |
| 802 | #elif defined(OS_WIN) |
| 803 | ps = new PasswordStoreWin(GetWebDataService(Profile::IMPLICIT_ACCESS)); |
[email protected] | 034eba5 | 2009-06-03 22:50:56 | [diff] [blame] | 804 | #elif defined(OS_MACOSX) |
| 805 | ps = new PasswordStoreMac(new MacKeychain()); |
[email protected] | e69d3395 | 2009-06-03 22:00:41 | [diff] [blame] | 806 | #else |
| 807 | NOTIMPLEMENTED(); |
| 808 | #endif |
| 809 | if (!ps || !ps->Init()) { |
| 810 | // Try falling back to the default password manager |
| 811 | LOG(WARNING) << "Could not initialise native password manager - " |
| 812 | "falling back to default"; |
| 813 | ps = new PasswordStoreDefault(GetWebDataService(Profile::IMPLICIT_ACCESS)); |
| 814 | if (!ps->Init()) |
| 815 | return; |
| 816 | } |
| 817 | password_store_.swap(ps); |
| 818 | } |
| 819 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 820 | DownloadManager* ProfileImpl::GetDownloadManager() { |
| 821 | if (!created_download_manager_) { |
| 822 | scoped_refptr<DownloadManager> dlm(new DownloadManager); |
| 823 | dlm->Init(this); |
| 824 | created_download_manager_ = true; |
| 825 | download_manager_.swap(dlm); |
| 826 | } |
| 827 | return download_manager_.get(); |
| 828 | } |
| 829 | |
| 830 | bool ProfileImpl::HasCreatedDownloadManager() const { |
| 831 | return created_download_manager_; |
| 832 | } |
| 833 | |
[email protected] | 4a19063 | 2009-05-09 01:07:42 | [diff] [blame] | 834 | void ProfileImpl::InitThemes() { |
| 835 | if (!created_theme_provider_) { |
| 836 | scoped_refptr<BrowserThemeProvider> themes(new BrowserThemeProvider); |
| 837 | themes->Init(this); |
| 838 | created_theme_provider_ = true; |
| 839 | theme_provider_.swap(themes); |
| 840 | } |
| 841 | } |
| 842 | |
| 843 | void ProfileImpl::SetTheme(Extension* extension) { |
| 844 | InitThemes(); |
| 845 | theme_provider_.get()->SetTheme(extension); |
| 846 | } |
| 847 | |
| 848 | void ProfileImpl::ClearTheme() { |
| 849 | InitThemes(); |
| 850 | theme_provider_.get()->UseDefaultTheme(); |
| 851 | } |
| 852 | |
| 853 | ThemeProvider* ProfileImpl::GetThemeProvider() { |
| 854 | InitThemes(); |
| 855 | return theme_provider_.get(); |
| 856 | } |
| 857 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 858 | SessionService* ProfileImpl::GetSessionService() { |
| 859 | if (!session_service_.get() && !shutdown_session_service_) { |
| 860 | session_service_ = new SessionService(this); |
| 861 | session_service_->ResetFromCurrentBrowsers(); |
| 862 | } |
| 863 | return session_service_.get(); |
| 864 | } |
| 865 | |
| 866 | void ProfileImpl::ShutdownSessionService() { |
| 867 | if (shutdown_session_service_) |
| 868 | return; |
| 869 | |
| 870 | // We're about to exit, force creation of the session service if it hasn't |
| 871 | // been created yet. We do this to ensure session state matches the point in |
| 872 | // time the user exited. |
| 873 | GetSessionService(); |
| 874 | shutdown_session_service_ = true; |
| 875 | session_service_ = NULL; |
| 876 | } |
| 877 | |
| 878 | bool ProfileImpl::HasSessionService() const { |
| 879 | return (session_service_.get() != NULL); |
| 880 | } |
| 881 | |
| 882 | std::wstring ProfileImpl::GetName() { |
| 883 | return GetPrefs()->GetString(prefs::kProfileName); |
| 884 | } |
| 885 | void ProfileImpl::SetName(const std::wstring& name) { |
| 886 | GetPrefs()->SetString(prefs::kProfileName, name); |
| 887 | } |
| 888 | |
| 889 | std::wstring ProfileImpl::GetID() { |
| 890 | return GetPrefs()->GetString(prefs::kProfileID); |
| 891 | } |
| 892 | void ProfileImpl::SetID(const std::wstring& id) { |
| 893 | GetPrefs()->SetString(prefs::kProfileID, id); |
| 894 | } |
| 895 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 896 | bool ProfileImpl::DidLastSessionExitCleanly() { |
| 897 | // last_session_exited_cleanly_ is set when the preferences are loaded. Force |
| 898 | // it to be set by asking for the prefs. |
| 899 | GetPrefs(); |
| 900 | return last_session_exited_cleanly_; |
| 901 | } |
| 902 | |
[email protected] | d8e41ed | 2008-09-11 15:22:32 | [diff] [blame] | 903 | BookmarkModel* ProfileImpl::GetBookmarkModel() { |
[email protected] | 90ef1313 | 2008-08-27 03:27:46 | [diff] [blame] | 904 | if (!bookmark_bar_model_.get()) { |
[email protected] | d8e41ed | 2008-09-11 15:22:32 | [diff] [blame] | 905 | bookmark_bar_model_.reset(new BookmarkModel(this)); |
[email protected] | 90ef1313 | 2008-08-27 03:27:46 | [diff] [blame] | 906 | bookmark_bar_model_->Load(); |
| 907 | } |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 908 | return bookmark_bar_model_.get(); |
| 909 | } |
| 910 | |
| 911 | bool ProfileImpl::IsSameProfile(Profile* profile) { |
| 912 | if (profile == static_cast<Profile*>(this)) |
| 913 | return true; |
| 914 | OffTheRecordProfileImpl* otr_profile = off_the_record_profile_.get(); |
| 915 | return otr_profile && profile == static_cast<Profile*>(otr_profile); |
| 916 | } |
| 917 | |
| 918 | Time ProfileImpl::GetStartTime() const { |
| 919 | return start_time_; |
| 920 | } |
| 921 | |
| 922 | TabRestoreService* ProfileImpl::GetTabRestoreService() { |
| 923 | if (!tab_restore_service_.get()) |
[email protected] | 169627b | 2008-12-06 19:30:19 | [diff] [blame] | 924 | tab_restore_service_ = new TabRestoreService(this); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 925 | return tab_restore_service_.get(); |
| 926 | } |
| 927 | |
[email protected] | 44947830 | 2009-06-09 20:04:28 | [diff] [blame] | 928 | ThumbnailStore* ProfileImpl::GetThumbnailStore() { |
| 929 | if (!thumbnail_store_.get()) { |
| 930 | thumbnail_store_ = new ThumbnailStore; |
| 931 | thumbnail_store_->Init(GetPath().AppendASCII("thumbnailstore\\")); |
| 932 | } |
| 933 | return thumbnail_store_.get(); |
| 934 | } |
| 935 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 936 | void ProfileImpl::ResetTabRestoreService() { |
[email protected] | 169627b | 2008-12-06 19:30:19 | [diff] [blame] | 937 | tab_restore_service_ = NULL; |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 938 | } |
| 939 | |
[email protected] | a9afddb | 2009-02-12 17:49:42 | [diff] [blame] | 940 | // To be run in the IO thread to notify all resource message filters that the |
[email protected] | 2093085 | 2008-10-15 19:30:41 | [diff] [blame] | 941 | // spellchecker has changed. |
| 942 | class NotifySpellcheckerChangeTask : public Task { |
| 943 | public: |
| 944 | NotifySpellcheckerChangeTask( |
[email protected] | e7244d8 | 2008-10-29 18:13:26 | [diff] [blame] | 945 | Profile* profile, |
| 946 | const SpellcheckerReinitializedDetails& spellchecker) |
[email protected] | 2093085 | 2008-10-15 19:30:41 | [diff] [blame] | 947 | : profile_(profile), |
| 948 | spellchecker_(spellchecker) { |
| 949 | } |
| 950 | |
| 951 | private: |
| 952 | void Run(void) { |
| 953 | NotificationService::current()->Notify( |
[email protected] | bfd04a6 | 2009-02-01 18:16:56 | [diff] [blame] | 954 | NotificationType::SPELLCHECKER_REINITIALIZED, |
[email protected] | 2093085 | 2008-10-15 19:30:41 | [diff] [blame] | 955 | Source<Profile>(profile_), |
| 956 | Details<SpellcheckerReinitializedDetails>(&spellchecker_)); |
| 957 | } |
| 958 | |
| 959 | Profile* profile_; |
| 960 | SpellcheckerReinitializedDetails spellchecker_; |
| 961 | }; |
| 962 | |
[email protected] | e7244d8 | 2008-10-29 18:13:26 | [diff] [blame] | 963 | void ProfileImpl::InitializeSpellChecker(bool need_to_broadcast) { |
[email protected] | 2093085 | 2008-10-15 19:30:41 | [diff] [blame] | 964 | // The I/O thread may be NULL during testing. |
| 965 | base::Thread* io_thread = g_browser_process->io_thread(); |
| 966 | if (spellchecker_) { |
| 967 | // The spellchecker must be deleted on the I/O thread. |
| 968 | // A dummy variable to aid in logical clarity. |
| 969 | SpellChecker* last_spellchecker = spellchecker_; |
| 970 | |
| 971 | if (io_thread) |
| 972 | io_thread->message_loop()->ReleaseSoon(FROM_HERE, last_spellchecker); |
| 973 | else // during testing, we don't have an I/O thread |
| 974 | last_spellchecker->Release(); |
[email protected] | 2093085 | 2008-10-15 19:30:41 | [diff] [blame] | 975 | } |
| 976 | |
[email protected] | 2093085 | 2008-10-15 19:30:41 | [diff] [blame] | 977 | // Retrieve the (perhaps updated recently) dictionary name from preferences. |
| 978 | PrefService* prefs = GetPrefs(); |
[email protected] | e7244d8 | 2008-10-29 18:13:26 | [diff] [blame] | 979 | bool enable_spellcheck = prefs->GetBoolean(prefs::kEnableSpellCheck); |
[email protected] | 2093085 | 2008-10-15 19:30:41 | [diff] [blame] | 980 | |
[email protected] | e7244d8 | 2008-10-29 18:13:26 | [diff] [blame] | 981 | if (enable_spellcheck) { |
[email protected] | bd17b70 | 2009-02-25 20:44:08 | [diff] [blame] | 982 | FilePath dict_dir; |
[email protected] | e7244d8 | 2008-10-29 18:13:26 | [diff] [blame] | 983 | PathService::Get(chrome::DIR_APP_DICTIONARIES, &dict_dir); |
[email protected] | a9afddb | 2009-02-12 17:49:42 | [diff] [blame] | 984 | // Note that, as the object pointed to by previously by spellchecker_ |
[email protected] | e7244d8 | 2008-10-29 18:13:26 | [diff] [blame] | 985 | // is being deleted in the io thread, the spellchecker_ can be made to point |
| 986 | // to a new object (RE-initialized) in parallel in this UI thread. |
[email protected] | 4b4d1adc | 2008-12-10 22:28:58 | [diff] [blame] | 987 | spellchecker_ = new SpellChecker(dict_dir, |
[email protected] | 74c8b42 | 2009-03-11 00:34:12 | [diff] [blame] | 988 | WideToASCII(prefs->GetString(prefs::kSpellCheckDictionary)), |
| 989 | GetRequestContext(), |
[email protected] | bd17b70 | 2009-02-25 20:44:08 | [diff] [blame] | 990 | FilePath()); |
[email protected] | e7244d8 | 2008-10-29 18:13:26 | [diff] [blame] | 991 | spellchecker_->AddRef(); // Manual refcounting. |
| 992 | } else { |
| 993 | spellchecker_ = NULL; |
| 994 | } |
[email protected] | 2093085 | 2008-10-15 19:30:41 | [diff] [blame] | 995 | |
[email protected] | 154a433 | 2009-06-03 20:20:58 | [diff] [blame] | 996 | // Set auto spell correct status for spellchecker. |
| 997 | if (spellchecker_) { |
| 998 | spellchecker_->EnableAutoSpellCorrect( |
| 999 | prefs->GetBoolean(prefs::kEnableAutoSpellCorrect)); |
| 1000 | } |
| 1001 | |
[email protected] | 2093085 | 2008-10-15 19:30:41 | [diff] [blame] | 1002 | if (need_to_broadcast && io_thread) { // Notify resource message filters. |
| 1003 | SpellcheckerReinitializedDetails scoped_spellchecker; |
| 1004 | scoped_spellchecker.spellchecker = spellchecker_; |
[email protected] | e7244d8 | 2008-10-29 18:13:26 | [diff] [blame] | 1005 | if (io_thread) { |
| 1006 | io_thread->message_loop()->PostTask( |
[email protected] | a9afddb | 2009-02-12 17:49:42 | [diff] [blame] | 1007 | FROM_HERE, |
[email protected] | e7244d8 | 2008-10-29 18:13:26 | [diff] [blame] | 1008 | new NotifySpellcheckerChangeTask(this, scoped_spellchecker)); |
| 1009 | } |
[email protected] | 2093085 | 2008-10-15 19:30:41 | [diff] [blame] | 1010 | } |
| 1011 | } |
| 1012 | |
[email protected] | e7244d8 | 2008-10-29 18:13:26 | [diff] [blame] | 1013 | void ProfileImpl::ReinitializeSpellChecker() { |
| 1014 | InitializeSpellChecker(true); |
| 1015 | } |
| 1016 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1017 | SpellChecker* ProfileImpl::GetSpellChecker() { |
| 1018 | if (!spellchecker_) { |
[email protected] | 2093085 | 2008-10-15 19:30:41 | [diff] [blame] | 1019 | // This is where spellchecker gets initialized. Note that this is being |
| 1020 | // initialized in the ui_thread. However, this is not a problem as long as |
| 1021 | // it is *used* in the io thread. |
[email protected] | 34cc84f | 2009-02-13 10:04:35 | [diff] [blame] | 1022 | // TODO(sidchat): One day, change everything so that spellchecker gets |
[email protected] | 2093085 | 2008-10-15 19:30:41 | [diff] [blame] | 1023 | // initialized in the IO thread itself. |
[email protected] | e7244d8 | 2008-10-29 18:13:26 | [diff] [blame] | 1024 | InitializeSpellChecker(false); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1025 | } |
[email protected] | 2093085 | 2008-10-15 19:30:41 | [diff] [blame] | 1026 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1027 | return spellchecker_; |
| 1028 | } |
| 1029 | |
| 1030 | void ProfileImpl::MarkAsCleanShutdown() { |
| 1031 | if (prefs_.get()) { |
| 1032 | // The session cleanly exited, set kSessionExitedCleanly appropriately. |
| 1033 | prefs_->SetBoolean(prefs::kSessionExitedCleanly, true); |
| 1034 | |
| 1035 | // NOTE: If you change what thread this writes on, be sure and update |
| 1036 | // ChromeFrame::EndSession(). |
[email protected] | 6faa0e0d | 2009-04-28 06:50:36 | [diff] [blame] | 1037 | prefs_->SavePersistentPrefs(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1038 | } |
| 1039 | } |
| 1040 | |
[email protected] | e7244d8 | 2008-10-29 18:13:26 | [diff] [blame] | 1041 | void ProfileImpl::Observe(NotificationType type, |
| 1042 | const NotificationSource& source, |
| 1043 | const NotificationDetails& details) { |
[email protected] | bfd04a6 | 2009-02-01 18:16:56 | [diff] [blame] | 1044 | if (NotificationType::PREF_CHANGED == type) { |
[email protected] | e7244d8 | 2008-10-29 18:13:26 | [diff] [blame] | 1045 | std::wstring* pref_name_in = Details<std::wstring>(details).ptr(); |
| 1046 | PrefService* prefs = Source<PrefService>(source).ptr(); |
| 1047 | DCHECK(pref_name_in && prefs); |
| 1048 | if (*pref_name_in == prefs::kSpellCheckDictionary || |
[email protected] | 154a433 | 2009-06-03 20:20:58 | [diff] [blame] | 1049 | *pref_name_in == prefs::kEnableSpellCheck || |
| 1050 | *pref_name_in == prefs::kEnableAutoSpellCorrect) { |
[email protected] | e7244d8 | 2008-10-29 18:13:26 | [diff] [blame] | 1051 | InitializeSpellChecker(true); |
| 1052 | } |
[email protected] | 4a19063 | 2009-05-09 01:07:42 | [diff] [blame] | 1053 | } else if (NotificationType::THEME_INSTALLED == type) { |
| 1054 | Extension* extension = Details<Extension>(details).ptr(); |
| 1055 | SetTheme(extension); |
[email protected] | e7244d8 | 2008-10-29 18:13:26 | [diff] [blame] | 1056 | } |
| 1057 | } |
| 1058 | |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1059 | void ProfileImpl::StopCreateSessionServiceTimer() { |
[email protected] | 2d31666 | 2008-09-03 18:18:14 | [diff] [blame] | 1060 | create_session_service_timer_.Stop(); |
initial.commit | 09911bf | 2008-07-26 23:55:29 | [diff] [blame] | 1061 | } |
[email protected] | 3a453fa | 2008-08-15 18:46:34 | [diff] [blame] | 1062 | |
| 1063 | #ifdef CHROME_PERSONALIZATION |
[email protected] | 57d3d0a | 2008-09-24 00:50:07 | [diff] [blame] | 1064 | ProfilePersonalization* ProfileImpl::GetProfilePersonalization() { |
[email protected] | 57d3d0a | 2008-09-24 00:50:07 | [diff] [blame] | 1065 | return personalization_.get(); |
[email protected] | 3a453fa | 2008-08-15 18:46:34 | [diff] [blame] | 1066 | } |
license.bot | bf09a50 | 2008-08-24 00:55:55 | [diff] [blame] | 1067 | #endif |