| 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/resource_bundle.h" | 7 #include "app/resource_bundle.h" |
| 8 #include "app/theme_provider.h" | 8 #include "app/theme_provider.h" |
| 9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
| 10 #include "base/env_var.h" | 10 #include "base/env_var.h" |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 255 request_context_ = ChromeURLRequestContextGetter::CreateOffTheRecord(this); | 255 request_context_ = ChromeURLRequestContextGetter::CreateOffTheRecord(this); |
| 256 | 256 |
| 257 // Register for browser close notifications so we can detect when the last | 257 // Register for browser close notifications so we can detect when the last |
| 258 // off-the-record window is closed, in which case we can clean our states | 258 // off-the-record window is closed, in which case we can clean our states |
| 259 // (cookies, downloads...). | 259 // (cookies, downloads...). |
| 260 registrar_.Add(this, NotificationType::BROWSER_CLOSED, | 260 registrar_.Add(this, NotificationType::BROWSER_CLOSED, |
| 261 NotificationService::AllSources()); | 261 NotificationService::AllSources()); |
| 262 } | 262 } |
| 263 | 263 |
| 264 virtual ~OffTheRecordProfileImpl() { | 264 virtual ~OffTheRecordProfileImpl() { |
| 265 NotificationService::current()->Notify( | 265 NotificationService::current()->Notify( |
| 266 NotificationType::PROFILE_DESTROYED, | 266 NotificationType::PROFILE_DESTROYED, |
| 267 Source<Profile>(this), | 267 Source<Profile>(this), |
| 268 NotificationService::NoDetails()); | 268 NotificationService::NoDetails()); |
| 269 CleanupRequestContext(request_context_); | 269 CleanupRequestContext(request_context_); |
| 270 |
| 271 // Clean up all DB files/directories |
| 272 ChromeThread::PostTask( |
| 273 ChromeThread::FILE, FROM_HERE, |
| 274 NewRunnableMethod( |
| 275 db_tracker_.get(), |
| 276 &webkit_database::DatabaseTracker::DeleteIncognitoDBDirectory)); |
| 270 } | 277 } |
| 271 | 278 |
| 272 virtual ProfileId GetRuntimeId() { | 279 virtual ProfileId GetRuntimeId() { |
| 273 return reinterpret_cast<ProfileId>(this); | 280 return reinterpret_cast<ProfileId>(this); |
| 274 } | 281 } |
| 275 | 282 |
| 276 virtual FilePath GetPath() { return profile_->GetPath(); } | 283 virtual FilePath GetPath() { return profile_->GetPath(); } |
| 277 | 284 |
| 278 virtual bool IsOffTheRecord() { | 285 virtual bool IsOffTheRecord() { |
| 279 return true; | 286 return true; |
| 280 } | 287 } |
| 281 | 288 |
| 282 virtual Profile* GetOffTheRecordProfile() { | 289 virtual Profile* GetOffTheRecordProfile() { |
| 283 return this; | 290 return this; |
| 284 } | 291 } |
| 285 | 292 |
| 286 virtual void DestroyOffTheRecordProfile() { | 293 virtual void DestroyOffTheRecordProfile() { |
| 287 // Suicide is bad! | 294 // Suicide is bad! |
| 288 NOTREACHED(); | 295 NOTREACHED(); |
| 289 } | 296 } |
| 290 | 297 |
| 291 virtual Profile* GetOriginalProfile() { | 298 virtual Profile* GetOriginalProfile() { |
| 292 return profile_; | 299 return profile_; |
| 293 } | 300 } |
| 294 | 301 |
| 295 virtual webkit_database::DatabaseTracker* GetDatabaseTracker() { | 302 virtual webkit_database::DatabaseTracker* GetDatabaseTracker() { |
| 296 if (!db_tracker_) | 303 if (!db_tracker_) { |
| 297 db_tracker_ = new webkit_database::DatabaseTracker(FilePath()); | 304 db_tracker_ = new webkit_database::DatabaseTracker( |
| 305 GetPath(), IsOffTheRecord()); |
| 306 } |
| 298 return db_tracker_; | 307 return db_tracker_; |
| 299 } | 308 } |
| 300 | 309 |
| 301 virtual VisitedLinkMaster* GetVisitedLinkMaster() { | 310 virtual VisitedLinkMaster* GetVisitedLinkMaster() { |
| 302 // We don't provide access to the VisitedLinkMaster when we're OffTheRecord | 311 // We don't provide access to the VisitedLinkMaster when we're OffTheRecord |
| 303 // because we don't want to leak the sites that the user has visited before. | 312 // because we don't want to leak the sites that the user has visited before. |
| 304 return NULL; | 313 return NULL; |
| 305 } | 314 } |
| 306 | 315 |
| 307 virtual ExtensionsService* GetExtensionsService() { | 316 virtual ExtensionsService* GetExtensionsService() { |
| (...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 951 | 960 |
| 952 void ProfileImpl::DestroyOffTheRecordProfile() { | 961 void ProfileImpl::DestroyOffTheRecordProfile() { |
| 953 off_the_record_profile_.reset(); | 962 off_the_record_profile_.reset(); |
| 954 } | 963 } |
| 955 | 964 |
| 956 Profile* ProfileImpl::GetOriginalProfile() { | 965 Profile* ProfileImpl::GetOriginalProfile() { |
| 957 return this; | 966 return this; |
| 958 } | 967 } |
| 959 | 968 |
| 960 webkit_database::DatabaseTracker* ProfileImpl::GetDatabaseTracker() { | 969 webkit_database::DatabaseTracker* ProfileImpl::GetDatabaseTracker() { |
| 961 if (!db_tracker_) | 970 if (!db_tracker_) { |
| 962 db_tracker_ = new webkit_database::DatabaseTracker(GetPath()); | 971 db_tracker_ = new webkit_database::DatabaseTracker( |
| 972 GetPath(), IsOffTheRecord()); |
| 973 } |
| 963 return db_tracker_; | 974 return db_tracker_; |
| 964 } | 975 } |
| 965 | 976 |
| 966 VisitedLinkMaster* ProfileImpl::GetVisitedLinkMaster() { | 977 VisitedLinkMaster* ProfileImpl::GetVisitedLinkMaster() { |
| 967 if (!visited_link_master_.get()) { | 978 if (!visited_link_master_.get()) { |
| 968 scoped_ptr<VisitedLinkMaster> visited_links( | 979 scoped_ptr<VisitedLinkMaster> visited_links( |
| 969 new VisitedLinkMaster(visited_link_event_listener_.get(), this)); | 980 new VisitedLinkMaster(visited_link_event_listener_.get(), this)); |
| 970 if (!visited_links->Init()) | 981 if (!visited_links->Init()) |
| 971 return NULL; | 982 return NULL; |
| 972 visited_link_master_.swap(visited_links); | 983 visited_link_master_.swap(visited_links); |
| (...skipping 581 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1554 CommandLine::ForCurrentProcess())); | 1565 CommandLine::ForCurrentProcess())); |
| 1555 sync_service_.reset( | 1566 sync_service_.reset( |
| 1556 profile_sync_factory_->CreateProfileSyncService()); | 1567 profile_sync_factory_->CreateProfileSyncService()); |
| 1557 sync_service_->Initialize(); | 1568 sync_service_->Initialize(); |
| 1558 } | 1569 } |
| 1559 | 1570 |
| 1560 void ProfileImpl::InitCloudPrintProxyService() { | 1571 void ProfileImpl::InitCloudPrintProxyService() { |
| 1561 cloud_print_proxy_service_.reset(new CloudPrintProxyService(this)); | 1572 cloud_print_proxy_service_.reset(new CloudPrintProxyService(this)); |
| 1562 cloud_print_proxy_service_->Initialize(); | 1573 cloud_print_proxy_service_->Initialize(); |
| 1563 } | 1574 } |
| OLD | NEW |