Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(206)

Unified Diff: chrome/browser/ui/webui/signin/profile_signin_confirmation_dialog.cc

Issue 14846020: Add Views implementation of ProfileSigninConfirmationDialog. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: more nits Created 7 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..eebfecddb4b9c707e5242494847151aace786ce1 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,9 +21,7 @@
#include "grit/generated_resources.h"
#include "ui/base/l10n/l10n_util.h"
-namespace content {
-class WebContents;
-}
+// ProfileSigninConfirmationHandler --------------------------------------------
namespace {
@@ -55,8 +50,6 @@ class ProfileSigninConfirmationHandler : public content::WebUIMessageHandler {
base::Closure continue_signin_;
};
-} // namespace
-
ProfileSigninConfirmationHandler::ProfileSigninConfirmationHandler(
const ProfileSigninConfirmationDialog* dialog,
const base::Closure& cancel_signin,
@@ -72,13 +65,16 @@ ProfileSigninConfirmationHandler::~ProfileSigninConfirmationHandler() {
}
void ProfileSigninConfirmationHandler::RegisterMessages() {
- web_ui()->RegisterMessageCallback("cancel",
+ web_ui()->RegisterMessageCallback(
+ "cancel",
base::Bind(&ProfileSigninConfirmationHandler::OnCancelButtonClicked,
base::Unretained(this)));
- web_ui()->RegisterMessageCallback("createNewProfile",
+ web_ui()->RegisterMessageCallback(
+ "createNewProfile",
base::Bind(&ProfileSigninConfirmationHandler::OnCreateProfileClicked,
base::Unretained(this)));
- web_ui()->RegisterMessageCallback("continue",
+ web_ui()->RegisterMessageCallback(
+ "continue",
base::Bind(&ProfileSigninConfirmationHandler::OnContinueButtonClicked,
base::Unretained(this)));
}
@@ -102,42 +98,75 @@ void ProfileSigninConfirmationHandler::OnContinueButtonClicked(
dialog_->Close();
}
-void ProfileSigninConfirmationDialog::ShowDialog(
+} // 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(profile,
- username,
- cancel_signin,
- signin_with_new_profile,
- continue_signin);
- ui::CheckShouldPromptForNewProfile(
- profile,
- base::Bind(&ProfileSigninConfirmationDialog::Show,
- dialog->weak_pointer_factory_.GetWeakPtr()));
-}
+ ProfileSigninConfirmationDialog::ShowDialog(web_contents,
+ profile,
+ username,
+ cancel_signin,
+ signin_with_new_profile,
+ continue_signin);
+}
+} // namespace chrome
+#endif
+
+// ProfileSigninConfirmationDialog ---------------------------------------------
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 +174,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 +182,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 {

Powered by Google App Engine
This is Rietveld 408576698