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

Unified Diff: chrome/browser/ui/views/profiles/forced_reauthentication_dialog.cc

Issue 2944713003: After signin token check failed, show force reauth dialog and start window closing countdown. (Closed)
Patch Set: rebase from master Created 3 years, 6 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
« chrome/browser/ui/browser_dialogs.h ('K') | « chrome/browser/ui/browser_dialogs.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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
« chrome/browser/ui/browser_dialogs.h ('K') | « chrome/browser/ui/browser_dialogs.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698