| 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/profiles/profile.h" | 5 #include "chrome/browser/profiles/profile.h" |
| 6 | 6 |
| 7 #include "app/resource_bundle.h" | 7 #include "app/resource_bundle.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" |
| 11 #include "base/path_service.h" | 11 #include "base/path_service.h" |
| 12 #include "base/scoped_ptr.h" | 12 #include "base/scoped_ptr.h" |
| 13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
| 14 #include "chrome/browser/background_contents_service.h" | 14 #include "chrome/browser/background_contents_service.h" |
| 15 #include "chrome/browser/browser_list.h" | 15 #include "chrome/browser/browser_list.h" |
| 16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/browser_thread.h" | 17 #include "chrome/browser/browser_thread.h" |
| 18 #include "chrome/browser/chrome_blob_storage_context.h" | 18 #include "chrome/browser/chrome_blob_storage_context.h" |
| 19 #include "chrome/browser/download/download_manager.h" | 19 #include "chrome/browser/download/download_manager.h" |
| 20 #include "chrome/browser/extensions/extension_message_service.h" | 20 #include "chrome/browser/extensions/extension_message_service.h" |
| 21 #include "chrome/browser/extensions/extension_process_manager.h" | 21 #include "chrome/browser/extensions/extension_process_manager.h" |
| 22 #include "chrome/browser/file_system/browser_file_system_helper.h" | 22 #include "chrome/browser/file_system/browser_file_system_helper.h" |
| 23 #include "chrome/browser/in_process_webkit/webkit_context.h" | 23 #include "chrome/browser/in_process_webkit/webkit_context.h" |
| 24 #include "chrome/browser/net/chrome_url_request_context.h" | 24 #include "chrome/browser/net/chrome_url_request_context.h" |
| 25 #include "chrome/browser/net/ssl_config_service_manager.h" |
| 25 #include "chrome/browser/notifications/desktop_notification_service.h" | 26 #include "chrome/browser/notifications/desktop_notification_service.h" |
| 26 #include "chrome/browser/ssl/ssl_host_state.h" | 27 #include "chrome/browser/ssl/ssl_host_state.h" |
| 27 #include "chrome/browser/sync/profile_sync_service.h" | 28 #include "chrome/browser/sync/profile_sync_service.h" |
| 28 #include "chrome/browser/themes/browser_theme_provider.h" | 29 #include "chrome/browser/themes/browser_theme_provider.h" |
| 29 #include "chrome/browser/ui/find_bar/find_bar_state.h" | 30 #include "chrome/browser/ui/find_bar/find_bar_state.h" |
| 30 #include "chrome/common/chrome_constants.h" | 31 #include "chrome/common/chrome_constants.h" |
| 31 #include "chrome/common/chrome_paths.h" | 32 #include "chrome/common/chrome_paths.h" |
| 32 #include "chrome/common/chrome_switches.h" | 33 #include "chrome/common/chrome_switches.h" |
| 33 #include "chrome/common/json_pref_store.h" | 34 #include "chrome/common/json_pref_store.h" |
| 34 #include "chrome/common/notification_service.h" | 35 #include "chrome/common/notification_service.h" |
| (...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 128 // OffTheRecordProfileImpl is a profile subclass that wraps an existing profile | 129 // OffTheRecordProfileImpl is a profile subclass that wraps an existing profile |
| 129 // to make it suitable for the off the record mode. | 130 // to make it suitable for the off the record mode. |
| 130 // | 131 // |
| 131 //////////////////////////////////////////////////////////////////////////////// | 132 //////////////////////////////////////////////////////////////////////////////// |
| 132 class OffTheRecordProfileImpl : public Profile, | 133 class OffTheRecordProfileImpl : public Profile, |
| 133 public BrowserList::Observer { | 134 public BrowserList::Observer { |
| 134 public: | 135 public: |
| 135 explicit OffTheRecordProfileImpl(Profile* real_profile) | 136 explicit OffTheRecordProfileImpl(Profile* real_profile) |
| 136 : profile_(real_profile), | 137 : profile_(real_profile), |
| 137 start_time_(Time::Now()) { | 138 start_time_(Time::Now()) { |
| 139 ssl_config_service_manager_.reset( |
| 140 SSLConfigServiceManager::CreateDefaultManager(this)); |
| 141 |
| 138 request_context_ = ChromeURLRequestContextGetter::CreateOffTheRecord(this); | 142 request_context_ = ChromeURLRequestContextGetter::CreateOffTheRecord(this); |
| 139 extension_process_manager_.reset(ExtensionProcessManager::Create(this)); | 143 extension_process_manager_.reset(ExtensionProcessManager::Create(this)); |
| 140 | 144 |
| 141 BrowserList::AddObserver(this); | 145 BrowserList::AddObserver(this); |
| 142 | 146 |
| 143 background_contents_service_.reset( | 147 background_contents_service_.reset( |
| 144 new BackgroundContentsService(this, CommandLine::ForCurrentProcess())); | 148 new BackgroundContentsService(this, CommandLine::ForCurrentProcess())); |
| 145 } | 149 } |
| 146 | 150 |
| 147 virtual ~OffTheRecordProfileImpl() { | 151 virtual ~OffTheRecordProfileImpl() { |
| (...skipping 234 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 382 URLRequestContextGetter* GetRequestContextForExtensions() { | 386 URLRequestContextGetter* GetRequestContextForExtensions() { |
| 383 if (!extensions_request_context_) { | 387 if (!extensions_request_context_) { |
| 384 extensions_request_context_ = | 388 extensions_request_context_ = |
| 385 ChromeURLRequestContextGetter::CreateOffTheRecordForExtensions(this); | 389 ChromeURLRequestContextGetter::CreateOffTheRecordForExtensions(this); |
| 386 } | 390 } |
| 387 | 391 |
| 388 return extensions_request_context_; | 392 return extensions_request_context_; |
| 389 } | 393 } |
| 390 | 394 |
| 391 virtual net::SSLConfigService* GetSSLConfigService() { | 395 virtual net::SSLConfigService* GetSSLConfigService() { |
| 392 return profile_->GetSSLConfigService(); | 396 return ssl_config_service_manager_->Get(); |
| 393 } | 397 } |
| 394 | 398 |
| 395 virtual HostContentSettingsMap* GetHostContentSettingsMap() { | 399 virtual HostContentSettingsMap* GetHostContentSettingsMap() { |
| 396 // Retrieve the host content settings map of the parent profile in order to | 400 // Retrieve the host content settings map of the parent profile in order to |
| 397 // ensure the preferences have been migrated. | 401 // ensure the preferences have been migrated. |
| 398 profile_->GetHostContentSettingsMap(); | 402 profile_->GetHostContentSettingsMap(); |
| 399 if (!host_content_settings_map_.get()) | 403 if (!host_content_settings_map_.get()) |
| 400 host_content_settings_map_ = new HostContentSettingsMap(this); | 404 host_content_settings_map_ = new HostContentSettingsMap(this); |
| 401 return host_content_settings_map_.get(); | 405 return host_content_settings_map_.get(); |
| 402 } | 406 } |
| (...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 655 | 659 |
| 656 // Time we were started. | 660 // Time we were started. |
| 657 Time start_time_; | 661 Time start_time_; |
| 658 | 662 |
| 659 scoped_refptr<ChromeAppCacheService> appcache_service_; | 663 scoped_refptr<ChromeAppCacheService> appcache_service_; |
| 660 | 664 |
| 661 // The main database tracker for this profile. | 665 // The main database tracker for this profile. |
| 662 // Should be used only on the file thread. | 666 // Should be used only on the file thread. |
| 663 scoped_refptr<webkit_database::DatabaseTracker> db_tracker_; | 667 scoped_refptr<webkit_database::DatabaseTracker> db_tracker_; |
| 664 | 668 |
| 669 // A separate SSLConfigServiceManager from the main profile because |
| 670 // we require a separate SSL session cache. |
| 671 scoped_ptr<SSLConfigServiceManager> ssl_config_service_manager_; |
| 672 |
| 665 FilePath last_selected_directory_; | 673 FilePath last_selected_directory_; |
| 666 | 674 |
| 667 // Tracks all BackgroundContents running under this profile. | 675 // Tracks all BackgroundContents running under this profile. |
| 668 scoped_ptr<BackgroundContentsService> background_contents_service_; | 676 scoped_ptr<BackgroundContentsService> background_contents_service_; |
| 669 | 677 |
| 670 scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; | 678 scoped_refptr<ChromeBlobStorageContext> blob_storage_context_; |
| 671 | 679 |
| 672 // The file_system context for this profile. | 680 // The file_system context for this profile. |
| 673 scoped_refptr<fileapi::SandboxedFileSystemContext> file_system_context_; | 681 scoped_refptr<fileapi::SandboxedFileSystemContext> file_system_context_; |
| 674 | 682 |
| 675 DISALLOW_COPY_AND_ASSIGN(OffTheRecordProfileImpl); | 683 DISALLOW_COPY_AND_ASSIGN(OffTheRecordProfileImpl); |
| 676 }; | 684 }; |
| 677 | 685 |
| 678 Profile* Profile::CreateOffTheRecordProfile() { | 686 Profile* Profile::CreateOffTheRecordProfile() { |
| 679 return new OffTheRecordProfileImpl(this); | 687 return new OffTheRecordProfileImpl(this); |
| 680 } | 688 } |
| OLD | NEW |