Index: chrome/browser/ui/startup/default_browser_prompt.cc |
diff --git a/chrome/browser/ui/startup/default_browser_prompt.cc b/chrome/browser/ui/startup/default_browser_prompt.cc |
index d4f57eb34523522d26ba0911cf7a90608fd6b78f..832f36dd5b7c9692b974f5ccb3739e491148aff8 100644 |
--- a/chrome/browser/ui/startup/default_browser_prompt.cc |
+++ b/chrome/browser/ui/startup/default_browser_prompt.cc |
@@ -176,8 +176,12 @@ bool DefaultBrowserInfoBarDelegate::Accept() { |
UMA_HISTOGRAM_ENUMERATION("DefaultBrowser.InfoBar.UserInteraction", |
InfoBarUserInteraction::START_SET_AS_DEFAULT, |
NUM_INFO_BAR_USER_INTERACTION_TYPES); |
+ // The worker pointer is reference counted. While it is running, the |
+ // message loops of the FILE and UI thread will hold references to it |
+ // and it will be automatically freed once all its tasks have finished. |
scoped_refptr<shell_integration::DefaultBrowserWorker>( |
- new shell_integration::DefaultBrowserWorker(nullptr)) |
+ new shell_integration::DefaultBrowserWorker(nullptr, |
+ /*delete_observer=*/false)) |
->StartSetAsDefault(); |
return true; |
} |
@@ -208,7 +212,6 @@ class CheckDefaultBrowserObserver |
private: |
void SetDefaultWebClientUIState( |
shell_integration::DefaultWebClientUIState state) override; |
- bool IsOwnedByWorker() override; |
void ResetCheckDefaultBrowserPref(); |
void ShowPrompt(); |
@@ -242,11 +245,6 @@ void CheckDefaultBrowserObserver::SetDefaultWebClientUIState( |
} |
} |
-bool CheckDefaultBrowserObserver::IsOwnedByWorker() { |
- // Instruct the DefaultBrowserWorker to delete this instance when it is done. |
- return true; |
-} |
- |
void CheckDefaultBrowserObserver::ResetCheckDefaultBrowserPref() { |
Profile* profile = |
g_browser_process->profile_manager()->GetProfileByPath(profile_path_); |
@@ -317,7 +315,8 @@ void ShowDefaultBrowserPrompt(Profile* profile) { |
scoped_refptr<shell_integration::DefaultBrowserWorker>( |
new shell_integration::DefaultBrowserWorker( |
- new CheckDefaultBrowserObserver(profile->GetPath(), show_prompt))) |
+ new CheckDefaultBrowserObserver(profile->GetPath(), show_prompt), |
+ /*delete_observer=*/true)) |
->StartCheckIsDefault(); |
} |