Chromium Code Reviews| Index: chrome/browser/ui/views/profiles/force_signout_dialog.h |
| diff --git a/chrome/browser/ui/views/profiles/force_signout_dialog.h b/chrome/browser/ui/views/profiles/force_signout_dialog.h |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..85e383dd2557ae588e6a04d4600caa8598ab18c7 |
| --- /dev/null |
| +++ b/chrome/browser/ui/views/profiles/force_signout_dialog.h |
| @@ -0,0 +1,78 @@ |
| +// Copyright 2017 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#ifndef CHROME_BROWSER_UI_VIEWS_PROFILES_FORCE_SIGNOUT_DIALOG_H_ |
| +#define CHROME_BROWSER_UI_VIEWS_PROFILES_FORCE_SIGNOUT_DIALOG_H_ |
| + |
| +#include <memory> |
| +#include <string> |
| + |
| +#include "base/callback.h" |
| +#include "base/macros.h" |
| +#include "chrome/browser/ui/browser_list_observer.h" |
| +#include "chrome/browser/ui/views/browser_modal_dialog.h" |
| +#include "ui/views/controls/button/button.h" |
| +#include "ui/views/window/dialog_delegate.h" |
| + |
| +class Browser; |
| +class Profile; |
| +class SigninManager; |
| + |
| +// A modal dialog that displays a warning message of the auth failure |
| +// before signing the user out and closing browser windows. |
| +class ForceSignoutDialog : public BrowserModalDialog, |
| + public chrome::BrowserListObserver, |
| + public views::DialogDelegateView { |
| + public: |
| + // Callback when user confirm/cancel the dialog. True if the dialog is |
| + // confirmed. |
| + using SignoutCallback = base::Callback<void(bool)>; |
|
sky
2017/05/18 16:50:51
Use OnceCallback.
|
| + |
| + // Show the dialog for |browser|, call signout_callback after the dialog is |
| + // confirmed or canceled by user. |
| + ForceSignoutDialog(Browser* browser, |
| + SigninManager* signin_manager, |
| + const SignoutCallback& signout_callback, |
| + bool delay_allowed); |
|
sky
2017/05/18 16:50:51
I was confused by the name delay_allowed. How abou
|
| + ~ForceSignoutDialog() override; |
| + |
| + // Shows a warning dialog for |profile|. If there are no Browser windows |
| + // associated with |profile| this signs out the profile immediately, otherwise |
| + // the user clicks accept or cancel on the dialog. Sign out the profile if |
| + // user confirmed the window or sign out the profile with a delay if |
| + // |delay_allow| is true. Call |signout_callback| with false if user cancel |
| + // the dialog, otherwise call it with true. |
| + static ForceSignoutDialog* ShowDialog(Profile* profile, |
| + SigninManager* signin_manager, |
| + const SignoutCallback& signout_callback, |
| + bool delay_allowed); |
| + |
| + // override BrowserModalDialog |
| + void ActivateModalDialog(Browser* browser) override; |
| + bool IsShowing() override; |
| + |
| + // override chrome::BrowserListObserver |
| + void OnBrowserRemoved(Browser* browser) override; |
| + |
| + // override views::DialogDelegateView |
| + bool Accept() override; |
| + bool Cancel() override; |
| + base::string16 GetWindowTitle() const override; |
| + base::string16 GetDialogButtonLabel(ui::DialogButton button) const override; |
| + int GetDialogButtons() const override; |
| + ui::ModalType GetModalType() const override; |
| + |
| + // override views::View |
| + void AddedToWidget() override; |
| + |
| + private: |
| + Browser* browser_; |
| + SigninManager* signin_manager_; |
| + const SignoutCallback signout_callback_; |
| + bool delay_allowed_; |
| + |
| + DISALLOW_COPY_AND_ASSIGN(ForceSignoutDialog); |
| +}; |
| + |
| +#endif // CHROME_BROWSER_UI_VIEWS_PROFILES_FORCE_SIGNOUT_DIALOG_H_ |