Chromium Code Reviews| Index: chrome/browser/ui/webui/signin/profile_signin_confirmation_dialog.cc |
| diff --git a/chrome/browser/ui/webui/signin/profile_signin_confirmation_dialog.cc b/chrome/browser/ui/webui/signin/profile_signin_confirmation_dialog.cc |
| index 94a426760e1ff3a0ec5e44238ca41fb6f023205c..a38895e09a0be4e911d7ccc7647fb4d9c4f11e5a 100644 |
| --- a/chrome/browser/ui/webui/signin/profile_signin_confirmation_dialog.cc |
| +++ b/chrome/browser/ui/webui/signin/profile_signin_confirmation_dialog.cc |
| @@ -12,7 +12,7 @@ |
| #include "chrome/browser/ui/browser.h" |
| #include "chrome/browser/ui/browser_dialogs.h" |
| #include "chrome/browser/ui/browser_finder.h" |
| -#include "chrome/browser/ui/browser_list.h" |
| +#include "chrome/browser/ui/browser_window.h" |
| #include "chrome/browser/ui/sync/profile_signin_confirmation_helper.h" |
| #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" |
| @@ -57,6 +57,32 @@ class ProfileSigninConfirmationHandler : public content::WebUIMessageHandler { |
| } // namespace |
| +#if !defined(TOOLKIT_VIEWS) |
| +namespace chrome { |
| +// static |
| +// Declared in browser_dialogs.h |
| +void ShowProfileSigninConfirmationDialog( |
| + Profile* profile, |
| + const std::string& username, |
| + const base::Closure& cancel_signin, |
| + const base::Closure& signin_with_new_profile, |
| + const base::Closure& continue_signin) { |
| + ProfileSigninConfirmationDialog* dialog = |
| + new ProfileSigninConfirmationDialog(profile, |
| + username, |
| + cancel_signin, |
| + signin_with_new_profile, |
| + continue_signin); |
| + ui::CheckShouldPromptForNewProfile( |
| + profile, |
| + // This callback is guaranteed to be invoked, and once it is, the dialog |
| + // owns itself. |
| + base::Bind(&ProfileSigninConfirmationDialog::Show, |
| + base::Unretained(dialog))); |
| +} |
| +} // namespace chrome |
| +#endif |
| + |
| ProfileSigninConfirmationHandler::ProfileSigninConfirmationHandler( |
| const ProfileSigninConfirmationDialog* dialog, |
| const base::Closure& cancel_signin, |
| @@ -102,37 +128,19 @@ void ProfileSigninConfirmationHandler::OnContinueButtonClicked( |
| dialog_->Close(); |
| } |
| -void ProfileSigninConfirmationDialog::ShowDialog( |
| - Profile* profile, |
| - const std::string& username, |
| - const base::Closure& cancel_signin, |
| - const base::Closure& signin_with_new_profile, |
| - const base::Closure& continue_signin) { |
| - ProfileSigninConfirmationDialog *dialog = |
| - new ProfileSigninConfirmationDialog(profile, |
| - username, |
| - cancel_signin, |
| - signin_with_new_profile, |
| - continue_signin); |
| - ui::CheckShouldPromptForNewProfile( |
| - profile, |
| - base::Bind(&ProfileSigninConfirmationDialog::Show, |
| - dialog->weak_pointer_factory_.GetWeakPtr())); |
| -} |
| - |
| ProfileSigninConfirmationDialog::ProfileSigninConfirmationDialog( |
| Profile* profile, |
| const std::string& username, |
| const base::Closure& cancel_signin, |
| const base::Closure& signin_with_new_profile, |
| const base::Closure& continue_signin) |
| - : username_(username), |
| + : delegate_(NULL), |
| + username_(username), |
| prompt_for_new_profile_(true), |
| cancel_signin_(cancel_signin), |
| signin_with_new_profile_(signin_with_new_profile), |
| continue_signin_(continue_signin), |
| - profile_(profile), |
| - weak_pointer_factory_(this) { |
| + profile_(profile) { |
| } |
| ProfileSigninConfirmationDialog::~ProfileSigninConfirmationDialog() { |
| @@ -144,24 +152,23 @@ void ProfileSigninConfirmationDialog::Close() const { |
| } |
| void ProfileSigninConfirmationDialog::Show(bool prompt) { |
| - prompt_for_new_profile_ = prompt; |
| - |
| Browser* browser = FindBrowserWithProfile(profile_, |
| chrome::GetActiveDesktop()); |
| if (!browser) { |
| DLOG(WARNING) << "No browser found to display the confirmation dialog"; |
| cancel_signin_.Run(); |
| + delete this; |
|
James Hawkins
2013/05/07 17:22:44
This is really fragile. Don't we have a ScopedDel
dconnelly
2013/05/07 17:31:30
I don't know anything about that, but it sounds go
dconnelly
2013/05/13 14:45:21
No longer needed
|
| return; |
| } |
| - |
| content::WebContents* web_contents = |
| browser->tab_strip_model()->GetActiveWebContents(); |
| if (!web_contents) { |
| DLOG(WARNING) << "No web contents found to display the confirmation dialog"; |
| cancel_signin_.Run(); |
| + delete this; |
| return; |
| } |
| - |
| + prompt_for_new_profile_ = prompt; |
| delegate_ = CreateConstrainedWebDialog(profile_, this, NULL, web_contents); |
| } |