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..325017b33245a0b9dda242090b873f2a66b8854f 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 { |
| @@ -57,6 +50,35 @@ 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* 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))); |
| +} |
| +} // namespace chrome |
| +#endif |
| + |
| ProfileSigninConfirmationHandler::ProfileSigninConfirmationHandler( |
| const ProfileSigninConfirmationDialog* dialog, |
| const base::Closure& cancel_signin, |
| @@ -102,37 +124,21 @@ 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), |
|
Peter Kasting
2013/05/15 00:11:03
Tiny nit: It would be nice if this function's arg
dconnelly
2013/05/17 13:01:55
Done.
|
| + delegate_(NULL), |
| + username_(username), |
| + prompt_for_new_profile_(ui::PROMPT_TO_CREATE_PROFILE), |
| 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() { |
| @@ -143,26 +149,10 @@ void ProfileSigninConfirmationDialog::Close() const { |
| delegate_->OnDialogCloseFromWebUI(); |
| } |
| -void ProfileSigninConfirmationDialog::Show(bool prompt) { |
| +void ProfileSigninConfirmationDialog::Show( |
| + ui::DisplayCreateProfilePrompt 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 { |
| @@ -194,7 +184,8 @@ void ProfileSigninConfirmationDialog::GetDialogSize(gfx::Size* size) const { |
| #else |
| const int kMinimumDialogHeight = 210; |
| #endif |
| - const int kProfileCreationMessageHeight = prompt_for_new_profile_ ? 50 : 0; |
| + const int kProfileCreationMessageHeight = |
| + prompt_for_new_profile_ == ui::PROMPT_TO_CREATE_PROFILE ? 50 : 0; |
| size->SetSize(kMinimumDialogWidth, |
| kMinimumDialogHeight + kProfileCreationMessageHeight); |
| } |
| @@ -203,7 +194,8 @@ std::string ProfileSigninConfirmationDialog::GetDialogArgs() const { |
| std::string data; |
| base::DictionaryValue dict; |
| dict.SetString("username", username_); |
| - dict.SetBoolean("promptForNewProfile", prompt_for_new_profile_); |
| + dict.SetBoolean("promptForNewProfile", |
| + prompt_for_new_profile_ == ui::PROMPT_TO_CREATE_PROFILE); |
| #if defined(OS_WIN) |
| dict.SetBoolean("hideTitle", true); |
| #endif |