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

Side by Side Diff: chrome/browser/ui/views/profiles/forced_reauthentication_dialog.h

Issue 2944713003: After signin token check failed, show force reauth dialog and start window closing countdown. (Closed)
Patch Set: delegate 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 unified diff | Download patch
OLDNEW
1 // Copyright 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_UI_VIEWS_PROFILES_FORCED_REAUTHENTICATION_DIALOG_H_ 5 #ifndef CHROME_BROWSER_UI_VIEWS_PROFILES_FORCED_REAUTHENTICATION_DIALOG_H_
6 #define CHROME_BROWSER_UI_VIEWS_PROFILES_FORCED_REAUTHENTICATION_DIALOG_H_ 6 #define CHROME_BROWSER_UI_VIEWS_PROFILES_FORCED_REAUTHENTICATION_DIALOG_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 10
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "base/memory/weak_ptr.h"
13 #include "base/timer/timer.h" 14 #include "base/timer/timer.h"
14 #include "ui/views/controls/button/button.h" 15 #include "ui/views/controls/button/button.h"
15 #include "ui/views/window/dialog_delegate.h" 16 #include "ui/views/window/dialog_delegate.h"
16 17
17 class Browser; 18 class Browser;
18 class Profile; 19 class Profile;
19 class SigninManager; 20 class SigninManager;
20 21
21 // A modal dialog that displays a warning message of the auth failure 22 // A modal dialog that displays a warning message of the auth failure
22 // and ask user to sign in again. 23 // and ask user to sign in again.
23 class ForcedReauthenticationDialog : public views::DialogDelegateView { 24 class ForcedReauthenticationDialog : public views::DialogDelegateView {
24 public: 25 public:
25 ~ForcedReauthenticationDialog() override; 26 ~ForcedReauthenticationDialog() override;
26 27
27 // Shows a warning dialog for |profile|. If there are no Browser windows 28 // Shows a warning dialog for |profile|. If there are no Browser windows
28 // associated with |profile|, signs out the profile immediately, otherwise the 29 // associated with |profile|, signs out the profile immediately, otherwise the
29 // user can clicks accept to sign in again. Dialog will be closed after 30 // user can clicks accept to sign in again. Dialog will be closed after
30 // |countdown_duration| seconds. 31 // |countdown_duration| seconds.
31 // Dialog will delete itself after closing. 32 // Dialog will delete itself after closing.
32 static ForcedReauthenticationDialog* ShowDialog( 33 static ForcedReauthenticationDialog* ShowDialog(
33 Profile* profile, 34 Profile* profile,
34 SigninManager* signin_manager, 35 SigninManager* signin_manager,
35 const base::TimeDelta& countdown_duration); 36 base::TimeDelta countdown_duration);
36 37
37 // override views::DialogDelegateView 38 // override views::DialogDelegateView
38 bool Accept() override; 39 bool Accept() override;
39 bool Cancel() override; 40 bool Cancel() override;
40 void WindowClosing() override; 41 void WindowClosing() override;
41 base::string16 GetWindowTitle() const override; 42 base::string16 GetWindowTitle() const override;
42 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override; 43 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
43 ui::ModalType GetModalType() const override; 44 ui::ModalType GetModalType() const override;
44 45
45 // override views::View 46 // override views::View
46 void AddedToWidget() override; 47 void AddedToWidget() override;
47 48
49 // Close the dialog
50 void CloseDialog();
51
52 base::WeakPtr<ForcedReauthenticationDialog> AsWeakPtr() {
53 return weak_factory_.GetWeakPtr();
54 }
55
48 private: 56 private:
49 // Show the dialog for |browser|. The dialog will delete itself after closing. 57 // Show the dialog for |browser|. The dialog will delete itself after closing.
50 ForcedReauthenticationDialog(Browser* browser, 58 ForcedReauthenticationDialog(Browser* browser,
51 SigninManager* signin_manager, 59 SigninManager* signin_manager,
52 const base::TimeDelta& countdown_duration); 60 base::TimeDelta countdown_duration);
53 61
54 void OnCountDown(); 62 void OnCountDown();
55 base::TimeDelta GetTimeRemaining() const; 63 base::TimeDelta GetTimeRemaining() const;
56 64
57 Browser* browser_; 65 Browser* browser_;
58 SigninManager* signin_manager_; 66 SigninManager* signin_manager_;
59 67
60 const base::TimeTicks desired_close_time_; 68 const base::TimeTicks desired_close_time_;
61 69
62 // The timer which is used to refresh the dialog title to display the 70 // The timer which is used to refresh the dialog title to display the
63 // remaining time. 71 // remaining time.
64 base::RepeatingTimer refresh_timer_; 72 base::RepeatingTimer refresh_timer_;
65 73
74 base::WeakPtrFactory<ForcedReauthenticationDialog> weak_factory_;
75
66 DISALLOW_COPY_AND_ASSIGN(ForcedReauthenticationDialog); 76 DISALLOW_COPY_AND_ASSIGN(ForcedReauthenticationDialog);
67 }; 77 };
68 78
69 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_FORCED_REAUTHENTICATION_DIALOG_H_ 79 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_FORCED_REAUTHENTICATION_DIALOG_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698