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..04f84cdbb6cf6610091e1ac075f21da44852b1f3 100644 |
| --- a/chrome/browser/ui/webui/signin/profile_signin_confirmation_dialog.cc |
| +++ b/chrome/browser/ui/webui/signin/profile_signin_confirmation_dialog.cc |
| @@ -11,10 +11,7 @@ |
| #include "chrome/browser/profiles/profile_manager.h" |
| #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/sync/profile_signin_confirmation_helper.h" |
| -#include "chrome/browser/ui/tabs/tab_strip_model.h" |
| +#include "chrome/browser/ui/browser_window.h" |
| #include "chrome/browser/ui/webui/constrained_web_dialog_ui.h" |
| #include "chrome/common/url_constants.h" |
| #include "content/public/browser/web_ui.h" |
| @@ -24,10 +21,6 @@ |
| #include "grit/generated_resources.h" |
| #include "ui/base/l10n/l10n_util.h" |
| -namespace content { |
| -class WebContents; |
| -} |
| - |
| namespace { |
| class ProfileSigninConfirmationHandler : public content::WebUIMessageHandler { |
|
Peter Kasting
2013/05/28 23:25:11
Nit: Since you have multiple classes in this file,
dconnelly
2013/05/29 16:46:14
Done.
|
| @@ -57,6 +50,28 @@ class ProfileSigninConfirmationHandler : public content::WebUIMessageHandler { |
| } // namespace |
| +#if !defined(TOOLKIT_VIEWS) |
| +namespace chrome { |
| +// static |
| +// Declared in browser_dialogs.h |
| +void ShowProfileSigninConfirmationDialog( |
| + Browser* browser, |
| + content::WebContents* web_contents, |
| + Profile* profile, |
| + const std::string& username, |
| + const base::Closure& cancel_signin, |
| + const base::Closure& signin_with_new_profile, |
| + const base::Closure& continue_signin) { |
| + ProfileSigninConfirmationDialog::ShowDialog(web_contents, |
| + profile, |
| + username, |
| + cancel_signin, |
| + signin_with_new_profile, |
| + continue_signin); |
| +} |
| +} // namespace chrome |
| +#endif |
| + |
| ProfileSigninConfirmationHandler::ProfileSigninConfirmationHandler( |
|
Peter Kasting
2013/05/28 23:25:11
Nit: Put these function definitions next to the cl
dconnelly
2013/05/29 16:46:14
Done.
|
| const ProfileSigninConfirmationDialog* dialog, |
| const base::Closure& cancel_signin, |
| @@ -102,42 +117,49 @@ 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( |
| + content::WebContents* web_contents, |
| 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), |
| - prompt_for_new_profile_(true), |
| + : web_contents_(web_contents), |
| + profile_(profile), |
| + username_(username), |
| cancel_signin_(cancel_signin), |
| signin_with_new_profile_(signin_with_new_profile), |
| continue_signin_(continue_signin), |
| - profile_(profile), |
| - weak_pointer_factory_(this) { |
| + delegate_(NULL), |
| + prompt_for_new_profile_(true) { |
| } |
| ProfileSigninConfirmationDialog::~ProfileSigninConfirmationDialog() { |
| } |
| +// static |
| +void ProfileSigninConfirmationDialog::ShowDialog( |
| + content::WebContents* web_contents, |
| + 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(web_contents, |
| + 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))); |
| +} |
| + |
| void ProfileSigninConfirmationDialog::Close() const { |
| closed_by_handler_ = true; |
| delegate_->OnDialogCloseFromWebUI(); |
| @@ -145,24 +167,7 @@ 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(); |
| - 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(); |
| - return; |
| - } |
| - |
| - delegate_ = CreateConstrainedWebDialog(profile_, this, NULL, web_contents); |
| + delegate_ = CreateConstrainedWebDialog(profile_, this, NULL, web_contents_); |
| } |
| ui::ModalType ProfileSigninConfirmationDialog::GetDialogModalType() const { |
| @@ -170,8 +175,7 @@ ui::ModalType ProfileSigninConfirmationDialog::GetDialogModalType() const { |
| } |
| string16 ProfileSigninConfirmationDialog::GetDialogTitle() const { |
| - return l10n_util::GetStringUTF16( |
| - IDS_ENTERPRISE_SIGNIN_PROFILE_LINK_DIALOG_TITLE); |
| + return l10n_util::GetStringUTF16(IDS_ENTERPRISE_SIGNIN_TITLE); |
| } |
| GURL ProfileSigninConfirmationDialog::GetDialogContentURL() const { |