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

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

Issue 393133002: Migrate HostZoomMap to live in StoragePartition. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to r288093. Created 6 years, 4 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/files/file_path.h" 10 #include "base/files/file_path.h"
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 "chrome/browser/guest_view/guest_view_manager.h" 74 #include "chrome/browser/guest_view/guest_view_manager.h"
75 #include "extensions/browser/extension_system.h" 75 #include "extensions/browser/extension_system.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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
132 #endif // defined(OS_ANDROID) || defined(OS_IOS) 131 #endif // defined(OS_ANDROID) || defined(OS_IOS)
133 132
134 // TODO(oshima): Remove the need to eagerly initialize the request context 133 // TODO(oshima): Remove the need to eagerly initialize the request context
135 // getter. chromeos::OnlineAttempt is illegally trying to access this 134 // getter. chromeos::OnlineAttempt is illegally trying to access this
136 // Profile member from a thread other than the UI thread, so we need to 135 // Profile member from a thread other than the UI thread, so we need to
137 // prevent a race. 136 // prevent a race.
138 #if defined(OS_CHROMEOS) 137 #if defined(OS_CHROMEOS)
139 GetRequestContext(); 138 GetRequestContext();
140 #endif // defined(OS_CHROMEOS) 139 #endif // defined(OS_CHROMEOS)
141 140
142 InitHostZoomMap(); 141 TrackZoomLevelsFromParent(profile_);
143 142
144 #if defined(ENABLE_PLUGINS) 143 #if defined(ENABLE_PLUGINS)
145 ChromePluginServiceFilter::GetInstance()->RegisterResourceContext( 144 ChromePluginServiceFilter::GetInstance()->RegisterResourceContext(
146 PluginPrefs::GetForProfile(this).get(), 145 PluginPrefs::GetForProfile(this).get(),
147 io_data_->GetResourceContextNoInit()); 146 io_data_->GetResourceContextNoInit());
148 #endif 147 #endif
149 148
150 #if defined(ENABLE_EXTENSIONS) 149 #if defined(ENABLE_EXTENSIONS)
151 // Make the chrome//extension-icon/ resource available. 150 // Make the chrome//extension-icon/ resource available.
152 extensions::ExtensionIconSource* icon_source = 151 extensions::ExtensionIconSource* icon_source =
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 183
185 // Clears any data the network stack contains that may be related to the 184 // Clears any data the network stack contains that may be related to the
186 // OTR session. 185 // OTR session.
187 g_browser_process->io_thread()->ChangedToOnTheRecord(); 186 g_browser_process->io_thread()->ChangedToOnTheRecord();
188 } 187 }
189 188
190 void OffTheRecordProfileImpl::InitIoData() { 189 void OffTheRecordProfileImpl::InitIoData() {
191 io_data_.reset(new OffTheRecordProfileIOData::Handle(this)); 190 io_data_.reset(new OffTheRecordProfileIOData::Handle(this));
192 } 191 }
193 192
194 void OffTheRecordProfileImpl::InitHostZoomMap() {
195 HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this);
196 HostZoomMap* parent_host_zoom_map =
197 HostZoomMap::GetForBrowserContext(profile_);
198 host_zoom_map->CopyFrom(parent_host_zoom_map);
199 // Observe parent's HZM change for propagating change of parent's
200 // change to this HZM.
201 zoom_subscription_ = parent_host_zoom_map->AddZoomLevelChangedCallback(
202 base::Bind(&OffTheRecordProfileImpl::OnZoomLevelChanged,
203 base::Unretained(this)));
204 }
205
206 #if defined(OS_ANDROID) || defined(OS_IOS) 193 #if defined(OS_ANDROID) || defined(OS_IOS)
207 void OffTheRecordProfileImpl::UseSystemProxy() { 194 void OffTheRecordProfileImpl::UseSystemProxy() {
208 // Force the use of the system-assigned proxy when off the record. 195 // Force the use of the system-assigned proxy when off the record.
209 const char kProxyMode[] = "mode"; 196 const char kProxyMode[] = "mode";
210 const char kProxyServer[] = "server"; 197 const char kProxyServer[] = "server";
211 const char kProxyBypassList[] = "bypass_list"; 198 const char kProxyBypassList[] = "bypass_list";
212 const char kProxyPacUrl[] = "pac_url"; 199 const char kProxyPacUrl[] = "pac_url";
213 DictionaryPrefUpdate update(prefs_, prefs::kProxy); 200 DictionaryPrefUpdate update(prefs_, prefs::kProxy);
214 base::DictionaryValue* dict = update.Get(); 201 base::DictionaryValue* dict = update.Get();
215 dict->SetString(kProxyMode, ProxyModeToString(ProxyPrefs::MODE_SYSTEM)); 202 dict->SetString(kProxyMode, ProxyModeToString(ProxyPrefs::MODE_SYSTEM));
216 dict->SetString(kProxyPacUrl, ""); 203 dict->SetString(kProxyPacUrl, "");
217 dict->SetString(kProxyServer, ""); 204 dict->SetString(kProxyServer, "");
218 dict->SetString(kProxyBypassList, ""); 205 dict->SetString(kProxyBypassList, "");
219 } 206 }
220 #endif // defined(OS_ANDROID) || defined(OS_IOS) 207 #endif // defined(OS_ANDROID) || defined(OS_IOS)
221 208
222 std::string OffTheRecordProfileImpl::GetProfileName() { 209 std::string OffTheRecordProfileImpl::GetProfileName() {
223 // Incognito profile should not return the profile name. 210 // Incognito profile should not return the profile name.
224 return std::string(); 211 return std::string();
225 } 212 }
226 213
227 Profile::ProfileType OffTheRecordProfileImpl::GetProfileType() const { 214 Profile::ProfileType OffTheRecordProfileImpl::GetProfileType() const {
228 return INCOGNITO_PROFILE; 215 return INCOGNITO_PROFILE;
229 } 216 }
230 217
218 double OffTheRecordProfileImpl::GetDefaultZoomLevel() const {
219 return profile_->GetDefaultZoomLevel();
220 }
221
231 base::FilePath OffTheRecordProfileImpl::GetPath() const { 222 base::FilePath OffTheRecordProfileImpl::GetPath() const {
232 return profile_->GetPath(); 223 return profile_->GetPath();
233 } 224 }
234 225
235 scoped_refptr<base::SequencedTaskRunner> 226 scoped_refptr<base::SequencedTaskRunner>
236 OffTheRecordProfileImpl::GetIOTaskRunner() { 227 OffTheRecordProfileImpl::GetIOTaskRunner() {
237 return profile_->GetIOTaskRunner(); 228 return profile_->GetIOTaskRunner();
238 } 229 }
239 230
240 bool OffTheRecordProfileImpl::IsOffTheRecord() const { 231 bool OffTheRecordProfileImpl::IsOffTheRecord() const {
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after
504 #if defined(OS_CHROMEOS) 495 #if defined(OS_CHROMEOS)
505 if (IsGuestSession()) 496 if (IsGuestSession())
506 profile = new GuestSessionProfile(this); 497 profile = new GuestSessionProfile(this);
507 #endif 498 #endif
508 if (!profile) 499 if (!profile)
509 profile = new OffTheRecordProfileImpl(this); 500 profile = new OffTheRecordProfileImpl(this);
510 profile->Init(); 501 profile->Init();
511 return profile; 502 return profile;
512 } 503 }
513 504
514 void OffTheRecordProfileImpl::OnZoomLevelChanged(
515 const HostZoomMap::ZoomLevelChange& change) {
516 HostZoomMap* host_zoom_map = HostZoomMap::GetForBrowserContext(this);
517 switch (change.mode) {
518 case HostZoomMap::ZOOM_CHANGED_TEMPORARY_ZOOM:
519 return;
520 case HostZoomMap::ZOOM_CHANGED_FOR_HOST:
521 host_zoom_map->SetZoomLevelForHost(change.host, change.zoom_level);
522 return;
523 case HostZoomMap::ZOOM_CHANGED_FOR_SCHEME_AND_HOST:
524 host_zoom_map->SetZoomLevelForHostAndScheme(change.scheme,
525 change.host,
526 change.zoom_level);
527 return;
528 }
529 }
530
531 PrefProxyConfigTracker* OffTheRecordProfileImpl::CreateProxyConfigTracker() { 505 PrefProxyConfigTracker* OffTheRecordProfileImpl::CreateProxyConfigTracker() {
532 #if defined(OS_CHROMEOS) 506 #if defined(OS_CHROMEOS)
533 if (chromeos::ProfileHelper::IsSigninProfile(this)) { 507 if (chromeos::ProfileHelper::IsSigninProfile(this)) {
534 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState( 508 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfLocalState(
535 g_browser_process->local_state()); 509 g_browser_process->local_state());
536 } 510 }
537 #endif // defined(OS_CHROMEOS) 511 #endif // defined(OS_CHROMEOS)
538 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile( 512 return ProxyServiceFactory::CreatePrefProxyConfigTrackerOfProfile(
539 GetPrefs(), g_browser_process->local_state()); 513 GetPrefs(), g_browser_process->local_state());
540 } 514 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698