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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
71 | 71 |
72 #if defined(ENABLE_EXTENSIONS) | 72 #if defined(ENABLE_EXTENSIONS) |
73 #include "chrome/browser/extensions/api/web_request/web_request_api.h" | 73 #include "chrome/browser/extensions/api/web_request/web_request_api.h" |
74 #include "extensions/browser/extension_system.h" | 74 #include "extensions/browser/extension_system.h" |
75 #include "extensions/browser/guest_view/guest_view_manager.h" | 75 #include "extensions/browser/guest_view/guest_view_manager.h" |
76 #include "extensions/common/extension.h" | 76 #include "extensions/common/extension.h" |
77 #endif | 77 #endif |
78 | 78 |
79 using content::BrowserThread; | 79 using content::BrowserThread; |
80 using content::DownloadManagerDelegate; | 80 using content::DownloadManagerDelegate; |
81 using content::HostZoomMap; | |
82 | 81 |
83 #if defined(ENABLE_EXTENSIONS) | 82 #if defined(ENABLE_EXTENSIONS) |
84 namespace { | 83 namespace { |
85 | 84 |
86 void NotifyOTRProfileCreatedOnIOThread(void* original_profile, | 85 void NotifyOTRProfileCreatedOnIOThread(void* original_profile, |
87 void* otr_profile) { | 86 void* otr_profile) { |
88 ExtensionWebRequestEventRouter::GetInstance()->OnOTRProfileCreated( | 87 ExtensionWebRequestEventRouter::GetInstance()->OnOTRProfileCreated( |
89 original_profile, otr_profile); | 88 original_profile, otr_profile); |
90 } | 89 } |
91 | 90 |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 #endif // defined(OS_ANDROID) || defined(OS_IOS) | 133 #endif // defined(OS_ANDROID) || defined(OS_IOS) |
135 | 134 |
136 // TODO(oshima): Remove the need to eagerly initialize the request context | 135 // TODO(oshima): Remove the need to eagerly initialize the request context |
137 // getter. chromeos::OnlineAttempt is illegally trying to access this | 136 // getter. chromeos::OnlineAttempt is illegally trying to access this |
138 // Profile member from a thread other than the UI thread, so we need to | 137 // Profile member from a thread other than the UI thread, so we need to |
139 // prevent a race. | 138 // prevent a race. |
140 #if defined(OS_CHROMEOS) | 139 #if defined(OS_CHROMEOS) |
141 GetRequestContext(); | 140 GetRequestContext(); |
142 #endif // defined(OS_CHROMEOS) | 141 #endif // defined(OS_CHROMEOS) |
143 | 142 |
144 InitHostZoomMap(); | 143 TrackZoomLevelsFromParent(profile_); |
145 | 144 |
146 #if defined(ENABLE_PLUGINS) | 145 #if defined(ENABLE_PLUGINS) |
147 ChromePluginServiceFilter::GetInstance()->RegisterResourceContext( | 146 ChromePluginServiceFilter::GetInstance()->RegisterResourceContext( |
148 PluginPrefs::GetForProfile(this).get(), | 147 PluginPrefs::GetForProfile(this).get(), |
149 io_data_->GetResourceContextNoInit()); | 148 io_data_->GetResourceContextNoInit()); |
150 #endif | 149 #endif |
151 | 150 |
152 #if defined(ENABLE_EXTENSIONS) | 151 #if defined(ENABLE_EXTENSIONS) |
153 // Make the chrome//extension-icon/ resource available. | 152 // Make the chrome//extension-icon/ resource available. |
154 extensions::ExtensionIconSource* icon_source = | 153 extensions::ExtensionIconSource* icon_source = |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
186 | 185 |
187 // Clears any data the network stack contains that may be related to the | 186 // Clears any data the network stack contains that may be related to the |
188 // OTR session. | 187 // OTR session. |
189 g_browser_process->io_thread()->ChangedToOnTheRecord(); | 188 g_browser_process->io_thread()->ChangedToOnTheRecord(); |
190 } | 189 } |
191 | 190 |
192 void OffTheRecordProfileImpl::InitIoData() { | 191 void OffTheRecordProfileImpl::InitIoData() { |
193 io_data_.reset(new OffTheRecordProfileIOData::Handle(this)); | 192 io_data_.reset(new OffTheRecordProfileIOData::Handle(this)); |
194 } | 193 } |
195 | 194 |
196 void OffTheRecordProfileImpl::InitHostZoomMap() { | |
197 HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this); | |
198 HostZoomMap* parent_host_zoom_map = | |
199 HostZoomMap::GetForBrowserContext(profile_); | |
200 host_zoom_map->CopyFrom(parent_host_zoom_map); | |
201 // Observe parent's HZM change for propagating change of parent's | |
202 // change to this HZM. | |
203 zoom_subscription_ = parent_host_zoom_map->AddZoomLevelChangedCallback( | |
204 base::Bind(&OffTheRecordProfileImpl::OnZoomLevelChanged, | |
205 base::Unretained(this))); | |
206 } | |
207 | |
208 #if defined(OS_ANDROID) || defined(OS_IOS) | 195 #if defined(OS_ANDROID) || defined(OS_IOS) |
209 void OffTheRecordProfileImpl::UseSystemProxy() { | 196 void OffTheRecordProfileImpl::UseSystemProxy() { |
210 // Force the use of the system-assigned proxy when off the record. | 197 // Force the use of the system-assigned proxy when off the record. |
211 const char kProxyMode[] = "mode"; | 198 const char kProxyMode[] = "mode"; |
212 const char kProxyServer[] = "server"; | 199 const char kProxyServer[] = "server"; |
213 const char kProxyBypassList[] = "bypass_list"; | 200 const char kProxyBypassList[] = "bypass_list"; |
214 const char kProxyPacUrl[] = "pac_url"; | 201 const char kProxyPacUrl[] = "pac_url"; |
215 DictionaryPrefUpdate update(prefs_, prefs::kProxy); | 202 DictionaryPrefUpdate update(prefs_, prefs::kProxy); |
216 base::DictionaryValue* dict = update.Get(); | 203 base::DictionaryValue* dict = update.Get(); |
217 dict->SetString(kProxyMode, ProxyModeToString(ProxyPrefs::MODE_SYSTEM)); | 204 dict->SetString(kProxyMode, ProxyModeToString(ProxyPrefs::MODE_SYSTEM)); |
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
506 #if defined(OS_CHROMEOS) | 493 #if defined(OS_CHROMEOS) |
507 if (IsGuestSession()) | 494 if (IsGuestSession()) |
508 profile = new GuestSessionProfile(this); | 495 profile = new GuestSessionProfile(this); |
509 #endif | 496 #endif |
510 if (!profile) | 497 if (!profile) |
511 profile = new OffTheRecordProfileImpl(this); | 498 profile = new OffTheRecordProfileImpl(this); |
512 profile->Init(); | 499 profile->Init(); |
513 return profile; | 500 return profile; |
514 } | 501 } |
515 | 502 |
516 void OffTheRecordProfileImpl::OnZoomLevelChanged( | |
517 const HostZoomMap::ZoomLevelChange& change) { | |
518 HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this); | |
519 switch (change.mode) { | |
520 case HostZoomMap::ZOOM_CHANGED_TEMPORARY_ZOOM: | |
521 return; | |
522 case HostZoomMap::ZOOM_CHANGED_FOR_HOST: | |
523 host_zoom_map->SetZoomLevelForHost(change.host, change.zoom_level); | |
524 return; | |
525 case HostZoomMap::ZOOM_CHANGED_FOR_SCHEME_AND_HOST: | |
526 host_zoom_map->SetZoomLevelForHostAndScheme(change.scheme, | |
527 change.host, | |
528 change.zoom_level); | |
529 return; | |
530 } | |
531 } | |
532 | |
533 PrefProxyConfigTracker* OffTheRecordProfileImpl::CreateProxyConfigTracker() { | 503 PrefProxyConfigTracker* OffTheRecordProfileImpl::CreateProxyConfigTracker() { |
534 #if defined(OS_CHROMEOS) | 504 #if defined(OS_CHROMEOS) |
535 if (chromeos::ProfileHelper::IsSigninProfile(this)) { | 505 if (chromeos::ProfileHelper::IsSigninProfile(this)) { |
536 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( | 506 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( |
537 g_browser_process->local_state()); | 507 g_browser_process->local_state()); |
538 } | 508 } |
539 #endif // defined(OS_CHROMEOS) | 509 #endif // defined(OS_CHROMEOS) |
540 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( | 510 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( |
541 GetPrefs(), g_browser_process->local_state()); | 511 GetPrefs(), g_browser_process->local_state()); |
542 } | 512 } |
OLD | NEW |