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

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: callbacks 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 27 matching lines...) Expand all
38 #include "chrome/browser/ui/webui/chrome_url_data_manager_factory.h" 38 #include "chrome/browser/ui/webui/chrome_url_data_manager_factory.h"
39 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" 39 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h"
40 #include "chrome/common/chrome_constants.h" 40 #include "chrome/common/chrome_constants.h"
41 #include "chrome/common/chrome_paths.h" 41 #include "chrome/common/chrome_paths.h"
42 #include "chrome/common/chrome_switches.h" 42 #include "chrome/common/chrome_switches.h"
43 #include "chrome/common/extensions/extension.h" 43 #include "chrome/common/extensions/extension.h"
44 #include "chrome/common/pref_names.h" 44 #include "chrome/common/pref_names.h"
45 #include "chrome/common/render_messages.h" 45 #include "chrome/common/render_messages.h"
46 #include "content/public/browser/browser_thread.h" 46 #include "content/public/browser/browser_thread.h"
47 #include "content/public/browser/host_zoom_map.h" 47 #include "content/public/browser/host_zoom_map.h"
48 #include "content/public/browser/notification_service.h"
49 #include "content/public/browser/notification_types.h"
50 #include "content/public/browser/render_process_host.h" 48 #include "content/public/browser/render_process_host.h"
51 #include "content/public/browser/storage_partition.h" 49 #include "content/public/browser/storage_partition.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"
59 #endif 57 #endif
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
122 #endif 120 #endif
123 121
124 BrowserThread::PostTask( 122 BrowserThread::PostTask(
125 BrowserThread::IO, FROM_HERE, 123 BrowserThread::IO, FROM_HERE,
126 base::Bind(&NotifyOTRProfileCreatedOnIOThread, profile_, this)); 124 base::Bind(&NotifyOTRProfileCreatedOnIOThread, profile_, this));
127 } 125 }
128 126
129 OffTheRecordProfileImpl::~OffTheRecordProfileImpl() { 127 OffTheRecordProfileImpl::~OffTheRecordProfileImpl() {
130 MaybeSendDestroyedNotification(); 128 MaybeSendDestroyedNotification();
131 129
130 HostZoomMap::GetForBrowserContext(profile_)->RemoveZoomLevelChangedCallback(
131 base::Bind(&OffTheRecordProfileImpl::OnZoomLevelChanged,
132 base::Unretained(this)));
133
132 #if defined(ENABLE_PLUGINS) 134 #if defined(ENABLE_PLUGINS)
133 ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext( 135 ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext(
134 io_data_.GetResourceContextNoInit()); 136 io_data_.GetResourceContextNoInit());
135 #endif 137 #endif
136 138
137 ExtensionService* extension_service = 139 ExtensionService* extension_service =
138 extensions::ExtensionSystem::Get(this)->extension_service(); 140 extensions::ExtensionSystem::Get(this)->extension_service();
139 if (extension_service && extension_service->extensions_enabled()) { 141 if (extension_service && extension_service->extensions_enabled()) {
140 extension_service->extension_prefs()-> 142 extension_service->extension_prefs()->
141 ClearIncognitoSessionOnlyContentSettings(); 143 ClearIncognitoSessionOnlyContentSettings();
(...skipping 16 matching lines...) Expand all
158 g_browser_process->io_thread()->ChangedToOnTheRecord(); 160 g_browser_process->io_thread()->ChangedToOnTheRecord();
159 } 161 }
160 162
161 void OffTheRecordProfileImpl::InitHostZoomMap() { 163 void OffTheRecordProfileImpl::InitHostZoomMap() {
162 HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this); 164 HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this);
163 HostZoomMap* parent_host_zoom_map = 165 HostZoomMap* parent_host_zoom_map =
164 HostZoomMap::GetForBrowserContext(profile_); 166 HostZoomMap::GetForBrowserContext(profile_);
165 host_zoom_map->CopyFrom(parent_host_zoom_map); 167 host_zoom_map->CopyFrom(parent_host_zoom_map);
166 // Observe parent's HZM change for propagating change of parent's 168 // Observe parent's HZM change for propagating change of parent's
167 // change to this HZM. 169 // change to this HZM.
168 registrar_.Add(this, content::NOTIFICATION_ZOOM_LEVEL_CHANGED, 170 parent_host_zoom_map->AddZoomLevelChangedCallback(
169 content::Source<HostZoomMap>(parent_host_zoom_map)); 171 base::Bind(&OffTheRecordProfileImpl::OnZoomLevelChanged,
172 base::Unretained(this)));
170 } 173 }
171 174
172 #if defined(OS_ANDROID) 175 #if defined(OS_ANDROID)
173 void OffTheRecordProfileImpl::UseSystemProxy() { 176 void OffTheRecordProfileImpl::UseSystemProxy() {
174 // Force the use of the system-assigned proxy when off the record. 177 // Force the use of the system-assigned proxy when off the record.
175 const char kProxyMode[] = "mode"; 178 const char kProxyMode[] = "mode";
176 const char kProxyServer[] = "server"; 179 const char kProxyServer[] = "server";
177 const char kProxyBypassList[] = "bypass_list"; 180 const char kProxyBypassList[] = "bypass_list";
178 const char kProxyPacUrl[] = "pac_url"; 181 const char kProxyPacUrl[] = "pac_url";
179 DictionaryPrefUpdate update(prefs_, prefs::kProxy); 182 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. 424 // closed. We must do this asynchronously in order to avoid reentrancy issues.
422 if (!completion.is_null()) { 425 if (!completion.is_null()) {
423 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, completion); 426 BrowserThread::PostTask(BrowserThread::UI, FROM_HERE, completion);
424 } 427 }
425 } 428 }
426 429
427 GURL OffTheRecordProfileImpl::GetHomePage() { 430 GURL OffTheRecordProfileImpl::GetHomePage() {
428 return profile_->GetHomePage(); 431 return profile_->GetHomePage();
429 } 432 }
430 433
431 void OffTheRecordProfileImpl::Observe( 434 void OffTheRecordProfileImpl::OnZoomLevelChanged(const std::string& host) {
432 int type, 435 if (host.empty())
433 const content::NotificationSource& source, 436 return;
434 const content::NotificationDetails& details) { 437
435 if (type == content::NOTIFICATION_ZOOM_LEVEL_CHANGED) { 438 HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this);
436 const std::string& host = 439 HostZoomMap* parent_host_zoom_map =
437 *(content::Details<const std::string>(details).ptr()); 440 HostZoomMap::GetForBrowserContext(profile_);
438 if (!host.empty()) { 441 double level = parent_host_zoom_map->GetZoomLevel(host);
439 HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this); 442 host_zoom_map->SetZoomLevel(host, level);
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 } 443 }
447 444
448 #if defined(OS_CHROMEOS) 445 #if defined(OS_CHROMEOS)
449 // Special case of the OffTheRecordProfileImpl which is used while Guest 446 // Special case of the OffTheRecordProfileImpl which is used while Guest
450 // session in CrOS. 447 // session in CrOS.
451 class GuestSessionProfile : public OffTheRecordProfileImpl { 448 class GuestSessionProfile : public OffTheRecordProfileImpl {
452 public: 449 public:
453 explicit GuestSessionProfile(Profile* real_profile) 450 explicit GuestSessionProfile(Profile* real_profile)
454 : OffTheRecordProfileImpl(real_profile) { 451 : OffTheRecordProfileImpl(real_profile) {
455 } 452 }
(...skipping 18 matching lines...) Expand all
474 if (!profile) 471 if (!profile)
475 profile = new OffTheRecordProfileImpl(this); 472 profile = new OffTheRecordProfileImpl(this);
476 profile->Init(); 473 profile->Init();
477 return profile; 474 return profile;
478 } 475 }
479 476
480 base::Callback<ChromeURLDataManagerBackend*(void)> 477 base::Callback<ChromeURLDataManagerBackend*(void)>
481 OffTheRecordProfileImpl::GetChromeURLDataManagerBackendGetter() const { 478 OffTheRecordProfileImpl::GetChromeURLDataManagerBackendGetter() const {
482 return io_data_.GetChromeURLDataManagerBackendGetter(); 479 return io_data_.GetChromeURLDataManagerBackendGetter();
483 } 480 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698