Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/off_the_record_profile_impl.h" | 5 #include "chrome/browser/profiles/off_the_record_profile_impl.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/compiler_specific.h" | 9 #include "base/compiler_specific.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| (...skipping 14 matching lines...) Expand all Loading... | |
| 25 #include "chrome/browser/extensions/extension_info_map.h" | 25 #include "chrome/browser/extensions/extension_info_map.h" |
| 26 #include "chrome/browser/extensions/extension_pref_store.h" | 26 #include "chrome/browser/extensions/extension_pref_store.h" |
| 27 #include "chrome/browser/extensions/extension_service.h" | 27 #include "chrome/browser/extensions/extension_service.h" |
| 28 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 28 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
| 29 #include "chrome/browser/extensions/extension_system.h" | 29 #include "chrome/browser/extensions/extension_system.h" |
| 30 #include "chrome/browser/io_thread.h" | 30 #include "chrome/browser/io_thread.h" |
| 31 #include "chrome/browser/net/proxy_service_factory.h" | 31 #include "chrome/browser/net/proxy_service_factory.h" |
| 32 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" | 32 #include "chrome/browser/plugins/chrome_plugin_service_filter.h" |
| 33 #include "chrome/browser/plugins/plugin_prefs.h" | 33 #include "chrome/browser/plugins/plugin_prefs.h" |
| 34 #include "chrome/browser/prefs/incognito_mode_prefs.h" | 34 #include "chrome/browser/prefs/incognito_mode_prefs.h" |
| 35 #include "chrome/browser/prefs/pref_service.h" | 35 #include "chrome/browser/prefs/pref_service_syncable.h" |
| 36 #include "chrome/browser/profiles/profile_dependency_manager.h" | 36 #include "chrome/browser/profiles/profile_dependency_manager.h" |
| 37 #include "chrome/browser/themes/theme_service.h" | 37 #include "chrome/browser/themes/theme_service.h" |
| 38 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" | 38 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
| 39 #include "chrome/common/chrome_constants.h" | 39 #include "chrome/common/chrome_constants.h" |
| 40 #include "chrome/common/chrome_paths.h" | 40 #include "chrome/common/chrome_paths.h" |
| 41 #include "chrome/common/chrome_switches.h" | 41 #include "chrome/common/chrome_switches.h" |
| 42 #include "chrome/common/extensions/extension.h" | 42 #include "chrome/common/extensions/extension.h" |
| 43 #include "chrome/common/pref_names.h" | 43 #include "chrome/common/pref_names.h" |
| 44 #include "chrome/common/render_messages.h" | 44 #include "chrome/common/render_messages.h" |
| 45 #include "content/public/browser/browser_thread.h" | 45 #include "content/public/browser/browser_thread.h" |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 78 void NotifyOTRProfileDestroyedOnIOThread(void* original_profile, | 78 void NotifyOTRProfileDestroyedOnIOThread(void* original_profile, |
| 79 void* otr_profile) { | 79 void* otr_profile) { |
| 80 ExtensionWebRequestEventRouter::GetInstance()->OnOTRProfileDestroyed( | 80 ExtensionWebRequestEventRouter::GetInstance()->OnOTRProfileDestroyed( |
| 81 original_profile, otr_profile); | 81 original_profile, otr_profile); |
| 82 } | 82 } |
| 83 | 83 |
| 84 } // namespace | 84 } // namespace |
| 85 | 85 |
| 86 OffTheRecordProfileImpl::OffTheRecordProfileImpl(Profile* real_profile) | 86 OffTheRecordProfileImpl::OffTheRecordProfileImpl(Profile* real_profile) |
| 87 : profile_(real_profile), | 87 : profile_(real_profile), |
| 88 prefs_(real_profile->GetOffTheRecordPrefs()), | 88 prefs_(PrefServiceSyncable::IncognitoFromProfile(real_profile)), |
|
Mattias Nissler (ping if slow)
2013/02/06 17:53:33
Do we really need a PrefServiceSyncable typed poin
Jói
2013/02/07 14:52:32
I think we probably could, but we'd be casting it
Mattias Nissler (ping if slow)
2013/02/08 11:26:56
OK for now.
| |
| 89 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)), | 89 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)), |
| 90 start_time_(Time::Now()) { | 90 start_time_(Time::Now()) { |
| 91 } | 91 } |
| 92 | 92 |
| 93 void OffTheRecordProfileImpl::Init() { | 93 void OffTheRecordProfileImpl::Init() { |
| 94 ProfileDependencyManager::GetInstance()->CreateProfileServices(this, false); | 94 ProfileDependencyManager::GetInstance()->CreateProfileServices(this, false); |
| 95 | 95 |
| 96 extensions::ExtensionSystem::Get(this)->InitForOTRProfile(); | 96 extensions::ExtensionSystem::Get(this)->InitForOTRProfile(); |
| 97 | 97 |
| 98 DCHECK_NE(IncognitoModePrefs::DISABLED, | 98 DCHECK_NE(IncognitoModePrefs::DISABLED, |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 231 | 231 |
| 232 policy::ManagedModePolicyProvider* | 232 policy::ManagedModePolicyProvider* |
| 233 OffTheRecordProfileImpl::GetManagedModePolicyProvider() { | 233 OffTheRecordProfileImpl::GetManagedModePolicyProvider() { |
| 234 return profile_->GetManagedModePolicyProvider(); | 234 return profile_->GetManagedModePolicyProvider(); |
| 235 } | 235 } |
| 236 | 236 |
| 237 policy::PolicyService* OffTheRecordProfileImpl::GetPolicyService() { | 237 policy::PolicyService* OffTheRecordProfileImpl::GetPolicyService() { |
| 238 return profile_->GetPolicyService(); | 238 return profile_->GetPolicyService(); |
| 239 } | 239 } |
| 240 | 240 |
| 241 PrefServiceSyncable* OffTheRecordProfileImpl::GetPrefs() { | 241 PrefService* OffTheRecordProfileImpl::GetPrefs() { |
| 242 return prefs_; | 242 return prefs_; |
| 243 } | 243 } |
| 244 | 244 |
| 245 PrefServiceSyncable* OffTheRecordProfileImpl::GetOffTheRecordPrefs() { | 245 PrefService* OffTheRecordProfileImpl::GetOffTheRecordPrefs() { |
| 246 return prefs_; | 246 return prefs_; |
| 247 } | 247 } |
| 248 | 248 |
| 249 DownloadManagerDelegate* OffTheRecordProfileImpl::GetDownloadManagerDelegate() { | 249 DownloadManagerDelegate* OffTheRecordProfileImpl::GetDownloadManagerDelegate() { |
| 250 return DownloadServiceFactory::GetForProfile(this)-> | 250 return DownloadServiceFactory::GetForProfile(this)-> |
| 251 GetDownloadManagerDelegate(); | 251 GetDownloadManagerDelegate(); |
| 252 } | 252 } |
| 253 | 253 |
| 254 net::URLRequestContextGetter* OffTheRecordProfileImpl::GetRequestContext() { | 254 net::URLRequestContextGetter* OffTheRecordProfileImpl::GetRequestContext() { |
| 255 return io_data_.GetMainRequestContextGetter(); | 255 return io_data_.GetMainRequestContextGetter(); |
| (...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 449 // Special case of the OffTheRecordProfileImpl which is used while Guest | 449 // Special case of the OffTheRecordProfileImpl which is used while Guest |
| 450 // session in CrOS. | 450 // session in CrOS. |
| 451 class GuestSessionProfile : public OffTheRecordProfileImpl { | 451 class GuestSessionProfile : public OffTheRecordProfileImpl { |
| 452 public: | 452 public: |
| 453 explicit GuestSessionProfile(Profile* real_profile) | 453 explicit GuestSessionProfile(Profile* real_profile) |
| 454 : OffTheRecordProfileImpl(real_profile) { | 454 : OffTheRecordProfileImpl(real_profile) { |
| 455 } | 455 } |
| 456 | 456 |
| 457 virtual void InitChromeOSPreferences() { | 457 virtual void InitChromeOSPreferences() { |
| 458 chromeos_preferences_.reset(new chromeos::Preferences()); | 458 chromeos_preferences_.reset(new chromeos::Preferences()); |
| 459 chromeos_preferences_->Init(GetPrefs()); | 459 chromeos_preferences_->Init(static_cast<PrefServiceSyncable*>(GetPrefs())); |
| 460 } | 460 } |
| 461 | 461 |
| 462 private: | 462 private: |
| 463 // The guest user should be able to customize Chrome OS preferences. | 463 // The guest user should be able to customize Chrome OS preferences. |
| 464 scoped_ptr<chromeos::Preferences> chromeos_preferences_; | 464 scoped_ptr<chromeos::Preferences> chromeos_preferences_; |
| 465 }; | 465 }; |
| 466 #endif | 466 #endif |
| 467 | 467 |
| 468 Profile* Profile::CreateOffTheRecordProfile() { | 468 Profile* Profile::CreateOffTheRecordProfile() { |
| 469 OffTheRecordProfileImpl* profile = NULL; | 469 OffTheRecordProfileImpl* profile = NULL; |
| 470 #if defined(OS_CHROMEOS) | 470 #if defined(OS_CHROMEOS) |
| 471 if (IsGuestSession()) | 471 if (IsGuestSession()) |
| 472 profile = new GuestSessionProfile(this); | 472 profile = new GuestSessionProfile(this); |
| 473 #endif | 473 #endif |
| 474 if (!profile) | 474 if (!profile) |
| 475 profile = new OffTheRecordProfileImpl(this); | 475 profile = new OffTheRecordProfileImpl(this); |
| 476 profile->Init(); | 476 profile->Init(); |
| 477 return profile; | 477 return profile; |
| 478 } | 478 } |
| OLD | NEW |