diff options
author | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-15 21:18:47 +0000 |
---|---|---|
committer | bauerb@chromium.org <bauerb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-12-15 21:18:47 +0000 |
commit | 6618d1d6b2a04e0782b46253ed2823d1cd404636 (patch) | |
tree | 19ba06fae87672e22ea593d7b106925419026ad4 /chrome | |
parent | a405b4c6c34f1ab69f73df8ec7e7b58631a3167d (diff) | |
download | chromium_src-6618d1d6b2a04e0782b46253ed2823d1cd404636.zip chromium_src-6618d1d6b2a04e0782b46253ed2823d1cd404636.tar.gz chromium_src-6618d1d6b2a04e0782b46253ed2823d1cd404636.tar.bz2 |
Add a preference to clear plugin data on browser shutdown.
BUG=58235
TEST=none
Review URL: http://codereview.chromium.org/5579002
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@69315 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome')
-rw-r--r-- | chrome/browser/browser_process_impl.cc | 36 | ||||
-rw-r--r-- | chrome/browser/browser_process_impl.h | 18 | ||||
-rw-r--r-- | chrome/browser/plugin_data_remover_helper.cc | 1 | ||||
-rw-r--r-- | chrome/browser/ui/browser.cc | 1 | ||||
-rw-r--r-- | chrome/browser/ui/options/options_util.cc | 1 | ||||
-rw-r--r-- | chrome/common/pref_names.cc | 5 | ||||
-rw-r--r-- | chrome/common/pref_names.h | 1 |
7 files changed, 62 insertions, 1 deletions
diff --git a/chrome/browser/browser_process_impl.cc b/chrome/browser/browser_process_impl.cc index 756aa6c..d60b672 100644 --- a/chrome/browser/browser_process_impl.cc +++ b/chrome/browser/browser_process_impl.cc @@ -37,6 +37,7 @@ #include "chrome/browser/net/predictor_api.h" #include "chrome/browser/net/sdch_dictionary_fetcher.h" #include "chrome/browser/notifications/notification_ui_manager.h" +#include "chrome/browser/plugin_data_remover.h" #include "chrome/browser/plugin_service.h" #include "chrome/browser/plugin_updater.h" #include "chrome/browser/prefs/pref_service.h" @@ -110,6 +111,10 @@ BrowserProcessImpl::BrowserProcessImpl(const CommandLine& command_line) clipboard_.reset(new Clipboard); main_notification_service_.reset(new NotificationService); + notification_registrar_.Add(this, + NotificationType::APP_TERMINATING, + NotificationService::AllSources()); + // Must be created after the NotificationService. print_job_manager_.reset(new printing::PrintJobManager); @@ -175,6 +180,9 @@ BrowserProcessImpl::~BrowserProcessImpl() { background_x11_thread_.reset(); #endif + // Wait for removing plugin data to finish before shutting down the IO thread. + WaitForPluginDataRemoverToFinish(); + // Need to stop io_thread_ before resource_dispatcher_host_, since // io_thread_ may still deref ResourceDispatcherHost and handle resource // request before going away. @@ -507,6 +515,34 @@ void BrowserProcessImpl::CheckForInspectorFiles() { NewRunnableMethod(this, &BrowserProcessImpl::DoInspectorFilesCheck)); } +void BrowserProcessImpl::Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details) { + if (type == NotificationType::APP_TERMINATING) { + Profile* profile = ProfileManager::GetDefaultProfile(); + if (profile) { + PrefService* prefs = profile->GetPrefs(); + if (prefs->GetBoolean(prefs::kClearPluginLSODataOnExit) && + local_state()->GetBoolean(prefs::kClearPluginLSODataEnabled)) { + plugin_data_remover_ = new PluginDataRemover(); + plugin_data_remover_->StartRemoving(base::Time(), NULL); + } + } + } else { + NOTREACHED(); + } +} + +void BrowserProcessImpl::WaitForPluginDataRemoverToFinish() { + if (!plugin_data_remover_.get() || !plugin_data_remover_->is_removing()) + return; + plugin_data_remover_->set_done_task(new MessageLoop::QuitTask()); + base::Time start_time(base::Time::Now()); + MessageLoop::current()->Run(); + UMA_HISTOGRAM_TIMES("ClearPluginData.wait_at_shutdown", + base::Time::Now() - start_time); +} + #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) void BrowserProcessImpl::StartAutoupdateTimer() { autoupdate_timer_.Start( diff --git a/chrome/browser/browser_process_impl.h b/chrome/browser/browser_process_impl.h index cc9d60c..c763d31 100644 --- a/chrome/browser/browser_process_impl.h +++ b/chrome/browser/browser_process_impl.h @@ -22,6 +22,8 @@ #include "chrome/browser/download/download_status_updater.h" #include "chrome/browser/prefs/pref_change_registrar.h" #include "chrome/browser/tab_contents/thumbnail_generator.h" +#include "chrome/common/notification_observer.h" +#include "chrome/common/notification_registrar.h" #include "ipc/ipc_message.h" class ChromeNetLog; @@ -29,16 +31,20 @@ class CommandLine; class DebuggerWrapper; class FilePath; class NotificationService; +class PluginDataRemover; class TabCloseableStateWatcher; // Real implementation of BrowserProcess that creates and returns the services. -class BrowserProcessImpl : public BrowserProcess, public NonThreadSafe { +class BrowserProcessImpl : public BrowserProcess, + public NonThreadSafe, + public NotificationObserver { public: explicit BrowserProcessImpl(const CommandLine& command_line); virtual ~BrowserProcessImpl(); virtual void EndSession(); + // BrowserProcess methods virtual ResourceDispatcherHost* resource_dispatcher_host(); virtual MetricsService* metrics_service(); virtual IOThread* io_thread(); @@ -75,6 +81,11 @@ class BrowserProcessImpl : public BrowserProcess, public NonThreadSafe { safe_browsing_detection_service(); virtual void CheckForInspectorFiles(); + // NotificationObserver methods + virtual void Observe(NotificationType type, + const NotificationSource& source, + const NotificationDetails& details); + #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) virtual void StartAutoupdateTimer(); #endif @@ -96,6 +107,8 @@ class BrowserProcessImpl : public BrowserProcess, public NonThreadSafe { void CreateIOThread(); static void CleanupOnIOThread(); + void WaitForPluginDataRemoverToFinish(); + void CreateFileThread(); void CreateDBThread(); void CreateProcessLauncherThread(); @@ -224,6 +237,9 @@ class BrowserProcessImpl : public BrowserProcess, public NonThreadSafe { // Lives here so can safely log events on shutdown. scoped_ptr<ChromeNetLog> net_log_; + NotificationRegistrar notification_registrar_; + scoped_refptr<PluginDataRemover> plugin_data_remover_; + #if (defined(OS_WIN) || defined(OS_LINUX)) && !defined(OS_CHROMEOS) base::RepeatingTimer<BrowserProcessImpl> autoupdate_timer_; diff --git a/chrome/browser/plugin_data_remover_helper.cc b/chrome/browser/plugin_data_remover_helper.cc index 679a517..43eb4f6 100644 --- a/chrome/browser/plugin_data_remover_helper.cc +++ b/chrome/browser/plugin_data_remover_helper.cc @@ -12,6 +12,7 @@ #include "chrome/browser/prefs/pref_service.h" #include "chrome/browser/profiles/profile.h" +// The internal class is refcounted so it can outlive PluginDataRemoverHelper. class PluginDataRemoverHelper::Internal : public base::RefCountedThreadSafe<PluginDataRemoverHelper::Internal> { public: diff --git a/chrome/browser/ui/browser.cc b/chrome/browser/ui/browser.cc index 5c566d5..8f8c281 100644 --- a/chrome/browser/ui/browser.cc +++ b/chrome/browser/ui/browser.cc @@ -2006,6 +2006,7 @@ void Browser::RegisterUserPrefs(PrefService* prefs) { chrome::kChromeUINewTabURL); prefs->RegisterBooleanPref(prefs::kHomePageIsNewTabPage, true); prefs->RegisterBooleanPref(prefs::kClearSiteDataOnExit, false); + prefs->RegisterBooleanPref(prefs::kClearPluginLSODataOnExit, false); prefs->RegisterBooleanPref(prefs::kShowHomeButton, false); #if defined(OS_MACOSX) // This really belongs in platform code, but there's no good place to diff --git a/chrome/browser/ui/options/options_util.cc b/chrome/browser/ui/options/options_util.cc index 5f546b8..0c8ba36 100644 --- a/chrome/browser/ui/options/options_util.cc +++ b/chrome/browser/ui/options/options_util.cc @@ -27,6 +27,7 @@ void OptionsUtil::ResetToDefaults(Profile* profile) { const char* kUserPrefs[] = { prefs::kAcceptLanguages, prefs::kAlternateErrorPagesEnabled, + prefs::kClearPluginLSODataOnExit, prefs::kClearSiteDataOnExit, prefs::kCookieBehavior, prefs::kDefaultCharset, diff --git a/chrome/common/pref_names.cc b/chrome/common/pref_names.cc index 3e84d53..44faf37 100644 --- a/chrome/common/pref_names.cc +++ b/chrome/common/pref_names.cc @@ -558,6 +558,11 @@ const char kBlockNonsandboxedPlugins[] = "profile.block_nonsandboxed_plugins"; // storage, etc..) should be deleted on exit. const char kClearSiteDataOnExit[] = "profile.clear_site_data_on_exit"; +// Boolean that is true when plug-in locally stored data ("Flash cookies") +// should be deleted on exit. +const char kClearPluginLSODataOnExit[] = + "profile.clear_plugin_lso_data_on_exit"; + // Double that indicates the default zoom level. const char kDefaultZoomLevel[] = "profile.default_zoom_level"; diff --git a/chrome/common/pref_names.h b/chrome/common/pref_names.h index 7537b5a..5ea454d 100644 --- a/chrome/common/pref_names.h +++ b/chrome/common/pref_names.h @@ -212,6 +212,7 @@ extern const char kContentSettingsPatterns[]; extern const char kBlockThirdPartyCookies[]; extern const char kBlockNonsandboxedPlugins[]; extern const char kClearSiteDataOnExit[]; +extern const char kClearPluginLSODataOnExit[]; extern const char kDefaultZoomLevel[]; extern const char kPerHostZoomLevels[]; extern const char kAutoFillEnabled[]; |