Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(230)

Side by Side Diff: chrome/browser/chromeos/options/network_config_view.h

Issue 21046008: Convert all connect code to use NetworkHandler instead of NetworkLibrary (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef CHROME_BROWSER_CHROMEOS_OPTIONS_NETWORK_CONFIG_VIEW_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_OPTIONS_NETWORK_CONFIG_VIEW_H_
6 #define CHROME_BROWSER_CHROMEOS_OPTIONS_NETWORK_CONFIG_VIEW_H_ 6 #define CHROME_BROWSER_CHROMEOS_OPTIONS_NETWORK_CONFIG_VIEW_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/strings/string16.h" 11 #include "base/strings/string16.h"
12 #include "chrome/browser/chromeos/cros/network_library.h"
13 #include "ui/gfx/native_widget_types.h" // gfx::NativeWindow 12 #include "ui/gfx/native_widget_types.h" // gfx::NativeWindow
14 #include "ui/views/controls/button/button.h" // views::ButtonListener 13 #include "ui/views/controls/button/button.h" // views::ButtonListener
15 #include "ui/views/window/dialog_delegate.h" 14 #include "ui/views/window/dialog_delegate.h"
16 15
17 namespace gfx { 16 namespace gfx {
18 class ImageSkia; 17 class ImageSkia;
19 } 18 }
20 19
21 namespace views { 20 namespace views {
22 class ImageView; 21 class ImageView;
23 class LabelButton; 22 class LabelButton;
24 } 23 }
25 24
26 namespace chromeos { 25 namespace chromeos {
27 26
28 class ChildNetworkConfigView; 27 class ChildNetworkConfigView;
29 class NetworkPropertyUIData; 28 class NetworkPropertyUIData;
29 class NetworkState;
30 30
31 // A dialog box for showing a password textfield. 31 // A dialog box for showing a password textfield.
32 class NetworkConfigView : public views::DialogDelegateView, 32 class NetworkConfigView : public views::DialogDelegateView,
33 public views::ButtonListener { 33 public views::ButtonListener {
34 public: 34 public:
35 class Delegate { 35 class Delegate {
36 public: 36 public:
37 // Called when dialog "OK" button is pressed. 37 // Called when dialog "OK" button is pressed.
38 virtual void OnDialogAccepted() = 0; 38 virtual void OnDialogAccepted() = 0;
39 39
40 // Called when dialog "Cancel" button is pressed. 40 // Called when dialog "Cancel" button is pressed.
41 virtual void OnDialogCancelled() = 0; 41 virtual void OnDialogCancelled() = 0;
42 42
43 protected: 43 protected:
44 virtual ~Delegate() {} 44 virtual ~Delegate() {}
45 }; 45 };
46 46
47 // Shows a network connection dialog if none is currently visible. 47 // Shows a network connection dialog if none is currently visible.
48 static void Show(Network* network, gfx::NativeWindow parent); 48 static void Show(const std::string& service_path, gfx::NativeWindow parent);
49 static void ShowForType(ConnectionType type, gfx::NativeWindow parent); 49 // Shows a dialog to configure a new network. |type| must be a valid Shill
50 static void ShowForPath(const std::string& path, gfx::NativeWindow parent); 50 // 'Type' property value.
51 static void ShowForType(const std::string& type, gfx::NativeWindow parent);
51 52
52 // Returns corresponding native window. 53 // Returns corresponding native window.
53 gfx::NativeWindow GetNativeWindow() const; 54 gfx::NativeWindow GetNativeWindow() const;
54 55
55 // views::DialogDelegate methods. 56 // views::DialogDelegate methods.
56 virtual string16 GetDialogButtonLabel(ui::DialogButton button) const OVERRIDE; 57 virtual string16 GetDialogButtonLabel(ui::DialogButton button) const OVERRIDE;
57 virtual bool IsDialogButtonEnabled(ui::DialogButton button) const OVERRIDE; 58 virtual bool IsDialogButtonEnabled(ui::DialogButton button) const OVERRIDE;
58 virtual bool Cancel() OVERRIDE; 59 virtual bool Cancel() OVERRIDE;
59 virtual bool Accept() OVERRIDE; 60 virtual bool Accept() OVERRIDE;
60 virtual views::View* CreateExtraView() OVERRIDE; 61 virtual views::View* CreateExtraView() OVERRIDE;
61 virtual views::View* GetInitiallyFocusedView() OVERRIDE; 62 virtual views::View* GetInitiallyFocusedView() OVERRIDE;
62 63
63 // views::WidgetDelegate methods. 64 // views::WidgetDelegate methods.
64 virtual string16 GetWindowTitle() const OVERRIDE; 65 virtual string16 GetWindowTitle() const OVERRIDE;
65 virtual ui::ModalType GetModalType() const OVERRIDE; 66 virtual ui::ModalType GetModalType() const OVERRIDE;
66 67
67 // views::View overrides. 68 // views::View overrides.
68 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; 69 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
69 70
70 // views::ButtonListener overrides. 71 // views::ButtonListener overrides.
71 virtual void ButtonPressed( 72 virtual void ButtonPressed(
72 views::Button* sender, const ui::Event& event) OVERRIDE; 73 views::Button* sender, const ui::Event& event) OVERRIDE;
73 74
74 void set_delegate(Delegate* delegate) { 75 void set_delegate(Delegate* delegate) {
75 delegate_ = delegate; 76 delegate_ = delegate;
76 } 77 }
77 78
78 static const base::DictionaryValue* FindPolicyForActiveUser(
79 const Network* network,
80 onc::ONCSource* onc_source);
81
82 protected: 79 protected:
83 // views::View overrides: 80 // views::View overrides:
84 virtual void Layout() OVERRIDE; 81 virtual void Layout() OVERRIDE;
85 virtual gfx::Size GetPreferredSize() OVERRIDE; 82 virtual gfx::Size GetPreferredSize() OVERRIDE;
86 virtual void ViewHierarchyChanged( 83 virtual void ViewHierarchyChanged(
87 const ViewHierarchyChangedDetails& details) OVERRIDE; 84 const ViewHierarchyChangedDetails& details) OVERRIDE;
88 85
89 private: 86 private:
87 NetworkConfigView();
88 virtual ~NetworkConfigView();
89
90 // Login dialog for known networks. 90 // Login dialog for known networks.
91 explicit NetworkConfigView(Network* network); 91 void InitWithNetworkState(const NetworkState* network);
92 // Login dialog for new/hidden networks. 92 // Login dialog for new/hidden networks.
93 explicit NetworkConfigView(ConnectionType type); 93 void InitWithType(const std::string& type);
94 virtual ~NetworkConfigView();
95 94
96 // Creates and shows a dialog containing this view. 95 // Creates and shows a dialog containing this view.
97 void ShowDialog(gfx::NativeWindow parent); 96 void ShowDialog(gfx::NativeWindow parent);
98 97
99 // Resets the underlying view to show advanced options. 98 // Resets the underlying view to show advanced options.
100 void ShowAdvancedView(); 99 void ShowAdvancedView();
101 100
102 // There's always only one child view, which will get deleted when 101 // There's always only one child view, which will get deleted when
103 // NetworkConfigView gets cleaned up. 102 // NetworkConfigView gets cleaned up.
104 ChildNetworkConfigView* child_config_view_; 103 ChildNetworkConfigView* child_config_view_;
105 104
106 Delegate* delegate_; 105 Delegate* delegate_;
107 106
108 // Button in lower-left corner, may be null or hidden. 107 // Button in lower-left corner, may be null or hidden.
109 views::LabelButton* advanced_button_; 108 views::LabelButton* advanced_button_;
110 109
111 DISALLOW_COPY_AND_ASSIGN(NetworkConfigView); 110 DISALLOW_COPY_AND_ASSIGN(NetworkConfigView);
112 }; 111 };
113 112
114 // Children of NetworkConfigView must subclass this and implement the virtual 113 // Children of NetworkConfigView must subclass this and implement the virtual
115 // methods, which are called by NetworkConfigView. 114 // methods, which are called by NetworkConfigView.
116 class ChildNetworkConfigView : public views::View { 115 class ChildNetworkConfigView : public views::View {
117 public: 116 public:
118 ChildNetworkConfigView(NetworkConfigView* parent, Network* network) 117 // If |service_path| is NULL, a dialog for configuring a new network will
119 : service_path_(network->service_path()), 118 // be created.
120 parent_(parent) {} 119 ChildNetworkConfigView(NetworkConfigView* parent,
121 explicit ChildNetworkConfigView(NetworkConfigView* parent) 120 const std::string& service_path);
122 : parent_(parent) {} 121 virtual ~ChildNetworkConfigView();
123 virtual ~ChildNetworkConfigView() {}
124 122
125 // Get the title to show for the dialog. 123 // Get the title to show for the dialog.
126 virtual string16 GetTitle() const = 0; 124 virtual string16 GetTitle() const = 0;
127 125
128 // Returns view that should be focused on dialog activation. 126 // Returns view that should be focused on dialog activation.
129 virtual views::View* GetInitiallyFocusedView() = 0; 127 virtual views::View* GetInitiallyFocusedView() = 0;
130 128
131 // Called to determine if "Connect" button should be enabled. 129 // Called to determine if "Connect" button should be enabled.
132 virtual bool CanLogin() = 0; 130 virtual bool CanLogin() = 0;
133 131
134 // Called when "Connect" button is clicked. 132 // Called when "Connect" button is clicked.
135 // Should return false if dialog should remain open. 133 // Should return false if dialog should remain open.
136 virtual bool Login() = 0; 134 virtual bool Login() = 0;
137 135
138 // Called when "Cancel" button is clicked. 136 // Called when "Cancel" button is clicked.
139 virtual void Cancel() = 0; 137 virtual void Cancel() = 0;
140 138
141 // Called to set focus when view is recreated with the same dialog 139 // Called to set focus when view is recreated with the same dialog
142 // being active. For example, clicking on "Advanced" button. 140 // being active. For example, clicking on "Advanced" button.
143 virtual void InitFocus() = 0; 141 virtual void InitFocus() = 0;
144 142
145 // Minimum with of input fields / combo boxes. 143 // Minimum with of input fields / combo boxes.
146 static const int kInputFieldMinWidth; 144 static const int kInputFieldMinWidth;
147 145
148 protected: 146 protected:
147 NetworkConfigView* parent_;
149 std::string service_path_; 148 std::string service_path_;
150 NetworkConfigView* parent_;
151 149
152 private: 150 private:
153 DISALLOW_COPY_AND_ASSIGN(ChildNetworkConfigView); 151 DISALLOW_COPY_AND_ASSIGN(ChildNetworkConfigView);
154 }; 152 };
155 153
156 // Shows an icon with tooltip indicating whether a setting is under policy 154 // Shows an icon with tooltip indicating whether a setting is under policy
157 // control. 155 // control.
158 class ControlledSettingIndicatorView : public views::View { 156 class ControlledSettingIndicatorView : public views::View {
159 public: 157 public:
160 ControlledSettingIndicatorView(); 158 ControlledSettingIndicatorView();
(...skipping 18 matching lines...) Expand all
179 views::ImageView* image_view_; 177 views::ImageView* image_view_;
180 const gfx::ImageSkia* gray_image_; 178 const gfx::ImageSkia* gray_image_;
181 const gfx::ImageSkia* color_image_; 179 const gfx::ImageSkia* color_image_;
182 180
183 DISALLOW_COPY_AND_ASSIGN(ControlledSettingIndicatorView); 181 DISALLOW_COPY_AND_ASSIGN(ControlledSettingIndicatorView);
184 }; 182 };
185 183
186 } // namespace chromeos 184 } // namespace chromeos
187 185
188 #endif // CHROME_BROWSER_CHROMEOS_OPTIONS_NETWORK_CONFIG_VIEW_H_ 186 #endif // CHROME_BROWSER_CHROMEOS_OPTIONS_NETWORK_CONFIG_VIEW_H_
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/network_login_observer.cc ('k') | chrome/browser/chromeos/options/network_config_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698