Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(801)

Side by Side Diff: chrome/browser/profiles/off_the_record_profile_impl.cc

Issue 9416070: Move creation and ownership of HostZoomMap to content instead of having every embedder do this. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 8 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 original_profile, otr_profile); 76 original_profile, otr_profile);
77 } 77 }
78 78
79 } // namespace 79 } // namespace
80 80
81 OffTheRecordProfileImpl::OffTheRecordProfileImpl(Profile* real_profile) 81 OffTheRecordProfileImpl::OffTheRecordProfileImpl(Profile* real_profile)
82 : profile_(real_profile), 82 : profile_(real_profile),
83 prefs_(real_profile->GetOffTheRecordPrefs()), 83 prefs_(real_profile->GetOffTheRecordPrefs()),
84 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)), 84 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)),
85 start_time_(Time::Now()) { 85 start_time_(Time::Now()) {
86 // Create new host zoom map and copy zoom levels from parent.
87 HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this);
88 HostZoomMap* parent_host_zoom_map =
89 HostZoomMap::GetForBrowserContext(profile_);
90 host_zoom_map->CopyFrom(parent_host_zoom_map);
91 // Observe parent's HZM change for propagating change of parent's
92 // change to this HZM.
93 registrar_.Add(this, content::NOTIFICATION_ZOOM_LEVEL_CHANGED,
94 content::Source<HostZoomMap>(parent_host_zoom_map));
86 } 95 }
87 96
88 void OffTheRecordProfileImpl::Init() { 97 void OffTheRecordProfileImpl::Init() {
89 extension_process_manager_.reset(ExtensionProcessManager::Create(this)); 98 extension_process_manager_.reset(ExtensionProcessManager::Create(this));
90 99
91 BrowserList::AddObserver(this); 100 BrowserList::AddObserver(this);
92 101
93 ProfileDependencyManager::GetInstance()->CreateProfileServices(this, false); 102 ProfileDependencyManager::GetInstance()->CreateProfileServices(this, false);
94 103
95 DCHECK_NE(IncognitoModePrefs::DISABLED, 104 DCHECK_NE(IncognitoModePrefs::DISABLED,
(...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 // Retrieve the host content settings map of the parent profile in order to 347 // Retrieve the host content settings map of the parent profile in order to
339 // ensure the preferences have been migrated. 348 // ensure the preferences have been migrated.
340 profile_->GetHostContentSettingsMap(); 349 profile_->GetHostContentSettingsMap();
341 if (!host_content_settings_map_.get()) { 350 if (!host_content_settings_map_.get()) {
342 host_content_settings_map_ = new HostContentSettingsMap( 351 host_content_settings_map_ = new HostContentSettingsMap(
343 GetPrefs(), GetExtensionService(), true); 352 GetPrefs(), GetExtensionService(), true);
344 } 353 }
345 return host_content_settings_map_.get(); 354 return host_content_settings_map_.get();
346 } 355 }
347 356
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* 357 content::GeolocationPermissionContext*
362 OffTheRecordProfileImpl::GetGeolocationPermissionContext() { 358 OffTheRecordProfileImpl::GetGeolocationPermissionContext() {
363 return profile_->GetGeolocationPermissionContext(); 359 return profile_->GetGeolocationPermissionContext();
364 } 360 }
365 361
366 content::SpeechInputPreferences* 362 content::SpeechInputPreferences*
367 OffTheRecordProfileImpl::GetSpeechInputPreferences() { 363 OffTheRecordProfileImpl::GetSpeechInputPreferences() {
368 return profile_->GetSpeechInputPreferences(); 364 return profile_->GetSpeechInputPreferences();
369 } 365 }
370 366
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
495 void OffTheRecordProfileImpl::ClearNetworkingHistorySince(base::Time time) { 491 void OffTheRecordProfileImpl::ClearNetworkingHistorySince(base::Time time) {
496 // No need to do anything here, our transport security state is read-only. 492 // No need to do anything here, our transport security state is read-only.
497 } 493 }
498 494
499 GURL OffTheRecordProfileImpl::GetHomePage() { 495 GURL OffTheRecordProfileImpl::GetHomePage() {
500 return profile_->GetHomePage(); 496 return profile_->GetHomePage();
501 } 497 }
502 498
503 void OffTheRecordProfileImpl::Observe(int type, 499 void OffTheRecordProfileImpl::Observe(int type,
504 const content::NotificationSource& source, 500 const content::NotificationSource& source,
505 const content::NotificationDetails& details) { 501 const content::NotificationDetails& details) {
Avi (use Gerrit) 2012/02/21 20:40:16 fix indent here
jam 2012/02/21 20:41:20 Done.
506 if (type == content::NOTIFICATION_ZOOM_LEVEL_CHANGED) { 502 if (type == content::NOTIFICATION_ZOOM_LEVEL_CHANGED) {
507 const std::string& host = 503 const std::string& host =
508 *(content::Details<const std::string>(details).ptr()); 504 *(content::Details<const std::string>(details).ptr());
509 if (!host.empty()) { 505 if (!host.empty()) {
510 double level = profile_->GetHostZoomMap()->GetZoomLevel(host); 506 HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this);
511 GetHostZoomMap()->SetZoomLevel(host, level); 507 HostZoomMap* parent_host_zoom_map =
508 HostZoomMap::GetForBrowserContext(profile_);
509 double level = parent_host_zoom_map->GetZoomLevel(host);
510 host_zoom_map->SetZoomLevel(host, level);
512 } 511 }
513 } 512 }
514 } 513 }
515 514
516 #if defined(OS_CHROMEOS) 515 #if defined(OS_CHROMEOS)
517 // Special case of the OffTheRecordProfileImpl which is used while Guest 516 // Special case of the OffTheRecordProfileImpl which is used while Guest
518 // session in CrOS. 517 // session in CrOS.
519 class GuestSessionProfile : public OffTheRecordProfileImpl { 518 class GuestSessionProfile : public OffTheRecordProfileImpl {
520 public: 519 public:
521 explicit GuestSessionProfile(Profile* real_profile) 520 explicit GuestSessionProfile(Profile* real_profile)
(...skipping 15 matching lines...) Expand all
537 OffTheRecordProfileImpl* profile = NULL; 536 OffTheRecordProfileImpl* profile = NULL;
538 #if defined(OS_CHROMEOS) 537 #if defined(OS_CHROMEOS)
539 if (Profile::IsGuestSession()) 538 if (Profile::IsGuestSession())
540 profile = new GuestSessionProfile(this); 539 profile = new GuestSessionProfile(this);
541 #endif 540 #endif
542 if (!profile) 541 if (!profile)
543 profile = new OffTheRecordProfileImpl(this); 542 profile = new OffTheRecordProfileImpl(this);
544 profile->Init(); 543 profile->Init();
545 return profile; 544 return profile;
546 } 545 }
OLDNEW
« no previous file with comments | « chrome/browser/profiles/off_the_record_profile_impl.h ('k') | chrome/browser/profiles/off_the_record_profile_impl_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698