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

Unified Diff: chrome/browser/profiles/profile_manager.cc

Issue 214523003: Before deleting a profile, cancel all in-progress downloads (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 9 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/download/download_service.cc ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/profiles/profile_manager.cc
diff --git a/chrome/browser/profiles/profile_manager.cc b/chrome/browser/profiles/profile_manager.cc
index a6fcf7562cd25b8fbbc990029d5ac5b994edcc86..6631dca2bb0cc3692ae623da242e547951015e74 100644
--- a/chrome/browser/profiles/profile_manager.cc
+++ b/chrome/browser/profiles/profile_manager.cc
@@ -24,6 +24,8 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chrome_notification_types.h"
#include "chrome/browser/content_settings/host_content_settings_map.h"
+#include "chrome/browser/download/download_service.h"
+#include "chrome/browser/download/download_service_factory.h"
#include "chrome/browser/prefs/incognito_mode_prefs.h"
#include "chrome/browser/profiles/bookmark_model_loaded_observer.h"
#include "chrome/browser/profiles/profile_destroyer.h"
@@ -632,6 +634,17 @@ void ProfileManager::ScheduleProfileForDeletion(
const base::FilePath& profile_dir,
const CreateCallback& callback) {
DCHECK(profiles::IsMultipleProfilesEnabled());
+
+ // Cancel all in-progress downloads before deleting the profile to prevent a
+ // "Do you want to exit Google Chrome and cancel the downloads?" prompt
+ // (crbug.com/336725).
+ Profile* profile = GetProfileByPath(profile_dir);
+ if (profile) {
+ DownloadService* service =
+ DownloadServiceFactory::GetForBrowserContext(profile);
+ service->CancelDownloads();
+ }
+
PrefService* local_state = g_browser_process->local_state();
ProfileInfoCache& cache = GetProfileInfoCache();
@@ -1071,6 +1084,10 @@ void ProfileManager::FinishDeletingProfile(const base::FilePath& profile_dir) {
Profile* profile = GetProfileByPath(profile_dir);
if (profile) {
+ // By this point, all in-progress downloads for the profile being deleted
+ // must have been canceled (crbug.com/336725).
+ DCHECK(DownloadServiceFactory::GetForBrowserContext(profile)->
+ NonMaliciousDownloadCount() == 0);
BrowserList::CloseAllBrowsersWithProfile(profile);
// Disable sync for doomed profile.
« no previous file with comments | « chrome/browser/download/download_service.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698