summaryrefslogtreecommitdiffstats
path: root/chrome/browser/browser_process_impl.cc
diff options
context:
space:
mode:
authorjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-03 00:37:18 +0000
committerjochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-02-03 00:37:18 +0000
commit7e2584b7da3b6a7f797ec9040c91e0f612d11239 (patch)
treed11a1f798d166da8998da12419124a1a6a1efaba /chrome/browser/browser_process_impl.cc
parentffdd3aafda7da07f7cb7d5d10eae6276336e3270 (diff)
downloadchromium_src-7e2584b7da3b6a7f797ec9040c91e0f612d11239.zip
chromium_src-7e2584b7da3b6a7f797ec9040c91e0f612d11239.tar.gz
chromium_src-7e2584b7da3b6a7f797ec9040c91e0f612d11239.tar.bz2
Clear local state (cookies, databases, local storage) on exit.
BUG=32719 TEST=none Review URL: http://codereview.chromium.org/564012 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@37913 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome/browser/browser_process_impl.cc')
-rw-r--r--chrome/browser/browser_process_impl.cc35
1 files changed, 35 insertions, 0 deletions
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc
index a63f6a4..f58357b 100644
--- a/chrome/browser/browser_process_impl.cc
+++ b/chrome/browser/browser_process_impl.cc
@@ -21,11 +21,13 @@
#include "chrome/browser/download/save_file_manager.h"
#include "chrome/browser/google_url_tracker.h"
#include "chrome/browser/icon_manager.h"
+#include "chrome/browser/in_process_webkit/dom_storage_context.h"
#include "chrome/browser/intranet_redirect_detector.h"
#include "chrome/browser/io_thread.h"
#include "chrome/browser/metrics/metrics_service.h"
#include "chrome/browser/net/dns_global.h"
#include "chrome/browser/net/sdch_dictionary_fetcher.h"
+#include "chrome/browser/net/sqlite_persistent_cookie_store.h"
#include "chrome/browser/notifications/notification_ui_manager.h"
#include "chrome/browser/plugin_service.h"
#include "chrome/browser/profile_manager.h"
@@ -33,12 +35,15 @@
#include "chrome/browser/renderer_host/resource_dispatcher_host.h"
#include "chrome/browser/safe_browsing/safe_browsing_service.h"
#include "chrome/common/child_process_host.h"
+#include "chrome/common/chrome_constants.h"
#include "chrome/common/chrome_paths.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/notification_service.h"
#include "chrome/common/pref_names.h"
#include "chrome/common/pref_service.h"
+#include "chrome/common/url_constants.h"
#include "ipc/ipc_logging.h"
+#include "webkit/database/database_tracker.h"
#if defined(OS_WIN)
#include "views/focus/view_storage.h"
@@ -88,6 +93,12 @@ BrowserProcessImpl::BrowserProcessImpl(const CommandLine& command_line)
}
BrowserProcessImpl::~BrowserProcessImpl() {
+ FilePath profile_path;
+ bool clear_local_state_on_exit;
+
+ // Store the profile path for clearing local state data on exit.
+ clear_local_state_on_exit = ShouldClearLocalState(&profile_path);
+
// Delete the AutomationProviderList before NotificationService,
// since it may try to unregister notifications
// Both NotificationService and AutomationProvider are singleton instances in
@@ -153,6 +164,11 @@ BrowserProcessImpl::~BrowserProcessImpl() {
// SaveFileManager and SessionService.
file_thread_.reset();
+ // At this point, no render process exist, so it's safe to access local
+ // state data such as cookies, database, or local storage.
+ if (clear_local_state_on_exit)
+ ClearLocalState(profile_path);
+
// With the file_thread_ flushed, we can release any icon resources.
icon_manager_.reset();
@@ -232,6 +248,25 @@ printing::PrintJobManager* BrowserProcessImpl::print_job_manager() {
return print_job_manager_.get();
}
+void BrowserProcessImpl::ClearLocalState(const FilePath& profile_path) {
+ SQLitePersistentCookieStore::ClearLocalState(profile_path.Append(
+ chrome::kCookieFilename));
+ DOMStorageContext::ClearLocalState(profile_path, chrome::kExtensionScheme);
+ webkit_database::DatabaseTracker::ClearLocalState(profile_path,
+ chrome::kExtensionScheme);
+ // TODO(jochen): clear app cache local state.
+}
+
+bool BrowserProcessImpl::ShouldClearLocalState(FilePath* profile_path) {
+ FilePath user_data_dir;
+ Profile* profile;
+
+ PathService::Get(chrome::DIR_USER_DATA, &user_data_dir);
+ profile = profile_manager_->GetDefaultProfile(user_data_dir);
+ *profile_path = profile->GetPath();
+ return profile->GetPrefs()->GetBoolean(prefs::kClearSiteDataOnExit);
+}
+
void BrowserProcessImpl::CreateResourceDispatcherHost() {
DCHECK(!created_resource_dispatcher_host_ &&
resource_dispatcher_host_.get() == NULL);