Index: chrome/browser/ui/views/profiles/forced_reauthentication_dialog.cc |
diff --git a/chrome/browser/ui/views/profiles/forced_reauthentication_dialog.cc b/chrome/browser/ui/views/profiles/forced_reauthentication_dialog.cc |
index d02b9265849fc78e230351abdbc301786206f4d5..de07c556adb784495f79b4e806113ae598162cee 100644 |
--- a/chrome/browser/ui/views/profiles/forced_reauthentication_dialog.cc |
+++ b/chrome/browser/ui/views/profiles/forced_reauthentication_dialog.cc |
@@ -4,6 +4,7 @@ |
#include "chrome/browser/ui/views/profiles/forced_reauthentication_dialog.h" |
+#include <map> |
#include <memory> |
#include <string> |
#include <utility> |
@@ -13,6 +14,7 @@ |
#include "base/strings/utf_string_conversions.h" |
#include "chrome/browser/profiles/profile.h" |
#include "chrome/browser/ui/browser.h" |
+#include "chrome/browser/ui/browser_dialogs.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" |
@@ -36,6 +38,9 @@ namespace { |
// Refresh title of the dialog every second. |
constexpr int kRefreshTitleTimer = 1; |
+base::LazyInstance<std::map<Profile*, ForcedReauthenticationDialog*>>:: |
+ DestructorAtExit g_dialogs = LAZY_INSTANCE_INITIALIZER; |
+ |
// If browser windows are going to be closed soon, close browser window before |
// showing sign in dialog because there might not be enough time for user to |
// finish sign in. |
@@ -96,7 +101,9 @@ ForcedReauthenticationDialog::ForcedReauthenticationDialog( |
browser->window()->Activate(); |
} |
-ForcedReauthenticationDialog::~ForcedReauthenticationDialog() {} |
+ForcedReauthenticationDialog::~ForcedReauthenticationDialog() { |
+ g_dialogs.Get().erase(browser_->profile()); |
+} |
// static |
ForcedReauthenticationDialog* ForcedReauthenticationDialog::ShowDialog( |
@@ -110,8 +117,10 @@ ForcedReauthenticationDialog* ForcedReauthenticationDialog::ShowDialog( |
return nullptr; |
} |
- return new ForcedReauthenticationDialog(browser, signin_manager, |
- countdown_duration); |
+ ForcedReauthenticationDialog* dialog = new ForcedReauthenticationDialog( |
+ browser, signin_manager, countdown_duration); |
+ g_dialogs.Get()[profile] = dialog; |
+ return dialog; |
} |
bool ForcedReauthenticationDialog::Accept() { |
@@ -248,3 +257,21 @@ base::TimeDelta ForcedReauthenticationDialog::GetTimeRemaining() const { |
return base::TimeDelta(); |
return desired_close_time_ - now; |
} |
+ |
+namespace chrome { |
+void ShowForcedReauthenticationDialog( |
+ Profile* profile, |
+ SigninManager* signin_manager, |
+ const base::TimeDelta& countdown_duration) { |
+ ForcedReauthenticationDialog::ShowDialog(profile, signin_manager, |
+ countdown_duration); |
+} |
+ |
+void HideForcedReauthenticationDialog(Profile* profile) { |
+ auto it = g_dialogs.Get().find(profile); |
+ if (it != g_dialogs.Get().end()) { |
+ it->second->GetWidget()->Close(); |
+ } |
+} |
+ |
+} // namespace chrome |