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/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 125 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 136 DataReductionProxyChromeConfigurator::DisableInProxyConfigPref(prefs_); | 136 DataReductionProxyChromeConfigurator::DisableInProxyConfigPref(prefs_); |
| 137 | 137 |
| 138 // TODO(oshima): Remove the need to eagerly initialize the request context | 138 // TODO(oshima): Remove the need to eagerly initialize the request context |
| 139 // getter. chromeos::OnlineAttempt is illegally trying to access this | 139 // getter. chromeos::OnlineAttempt is illegally trying to access this |
| 140 // Profile member from a thread other than the UI thread, so we need to | 140 // Profile member from a thread other than the UI thread, so we need to |
| 141 // prevent a race. | 141 // prevent a race. |
| 142 #if defined(OS_CHROMEOS) | 142 #if defined(OS_CHROMEOS) |
| 143 GetRequestContext(); | 143 GetRequestContext(); |
| 144 #endif // defined(OS_CHROMEOS) | 144 #endif // defined(OS_CHROMEOS) |
| 145 | 145 |
| 146 InitHostZoomMap(); | 146 TrackZoomLevelsFromParent(); |
| 147 | 147 |
| 148 #if defined(ENABLE_PLUGINS) | 148 #if defined(ENABLE_PLUGINS) |
| 149 ChromePluginServiceFilter::GetInstance()->RegisterResourceContext( | 149 ChromePluginServiceFilter::GetInstance()->RegisterResourceContext( |
| 150 PluginPrefs::GetForProfile(this).get(), | 150 PluginPrefs::GetForProfile(this).get(), |
| 151 io_data_->GetResourceContextNoInit()); | 151 io_data_->GetResourceContextNoInit()); |
| 152 #endif | 152 #endif |
| 153 | 153 |
| 154 #if defined(ENABLE_EXTENSIONS) | 154 #if defined(ENABLE_EXTENSIONS) |
| 155 // Make the chrome//extension-icon/ resource available. | 155 // Make the chrome//extension-icon/ resource available. |
| 156 extensions::ExtensionIconSource* icon_source = | 156 extensions::ExtensionIconSource* icon_source = |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 192 | 192 |
| 193 // Clears any data the network stack contains that may be related to the | 193 // Clears any data the network stack contains that may be related to the |
| 194 // OTR session. | 194 // OTR session. |
| 195 g_browser_process->io_thread()->ChangedToOnTheRecord(); | 195 g_browser_process->io_thread()->ChangedToOnTheRecord(); |
| 196 } | 196 } |
| 197 | 197 |
| 198 void OffTheRecordProfileImpl::InitIoData() { | 198 void OffTheRecordProfileImpl::InitIoData() { |
| 199 io_data_.reset(new OffTheRecordProfileIOData::Handle(this)); | 199 io_data_.reset(new OffTheRecordProfileIOData::Handle(this)); |
| 200 } | 200 } |
| 201 | 201 |
| 202 void OffTheRecordProfileImpl::InitHostZoomMap() { | 202 void OffTheRecordProfileImpl::TrackZoomLevelsFromParent() { |
| 203 DCHECK(profile_->GetProfileType() != INCOGNITO_PROFILE); | |
|
Charlie Reis
2014/11/04 23:43:16
DCHECK_NE
wjmaclean
2014/11/05 21:55:42
Done.
| |
| 204 | |
| 205 // Here we only want to use zoom levels stored in the main-context's default | |
| 206 // storage partition. We're not interested in zoom levels in special | |
| 207 // partitions, e.g. those used by WebViewGuests. | |
| 203 HostZoomMap* host_zoom_map = HostZoomMap::GetDefaultForBrowserContext(this); | 208 HostZoomMap* host_zoom_map = HostZoomMap::GetDefaultForBrowserContext(this); |
| 204 HostZoomMap* parent_host_zoom_map = | 209 HostZoomMap* parent_host_zoom_map = |
| 205 HostZoomMap::GetDefaultForBrowserContext(profile_); | 210 HostZoomMap::GetDefaultForBrowserContext(profile_); |
| 206 host_zoom_map->CopyFrom(parent_host_zoom_map); | 211 host_zoom_map->CopyFrom(parent_host_zoom_map); |
| 207 // Observe parent's HZM change for propagating change of parent's | 212 // Observe parent profile's HostZoomMap changes so they can also be applied |
| 208 // change to this HZM. | 213 // to this profile's HostZoomMap. |
| 209 zoom_subscription_ = parent_host_zoom_map->AddZoomLevelChangedCallback( | 214 // Important: this function should never be made virtual without moving the |
|
Charlie Reis
2014/11/04 23:43:16
I don't fully understand this comment, but it also
wjmaclean
2014/11/05 21:55:42
Actually, I'm removing it ... it used to apply whe
| |
| 210 base::Bind(&OffTheRecordProfileImpl::OnZoomLevelChanged, | 215 // subscription down to the leaf nodes(s). |
|
Charlie Reis
2014/11/04 23:43:16
nit: node(s)
(I think. Node is an unusual term f
wjmaclean
2014/11/05 21:55:42
Acknowledged.
| |
| 216 track_zoom_subscription_ = parent_host_zoom_map->AddZoomLevelChangedCallback( | |
| 217 base::Bind(&OffTheRecordProfileImpl::TrackParentZoomLevelChanged, | |
| 211 base::Unretained(this))); | 218 base::Unretained(this))); |
| 212 } | 219 } |
| 213 | 220 |
| 214 std::string OffTheRecordProfileImpl::GetProfileName() { | 221 std::string OffTheRecordProfileImpl::GetProfileName() { |
| 215 // Incognito profile should not return the profile name. | 222 // Incognito profile should not return the profile name. |
| 216 return std::string(); | 223 return std::string(); |
| 217 } | 224 } |
| 218 | 225 |
| 219 Profile::ProfileType OffTheRecordProfileImpl::GetProfileType() const { | 226 Profile::ProfileType OffTheRecordProfileImpl::GetProfileType() const { |
| 220 return INCOGNITO_PROFILE; | 227 return INCOGNITO_PROFILE; |
| (...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 503 #if defined(OS_CHROMEOS) | 510 #if defined(OS_CHROMEOS) |
| 504 if (IsGuestSession()) | 511 if (IsGuestSession()) |
| 505 profile = new GuestSessionProfile(this); | 512 profile = new GuestSessionProfile(this); |
| 506 #endif | 513 #endif |
| 507 if (!profile) | 514 if (!profile) |
| 508 profile = new OffTheRecordProfileImpl(this); | 515 profile = new OffTheRecordProfileImpl(this); |
| 509 profile->Init(); | 516 profile->Init(); |
| 510 return profile; | 517 return profile; |
| 511 } | 518 } |
| 512 | 519 |
| 513 void OffTheRecordProfileImpl::OnZoomLevelChanged( | 520 void OffTheRecordProfileImpl::TrackParentZoomLevelChanged( |
| 514 const HostZoomMap::ZoomLevelChange& change) { | 521 const HostZoomMap::ZoomLevelChange& change) { |
| 515 HostZoomMap* host_zoom_map = HostZoomMap::GetDefaultForBrowserContext(this); | 522 HostZoomMap* host_zoom_map = HostZoomMap::GetDefaultForBrowserContext(this); |
| 516 switch (change.mode) { | 523 switch (change.mode) { |
| 517 case HostZoomMap::ZOOM_CHANGED_TEMPORARY_ZOOM: | 524 case HostZoomMap::ZOOM_CHANGED_TEMPORARY_ZOOM: |
| 518 return; | 525 return; |
| 519 case HostZoomMap::ZOOM_CHANGED_FOR_HOST: | 526 case HostZoomMap::ZOOM_CHANGED_FOR_HOST: |
| 520 host_zoom_map->SetZoomLevelForHost(change.host, change.zoom_level); | 527 host_zoom_map->SetZoomLevelForHost(change.host, change.zoom_level); |
| 521 return; | 528 return; |
| 522 case HostZoomMap::ZOOM_CHANGED_FOR_SCHEME_AND_HOST: | 529 case HostZoomMap::ZOOM_CHANGED_FOR_SCHEME_AND_HOST: |
| 523 host_zoom_map->SetZoomLevelForHostAndScheme(change.scheme, | 530 host_zoom_map->SetZoomLevelForHostAndScheme(change.scheme, |
| 524 change.host, | 531 change.host, |
| 525 change.zoom_level); | 532 change.zoom_level); |
| 526 return; | 533 return; |
| 527 } | 534 } |
| 528 } | 535 } |
| 529 | 536 |
| 530 PrefProxyConfigTracker* OffTheRecordProfileImpl::CreateProxyConfigTracker() { | 537 PrefProxyConfigTracker* OffTheRecordProfileImpl::CreateProxyConfigTracker() { |
| 531 #if defined(OS_CHROMEOS) | 538 #if defined(OS_CHROMEOS) |
| 532 if (chromeos::ProfileHelper::IsSigninProfile(this)) { | 539 if (chromeos::ProfileHelper::IsSigninProfile(this)) { |
| 533 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( | 540 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( |
| 534 g_browser_process->local_state()); | 541 g_browser_process->local_state()); |
| 535 } | 542 } |
| 536 #endif // defined(OS_CHROMEOS) | 543 #endif // defined(OS_CHROMEOS) |
| 537 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( | 544 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( |
| 538 GetPrefs(), g_browser_process->local_state()); | 545 GetPrefs(), g_browser_process->local_state()); |
| 539 } | 546 } |
| OLD | NEW |