| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/compiler_specific.h" | 8 #include "base/compiler_specific.h" |
| 9 #include "base/environment.h" | 9 #include "base/environment.h" |
| 10 #include "base/file_path.h" | 10 #include "base/file_path.h" |
| 11 #include "base/file_util.h" | 11 #include "base/file_util.h" |
| 12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/metrics/histogram.h" | 13 #include "base/metrics/histogram.h" |
| 14 #include "base/path_service.h" | 14 #include "base/path_service.h" |
| 15 #include "base/string_number_conversions.h" | 15 #include "base/string_number_conversions.h" |
| 16 #include "base/string_util.h" | 16 #include "base/string_util.h" |
| 17 #include "base/synchronization/waitable_event.h" |
| 17 #include "chrome/browser/autocomplete/autocomplete_classifier.h" | 18 #include "chrome/browser/autocomplete/autocomplete_classifier.h" |
| 18 #include "chrome/browser/autofill/personal_data_manager.h" | 19 #include "chrome/browser/autofill/personal_data_manager.h" |
| 19 #include "chrome/browser/background/background_contents_service_factory.h" | 20 #include "chrome/browser/background/background_contents_service_factory.h" |
| 20 #include "chrome/browser/background/background_mode_manager.h" | 21 #include "chrome/browser/background/background_mode_manager.h" |
| 21 #include "chrome/browser/bookmarks/bookmark_model.h" | 22 #include "chrome/browser/bookmarks/bookmark_model.h" |
| 22 #include "chrome/browser/browser_process.h" | 23 #include "chrome/browser/browser_process.h" |
| 23 #include "chrome/browser/browser_signin.h" | 24 #include "chrome/browser/browser_signin.h" |
| 24 #include "chrome/browser/browsing_data_remover.h" | 25 #include "chrome/browser/browsing_data_remover.h" |
| 25 #include "chrome/browser/content_settings/host_content_settings_map.h" | 26 #include "chrome/browser/content_settings/host_content_settings_map.h" |
| 26 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" | 27 #include "chrome/browser/custom_handlers/protocol_handler_registry.h" |
| (...skipping 555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 582 void ProfileImpl::set_last_selected_directory(const FilePath& path) { | 583 void ProfileImpl::set_last_selected_directory(const FilePath& path) { |
| 583 GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path); | 584 GetPrefs()->SetFilePath(prefs::kSelectFileLastDirectory, path); |
| 584 } | 585 } |
| 585 | 586 |
| 586 ProfileImpl::~ProfileImpl() { | 587 ProfileImpl::~ProfileImpl() { |
| 587 NotificationService::current()->Notify( | 588 NotificationService::current()->Notify( |
| 588 NotificationType::PROFILE_DESTROYED, | 589 NotificationType::PROFILE_DESTROYED, |
| 589 Source<Profile>(this), | 590 Source<Profile>(this), |
| 590 NotificationService::NoDetails()); | 591 NotificationService::NoDetails()); |
| 591 | 592 |
| 593 if (appcache_service_ && prefs_->GetBoolean(prefs::kClearSiteDataOnExit)) { |
| 594 // We don't own event |
| 595 base::WaitableEvent* event = appcache_service_->ClearAppCache(NULL); |
| 596 event->Wait(); |
| 597 } |
| 598 |
| 592 StopCreateSessionServiceTimer(); | 599 StopCreateSessionServiceTimer(); |
| 593 | 600 |
| 594 // Remove pref observers | 601 // Remove pref observers |
| 595 pref_change_registrar_.RemoveAll(); | 602 pref_change_registrar_.RemoveAll(); |
| 596 | 603 |
| 597 ProfileDependencyManager::GetInstance()->DestroyProfileServices(this); | 604 ProfileDependencyManager::GetInstance()->DestroyProfileServices(this); |
| 598 | 605 |
| 599 if (clear_local_state_on_exit_) { | 606 if (clear_local_state_on_exit_) { |
| 600 BrowserThread::PostTask( | 607 BrowserThread::PostTask( |
| 601 BrowserThread::FILE, FROM_HERE, | 608 BrowserThread::FILE, FROM_HERE, |
| (...skipping 713 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1315 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::WEBKIT)); | 1322 BrowserThread::GetMessageLoopProxyForThread(BrowserThread::WEBKIT)); |
| 1316 appcache_service_ = new ChromeAppCacheService(quota_manager_->proxy()); | 1323 appcache_service_ = new ChromeAppCacheService(quota_manager_->proxy()); |
| 1317 BrowserThread::PostTask( | 1324 BrowserThread::PostTask( |
| 1318 BrowserThread::IO, FROM_HERE, | 1325 BrowserThread::IO, FROM_HERE, |
| 1319 NewRunnableMethod( | 1326 NewRunnableMethod( |
| 1320 appcache_service_.get(), | 1327 appcache_service_.get(), |
| 1321 &ChromeAppCacheService::InitializeOnIOThread, | 1328 &ChromeAppCacheService::InitializeOnIOThread, |
| 1322 IsOffTheRecord() | 1329 IsOffTheRecord() |
| 1323 ? FilePath() : GetPath().Append(chrome::kAppCacheDirname), | 1330 ? FilePath() : GetPath().Append(chrome::kAppCacheDirname), |
| 1324 &GetResourceContext(), | 1331 &GetResourceContext(), |
| 1325 make_scoped_refptr(GetExtensionSpecialStoragePolicy()), | 1332 make_scoped_refptr(GetExtensionSpecialStoragePolicy()))); |
| 1326 clear_local_state_on_exit_)); | |
| 1327 } | 1333 } |
| 1328 | 1334 |
| 1329 WebKitContext* ProfileImpl::GetWebKitContext() { | 1335 WebKitContext* ProfileImpl::GetWebKitContext() { |
| 1330 CreateQuotaManagerAndClients(); | 1336 CreateQuotaManagerAndClients(); |
| 1331 return webkit_context_.get(); | 1337 return webkit_context_.get(); |
| 1332 } | 1338 } |
| 1333 | 1339 |
| 1334 void ProfileImpl::MarkAsCleanShutdown() { | 1340 void ProfileImpl::MarkAsCleanShutdown() { |
| 1335 if (prefs_.get()) { | 1341 if (prefs_.get()) { |
| 1336 // The session cleanly exited, set kSessionExitedCleanly appropriately. | 1342 // The session cleanly exited, set kSessionExitedCleanly appropriately. |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1370 RenderProcessHost* process = i.GetCurrentValue(); | 1376 RenderProcessHost* process = i.GetCurrentValue(); |
| 1371 process->Send(new SpellCheckMsg_EnableAutoSpellCorrect(enabled)); | 1377 process->Send(new SpellCheckMsg_EnableAutoSpellCorrect(enabled)); |
| 1372 } | 1378 } |
| 1373 } else if (*pref_name_in == prefs::kClearSiteDataOnExit) { | 1379 } else if (*pref_name_in == prefs::kClearSiteDataOnExit) { |
| 1374 clear_local_state_on_exit_ = | 1380 clear_local_state_on_exit_ = |
| 1375 prefs->GetBoolean(prefs::kClearSiteDataOnExit); | 1381 prefs->GetBoolean(prefs::kClearSiteDataOnExit); |
| 1376 if (webkit_context_) { | 1382 if (webkit_context_) { |
| 1377 webkit_context_->set_clear_local_state_on_exit( | 1383 webkit_context_->set_clear_local_state_on_exit( |
| 1378 clear_local_state_on_exit_); | 1384 clear_local_state_on_exit_); |
| 1379 } | 1385 } |
| 1380 if (appcache_service_) { | |
| 1381 appcache_service_->SetClearLocalStateOnExit( | |
| 1382 clear_local_state_on_exit_); | |
| 1383 } | |
| 1384 } else if (*pref_name_in == prefs::kGoogleServicesUsername) { | 1386 } else if (*pref_name_in == prefs::kGoogleServicesUsername) { |
| 1385 ProfileManager* profile_manager = g_browser_process->profile_manager(); | 1387 ProfileManager* profile_manager = g_browser_process->profile_manager(); |
| 1386 profile_manager->RegisterProfileName(this); | 1388 profile_manager->RegisterProfileName(this); |
| 1387 } else if (*pref_name_in == prefs::kDefaultZoomLevel) { | 1389 } else if (*pref_name_in == prefs::kDefaultZoomLevel) { |
| 1388 GetHostZoomMap()->set_default_zoom_level( | 1390 GetHostZoomMap()->set_default_zoom_level( |
| 1389 prefs->GetDouble(prefs::kDefaultZoomLevel)); | 1391 prefs->GetDouble(prefs::kDefaultZoomLevel)); |
| 1390 } | 1392 } |
| 1391 break; | 1393 break; |
| 1392 } | 1394 } |
| 1393 case NotificationType::BOOKMARK_MODEL_LOADED: | 1395 case NotificationType::BOOKMARK_MODEL_LOADED: |
| (...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1632 if (!prerender::PrerenderManager::IsPrerenderingPossible()) | 1634 if (!prerender::PrerenderManager::IsPrerenderingPossible()) |
| 1633 return NULL; | 1635 return NULL; |
| 1634 if (!prerender_manager_.get()) { | 1636 if (!prerender_manager_.get()) { |
| 1635 CHECK(g_browser_process->prerender_tracker()); | 1637 CHECK(g_browser_process->prerender_tracker()); |
| 1636 prerender_manager_.reset( | 1638 prerender_manager_.reset( |
| 1637 new prerender::PrerenderManager( | 1639 new prerender::PrerenderManager( |
| 1638 this, g_browser_process->prerender_tracker())); | 1640 this, g_browser_process->prerender_tracker())); |
| 1639 } | 1641 } |
| 1640 return prerender_manager_.get(); | 1642 return prerender_manager_.get(); |
| 1641 } | 1643 } |
| OLD | NEW |