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 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 135 DataReductionProxyChromeConfigurator::DisableInProxyConfigPref(prefs_); | 135 DataReductionProxyChromeConfigurator::DisableInProxyConfigPref(prefs_); |
| 136 | 136 |
| 137 // TODO(oshima): Remove the need to eagerly initialize the request context | 137 // TODO(oshima): Remove the need to eagerly initialize the request context |
| 138 // getter. chromeos::OnlineAttempt is illegally trying to access this | 138 // getter. chromeos::OnlineAttempt is illegally trying to access this |
| 139 // 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 |
| 140 // prevent a race. | 140 // prevent a race. |
| 141 #if defined(OS_CHROMEOS) | 141 #if defined(OS_CHROMEOS) |
| 142 GetRequestContext(); | 142 GetRequestContext(); |
| 143 #endif // defined(OS_CHROMEOS) | 143 #endif // defined(OS_CHROMEOS) |
| 144 | 144 |
| 145 InitHostZoomMap(); | 145 TrackZoomLevelsFromParent(); |
| 146 | 146 |
| 147 #if defined(ENABLE_PLUGINS) | 147 #if defined(ENABLE_PLUGINS) |
| 148 ChromePluginServiceFilter::GetInstance()->RegisterResourceContext( | 148 ChromePluginServiceFilter::GetInstance()->RegisterResourceContext( |
| 149 PluginPrefs::GetForProfile(this).get(), | 149 PluginPrefs::GetForProfile(this).get(), |
| 150 io_data_->GetResourceContextNoInit()); | 150 io_data_->GetResourceContextNoInit()); |
| 151 #endif | 151 #endif |
| 152 | 152 |
| 153 #if defined(ENABLE_EXTENSIONS) | 153 #if defined(ENABLE_EXTENSIONS) |
| 154 // Make the chrome//extension-icon/ resource available. | 154 // Make the chrome//extension-icon/ resource available. |
| 155 extensions::ExtensionIconSource* icon_source = | 155 extensions::ExtensionIconSource* icon_source = |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 191 | 191 |
| 192 // 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 |
| 193 // OTR session. | 193 // OTR session. |
| 194 g_browser_process->io_thread()->ChangedToOnTheRecord(); | 194 g_browser_process->io_thread()->ChangedToOnTheRecord(); |
| 195 } | 195 } |
| 196 | 196 |
| 197 void OffTheRecordProfileImpl::InitIoData() { | 197 void OffTheRecordProfileImpl::InitIoData() { |
| 198 io_data_.reset(new OffTheRecordProfileIOData::Handle(this)); | 198 io_data_.reset(new OffTheRecordProfileIOData::Handle(this)); |
| 199 } | 199 } |
| 200 | 200 |
| 201 void OffTheRecordProfileImpl::InitHostZoomMap() { | 201 void OffTheRecordProfileImpl::TrackZoomLevelsFromParent() { |
| 202 DCHECK_NE(profile_->GetProfileType(), INCOGNITO_PROFILE); | |
|
Bernhard Bauer
2014/11/12 10:39:20
Put the expected (well, non-expected here) value f
wjmaclean
2014/11/12 15:12:55
Done.
| |
| 203 | |
| 204 // Here we only want to use zoom levels stored in the main-context's default | |
| 205 // storage partition. We're not interested in zoom levels in special | |
| 206 // partitions, e.g. those used by WebViewGuests. | |
| 202 HostZoomMap* host_zoom_map = HostZoomMap::GetDefaultForBrowserContext(this); | 207 HostZoomMap* host_zoom_map = HostZoomMap::GetDefaultForBrowserContext(this); |
| 203 HostZoomMap* parent_host_zoom_map = | 208 HostZoomMap* parent_host_zoom_map = |
| 204 HostZoomMap::GetDefaultForBrowserContext(profile_); | 209 HostZoomMap::GetDefaultForBrowserContext(profile_); |
| 205 host_zoom_map->CopyFrom(parent_host_zoom_map); | 210 host_zoom_map->CopyFrom(parent_host_zoom_map); |
| 206 // Observe parent's HZM change for propagating change of parent's | 211 // Observe parent profile's HostZoomMap changes so they can also be applied |
| 207 // change to this HZM. | 212 // to this profile's HostZoomMap. |
| 208 zoom_subscription_ = parent_host_zoom_map->AddZoomLevelChangedCallback( | 213 track_zoom_subscription_ = parent_host_zoom_map->AddZoomLevelChangedCallback( |
| 209 base::Bind(&OffTheRecordProfileImpl::OnZoomLevelChanged, | 214 base::Bind(&OffTheRecordProfileImpl::OnParentZoomLevelChanged, |
| 210 base::Unretained(this))); | 215 base::Unretained(this))); |
| 211 } | 216 } |
| 212 | 217 |
| 213 std::string OffTheRecordProfileImpl::GetProfileName() { | 218 std::string OffTheRecordProfileImpl::GetProfileName() { |
| 214 // Incognito profile should not return the profile name. | 219 // Incognito profile should not return the profile name. |
| 215 return std::string(); | 220 return std::string(); |
| 216 } | 221 } |
| 217 | 222 |
| 218 Profile::ProfileType OffTheRecordProfileImpl::GetProfileType() const { | 223 Profile::ProfileType OffTheRecordProfileImpl::GetProfileType() const { |
| 219 #if !defined(OS_CHROMEOS) | 224 #if !defined(OS_CHROMEOS) |
| 220 return profile_->IsGuestSession() ? GUEST_PROFILE : INCOGNITO_PROFILE; | 225 return profile_->IsGuestSession() ? GUEST_PROFILE : INCOGNITO_PROFILE; |
| 221 #else | 226 #else |
| 222 return INCOGNITO_PROFILE; | 227 return INCOGNITO_PROFILE; |
| 223 #endif | 228 #endif |
| 224 } | 229 } |
| 225 | 230 |
| 226 base::FilePath OffTheRecordProfileImpl::GetPath() const { | 231 base::FilePath OffTheRecordProfileImpl::GetPath() const { |
| 227 return profile_->GetPath(); | 232 return profile_->GetPath(); |
| 228 } | 233 } |
| 229 | 234 |
| 235 scoped_ptr<content::ZoomLevelDelegate> | |
| 236 OffTheRecordProfileImpl::CreateZoomLevelDelegate( | |
| 237 const base::FilePath& partition_path) { | |
| 238 return nullptr; | |
| 239 } | |
| 240 | |
| 230 scoped_refptr<base::SequencedTaskRunner> | 241 scoped_refptr<base::SequencedTaskRunner> |
| 231 OffTheRecordProfileImpl::GetIOTaskRunner() { | 242 OffTheRecordProfileImpl::GetIOTaskRunner() { |
| 232 return profile_->GetIOTaskRunner(); | 243 return profile_->GetIOTaskRunner(); |
| 233 } | 244 } |
| 234 | 245 |
| 235 bool OffTheRecordProfileImpl::IsOffTheRecord() const { | 246 bool OffTheRecordProfileImpl::IsOffTheRecord() const { |
| 236 return true; | 247 return true; |
| 237 } | 248 } |
| 238 | 249 |
| 239 Profile* OffTheRecordProfileImpl::GetOffTheRecordProfile() { | 250 Profile* OffTheRecordProfileImpl::GetOffTheRecordProfile() { |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 506 #if defined(OS_CHROMEOS) | 517 #if defined(OS_CHROMEOS) |
| 507 if (IsGuestSession()) | 518 if (IsGuestSession()) |
| 508 profile = new GuestSessionProfile(this); | 519 profile = new GuestSessionProfile(this); |
| 509 #endif | 520 #endif |
| 510 if (!profile) | 521 if (!profile) |
| 511 profile = new OffTheRecordProfileImpl(this); | 522 profile = new OffTheRecordProfileImpl(this); |
| 512 profile->Init(); | 523 profile->Init(); |
| 513 return profile; | 524 return profile; |
| 514 } | 525 } |
| 515 | 526 |
| 516 void OffTheRecordProfileImpl::OnZoomLevelChanged( | 527 void OffTheRecordProfileImpl::OnParentZoomLevelChanged( |
| 517 const HostZoomMap::ZoomLevelChange& change) { | 528 const HostZoomMap::ZoomLevelChange& change) { |
| 518 HostZoomMap* host_zoom_map = HostZoomMap::GetDefaultForBrowserContext(this); | 529 HostZoomMap* host_zoom_map = HostZoomMap::GetDefaultForBrowserContext(this); |
| 519 switch (change.mode) { | 530 switch (change.mode) { |
| 520 case HostZoomMap::ZOOM_CHANGED_TEMPORARY_ZOOM: | 531 case HostZoomMap::ZOOM_CHANGED_TEMPORARY_ZOOM: |
| 521 return; | 532 return; |
| 522 case HostZoomMap::ZOOM_CHANGED_FOR_HOST: | 533 case HostZoomMap::ZOOM_CHANGED_FOR_HOST: |
| 523 host_zoom_map->SetZoomLevelForHost(change.host, change.zoom_level); | 534 host_zoom_map->SetZoomLevelForHost(change.host, change.zoom_level); |
| 524 return; | 535 return; |
| 525 case HostZoomMap::ZOOM_CHANGED_FOR_SCHEME_AND_HOST: | 536 case HostZoomMap::ZOOM_CHANGED_FOR_SCHEME_AND_HOST: |
| 526 host_zoom_map->SetZoomLevelForHostAndScheme(change.scheme, | 537 host_zoom_map->SetZoomLevelForHostAndScheme(change.scheme, |
| 527 change.host, | 538 change.host, |
| 528 change.zoom_level); | 539 change.zoom_level); |
| 529 return; | 540 return; |
| 530 } | 541 } |
| 531 } | 542 } |
| 532 | 543 |
| 533 PrefProxyConfigTracker* OffTheRecordProfileImpl::CreateProxyConfigTracker() { | 544 PrefProxyConfigTracker* OffTheRecordProfileImpl::CreateProxyConfigTracker() { |
| 534 #if defined(OS_CHROMEOS) | 545 #if defined(OS_CHROMEOS) |
| 535 if (chromeos::ProfileHelper::IsSigninProfile(this)) { | 546 if (chromeos::ProfileHelper::IsSigninProfile(this)) { |
| 536 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( | 547 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( |
| 537 g_browser_process->local_state()); | 548 g_browser_process->local_state()); |
| 538 } | 549 } |
| 539 #endif // defined(OS_CHROMEOS) | 550 #endif // defined(OS_CHROMEOS) |
| 540 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( | 551 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( |
| 541 GetPrefs(), g_browser_process->local_state()); | 552 GetPrefs(), g_browser_process->local_state()); |
| 542 } | 553 } |
| OLD | NEW |