| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CHROME_BROWSER_UI_VIEWS_PROFILES_FORCED_REAUTHENTICATION_DIALOG_H_ | |
| 6 #define CHROME_BROWSER_UI_VIEWS_PROFILES_FORCED_REAUTHENTICATION_DIALOG_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/callback.h" | |
| 12 #include "base/macros.h" | |
| 13 #include "base/timer/timer.h" | |
| 14 #include "ui/views/controls/button/button.h" | |
| 15 #include "ui/views/window/dialog_delegate.h" | |
| 16 | |
| 17 class Browser; | |
| 18 class Profile; | |
| 19 class SigninManager; | |
| 20 | |
| 21 // A modal dialog that displays a warning message of the auth failure | |
| 22 // and ask user to sign in again. | |
| 23 class ForcedReauthenticationDialog : public views::DialogDelegateView { | |
| 24 public: | |
| 25 ~ForcedReauthenticationDialog() override; | |
| 26 | |
| 27 // Shows a warning dialog for |profile|. If there are no Browser windows | |
| 28 // 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 // |countdown_duration| seconds. | |
| 31 // Dialog will delete itself after closing. | |
| 32 static ForcedReauthenticationDialog* ShowDialog( | |
| 33 Profile* profile, | |
| 34 SigninManager* signin_manager, | |
| 35 const base::TimeDelta& countdown_duration); | |
| 36 | |
| 37 // override views::DialogDelegateView | |
| 38 bool Accept() override; | |
| 39 bool Cancel() override; | |
| 40 void WindowClosing() override; | |
| 41 base::string16 GetWindowTitle() const override; | |
| 42 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override; | |
| 43 ui::ModalType GetModalType() const override; | |
| 44 | |
| 45 // override views::View | |
| 46 void AddedToWidget() override; | |
| 47 | |
| 48 private: | |
| 49 // Show the dialog for |browser|. The dialog will delete itself after closing. | |
| 50 ForcedReauthenticationDialog(Browser* browser, | |
| 51 SigninManager* signin_manager, | |
| 52 const base::TimeDelta& countdown_duration); | |
| 53 | |
| 54 void OnCountDown(); | |
| 55 base::TimeDelta GetTimeRemaining() const; | |
| 56 | |
| 57 Browser* browser_; | |
| 58 SigninManager* signin_manager_; | |
| 59 | |
| 60 const base::TimeTicks desired_close_time_; | |
| 61 | |
| 62 // The timer which is used to refresh the dialog title to display the | |
| 63 // remaining time. | |
| 64 base::RepeatingTimer refresh_timer_; | |
| 65 | |
| 66 DISALLOW_COPY_AND_ASSIGN(ForcedReauthenticationDialog); | |
| 67 }; | |
| 68 | |
| 69 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_FORCED_REAUTHENTICATION_DIALOG_H_ | |
| OLD | NEW |