#include "base/strings/string_number_conversions.h"
#include "base/strings/string_util.h"
#include "base/strings/utf_string_conversions.h"
-#include "chrome/browser/bookmarks/bookmark_model.h"
#include "chrome/browser/bookmarks/bookmark_model_factory.h"
#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_avatar_icon_util.h"
#include "chrome/browser/profiles/profile_destroyer.h"
#include "chrome/browser/profiles/profile_info_cache.h"
#include "chrome/browser/profiles/profile_metrics.h"
#include "chrome/common/chrome_switches.h"
#include "chrome/common/logging_chrome.h"
#include "chrome/common/pref_names.h"
-#include "chrome/common/profile_management_switches.h"
#include "chrome/common/url_constants.h"
+#include "components/bookmarks/core/browser/bookmark_model.h"
+#include "components/signin/core/common/profile_management_switches.h"
#include "content/public/browser/browser_thread.h"
#include "content/public/browser/notification_service.h"
#include "content/public/browser/user_metrics.h"
// Get the icon index from the user's icon url
size_t icon_index;
std::string icon_url_std = base::UTF16ToASCII(icon_url);
- if (cache.IsDefaultAvatarIconUrl(icon_url_std, &icon_index)) {
+ if (profiles::IsDefaultAvatarIconUrl(icon_url_std, &icon_index)) {
// add profile to cache with user selected name and avatar
cache.AddProfileToCache(profile_path, name, base::string16(), icon_index,
managed_user_id);
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();
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.
void ProfileManager::SetGuestProfilePrefs(Profile* profile) {
PrefService* prefs = profile->GetPrefs();
prefs->SetBoolean(prefs::kSigninAllowed, false);
+ prefs->SetBoolean(prefs::kEditBookmarksEnabled, false);
+ prefs->SetBoolean(prefs::kShowBookmarkBar, false);
// This can be removed in the future but needs to be present through
// a release (or two) so that any existing installs get switched to
// the new state and away from the previous "forced" state.