| 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 30 matching lines...) Expand all Loading... |
| 76 void NotifyOTRProfileDestroyedOnIOThread(void* original_profile, | 76 void NotifyOTRProfileDestroyedOnIOThread(void* original_profile, |
| 77 void* otr_profile) { | 77 void* otr_profile) { |
| 78 ExtensionWebRequestEventRouter::GetInstance()->OnOTRProfileDestroyed( | 78 ExtensionWebRequestEventRouter::GetInstance()->OnOTRProfileDestroyed( |
| 79 original_profile, otr_profile); | 79 original_profile, otr_profile); |
| 80 } | 80 } |
| 81 | 81 |
| 82 } // namespace | 82 } // namespace |
| 83 | 83 |
| 84 OffTheRecordProfileImpl::OffTheRecordProfileImpl(Profile* real_profile) | 84 OffTheRecordProfileImpl::OffTheRecordProfileImpl(Profile* real_profile) |
| 85 : profile_(real_profile), | 85 : profile_(real_profile), |
| 86 prefs_(real_profile->GetOffTheRecordPrefs()), | 86 prefs_(PrefServiceSyncable::IncognitoFromProfile(real_profile)), |
| 87 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)), | 87 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)), |
| 88 start_time_(Time::Now()), | 88 start_time_(Time::Now()), |
| 89 zoom_callback_(base::Bind(&OffTheRecordProfileImpl::OnZoomLevelChanged, | 89 zoom_callback_(base::Bind(&OffTheRecordProfileImpl::OnZoomLevelChanged, |
| 90 base::Unretained(this))) { | 90 base::Unretained(this))) { |
| 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(); |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 233 | 233 |
| 234 policy::ManagedModePolicyProvider* | 234 policy::ManagedModePolicyProvider* |
| 235 OffTheRecordProfileImpl::GetManagedModePolicyProvider() { | 235 OffTheRecordProfileImpl::GetManagedModePolicyProvider() { |
| 236 return profile_->GetManagedModePolicyProvider(); | 236 return profile_->GetManagedModePolicyProvider(); |
| 237 } | 237 } |
| 238 | 238 |
| 239 policy::PolicyService* OffTheRecordProfileImpl::GetPolicyService() { | 239 policy::PolicyService* OffTheRecordProfileImpl::GetPolicyService() { |
| 240 return profile_->GetPolicyService(); | 240 return profile_->GetPolicyService(); |
| 241 } | 241 } |
| 242 | 242 |
| 243 PrefServiceSyncable* OffTheRecordProfileImpl::GetPrefs() { | 243 PrefService* OffTheRecordProfileImpl::GetPrefs() { |
| 244 return prefs_; | 244 return prefs_; |
| 245 } | 245 } |
| 246 | 246 |
| 247 PrefServiceSyncable* OffTheRecordProfileImpl::GetOffTheRecordPrefs() { | 247 PrefService* OffTheRecordProfileImpl::GetOffTheRecordPrefs() { |
| 248 return prefs_; | 248 return prefs_; |
| 249 } | 249 } |
| 250 | 250 |
| 251 DownloadManagerDelegate* OffTheRecordProfileImpl::GetDownloadManagerDelegate() { | 251 DownloadManagerDelegate* OffTheRecordProfileImpl::GetDownloadManagerDelegate() { |
| 252 return DownloadServiceFactory::GetForProfile(this)-> | 252 return DownloadServiceFactory::GetForProfile(this)-> |
| 253 GetDownloadManagerDelegate(); | 253 GetDownloadManagerDelegate(); |
| 254 } | 254 } |
| 255 | 255 |
| 256 net::URLRequestContextGetter* OffTheRecordProfileImpl::GetRequestContext() { | 256 net::URLRequestContextGetter* OffTheRecordProfileImpl::GetRequestContext() { |
| 257 return GetDefaultStoragePartition(this)->GetURLRequestContext(); | 257 return GetDefaultStoragePartition(this)->GetURLRequestContext(); |
| (...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 463 // Special case of the OffTheRecordProfileImpl which is used while Guest | 463 // Special case of the OffTheRecordProfileImpl which is used while Guest |
| 464 // session in CrOS. | 464 // session in CrOS. |
| 465 class GuestSessionProfile : public OffTheRecordProfileImpl { | 465 class GuestSessionProfile : public OffTheRecordProfileImpl { |
| 466 public: | 466 public: |
| 467 explicit GuestSessionProfile(Profile* real_profile) | 467 explicit GuestSessionProfile(Profile* real_profile) |
| 468 : OffTheRecordProfileImpl(real_profile) { | 468 : OffTheRecordProfileImpl(real_profile) { |
| 469 } | 469 } |
| 470 | 470 |
| 471 virtual void InitChromeOSPreferences() OVERRIDE { | 471 virtual void InitChromeOSPreferences() OVERRIDE { |
| 472 chromeos_preferences_.reset(new chromeos::Preferences()); | 472 chromeos_preferences_.reset(new chromeos::Preferences()); |
| 473 chromeos_preferences_->Init(GetPrefs()); | 473 chromeos_preferences_->Init(static_cast<PrefServiceSyncable*>(GetPrefs())); |
| 474 } | 474 } |
| 475 | 475 |
| 476 private: | 476 private: |
| 477 // The guest user should be able to customize Chrome OS preferences. | 477 // The guest user should be able to customize Chrome OS preferences. |
| 478 scoped_ptr<chromeos::Preferences> chromeos_preferences_; | 478 scoped_ptr<chromeos::Preferences> chromeos_preferences_; |
| 479 }; | 479 }; |
| 480 #endif | 480 #endif |
| 481 | 481 |
| 482 Profile* Profile::CreateOffTheRecordProfile() { | 482 Profile* Profile::CreateOffTheRecordProfile() { |
| 483 OffTheRecordProfileImpl* profile = NULL; | 483 OffTheRecordProfileImpl* profile = NULL; |
| (...skipping 10 matching lines...) Expand all Loading... |
| 494 void OffTheRecordProfileImpl::OnZoomLevelChanged(const std::string& host) { | 494 void OffTheRecordProfileImpl::OnZoomLevelChanged(const std::string& host) { |
| 495 if (host.empty()) | 495 if (host.empty()) |
| 496 return; | 496 return; |
| 497 | 497 |
| 498 HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this); | 498 HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this); |
| 499 HostZoomMap* parent_host_zoom_map = | 499 HostZoomMap* parent_host_zoom_map = |
| 500 HostZoomMap::GetForBrowserContext(profile_); | 500 HostZoomMap::GetForBrowserContext(profile_); |
| 501 double level = parent_host_zoom_map->GetZoomLevel(host); | 501 double level = parent_host_zoom_map->GetZoomLevel(host); |
| 502 host_zoom_map->SetZoomLevel(host, level); | 502 host_zoom_map->SetZoomLevel(host, level); |
| 503 } | 503 } |
| OLD | NEW |