| 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_NE(profile_->GetProfileType(), INCOGNITO_PROFILE); |
| 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 track_zoom_subscription_ = parent_host_zoom_map->AddZoomLevelChangedCallback( |
| 210 base::Bind(&OffTheRecordProfileImpl::OnZoomLevelChanged, | 215 base::Bind(&OffTheRecordProfileImpl::OnParentZoomLevelChanged, |
| 211 base::Unretained(this))); | 216 base::Unretained(this))); |
| 212 } | 217 } |
| 213 | 218 |
| 214 std::string OffTheRecordProfileImpl::GetProfileName() { | 219 std::string OffTheRecordProfileImpl::GetProfileName() { |
| 215 // Incognito profile should not return the profile name. | 220 // Incognito profile should not return the profile name. |
| 216 return std::string(); | 221 return std::string(); |
| 217 } | 222 } |
| 218 | 223 |
| 219 Profile::ProfileType OffTheRecordProfileImpl::GetProfileType() const { | 224 Profile::ProfileType OffTheRecordProfileImpl::GetProfileType() const { |
| 220 return INCOGNITO_PROFILE; | 225 return INCOGNITO_PROFILE; |
| 221 } | 226 } |
| 222 | 227 |
| 223 base::FilePath OffTheRecordProfileImpl::GetPath() const { | 228 base::FilePath OffTheRecordProfileImpl::GetPath() const { |
| 224 return profile_->GetPath(); | 229 return profile_->GetPath(); |
| 225 } | 230 } |
| 226 | 231 |
| 232 scoped_ptr<content::ZoomLevelDelegate> |
| 233 OffTheRecordProfileImpl::CreateZoomLevelDelegate( |
| 234 const base::FilePath& partition_path) { |
| 235 return scoped_ptr<content::ZoomLevelDelegate>(); |
| 236 } |
| 237 |
| 227 scoped_refptr<base::SequencedTaskRunner> | 238 scoped_refptr<base::SequencedTaskRunner> |
| 228 OffTheRecordProfileImpl::GetIOTaskRunner() { | 239 OffTheRecordProfileImpl::GetIOTaskRunner() { |
| 229 return profile_->GetIOTaskRunner(); | 240 return profile_->GetIOTaskRunner(); |
| 230 } | 241 } |
| 231 | 242 |
| 232 bool OffTheRecordProfileImpl::IsOffTheRecord() const { | 243 bool OffTheRecordProfileImpl::IsOffTheRecord() const { |
| 233 return true; | 244 return true; |
| 234 } | 245 } |
| 235 | 246 |
| 236 Profile* OffTheRecordProfileImpl::GetOffTheRecordProfile() { | 247 Profile* OffTheRecordProfileImpl::GetOffTheRecordProfile() { |
| (...skipping 266 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 503 #if defined(OS_CHROMEOS) | 514 #if defined(OS_CHROMEOS) |
| 504 if (IsGuestSession()) | 515 if (IsGuestSession()) |
| 505 profile = new GuestSessionProfile(this); | 516 profile = new GuestSessionProfile(this); |
| 506 #endif | 517 #endif |
| 507 if (!profile) | 518 if (!profile) |
| 508 profile = new OffTheRecordProfileImpl(this); | 519 profile = new OffTheRecordProfileImpl(this); |
| 509 profile->Init(); | 520 profile->Init(); |
| 510 return profile; | 521 return profile; |
| 511 } | 522 } |
| 512 | 523 |
| 513 void OffTheRecordProfileImpl::OnZoomLevelChanged( | 524 void OffTheRecordProfileImpl::OnParentZoomLevelChanged( |
| 514 const HostZoomMap::ZoomLevelChange& change) { | 525 const HostZoomMap::ZoomLevelChange& change) { |
| 515 HostZoomMap* host_zoom_map = HostZoomMap::GetDefaultForBrowserContext(this); | 526 HostZoomMap* host_zoom_map = HostZoomMap::GetDefaultForBrowserContext(this); |
| 516 switch (change.mode) { | 527 switch (change.mode) { |
| 517 case HostZoomMap::ZOOM_CHANGED_TEMPORARY_ZOOM: | 528 case HostZoomMap::ZOOM_CHANGED_TEMPORARY_ZOOM: |
| 518 return; | 529 return; |
| 519 case HostZoomMap::ZOOM_CHANGED_FOR_HOST: | 530 case HostZoomMap::ZOOM_CHANGED_FOR_HOST: |
| 520 host_zoom_map->SetZoomLevelForHost(change.host, change.zoom_level); | 531 host_zoom_map->SetZoomLevelForHost(change.host, change.zoom_level); |
| 521 return; | 532 return; |
| 522 case HostZoomMap::ZOOM_CHANGED_FOR_SCHEME_AND_HOST: | 533 case HostZoomMap::ZOOM_CHANGED_FOR_SCHEME_AND_HOST: |
| 523 host_zoom_map->SetZoomLevelForHostAndScheme(change.scheme, | 534 host_zoom_map->SetZoomLevelForHostAndScheme(change.scheme, |
| 524 change.host, | 535 change.host, |
| 525 change.zoom_level); | 536 change.zoom_level); |
| 526 return; | 537 return; |
| 527 } | 538 } |
| 528 } | 539 } |
| 529 | 540 |
| 530 PrefProxyConfigTracker* OffTheRecordProfileImpl::CreateProxyConfigTracker() { | 541 PrefProxyConfigTracker* OffTheRecordProfileImpl::CreateProxyConfigTracker() { |
| 531 #if defined(OS_CHROMEOS) | 542 #if defined(OS_CHROMEOS) |
| 532 if (chromeos::ProfileHelper::IsSigninProfile(this)) { | 543 if (chromeos::ProfileHelper::IsSigninProfile(this)) { |
| 533 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( | 544 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( |
| 534 g_browser_process->local_state()); | 545 g_browser_process->local_state()); |
| 535 } | 546 } |
| 536 #endif // defined(OS_CHROMEOS) | 547 #endif // defined(OS_CHROMEOS) |
| 537 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( | 548 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( |
| 538 GetPrefs(), g_browser_process->local_state()); | 549 GetPrefs(), g_browser_process->local_state()); |
| 539 } | 550 } |
| OLD | NEW |