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 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
83 ExtensionWebRequestEventRouter::GetInstance()->OnOTRProfileDestroyed( | 83 ExtensionWebRequestEventRouter::GetInstance()->OnOTRProfileDestroyed( |
84 original_profile, otr_profile); | 84 original_profile, otr_profile); |
85 } | 85 } |
86 | 86 |
87 } // namespace | 87 } // namespace |
88 | 88 |
89 OffTheRecordProfileImpl::OffTheRecordProfileImpl(Profile* real_profile) | 89 OffTheRecordProfileImpl::OffTheRecordProfileImpl(Profile* real_profile) |
90 : profile_(real_profile), | 90 : profile_(real_profile), |
91 prefs_(PrefServiceSyncable::IncognitoFromProfile(real_profile)), | 91 prefs_(PrefServiceSyncable::IncognitoFromProfile(real_profile)), |
92 io_data_(this), | 92 io_data_(this), |
93 start_time_(Time::Now()), | 93 start_time_(Time::Now()) { |
94 zoom_callback_(base::Bind(&OffTheRecordProfileImpl::OnZoomLevelChanged, | |
95 base::Unretained(this))) { | |
96 // Register on BrowserContext. | 94 // Register on BrowserContext. |
97 user_prefs::UserPrefs::Set(this, prefs_); | 95 user_prefs::UserPrefs::Set(this, prefs_); |
98 } | 96 } |
99 | 97 |
100 void OffTheRecordProfileImpl::Init() { | 98 void OffTheRecordProfileImpl::Init() { |
101 BrowserContextDependencyManager::GetInstance()->CreateBrowserContextServices( | 99 BrowserContextDependencyManager::GetInstance()->CreateBrowserContextServices( |
102 this); | 100 this); |
103 | 101 |
104 DCHECK_NE(IncognitoModePrefs::DISABLED, | 102 DCHECK_NE(IncognitoModePrefs::DISABLED, |
105 IncognitoModePrefs::GetAvailability(profile_->GetPrefs())); | 103 IncognitoModePrefs::GetAvailability(profile_->GetPrefs())); |
(...skipping 24 matching lines...) Expand all Loading... |
130 #endif | 128 #endif |
131 | 129 |
132 BrowserThread::PostTask( | 130 BrowserThread::PostTask( |
133 BrowserThread::IO, FROM_HERE, | 131 BrowserThread::IO, FROM_HERE, |
134 base::Bind(&NotifyOTRProfileCreatedOnIOThread, profile_, this)); | 132 base::Bind(&NotifyOTRProfileCreatedOnIOThread, profile_, this)); |
135 } | 133 } |
136 | 134 |
137 OffTheRecordProfileImpl::~OffTheRecordProfileImpl() { | 135 OffTheRecordProfileImpl::~OffTheRecordProfileImpl() { |
138 MaybeSendDestroyedNotification(); | 136 MaybeSendDestroyedNotification(); |
139 | 137 |
140 HostZoomMap::GetForBrowserContext(profile_)->RemoveZoomLevelChangedCallback( | |
141 zoom_callback_); | |
142 | |
143 #if defined(ENABLE_PLUGINS) | 138 #if defined(ENABLE_PLUGINS) |
144 ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext( | 139 ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext( |
145 io_data_.GetResourceContextNoInit()); | 140 io_data_.GetResourceContextNoInit()); |
146 #endif | 141 #endif |
147 | 142 |
148 BrowserContextDependencyManager::GetInstance()->DestroyBrowserContextServices( | 143 BrowserContextDependencyManager::GetInstance()->DestroyBrowserContextServices( |
149 this); | 144 this); |
150 | 145 |
151 BrowserThread::PostTask( | 146 BrowserThread::PostTask( |
152 BrowserThread::IO, FROM_HERE, | 147 BrowserThread::IO, FROM_HERE, |
(...skipping 10 matching lines...) Expand all Loading... |
163 g_browser_process->io_thread()->ChangedToOnTheRecord(); | 158 g_browser_process->io_thread()->ChangedToOnTheRecord(); |
164 } | 159 } |
165 | 160 |
166 void OffTheRecordProfileImpl::InitHostZoomMap() { | 161 void OffTheRecordProfileImpl::InitHostZoomMap() { |
167 HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this); | 162 HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this); |
168 HostZoomMap* parent_host_zoom_map = | 163 HostZoomMap* parent_host_zoom_map = |
169 HostZoomMap::GetForBrowserContext(profile_); | 164 HostZoomMap::GetForBrowserContext(profile_); |
170 host_zoom_map->CopyFrom(parent_host_zoom_map); | 165 host_zoom_map->CopyFrom(parent_host_zoom_map); |
171 // Observe parent's HZM change for propagating change of parent's | 166 // Observe parent's HZM change for propagating change of parent's |
172 // change to this HZM. | 167 // change to this HZM. |
173 parent_host_zoom_map->AddZoomLevelChangedCallback(zoom_callback_); | 168 zoom_subscription_ = parent_host_zoom_map->AddZoomLevelChangedCallback( |
| 169 base::Bind(&OffTheRecordProfileImpl::OnZoomLevelChanged, |
| 170 base::Unretained(this))); |
174 } | 171 } |
175 | 172 |
176 #if defined(OS_ANDROID) || defined(OS_IOS) | 173 #if defined(OS_ANDROID) || defined(OS_IOS) |
177 void OffTheRecordProfileImpl::UseSystemProxy() { | 174 void OffTheRecordProfileImpl::UseSystemProxy() { |
178 // Force the use of the system-assigned proxy when off the record. | 175 // Force the use of the system-assigned proxy when off the record. |
179 const char kProxyMode[] = "mode"; | 176 const char kProxyMode[] = "mode"; |
180 const char kProxyServer[] = "server"; | 177 const char kProxyServer[] = "server"; |
181 const char kProxyBypassList[] = "bypass_list"; | 178 const char kProxyBypassList[] = "bypass_list"; |
182 const char kProxyPacUrl[] = "pac_url"; | 179 const char kProxyPacUrl[] = "pac_url"; |
183 DictionaryPrefUpdate update(prefs_, prefs::kProxy); | 180 DictionaryPrefUpdate update(prefs_, prefs::kProxy); |
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
485 PrefProxyConfigTracker* OffTheRecordProfileImpl::CreateProxyConfigTracker() { | 482 PrefProxyConfigTracker* OffTheRecordProfileImpl::CreateProxyConfigTracker() { |
486 #if defined(OS_CHROMEOS) | 483 #if defined(OS_CHROMEOS) |
487 if (chromeos::ProfileHelper::IsSigninProfile(this)) { | 484 if (chromeos::ProfileHelper::IsSigninProfile(this)) { |
488 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( | 485 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( |
489 g_browser_process->local_state()); | 486 g_browser_process->local_state()); |
490 } | 487 } |
491 #endif // defined(OS_CHROMEOS) | 488 #endif // defined(OS_CHROMEOS) |
492 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( | 489 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( |
493 GetPrefs(), g_browser_process->local_state()); | 490 GetPrefs(), g_browser_process->local_state()); |
494 } | 491 } |
OLD | NEW |