Chromium Code Reviews| 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_FORCE_SIGNOUT_DIALOG_H_ | |
| 6 #define CHROME_BROWSER_UI_VIEWS_PROFILES_FORCE_SIGNOUT_DIALOG_H_ | |
| 7 | |
| 8 #include <memory> | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/callback.h" | |
| 12 #include "base/macros.h" | |
| 13 #include "chrome/browser/ui/browser_list_observer.h" | |
| 14 #include "chrome/browser/ui/views/browser_modal_dialog.h" | |
| 15 #include "ui/views/controls/button/button.h" | |
| 16 #include "ui/views/window/dialog_delegate.h" | |
| 17 | |
| 18 class Browser; | |
| 19 class Profile; | |
| 20 class SigninManager; | |
| 21 | |
| 22 // A modal dialog that displays a warning message of the auth failure | |
| 23 // before signing the user out and closing browser windows. | |
| 24 class ForceSignoutDialog : public BrowserModalDialog, | |
| 25 public chrome::BrowserListObserver, | |
| 26 public views::DialogDelegateView { | |
| 27 public: | |
| 28 // Callback when user confirm/cancel the dialog. True if the dialog is | |
| 29 // confirmed. | |
| 30 using SignoutCallback = base::Callback<void(bool)>; | |
|
sky
2017/05/18 16:50:51
Use OnceCallback.
| |
| 31 | |
| 32 // Show the dialog for |browser|, call signout_callback after the dialog is | |
| 33 // confirmed or canceled by user. | |
| 34 ForceSignoutDialog(Browser* browser, | |
| 35 SigninManager* signin_manager, | |
| 36 const SignoutCallback& signout_callback, | |
| 37 bool delay_allowed); | |
|
sky
2017/05/18 16:50:51
I was confused by the name delay_allowed. How abou
| |
| 38 ~ForceSignoutDialog() override; | |
| 39 | |
| 40 // Shows a warning dialog for |profile|. If there are no Browser windows | |
| 41 // associated with |profile| this signs out the profile immediately, otherwise | |
| 42 // the user clicks accept or cancel on the dialog. Sign out the profile if | |
| 43 // user confirmed the window or sign out the profile with a delay if | |
| 44 // |delay_allow| is true. Call |signout_callback| with false if user cancel | |
| 45 // the dialog, otherwise call it with true. | |
| 46 static ForceSignoutDialog* ShowDialog(Profile* profile, | |
| 47 SigninManager* signin_manager, | |
| 48 const SignoutCallback& signout_callback, | |
| 49 bool delay_allowed); | |
| 50 | |
| 51 // override BrowserModalDialog | |
| 52 void ActivateModalDialog(Browser* browser) override; | |
| 53 bool IsShowing() override; | |
| 54 | |
| 55 // override chrome::BrowserListObserver | |
| 56 void OnBrowserRemoved(Browser* browser) override; | |
| 57 | |
| 58 // override views::DialogDelegateView | |
| 59 bool Accept() override; | |
| 60 bool Cancel() override; | |
| 61 base::string16 GetWindowTitle() const override; | |
| 62 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override; | |
| 63 int GetDialogButtons() const override; | |
| 64 ui::ModalType GetModalType() const override; | |
| 65 | |
| 66 // override views::View | |
| 67 void AddedToWidget() override; | |
| 68 | |
| 69 private: | |
| 70 Browser* browser_; | |
| 71 SigninManager* signin_manager_; | |
| 72 const SignoutCallback signout_callback_; | |
| 73 bool delay_allowed_; | |
| 74 | |
| 75 DISALLOW_COPY_AND_ASSIGN(ForceSignoutDialog); | |
| 76 }; | |
| 77 | |
| 78 #endif // CHROME_BROWSER_UI_VIEWS_PROFILES_FORCE_SIGNOUT_DIALOG_H_ | |
| OLD | NEW |