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

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

Issue 12039058: content: convert zoom notifications to observer usage (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 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 26 matching lines...) Expand all
37 #include "chrome/browser/themes/theme_service.h" 37 #include "chrome/browser/themes/theme_service.h"
38 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" 38 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
39 #include "chrome/common/chrome_constants.h" 39 #include "chrome/common/chrome_constants.h"
40 #include "chrome/common/chrome_paths.h" 40 #include "chrome/common/chrome_paths.h"
41 #include "chrome/common/chrome_switches.h" 41 #include "chrome/common/chrome_switches.h"
42 #include "chrome/common/extensions/extension.h" 42 #include "chrome/common/extensions/extension.h"
43 #include "chrome/common/pref_names.h" 43 #include "chrome/common/pref_names.h"
44 #include "chrome/common/render_messages.h" 44 #include "chrome/common/render_messages.h"
45 #include "content/public/browser/browser_thread.h" 45 #include "content/public/browser/browser_thread.h"
46 #include "content/public/browser/host_zoom_map.h" 46 #include "content/public/browser/host_zoom_map.h"
47 #include "content/public/browser/notification_service.h"
48 #include "content/public/browser/notification_types.h"
49 #include "content/public/browser/render_process_host.h" 47 #include "content/public/browser/render_process_host.h"
50 #include "content/public/browser/storage_partition.h" 48 #include "content/public/browser/storage_partition.h"
51 #include "content/public/browser/url_data_source.h" 49 #include "content/public/browser/url_data_source.h"
52 #include "content/public/browser/web_contents.h" 50 #include "content/public/browser/web_contents.h"
53 #include "net/base/transport_security_state.h" 51 #include "net/base/transport_security_state.h"
54 #include "net/http/http_server_properties.h" 52 #include "net/http/http_server_properties.h"
55 #include "webkit/database/database_tracker.h" 53 #include "webkit/database/database_tracker.h"
56 54
57 #if defined(OS_ANDROID) 55 #if defined(OS_ANDROID)
58 #include "chrome/browser/prefs/scoped_user_pref_update.h" 56 #include "chrome/browser/prefs/scoped_user_pref_update.h"
(...skipping 21 matching lines...) Expand all
80 ExtensionWebRequestEventRouter::GetInstance()->OnOTRProfileDestroyed( 78 ExtensionWebRequestEventRouter::GetInstance()->OnOTRProfileDestroyed(
81 original_profile, otr_profile); 79 original_profile, otr_profile);
82 } 80 }
83 81
84 } // namespace 82 } // namespace
85 83
86 OffTheRecordProfileImpl::OffTheRecordProfileImpl(Profile* real_profile) 84 OffTheRecordProfileImpl::OffTheRecordProfileImpl(Profile* real_profile)
87 : profile_(real_profile), 85 : profile_(real_profile),
88 prefs_(real_profile->GetOffTheRecordPrefs()), 86 prefs_(real_profile->GetOffTheRecordPrefs()),
89 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)), 87 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)),
90 start_time_(Time::Now()) { 88 start_time_(Time::Now()),
89 zoom_callback_(base::Bind(&OffTheRecordProfileImpl::OnZoomLevelChanged,
90 base::Unretained(this))) {
91 } 91 }
92 92
93 void OffTheRecordProfileImpl::Init() { 93 void OffTheRecordProfileImpl::Init() {
94 ProfileDependencyManager::GetInstance()->CreateProfileServices(this, false); 94 ProfileDependencyManager::GetInstance()->CreateProfileServices(this, false);
95 95
96 extensions::ExtensionSystem::Get(this)->InitForOTRProfile(); 96 extensions::ExtensionSystem::Get(this)->InitForOTRProfile();
97 97
98 DCHECK_NE(IncognitoModePrefs::DISABLED, 98 DCHECK_NE(IncognitoModePrefs::DISABLED,
99 IncognitoModePrefs::GetAvailability(profile_->GetPrefs())); 99 IncognitoModePrefs::GetAvailability(profile_->GetPrefs()));
100 100
(...skipping 21 matching lines...) Expand all
122 #endif 122 #endif
123 123
124 BrowserThread::PostTask( 124 BrowserThread::PostTask(
125 BrowserThread::IO, FROM_HERE, 125 BrowserThread::IO, FROM_HERE,
126 base::Bind(&NotifyOTRProfileCreatedOnIOThread, profile_, this)); 126 base::Bind(&NotifyOTRProfileCreatedOnIOThread, profile_, this));
127 } 127 }
128 128
129 OffTheRecordProfileImpl::~OffTheRecordProfileImpl() { 129 OffTheRecordProfileImpl::~OffTheRecordProfileImpl() {
130 MaybeSendDestroyedNotification(); 130 MaybeSendDestroyedNotification();
131 131
132 HostZoomMap::GetForBrowserContext(profile_)->RemoveZoomLevelChangedCallback(
133 zoom_callback_);
134
132 #if defined(ENABLE_PLUGINS) 135 #if defined(ENABLE_PLUGINS)
133 ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext( 136 ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext(
134 io_data_.GetResourceContextNoInit()); 137 io_data_.GetResourceContextNoInit());
135 #endif 138 #endif
136 139
137 ExtensionService* extension_service = 140 ExtensionService* extension_service =
138 extensions::ExtensionSystem::Get(this)->extension_service(); 141 extensions::ExtensionSystem::Get(this)->extension_service();
139 if (extension_service && extension_service->extensions_enabled()) { 142 if (extension_service && extension_service->extensions_enabled()) {
140 extension_service->extension_prefs()-> 143 extension_service->extension_prefs()->
141 ClearIncognitoSessionOnlyContentSettings(); 144 ClearIncognitoSessionOnlyContentSettings();
(...skipping 16 matching lines...) Expand all
158 g_browser_process->io_thread()->ChangedToOnTheRecord(); 161 g_browser_process->io_thread()->ChangedToOnTheRecord();
159 } 162 }
160 163
161 void OffTheRecordProfileImpl::InitHostZoomMap() { 164 void OffTheRecordProfileImpl::InitHostZoomMap() {
162 HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this); 165 HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this);
163 HostZoomMap* parent_host_zoom_map = 166 HostZoomMap* parent_host_zoom_map =
164 HostZoomMap::GetForBrowserContext(profile_); 167 HostZoomMap::GetForBrowserContext(profile_);
165 host_zoom_map->CopyFrom(parent_host_zoom_map); 168 host_zoom_map->CopyFrom(parent_host_zoom_map);
166 // Observe parent's HZM change for propagating change of parent's 169 // Observe parent's HZM change for propagating change of parent's
167 // change to this HZM. 170 // change to this HZM.
168 registrar_.Add(this, content::NOTIFICATION_ZOOM_LEVEL_CHANGED, 171 parent_host_zoom_map->AddZoomLevelChangedCallback(zoom_callback_);
169 content::Source<HostZoomMap>(parent_host_zoom_map));
170 } 172 }
171 173
172 #if defined(OS_ANDROID) 174 #if defined(OS_ANDROID)
173 void OffTheRecordProfileImpl::UseSystemProxy() { 175 void OffTheRecordProfileImpl::UseSystemProxy() {
174 // Force the use of the system-assigned proxy when off the record. 176 // Force the use of the system-assigned proxy when off the record.
175 const char kProxyMode[] = "mode"; 177 const char kProxyMode[] = "mode";
176 const char kProxyServer[] = "server"; 178 const char kProxyServer[] = "server";
177 const char kProxyBypassList[] = "bypass_list"; 179 const char kProxyBypassList[] = "bypass_list";
178 const char kProxyPacUrl[] = "pac_url"; 180 const char kProxyPacUrl[] = "pac_url";
179 DictionaryPrefUpdate update(prefs_, prefs::kProxy); 181 DictionaryPrefUpdate update(prefs_, prefs::kProxy);
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
421 // closed. We must do this asynchronously in order to avoid reentrancy issues. 423 // closed. We must do this asynchronously in order to avoid reentrancy issues.
422 if (!completion.is_null()) { 424 if (!completion.is_null()) {
423 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, completion); 425 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, completion);
424 } 426 }
425 } 427 }
426 428
427 GURL OffTheRecordProfileImpl::GetHomePage() { 429 GURL OffTheRecordProfileImpl::GetHomePage() {
428 return profile_->GetHomePage(); 430 return profile_->GetHomePage();
429 } 431 }
430 432
431 void OffTheRecordProfileImpl::Observe(
432 int type,
433 const content::NotificationSource& source,
434 const content::NotificationDetails& details) {
435 if (type == content::NOTIFICATION_ZOOM_LEVEL_CHANGED) {
436 const std::string& host =
437 *(content::Details<const std::string>(details).ptr());
438 if (!host.empty()) {
439 HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this);
440 HostZoomMap* parent_host_zoom_map =
441 HostZoomMap::GetForBrowserContext(profile_);
442 double level = parent_host_zoom_map->GetZoomLevel(host);
443 host_zoom_map->SetZoomLevel(host, level);
444 }
445 }
446 }
447
448 #if defined(OS_CHROMEOS) 433 #if defined(OS_CHROMEOS)
449 // Special case of the OffTheRecordProfileImpl which is used while Guest 434 // Special case of the OffTheRecordProfileImpl which is used while Guest
450 // session in CrOS. 435 // session in CrOS.
451 class GuestSessionProfile : public OffTheRecordProfileImpl { 436 class GuestSessionProfile : public OffTheRecordProfileImpl {
452 public: 437 public:
453 explicit GuestSessionProfile(Profile* real_profile) 438 explicit GuestSessionProfile(Profile* real_profile)
454 : OffTheRecordProfileImpl(real_profile) { 439 : OffTheRecordProfileImpl(real_profile) {
455 } 440 }
456 441
457 virtual void InitChromeOSPreferences() OVERRIDE { 442 virtual void InitChromeOSPreferences() OVERRIDE {
(...skipping 11 matching lines...) Expand all
469 OffTheRecordProfileImpl* profile = NULL; 454 OffTheRecordProfileImpl* profile = NULL;
470 #if defined(OS_CHROMEOS) 455 #if defined(OS_CHROMEOS)
471 if (IsGuestSession()) 456 if (IsGuestSession())
472 profile = new GuestSessionProfile(this); 457 profile = new GuestSessionProfile(this);
473 #endif 458 #endif
474 if (!profile) 459 if (!profile)
475 profile = new OffTheRecordProfileImpl(this); 460 profile = new OffTheRecordProfileImpl(this);
476 profile->Init(); 461 profile->Init();
477 return profile; 462 return profile;
478 } 463 }
464
465 void OffTheRecordProfileImpl::OnZoomLevelChanged(const std::string& host) {
466 if (host.empty())
467 return;
468
469 HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this);
470 HostZoomMap* parent_host_zoom_map =
471 HostZoomMap::GetForBrowserContext(profile_);
472 double level = parent_host_zoom_map->GetZoomLevel(host);
473 host_zoom_map->SetZoomLevel(host, level);
474 }
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