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 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
96 IncognitoModePrefs::GetAvailability(profile_->GetPrefs())); | 96 IncognitoModePrefs::GetAvailability(profile_->GetPrefs())); |
97 | 97 |
98 // TODO(oshima): Remove the need to eagerly initialize the request context | 98 // TODO(oshima): Remove the need to eagerly initialize the request context |
99 // getter. chromeos::OnlineAttempt is illegally trying to access this | 99 // getter. chromeos::OnlineAttempt is illegally trying to access this |
100 // Profile member from a thread other than the UI thread, so we need to | 100 // Profile member from a thread other than the UI thread, so we need to |
101 // prevent a race. | 101 // prevent a race. |
102 #if defined(OS_CHROMEOS) | 102 #if defined(OS_CHROMEOS) |
103 GetRequestContext(); | 103 GetRequestContext(); |
104 #endif // defined(OS_CHROMEOS) | 104 #endif // defined(OS_CHROMEOS) |
105 | 105 |
| 106 InitHostZoomMap(); |
| 107 |
106 // Make the chrome//extension-icon/ resource available. | 108 // Make the chrome//extension-icon/ resource available. |
107 ExtensionIconSource* icon_source = new ExtensionIconSource(profile_); | 109 ExtensionIconSource* icon_source = new ExtensionIconSource(profile_); |
108 GetChromeURLDataManager()->AddDataSource(icon_source); | 110 GetChromeURLDataManager()->AddDataSource(icon_source); |
109 | 111 |
110 ChromePluginServiceFilter::GetInstance()->RegisterResourceContext( | 112 ChromePluginServiceFilter::GetInstance()->RegisterResourceContext( |
111 PluginPrefs::GetForProfile(this), io_data_.GetResourceContextNoInit()); | 113 PluginPrefs::GetForProfile(this), io_data_.GetResourceContextNoInit()); |
112 | 114 |
113 BrowserThread::PostTask( | 115 BrowserThread::PostTask( |
114 BrowserThread::IO, FROM_HERE, | 116 BrowserThread::IO, FROM_HERE, |
115 base::Bind(&NotifyOTRProfileCreatedOnIOThread, profile_, this)); | 117 base::Bind(&NotifyOTRProfileCreatedOnIOThread, profile_, this)); |
(...skipping 25 matching lines...) Expand all Loading... |
141 if (extension_service) { | 143 if (extension_service) { |
142 ExtensionPrefs* extension_prefs = extension_service->extension_prefs(); | 144 ExtensionPrefs* extension_prefs = extension_service->extension_prefs(); |
143 extension_prefs->ClearIncognitoSessionOnlyContentSettings(); | 145 extension_prefs->ClearIncognitoSessionOnlyContentSettings(); |
144 } | 146 } |
145 | 147 |
146 // Clears any data the network stack contains that may be related to the | 148 // Clears any data the network stack contains that may be related to the |
147 // OTR session. | 149 // OTR session. |
148 g_browser_process->io_thread()->ChangedToOnTheRecord(); | 150 g_browser_process->io_thread()->ChangedToOnTheRecord(); |
149 } | 151 } |
150 | 152 |
| 153 void OffTheRecordProfileImpl::InitHostZoomMap() { |
| 154 HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this); |
| 155 HostZoomMap* parent_host_zoom_map = |
| 156 HostZoomMap::GetForBrowserContext(profile_); |
| 157 host_zoom_map->CopyFrom(parent_host_zoom_map); |
| 158 // Observe parent's HZM change for propagating change of parent's |
| 159 // change to this HZM. |
| 160 registrar_.Add(this, content::NOTIFICATION_ZOOM_LEVEL_CHANGED, |
| 161 content::Source<HostZoomMap>(parent_host_zoom_map)); |
| 162 } |
| 163 |
151 std::string OffTheRecordProfileImpl::GetProfileName() { | 164 std::string OffTheRecordProfileImpl::GetProfileName() { |
152 // Incognito profile should not return the profile name. | 165 // Incognito profile should not return the profile name. |
153 return std::string(); | 166 return std::string(); |
154 } | 167 } |
155 | 168 |
156 FilePath OffTheRecordProfileImpl::GetPath() { | 169 FilePath OffTheRecordProfileImpl::GetPath() { |
157 return profile_->GetPath(); | 170 return profile_->GetPath(); |
158 } | 171 } |
159 | 172 |
160 bool OffTheRecordProfileImpl::IsOffTheRecord() { | 173 bool OffTheRecordProfileImpl::IsOffTheRecord() { |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
338 // Retrieve the host content settings map of the parent profile in order to | 351 // Retrieve the host content settings map of the parent profile in order to |
339 // ensure the preferences have been migrated. | 352 // ensure the preferences have been migrated. |
340 profile_->GetHostContentSettingsMap(); | 353 profile_->GetHostContentSettingsMap(); |
341 if (!host_content_settings_map_.get()) { | 354 if (!host_content_settings_map_.get()) { |
342 host_content_settings_map_ = new HostContentSettingsMap( | 355 host_content_settings_map_ = new HostContentSettingsMap( |
343 GetPrefs(), GetExtensionService(), true); | 356 GetPrefs(), GetExtensionService(), true); |
344 } | 357 } |
345 return host_content_settings_map_.get(); | 358 return host_content_settings_map_.get(); |
346 } | 359 } |
347 | 360 |
348 HostZoomMap* OffTheRecordProfileImpl::GetHostZoomMap() { | |
349 // Create new host zoom map and copy zoom levels from parent. | |
350 if (!host_zoom_map_) { | |
351 host_zoom_map_ = HostZoomMap::Create(); | |
352 host_zoom_map_->CopyFrom(profile_->GetHostZoomMap()); | |
353 // Observe parent's HZM change for propagating change of parent's | |
354 // change to this HZM. | |
355 registrar_.Add(this, content::NOTIFICATION_ZOOM_LEVEL_CHANGED, | |
356 content::Source<HostZoomMap>(profile_->GetHostZoomMap())); | |
357 } | |
358 return host_zoom_map_.get(); | |
359 } | |
360 | |
361 content::GeolocationPermissionContext* | 361 content::GeolocationPermissionContext* |
362 OffTheRecordProfileImpl::GetGeolocationPermissionContext() { | 362 OffTheRecordProfileImpl::GetGeolocationPermissionContext() { |
363 return profile_->GetGeolocationPermissionContext(); | 363 return profile_->GetGeolocationPermissionContext(); |
364 } | 364 } |
365 | 365 |
366 content::SpeechInputPreferences* | 366 content::SpeechInputPreferences* |
367 OffTheRecordProfileImpl::GetSpeechInputPreferences() { | 367 OffTheRecordProfileImpl::GetSpeechInputPreferences() { |
368 return profile_->GetSpeechInputPreferences(); | 368 return profile_->GetSpeechInputPreferences(); |
369 } | 369 } |
370 | 370 |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
493 } | 493 } |
494 | 494 |
495 void OffTheRecordProfileImpl::ClearNetworkingHistorySince(base::Time time) { | 495 void OffTheRecordProfileImpl::ClearNetworkingHistorySince(base::Time time) { |
496 // No need to do anything here, our transport security state is read-only. | 496 // No need to do anything here, our transport security state is read-only. |
497 } | 497 } |
498 | 498 |
499 GURL OffTheRecordProfileImpl::GetHomePage() { | 499 GURL OffTheRecordProfileImpl::GetHomePage() { |
500 return profile_->GetHomePage(); | 500 return profile_->GetHomePage(); |
501 } | 501 } |
502 | 502 |
503 void OffTheRecordProfileImpl::Observe(int type, | 503 void OffTheRecordProfileImpl::Observe( |
504 const content::NotificationSource& source, | 504 int type, |
505 const content::NotificationDetails& details) { | 505 const content::NotificationSource& source, |
| 506 const content::NotificationDetails& details) { |
506 if (type == content::NOTIFICATION_ZOOM_LEVEL_CHANGED) { | 507 if (type == content::NOTIFICATION_ZOOM_LEVEL_CHANGED) { |
507 const std::string& host = | 508 const std::string& host = |
508 *(content::Details<const std::string>(details).ptr()); | 509 *(content::Details<const std::string>(details).ptr()); |
509 if (!host.empty()) { | 510 if (!host.empty()) { |
510 double level = profile_->GetHostZoomMap()->GetZoomLevel(host); | 511 HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this); |
511 GetHostZoomMap()->SetZoomLevel(host, level); | 512 HostZoomMap* parent_host_zoom_map = |
| 513 HostZoomMap::GetForBrowserContext(profile_); |
| 514 double level = parent_host_zoom_map->GetZoomLevel(host); |
| 515 host_zoom_map->SetZoomLevel(host, level); |
512 } | 516 } |
513 } | 517 } |
514 } | 518 } |
515 | 519 |
516 #if defined(OS_CHROMEOS) | 520 #if defined(OS_CHROMEOS) |
517 // Special case of the OffTheRecordProfileImpl which is used while Guest | 521 // Special case of the OffTheRecordProfileImpl which is used while Guest |
518 // session in CrOS. | 522 // session in CrOS. |
519 class GuestSessionProfile : public OffTheRecordProfileImpl { | 523 class GuestSessionProfile : public OffTheRecordProfileImpl { |
520 public: | 524 public: |
521 explicit GuestSessionProfile(Profile* real_profile) | 525 explicit GuestSessionProfile(Profile* real_profile) |
(...skipping 15 matching lines...) Expand all Loading... |
537 OffTheRecordProfileImpl* profile = NULL; | 541 OffTheRecordProfileImpl* profile = NULL; |
538 #if defined(OS_CHROMEOS) | 542 #if defined(OS_CHROMEOS) |
539 if (Profile::IsGuestSession()) | 543 if (Profile::IsGuestSession()) |
540 profile = new GuestSessionProfile(this); | 544 profile = new GuestSessionProfile(this); |
541 #endif | 545 #endif |
542 if (!profile) | 546 if (!profile) |
543 profile = new OffTheRecordProfileImpl(this); | 547 profile = new OffTheRecordProfileImpl(this); |
544 profile->Init(); | 548 profile->Init(); |
545 return profile; | 549 return profile; |
546 } | 550 } |
OLD | NEW |