| 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/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 #include "chrome/browser/extensions/extension_service.h" | 74 #include "chrome/browser/extensions/extension_service.h" |
| 75 #include "chrome/browser/extensions/extension_special_storage_policy.h" | 75 #include "chrome/browser/extensions/extension_special_storage_policy.h" |
| 76 #include "extensions/browser/api/web_request/web_request_api.h" | 76 #include "extensions/browser/api/web_request/web_request_api.h" |
| 77 #include "extensions/browser/extension_system.h" | 77 #include "extensions/browser/extension_system.h" |
| 78 #include "extensions/browser/guest_view/guest_view_manager.h" | 78 #include "extensions/browser/guest_view/guest_view_manager.h" |
| 79 #include "extensions/common/extension.h" | 79 #include "extensions/common/extension.h" |
| 80 #endif | 80 #endif |
| 81 | 81 |
| 82 using content::BrowserThread; | 82 using content::BrowserThread; |
| 83 using content::DownloadManagerDelegate; | 83 using content::DownloadManagerDelegate; |
| 84 using content::HostZoomMap; | |
| 85 | 84 |
| 86 #if defined(ENABLE_EXTENSIONS) | 85 #if defined(ENABLE_EXTENSIONS) |
| 87 namespace { | 86 namespace { |
| 88 | 87 |
| 89 void NotifyOTRProfileCreatedOnIOThread(void* original_profile, | 88 void NotifyOTRProfileCreatedOnIOThread(void* original_profile, |
| 90 void* otr_profile) { | 89 void* otr_profile) { |
| 91 ExtensionWebRequestEventRouter::GetInstance()->OnOTRBrowserContextCreated( | 90 ExtensionWebRequestEventRouter::GetInstance()->OnOTRBrowserContextCreated( |
| 92 original_profile, otr_profile); | 91 original_profile, otr_profile); |
| 93 } | 92 } |
| 94 | 93 |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 DataReductionProxyChromeConfigurator::DisableInProxyConfigPref(prefs_); | 135 DataReductionProxyChromeConfigurator::DisableInProxyConfigPref(prefs_); |
| 137 | 136 |
| 138 // TODO(oshima): Remove the need to eagerly initialize the request context | 137 // TODO(oshima): Remove the need to eagerly initialize the request context |
| 139 // getter. chromeos::OnlineAttempt is illegally trying to access this | 138 // getter. chromeos::OnlineAttempt is illegally trying to access this |
| 140 // Profile member from a thread other than the UI thread, so we need to | 139 // Profile member from a thread other than the UI thread, so we need to |
| 141 // prevent a race. | 140 // prevent a race. |
| 142 #if defined(OS_CHROMEOS) | 141 #if defined(OS_CHROMEOS) |
| 143 GetRequestContext(); | 142 GetRequestContext(); |
| 144 #endif // defined(OS_CHROMEOS) | 143 #endif // defined(OS_CHROMEOS) |
| 145 | 144 |
| 146 InitHostZoomMap(); | 145 TrackZoomLevelsFromParent(profile_); |
| 147 | 146 |
| 148 #if defined(ENABLE_PLUGINS) | 147 #if defined(ENABLE_PLUGINS) |
| 149 ChromePluginServiceFilter::GetInstance()->RegisterResourceContext( | 148 ChromePluginServiceFilter::GetInstance()->RegisterResourceContext( |
| 150 PluginPrefs::GetForProfile(this).get(), | 149 PluginPrefs::GetForProfile(this).get(), |
| 151 io_data_->GetResourceContextNoInit()); | 150 io_data_->GetResourceContextNoInit()); |
| 152 #endif | 151 #endif |
| 153 | 152 |
| 154 #if defined(ENABLE_EXTENSIONS) | 153 #if defined(ENABLE_EXTENSIONS) |
| 155 // Make the chrome//extension-icon/ resource available. | 154 // Make the chrome//extension-icon/ resource available. |
| 156 extensions::ExtensionIconSource* icon_source = | 155 extensions::ExtensionIconSource* icon_source = |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 192 | 191 |
| 193 // Clears any data the network stack contains that may be related to the | 192 // Clears any data the network stack contains that may be related to the |
| 194 // OTR session. | 193 // OTR session. |
| 195 g_browser_process->io_thread()->ChangedToOnTheRecord(); | 194 g_browser_process->io_thread()->ChangedToOnTheRecord(); |
| 196 } | 195 } |
| 197 | 196 |
| 198 void OffTheRecordProfileImpl::InitIoData() { | 197 void OffTheRecordProfileImpl::InitIoData() { |
| 199 io_data_.reset(new OffTheRecordProfileIOData::Handle(this)); | 198 io_data_.reset(new OffTheRecordProfileIOData::Handle(this)); |
| 200 } | 199 } |
| 201 | 200 |
| 202 void OffTheRecordProfileImpl::InitHostZoomMap() { | |
| 203 HostZoomMap* host_zoom_map = HostZoomMap::GetDefaultForBrowserContext(this); | |
| 204 HostZoomMap* parent_host_zoom_map = | |
| 205 HostZoomMap::GetDefaultForBrowserContext(profile_); | |
| 206 host_zoom_map->CopyFrom(parent_host_zoom_map); | |
| 207 // Observe parent's HZM change for propagating change of parent's | |
| 208 // change to this HZM. | |
| 209 zoom_subscription_ = parent_host_zoom_map->AddZoomLevelChangedCallback( | |
| 210 base::Bind(&OffTheRecordProfileImpl::OnZoomLevelChanged, | |
| 211 base::Unretained(this))); | |
| 212 } | |
| 213 | |
| 214 std::string OffTheRecordProfileImpl::GetProfileName() { | 201 std::string OffTheRecordProfileImpl::GetProfileName() { |
| 215 // Incognito profile should not return the profile name. | 202 // Incognito profile should not return the profile name. |
| 216 return std::string(); | 203 return std::string(); |
| 217 } | 204 } |
| 218 | 205 |
| 219 Profile::ProfileType OffTheRecordProfileImpl::GetProfileType() const { | 206 Profile::ProfileType OffTheRecordProfileImpl::GetProfileType() const { |
| 220 return INCOGNITO_PROFILE; | 207 return INCOGNITO_PROFILE; |
| 221 } | 208 } |
| 222 | 209 |
| 223 base::FilePath OffTheRecordProfileImpl::GetPath() const { | 210 base::FilePath OffTheRecordProfileImpl::GetPath() const { |
| (...skipping 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 #if defined(OS_CHROMEOS) | 490 #if defined(OS_CHROMEOS) |
| 504 if (IsGuestSession()) | 491 if (IsGuestSession()) |
| 505 profile = new GuestSessionProfile(this); | 492 profile = new GuestSessionProfile(this); |
| 506 #endif | 493 #endif |
| 507 if (!profile) | 494 if (!profile) |
| 508 profile = new OffTheRecordProfileImpl(this); | 495 profile = new OffTheRecordProfileImpl(this); |
| 509 profile->Init(); | 496 profile->Init(); |
| 510 return profile; | 497 return profile; |
| 511 } | 498 } |
| 512 | 499 |
| 513 void OffTheRecordProfileImpl::OnZoomLevelChanged( | |
| 514 const HostZoomMap::ZoomLevelChange& change) { | |
| 515 HostZoomMap* host_zoom_map = HostZoomMap::GetDefaultForBrowserContext(this); | |
| 516 switch (change.mode) { | |
| 517 case HostZoomMap::ZOOM_CHANGED_TEMPORARY_ZOOM: | |
| 518 return; | |
| 519 case HostZoomMap::ZOOM_CHANGED_FOR_HOST: | |
| 520 host_zoom_map->SetZoomLevelForHost(change.host, change.zoom_level); | |
| 521 return; | |
| 522 case HostZoomMap::ZOOM_CHANGED_FOR_SCHEME_AND_HOST: | |
| 523 host_zoom_map->SetZoomLevelForHostAndScheme(change.scheme, | |
| 524 change.host, | |
| 525 change.zoom_level); | |
| 526 return; | |
| 527 } | |
| 528 } | |
| 529 | |
| 530 PrefProxyConfigTracker* OffTheRecordProfileImpl::CreateProxyConfigTracker() { | 500 PrefProxyConfigTracker* OffTheRecordProfileImpl::CreateProxyConfigTracker() { |
| 531 #if defined(OS_CHROMEOS) | 501 #if defined(OS_CHROMEOS) |
| 532 if (chromeos::ProfileHelper::IsSigninProfile(this)) { | 502 if (chromeos::ProfileHelper::IsSigninProfile(this)) { |
| 533 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( | 503 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( |
| 534 g_browser_process->local_state()); | 504 g_browser_process->local_state()); |
| 535 } | 505 } |
| 536 #endif // defined(OS_CHROMEOS) | 506 #endif // defined(OS_CHROMEOS) |
| 537 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( | 507 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( |
| 538 GetPrefs(), g_browser_process->local_state()); | 508 GetPrefs(), g_browser_process->local_state()); |
| 539 } | 509 } |
| OLD | NEW |