Update {virtual,override,final} to follow C++11 style in chrome/browser/chromeos...
[chromium-blink-merge.git] / chrome / browser / chromeos / options / network_config_view.h
blob2de514e5ea0006fa34176ba3c5810939859df160
1 // Copyright (c) 2012 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.
5 #ifndef CHROME_BROWSER_CHROMEOS_OPTIONS_NETWORK_CONFIG_VIEW_H_
6 #define CHROME_BROWSER_CHROMEOS_OPTIONS_NETWORK_CONFIG_VIEW_H_
8 #include <string>
10 #include "base/compiler_specific.h"
11 #include "base/strings/string16.h"
12 #include "ui/gfx/native_widget_types.h" // gfx::NativeWindow
13 #include "ui/views/controls/button/button.h" // views::ButtonListener
14 #include "ui/views/window/dialog_delegate.h"
16 namespace gfx {
17 class ImageSkia;
20 namespace views {
21 class ImageView;
22 class LabelButton;
25 namespace chromeos {
27 class ChildNetworkConfigView;
28 class NetworkPropertyUIData;
29 class NetworkState;
31 // A dialog box for showing a password textfield.
32 class NetworkConfigView : public views::DialogDelegateView,
33 public views::ButtonListener {
34 public:
35 class Delegate {
36 public:
37 // Called when dialog "OK" button is pressed.
38 virtual void OnDialogAccepted() = 0;
40 // Called when dialog "Cancel" button is pressed.
41 virtual void OnDialogCancelled() = 0;
43 protected:
44 virtual ~Delegate() {}
47 // Shows a network connection dialog if none is currently visible.
48 static void Show(const std::string& service_path, gfx::NativeWindow parent);
49 // Shows a dialog to configure a new network. |type| must be a valid Shill
50 // 'Type' property value.
51 static void ShowForType(const std::string& type, gfx::NativeWindow parent);
53 // Returns corresponding native window.
54 gfx::NativeWindow GetNativeWindow() const;
56 // views::DialogDelegate methods.
57 base::string16 GetDialogButtonLabel(ui::DialogButton button) const override;
58 bool IsDialogButtonEnabled(ui::DialogButton button) const override;
59 bool Cancel() override;
60 bool Accept() override;
61 views::View* CreateExtraView() override;
62 views::View* GetInitiallyFocusedView() override;
64 // views::WidgetDelegate methods.
65 base::string16 GetWindowTitle() const override;
66 ui::ModalType GetModalType() const override;
68 // views::View overrides.
69 void GetAccessibleState(ui::AXViewState* state) override;
71 // views::ButtonListener overrides.
72 void ButtonPressed(views::Button* sender, const ui::Event& event) override;
74 void set_delegate(Delegate* delegate) {
75 delegate_ = delegate;
78 protected:
79 // views::View overrides:
80 void Layout() override;
81 gfx::Size GetPreferredSize() const override;
82 void ViewHierarchyChanged(
83 const ViewHierarchyChangedDetails& details) override;
85 private:
86 NetworkConfigView();
87 ~NetworkConfigView() override;
89 // Login dialog for known networks. Returns true if successfully created.
90 bool InitWithNetworkState(const NetworkState* network);
91 // Login dialog for new/hidden networks. Returns true if successfully created.
92 bool InitWithType(const std::string& type);
94 // Creates and shows a dialog containing this view.
95 void ShowDialog(gfx::NativeWindow parent);
97 // Resets the underlying view to show advanced options.
98 void ShowAdvancedView();
100 // There's always only one child view, which will get deleted when
101 // NetworkConfigView gets cleaned up.
102 ChildNetworkConfigView* child_config_view_;
104 Delegate* delegate_;
106 // Button in lower-left corner, may be null or hidden.
107 views::LabelButton* advanced_button_;
109 DISALLOW_COPY_AND_ASSIGN(NetworkConfigView);
112 // Children of NetworkConfigView must subclass this and implement the virtual
113 // methods, which are called by NetworkConfigView.
114 class ChildNetworkConfigView : public views::View {
115 public:
116 // If |service_path| is NULL, a dialog for configuring a new network will
117 // be created.
118 ChildNetworkConfigView(NetworkConfigView* parent,
119 const std::string& service_path);
120 ~ChildNetworkConfigView() override;
122 // Get the title to show for the dialog.
123 virtual base::string16 GetTitle() const = 0;
125 // Returns view that should be focused on dialog activation.
126 virtual views::View* GetInitiallyFocusedView() = 0;
128 // Called to determine if "Connect" button should be enabled.
129 virtual bool CanLogin() = 0;
131 // Called when "Connect" button is clicked.
132 // Should return false if dialog should remain open.
133 virtual bool Login() = 0;
135 // Called when "Cancel" button is clicked.
136 virtual void Cancel() = 0;
138 // Called to set focus when view is recreated with the same dialog
139 // being active. For example, clicking on "Advanced" button.
140 virtual void InitFocus() = 0;
142 // Returns 'true' if the dialog is for configuration only (default is false).
143 virtual bool IsConfigureDialog();
145 // Minimum with of input fields / combo boxes.
146 static const int kInputFieldMinWidth;
148 protected:
149 // Gets the default network share state for the current login state.
150 static void GetShareStateForLoginState(bool* default_value, bool* modifiable);
152 NetworkConfigView* parent_;
153 std::string service_path_;
155 private:
156 DISALLOW_COPY_AND_ASSIGN(ChildNetworkConfigView);
159 // Shows an icon with tooltip indicating whether a setting is under policy
160 // control.
161 class ControlledSettingIndicatorView : public views::View {
162 public:
163 ControlledSettingIndicatorView();
164 explicit ControlledSettingIndicatorView(const NetworkPropertyUIData& ui_data);
165 ~ControlledSettingIndicatorView() override;
167 // Updates the view based on |ui_data|.
168 void Update(const NetworkPropertyUIData& ui_data);
170 protected:
171 // views::View:
172 gfx::Size GetPreferredSize() const override;
173 void Layout() override;
175 private:
176 // Initializes the view.
177 void Init();
179 bool managed_;
180 views::ImageView* image_view_;
181 const gfx::ImageSkia* image_;
183 DISALLOW_COPY_AND_ASSIGN(ControlledSettingIndicatorView);
186 } // namespace chromeos
188 #endif // CHROME_BROWSER_CHROMEOS_OPTIONS_NETWORK_CONFIG_VIEW_H_