| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/profile.h" | 5 #include "chrome/browser/profile.h" |
| 6 | 6 |
| 7 #include "app/theme_provider.h" | 7 #include "app/theme_provider.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/file_path.h" | 9 #include "base/file_path.h" |
| 10 #include "base/file_util.h" | 10 #include "base/file_util.h" |
| (...skipping 178 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 189 // | 189 // |
| 190 // OffTheRecordProfileImpl is a profile subclass that wraps an existing profile | 190 // OffTheRecordProfileImpl is a profile subclass that wraps an existing profile |
| 191 // to make it suitable for the off the record mode. | 191 // to make it suitable for the off the record mode. |
| 192 // | 192 // |
| 193 //////////////////////////////////////////////////////////////////////////////// | 193 //////////////////////////////////////////////////////////////////////////////// |
| 194 class OffTheRecordProfileImpl : public Profile, | 194 class OffTheRecordProfileImpl : public Profile, |
| 195 public NotificationObserver { | 195 public NotificationObserver { |
| 196 public: | 196 public: |
| 197 explicit OffTheRecordProfileImpl(Profile* real_profile) | 197 explicit OffTheRecordProfileImpl(Profile* real_profile) |
| 198 : profile_(real_profile), | 198 : profile_(real_profile), |
| 199 extensions_request_context_(NULL), | |
| 200 start_time_(Time::Now()) { | 199 start_time_(Time::Now()) { |
| 201 request_context_ = ChromeURLRequestContextGetter::CreateOffTheRecord(this); | 200 request_context_ = ChromeURLRequestContextGetter::CreateOffTheRecord(this); |
| 202 | 201 |
| 203 // Register for browser close notifications so we can detect when the last | 202 // Register for browser close notifications so we can detect when the last |
| 204 // off-the-record window is closed, in which case we can clean our states | 203 // off-the-record window is closed, in which case we can clean our states |
| 205 // (cookies, downloads...). | 204 // (cookies, downloads...). |
| 206 registrar_.Add(this, NotificationType::BROWSER_CLOSED, | 205 registrar_.Add(this, NotificationType::BROWSER_CLOSED, |
| 207 NotificationService::AllSources()); | 206 NotificationService::AllSources()); |
| 208 } | 207 } |
| 209 | 208 |
| 210 virtual ~OffTheRecordProfileImpl() { | 209 virtual ~OffTheRecordProfileImpl() { |
| 211 CleanupRequestContext(request_context_); | 210 CleanupRequestContext(request_context_); |
| 212 CleanupRequestContext(extensions_request_context_); | |
| 213 } | 211 } |
| 214 | 212 |
| 215 virtual ProfileId GetRuntimeId() { | 213 virtual ProfileId GetRuntimeId() { |
| 216 return reinterpret_cast<ProfileId>(this); | 214 return reinterpret_cast<ProfileId>(this); |
| 217 } | 215 } |
| 218 | 216 |
| 219 virtual FilePath GetPath() { return profile_->GetPath(); } | 217 virtual FilePath GetPath() { return profile_->GetPath(); } |
| 220 | 218 |
| 221 virtual bool IsOffTheRecord() { | 219 virtual bool IsOffTheRecord() { |
| 222 return true; | 220 return true; |
| (...skipping 18 matching lines...) Expand all Loading... |
| 241 return db_tracker_; | 239 return db_tracker_; |
| 242 } | 240 } |
| 243 | 241 |
| 244 virtual VisitedLinkMaster* GetVisitedLinkMaster() { | 242 virtual VisitedLinkMaster* GetVisitedLinkMaster() { |
| 245 // We don't provide access to the VisitedLinkMaster when we're OffTheRecord | 243 // 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. | 244 // because we don't want to leak the sites that the user has visited before. |
| 247 return NULL; | 245 return NULL; |
| 248 } | 246 } |
| 249 | 247 |
| 250 virtual ExtensionsService* GetExtensionsService() { | 248 virtual ExtensionsService* GetExtensionsService() { |
| 251 return NULL; | 249 return GetOriginalProfile()->GetExtensionsService(); |
| 252 } | 250 } |
| 253 | 251 |
| 254 virtual UserScriptMaster* GetUserScriptMaster() { | 252 virtual UserScriptMaster* GetUserScriptMaster() { |
| 255 return NULL; | 253 return GetOriginalProfile()->GetUserScriptMaster(); |
| 256 } | 254 } |
| 257 | 255 |
| 258 virtual ExtensionDevToolsManager* GetExtensionDevToolsManager() { | 256 virtual ExtensionDevToolsManager* GetExtensionDevToolsManager() { |
| 257 // TODO(mpcomplete): figure out whether we should return the original |
| 258 // profile's version. |
| 259 return NULL; | 259 return NULL; |
| 260 } | 260 } |
| 261 | 261 |
| 262 virtual ExtensionProcessManager* GetExtensionProcessManager() { | 262 virtual ExtensionProcessManager* GetExtensionProcessManager() { |
| 263 return NULL; | 263 return GetOriginalProfile()->GetExtensionProcessManager(); |
| 264 } | 264 } |
| 265 | 265 |
| 266 virtual ExtensionMessageService* GetExtensionMessageService() { | 266 virtual ExtensionMessageService* GetExtensionMessageService() { |
| 267 return NULL; | 267 return GetOriginalProfile()->GetExtensionMessageService(); |
| 268 } | 268 } |
| 269 | 269 |
| 270 virtual SSLHostState* GetSSLHostState() { | 270 virtual SSLHostState* GetSSLHostState() { |
| 271 if (!ssl_host_state_.get()) | 271 if (!ssl_host_state_.get()) |
| 272 ssl_host_state_.reset(new SSLHostState()); | 272 ssl_host_state_.reset(new SSLHostState()); |
| 273 | 273 |
| 274 DCHECK(ssl_host_state_->CalledOnValidThread()); | 274 DCHECK(ssl_host_state_->CalledOnValidThread()); |
| 275 return ssl_host_state_.get(); | 275 return ssl_host_state_.get(); |
| 276 } | 276 } |
| 277 | 277 |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 virtual URLRequestContextGetter* GetRequestContext() { | 382 virtual URLRequestContextGetter* GetRequestContext() { |
| 383 return request_context_; | 383 return request_context_; |
| 384 } | 384 } |
| 385 | 385 |
| 386 virtual URLRequestContextGetter* GetRequestContextForMedia() { | 386 virtual URLRequestContextGetter* GetRequestContextForMedia() { |
| 387 // In OTR mode, media request context is the same as the original one. | 387 // In OTR mode, media request context is the same as the original one. |
| 388 return request_context_; | 388 return request_context_; |
| 389 } | 389 } |
| 390 | 390 |
| 391 URLRequestContextGetter* GetRequestContextForExtensions() { | 391 URLRequestContextGetter* GetRequestContextForExtensions() { |
| 392 if (!extensions_request_context_) { | 392 return GetOriginalProfile()->GetRequestContextForExtensions(); |
| 393 extensions_request_context_ = | |
| 394 ChromeURLRequestContextGetter::CreateOffTheRecordForExtensions(this); | |
| 395 } | |
| 396 | |
| 397 return extensions_request_context_; | |
| 398 } | 393 } |
| 399 | 394 |
| 400 virtual net::SSLConfigService* GetSSLConfigService() { | 395 virtual net::SSLConfigService* GetSSLConfigService() { |
| 401 return profile_->GetSSLConfigService(); | 396 return profile_->GetSSLConfigService(); |
| 402 } | 397 } |
| 403 | 398 |
| 404 virtual HostContentSettingsMap* GetHostContentSettingsMap() { | 399 virtual HostContentSettingsMap* GetHostContentSettingsMap() { |
| 405 return profile_->GetHostContentSettingsMap(); | 400 return profile_->GetHostContentSettingsMap(); |
| 406 } | 401 } |
| 407 | 402 |
| (...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 520 | 515 |
| 521 private: | 516 private: |
| 522 NotificationRegistrar registrar_; | 517 NotificationRegistrar registrar_; |
| 523 | 518 |
| 524 // The real underlying profile. | 519 // The real underlying profile. |
| 525 Profile* profile_; | 520 Profile* profile_; |
| 526 | 521 |
| 527 // The context to use for requests made from this OTR session. | 522 // The context to use for requests made from this OTR session. |
| 528 scoped_refptr<ChromeURLRequestContextGetter> request_context_; | 523 scoped_refptr<ChromeURLRequestContextGetter> request_context_; |
| 529 | 524 |
| 530 scoped_refptr<ChromeURLRequestContextGetter> extensions_request_context_; | |
| 531 | |
| 532 // The download manager that only stores downloaded items in memory. | 525 // The download manager that only stores downloaded items in memory. |
| 533 scoped_refptr<DownloadManager> download_manager_; | 526 scoped_refptr<DownloadManager> download_manager_; |
| 534 | 527 |
| 535 // Use a separate desktop notification service for OTR. | 528 // Use a separate desktop notification service for OTR. |
| 536 scoped_ptr<DesktopNotificationService> desktop_notification_service_; | 529 scoped_ptr<DesktopNotificationService> desktop_notification_service_; |
| 537 | 530 |
| 538 // Use a special WebKit context for OTR browsing. | 531 // Use a special WebKit context for OTR browsing. |
| 539 scoped_refptr<WebKitContext> webkit_context_; | 532 scoped_refptr<WebKitContext> webkit_context_; |
| 540 | 533 |
| 541 // We don't want SSLHostState from the OTR profile to leak back to the main | 534 // We don't want SSLHostState from the OTR profile to leak back to the main |
| (...skipping 776 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1318 } | 1311 } |
| 1319 | 1312 |
| 1320 void ProfileImpl::InitSyncService() { | 1313 void ProfileImpl::InitSyncService() { |
| 1321 profile_sync_factory_.reset( | 1314 profile_sync_factory_.reset( |
| 1322 new ProfileSyncFactoryImpl(this, | 1315 new ProfileSyncFactoryImpl(this, |
| 1323 CommandLine::ForCurrentProcess())); | 1316 CommandLine::ForCurrentProcess())); |
| 1324 sync_service_.reset( | 1317 sync_service_.reset( |
| 1325 profile_sync_factory_->CreateProfileSyncService()); | 1318 profile_sync_factory_->CreateProfileSyncService()); |
| 1326 sync_service_->Initialize(); | 1319 sync_service_->Initialize(); |
| 1327 } | 1320 } |
| OLD | NEW |