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

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

Issue 10447117: Unwire the clear on exit preference from the storage systems. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: updates Created 8 years, 6 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/profile_impl.h" 5 #include "chrome/browser/profiles/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/environment.h" 10 #include "base/environment.h"
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
198 } 198 }
199 199
200 // static 200 // static
201 int ProfileImpl::create_readme_delay_ms = 60000; 201 int ProfileImpl::create_readme_delay_ms = 60000;
202 202
203 // static 203 // static
204 void ProfileImpl::RegisterUserPrefs(PrefService* prefs) { 204 void ProfileImpl::RegisterUserPrefs(PrefService* prefs) {
205 prefs->RegisterBooleanPref(prefs::kSavingBrowserHistoryDisabled, 205 prefs->RegisterBooleanPref(prefs::kSavingBrowserHistoryDisabled,
206 false, 206 false,
207 PrefService::UNSYNCABLE_PREF); 207 PrefService::UNSYNCABLE_PREF);
208 prefs->RegisterBooleanPref(prefs::kClearSiteDataOnExit,
209 false,
210 PrefService::SYNCABLE_PREF);
211 prefs->RegisterBooleanPref(prefs::kProfileShortcutCreated, 208 prefs->RegisterBooleanPref(prefs::kProfileShortcutCreated,
212 false, 209 false,
213 PrefService::UNSYNCABLE_PREF); 210 PrefService::UNSYNCABLE_PREF);
214 prefs->RegisterIntegerPref(prefs::kProfileAvatarIndex, 211 prefs->RegisterIntegerPref(prefs::kProfileAvatarIndex,
215 -1, 212 -1,
216 PrefService::SYNCABLE_PREF); 213 PrefService::SYNCABLE_PREF);
217 prefs->RegisterStringPref(prefs::kProfileName, 214 prefs->RegisterStringPref(prefs::kProfileName,
218 "", 215 "",
219 PrefService::SYNCABLE_PREF); 216 PrefService::SYNCABLE_PREF);
220 prefs->RegisterBooleanPref(prefs::kRestoreSessionStateDialogShown, 217 prefs->RegisterBooleanPref(prefs::kRestoreSessionStateDialogShown,
221 false, 218 false,
222 PrefService::SYNCABLE_PREF); 219 PrefService::SYNCABLE_PREF);
220
221 // Deprecated. Kept around for migration.
222 prefs->RegisterBooleanPref(prefs::kClearSiteDataOnExit,
223 false,
224 PrefService::SYNCABLE_PREF);
223 } 225 }
224 226
225 ProfileImpl::ProfileImpl(const FilePath& path, 227 ProfileImpl::ProfileImpl(const FilePath& path,
226 Delegate* delegate, 228 Delegate* delegate,
227 CreateMode create_mode) 229 CreateMode create_mode)
228 : path_(path), 230 : path_(path),
229 ALLOW_THIS_IN_INITIALIZER_LIST(visited_link_event_listener_( 231 ALLOW_THIS_IN_INITIALIZER_LIST(visited_link_event_listener_(
230 new VisitedLinkEventListener(this))), 232 new VisitedLinkEventListener(this))),
231 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)), 233 ALLOW_THIS_IN_INITIALIZER_LIST(io_data_(this)),
232 host_content_settings_map_(NULL), 234 host_content_settings_map_(NULL),
233 history_service_created_(false), 235 history_service_created_(false),
234 favicon_service_created_(false), 236 favicon_service_created_(false),
235 clear_local_state_on_exit_(false),
236 start_time_(Time::Now()), 237 start_time_(Time::Now()),
237 delegate_(delegate), 238 delegate_(delegate),
238 predictor_(NULL), 239 predictor_(NULL),
239 session_restore_enabled_(false) { 240 session_restore_enabled_(false) {
240 DCHECK(!path.empty()) << "Using an empty path will attempt to write " << 241 DCHECK(!path.empty()) << "Using an empty path will attempt to write " <<
241 "profile files to the root directory!"; 242 "profile files to the root directory!";
242 243
243 #if defined(ENABLE_SESSION_SERVICE) 244 #if defined(ENABLE_SESSION_SERVICE)
244 create_session_service_timer_.Start(FROM_HERE, 245 create_session_service_timer_.Start(FROM_HERE,
245 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this, 246 TimeDelta::FromMilliseconds(kCreateSessionServiceDelayMS), this,
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 OnPrefsLoaded(true); 284 OnPrefsLoaded(true);
284 } else { 285 } else {
285 NOTREACHED(); 286 NOTREACHED();
286 } 287 }
287 } 288 }
288 289
289 void ProfileImpl::DoFinalInit(bool is_new_profile) { 290 void ProfileImpl::DoFinalInit(bool is_new_profile) {
290 PrefService* prefs = GetPrefs(); 291 PrefService* prefs = GetPrefs();
291 pref_change_registrar_.Init(prefs); 292 pref_change_registrar_.Init(prefs);
292 pref_change_registrar_.Add(prefs::kSpeechRecognitionFilterProfanities, this); 293 pref_change_registrar_.Add(prefs::kSpeechRecognitionFilterProfanities, this);
293 pref_change_registrar_.Add(prefs::kClearSiteDataOnExit, this);
294 pref_change_registrar_.Add(prefs::kGoogleServicesUsername, this); 294 pref_change_registrar_.Add(prefs::kGoogleServicesUsername, this);
295 pref_change_registrar_.Add(prefs::kDefaultZoomLevel, this); 295 pref_change_registrar_.Add(prefs::kDefaultZoomLevel, this);
296 pref_change_registrar_.Add(prefs::kProfileAvatarIndex, this); 296 pref_change_registrar_.Add(prefs::kProfileAvatarIndex, this);
297 pref_change_registrar_.Add(prefs::kProfileName, this); 297 pref_change_registrar_.Add(prefs::kProfileName, this);
298 298
299 // It would be nice to use PathService for fetching this directory, but 299 // It would be nice to use PathService for fetching this directory, but
300 // the cache directory depends on the profile directory, which isn't available 300 // the cache directory depends on the profile directory, which isn't available
301 // to PathService. 301 // to PathService.
302 chrome::GetUserCacheDirectory(path_, &base_cache_path_); 302 chrome::GetUserCacheDirectory(path_, &base_cache_path_);
303 // Always create the cache directory asynchronously. 303 // Always create the cache directory asynchronously.
(...skipping 28 matching lines...) Expand all
332 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kKeepAliveForTest)) 332 if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kKeepAliveForTest))
333 init_background_mode_manager = false; 333 init_background_mode_manager = false;
334 #endif 334 #endif
335 if (init_background_mode_manager) { 335 if (init_background_mode_manager) {
336 if (g_browser_process->background_mode_manager()) 336 if (g_browser_process->background_mode_manager())
337 g_browser_process->background_mode_manager()->RegisterProfile(this); 337 g_browser_process->background_mode_manager()->RegisterProfile(this);
338 } 338 }
339 339
340 InitRegisteredProtocolHandlers(); 340 InitRegisteredProtocolHandlers();
341 341
342 clear_local_state_on_exit_ = prefs->GetBoolean(prefs::kClearSiteDataOnExit);
343 if (clear_local_state_on_exit_) {
344 content::RecordAction(
345 UserMetricsAction("ClearSiteDataOnExitEnabled"));
346 } else {
347 content::RecordAction(
348 UserMetricsAction("ClearSiteDataOnExitDisabled"));
349 }
350
351 InstantController::RecordMetrics(this); 342 InstantController::RecordMetrics(this);
352 343
353 FilePath cookie_path = GetPath(); 344 FilePath cookie_path = GetPath();
354 cookie_path = cookie_path.Append(chrome::kCookieFilename); 345 cookie_path = cookie_path.Append(chrome::kCookieFilename);
355 FilePath server_bound_cert_path = GetPath(); 346 FilePath server_bound_cert_path = GetPath();
356 server_bound_cert_path = 347 server_bound_cert_path =
357 server_bound_cert_path.Append(chrome::kOBCertFilename); 348 server_bound_cert_path.Append(chrome::kOBCertFilename);
358 FilePath cache_path = base_cache_path_; 349 FilePath cache_path = base_cache_path_;
359 int cache_max_size; 350 int cache_max_size;
360 GetCacheParameters(false, &cache_path, &cache_max_size); 351 GetCacheParameters(false, &cache_path, &cache_max_size);
(...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after
487 GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path); 478 GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path);
488 } 479 }
489 480
490 ProfileImpl::~ProfileImpl() { 481 ProfileImpl::~ProfileImpl() {
491 content::NotificationService::current()->Notify( 482 content::NotificationService::current()->Notify(
492 chrome::NOTIFICATION_PROFILE_DESTROYED, 483 chrome::NOTIFICATION_PROFILE_DESTROYED,
493 content::Source<Profile>(this), 484 content::Source<Profile>(this),
494 content::NotificationService::NoDetails()); 485 content::NotificationService::NoDetails());
495 bool prefs_loaded = prefs_->GetInitializationStatus() != 486 bool prefs_loaded = prefs_->GetInitializationStatus() !=
496 PrefService::INITIALIZATION_STATUS_WAITING; 487 PrefService::INITIALIZATION_STATUS_WAITING;
497 // Honor the "clear local state" setting.
498 if (clear_local_state_on_exit_)
499 BrowserContext::ClearLocalOnDestruction(this);
500 488
501 #if defined(ENABLE_SESSION_SERVICE) 489 #if defined(ENABLE_SESSION_SERVICE)
502 StopCreateSessionServiceTimer(); 490 StopCreateSessionServiceTimer();
503 #endif 491 #endif
504 492
505 // Remove pref observers 493 // Remove pref observers
506 pref_change_registrar_.RemoveAll(); 494 pref_change_registrar_.RemoveAll();
507 495
508 ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext( 496 ChromePluginServiceFilter::GetInstance()->UnregisterResourceContext(
509 io_data_.GetResourceContextNoInit()); 497 io_data_.GetResourceContextNoInit());
(...skipping 412 matching lines...) Expand 10 before | Expand all | Expand 10 after
922 std::string* pref_name_in = content::Details<std::string>(details).ptr(); 910 std::string* pref_name_in = content::Details<std::string>(details).ptr();
923 PrefService* prefs = content::Source<PrefService>(source).ptr(); 911 PrefService* prefs = content::Source<PrefService>(source).ptr();
924 DCHECK(pref_name_in && prefs); 912 DCHECK(pref_name_in && prefs);
925 if (*pref_name_in == prefs::kSpeechRecognitionFilterProfanities) { 913 if (*pref_name_in == prefs::kSpeechRecognitionFilterProfanities) {
926 content::SpeechRecognitionPreferences* speech_prefs = 914 content::SpeechRecognitionPreferences* speech_prefs =
927 GetSpeechRecognitionPreferences(); 915 GetSpeechRecognitionPreferences();
928 if (speech_prefs) { 916 if (speech_prefs) {
929 speech_prefs->SetFilterProfanities(prefs->GetBoolean( 917 speech_prefs->SetFilterProfanities(prefs->GetBoolean(
930 prefs::kSpeechRecognitionFilterProfanities)); 918 prefs::kSpeechRecognitionFilterProfanities));
931 } 919 }
932 } else if (*pref_name_in == prefs::kClearSiteDataOnExit) {
933 clear_local_state_on_exit_ =
934 prefs->GetBoolean(prefs::kClearSiteDataOnExit);
935 } else if (*pref_name_in == prefs::kGoogleServicesUsername) { 920 } else if (*pref_name_in == prefs::kGoogleServicesUsername) {
936 UpdateProfileUserNameCache(); 921 UpdateProfileUserNameCache();
937 } else if (*pref_name_in == prefs::kProfileAvatarIndex) { 922 } else if (*pref_name_in == prefs::kProfileAvatarIndex) {
938 UpdateProfileAvatarCache(); 923 UpdateProfileAvatarCache();
939 } else if (*pref_name_in == prefs::kProfileName) { 924 } else if (*pref_name_in == prefs::kProfileName) {
940 UpdateProfileNameCache(); 925 UpdateProfileNameCache();
941 } else if (*pref_name_in == prefs::kDefaultZoomLevel) { 926 } else if (*pref_name_in == prefs::kDefaultZoomLevel) {
942 HostZoomMap::GetForBrowserContext(this)->SetDefaultZoomLevel( 927 HostZoomMap::GetForBrowserContext(this)->SetDefaultZoomLevel(
943 prefs->GetDouble(prefs::kDefaultZoomLevel)); 928 prefs->GetDouble(prefs::kDefaultZoomLevel));
944 } 929 }
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
1166 if (!path.empty()) 1151 if (!path.empty())
1167 *cache_path = path; 1152 *cache_path = path;
1168 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) : 1153 *max_size = is_media_context ? prefs_->GetInteger(prefs::kMediaCacheSize) :
1169 prefs_->GetInteger(prefs::kDiskCacheSize); 1154 prefs_->GetInteger(prefs::kDiskCacheSize);
1170 } 1155 }
1171 1156
1172 base::Callback<ChromeURLDataManagerBackend*(void)> 1157 base::Callback<ChromeURLDataManagerBackend*(void)>
1173 ProfileImpl::GetChromeURLDataManagerBackendGetter() const { 1158 ProfileImpl::GetChromeURLDataManagerBackendGetter() const {
1174 return io_data_.GetChromeURLDataManagerBackendGetter(); 1159 return io_data_.GetChromeURLDataManagerBackendGetter();
1175 } 1160 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698