1 // Copyright 2020 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_EXTENSIONS_SETTINGS_OVERRIDDEN_DIALOG_VIEW_H_
6 #define CHROME_BROWSER_UI_VIEWS_EXTENSIONS_SETTINGS_OVERRIDDEN_DIALOG_VIEW_H_
7 
8 #include <memory>
9 
10 #include "base/optional.h"
11 #include "chrome/browser/ui/extensions/settings_overridden_dialog_controller.h"
12 #include "ui/gfx/native_widget_types.h"
13 #include "ui/views/window/dialog_delegate.h"
14 
15 // A dialog that displays a warning to the user that their settings have been
16 // overridden by an extension.
17 class SettingsOverriddenDialogView : public views::DialogDelegateView {
18  public:
19   explicit SettingsOverriddenDialogView(
20       std::unique_ptr<SettingsOverriddenDialogController> controller);
21   SettingsOverriddenDialogView(const SettingsOverriddenDialogView&) = delete;
22   SettingsOverriddenDialogView& operator=(const SettingsOverriddenDialogView&) =
23       delete;
24   ~SettingsOverriddenDialogView() override;
25 
26   // Displays the dialog with the given |parent|.
27   void Show(gfx::NativeWindow parent);
28 
29  private:
30   // views::DialogDelegateView:
31   ui::ModalType GetModalType() const override;
32   gfx::Size CalculatePreferredSize() const override;
33 
34   // Notifies the |controller_| of the |result|.
35   void NotifyControllerOfResult(
36       SettingsOverriddenDialogController::DialogResult result);
37 
38   // The result of the dialog; set when notifying the controller.
39   base::Optional<SettingsOverriddenDialogController::DialogResult> result_;
40 
41   std::unique_ptr<SettingsOverriddenDialogController> controller_;
42 };
43 
44 #endif  // CHROME_BROWSER_UI_VIEWS_EXTENSIONS_SETTINGS_OVERRIDDEN_DIALOG_VIEW_H_
45