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

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: Feedback Round 1 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;
(...skipping 15 matching lines...) Expand all
38 virtual void OnDialogAccepted() = 0; 37 virtual void OnDialogAccepted() = 0;
39 38
40 // Called when dialog "Cancel" button is pressed. 39 // Called when dialog "Cancel" button is pressed.
41 virtual void OnDialogCancelled() = 0; 40 virtual void OnDialogCancelled() = 0;
42 41
43 protected: 42 protected:
44 virtual ~Delegate() {} 43 virtual ~Delegate() {}
45 }; 44 };
46 45
47 // Shows a network connection dialog if none is currently visible. 46 // Shows a network connection dialog if none is currently visible.
48 static void Show(Network* network, gfx::NativeWindow parent); 47 static void Show(const std::string& service_path, gfx::NativeWindow parent);
49 static void ShowForType(ConnectionType type, gfx::NativeWindow parent); 48 static void ShowForType(const std::string& type, gfx::NativeWindow parent);
pneubeck (no reviews) 2013/08/06 15:45:19 mention what format |type| is of. referring to Net
stevenjb 2013/08/06 20:23:55 Done.
50 static void ShowForPath(const std::string& path, gfx::NativeWindow parent);
51 49
52 // Returns corresponding native window. 50 // Returns corresponding native window.
53 gfx::NativeWindow GetNativeWindow() const; 51 gfx::NativeWindow GetNativeWindow() const;
54 52
55 // views::DialogDelegate methods. 53 // views::DialogDelegate methods.
56 virtual string16 GetDialogButtonLabel(ui::DialogButton button) const OVERRIDE; 54 virtual string16 GetDialogButtonLabel(ui::DialogButton button) const OVERRIDE;
57 virtual bool IsDialogButtonEnabled(ui::DialogButton button) const OVERRIDE; 55 virtual bool IsDialogButtonEnabled(ui::DialogButton button) const OVERRIDE;
58 virtual bool Cancel() OVERRIDE; 56 virtual bool Cancel() OVERRIDE;
59 virtual bool Accept() OVERRIDE; 57 virtual bool Accept() OVERRIDE;
60 virtual views::View* CreateExtraView() OVERRIDE; 58 virtual views::View* CreateExtraView() OVERRIDE;
61 virtual views::View* GetInitiallyFocusedView() OVERRIDE; 59 virtual views::View* GetInitiallyFocusedView() OVERRIDE;
62 60
63 // views::WidgetDelegate methods. 61 // views::WidgetDelegate methods.
64 virtual string16 GetWindowTitle() const OVERRIDE; 62 virtual string16 GetWindowTitle() const OVERRIDE;
65 virtual ui::ModalType GetModalType() const OVERRIDE; 63 virtual ui::ModalType GetModalType() const OVERRIDE;
66 64
67 // views::View overrides. 65 // views::View overrides.
68 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE; 66 virtual void GetAccessibleState(ui::AccessibleViewState* state) OVERRIDE;
69 67
70 // views::ButtonListener overrides. 68 // views::ButtonListener overrides.
71 virtual void ButtonPressed( 69 virtual void ButtonPressed(
72 views::Button* sender, const ui::Event& event) OVERRIDE; 70 views::Button* sender, const ui::Event& event) OVERRIDE;
73 71
74 void set_delegate(Delegate* delegate) { 72 void set_delegate(Delegate* delegate) {
75 delegate_ = delegate; 73 delegate_ = delegate;
76 } 74 }
77 75
78 static const base::DictionaryValue* FindPolicyForActiveUser(
79 const Network* network,
80 onc::ONCSource* onc_source);
81
82 protected: 76 protected:
83 // views::View overrides: 77 // views::View overrides:
84 virtual void Layout() OVERRIDE; 78 virtual void Layout() OVERRIDE;
85 virtual gfx::Size GetPreferredSize() OVERRIDE; 79 virtual gfx::Size GetPreferredSize() OVERRIDE;
86 virtual void ViewHierarchyChanged( 80 virtual void ViewHierarchyChanged(
87 const ViewHierarchyChangedDetails& details) OVERRIDE; 81 const ViewHierarchyChangedDetails& details) OVERRIDE;
88 82
89 private: 83 private:
84 NetworkConfigView();
85 virtual ~NetworkConfigView();
86
90 // Login dialog for known networks. 87 // Login dialog for known networks.
91 explicit NetworkConfigView(Network* network); 88 void InitWithPath(const std::string& service_path);
92 // Login dialog for new/hidden networks. 89 // Login dialog for new/hidden networks.
93 explicit NetworkConfigView(ConnectionType type); 90 void InitWithType(const std::string& type);
94 virtual ~NetworkConfigView();
95 91
96 // Creates and shows a dialog containing this view. 92 // Creates and shows a dialog containing this view.
97 void ShowDialog(gfx::NativeWindow parent); 93 void ShowDialog(gfx::NativeWindow parent);
98 94
99 // Resets the underlying view to show advanced options. 95 // Resets the underlying view to show advanced options.
100 void ShowAdvancedView(); 96 void ShowAdvancedView();
101 97
102 // There's always only one child view, which will get deleted when 98 // There's always only one child view, which will get deleted when
103 // NetworkConfigView gets cleaned up. 99 // NetworkConfigView gets cleaned up.
104 ChildNetworkConfigView* child_config_view_; 100 ChildNetworkConfigView* child_config_view_;
105 101
106 Delegate* delegate_; 102 Delegate* delegate_;
107 103
108 // Button in lower-left corner, may be null or hidden. 104 // Button in lower-left corner, may be null or hidden.
109 views::LabelButton* advanced_button_; 105 views::LabelButton* advanced_button_;
110 106
111 DISALLOW_COPY_AND_ASSIGN(NetworkConfigView); 107 DISALLOW_COPY_AND_ASSIGN(NetworkConfigView);
112 }; 108 };
113 109
114 // Children of NetworkConfigView must subclass this and implement the virtual 110 // Children of NetworkConfigView must subclass this and implement the virtual
115 // methods, which are called by NetworkConfigView. 111 // methods, which are called by NetworkConfigView.
116 class ChildNetworkConfigView : public views::View { 112 class ChildNetworkConfigView : public views::View {
117 public: 113 public:
118 ChildNetworkConfigView(NetworkConfigView* parent, Network* network) 114 ChildNetworkConfigView(NetworkConfigView* parent,
119 : service_path_(network->service_path()), 115 const std::string& service_path);
pneubeck (no reviews) 2013/08/06 15:45:19 mention that 'service_path' can be NULL, which mea
stevenjb 2013/08/06 20:23:55 Done.
120 parent_(parent) {} 116 virtual ~ChildNetworkConfigView();
121 explicit ChildNetworkConfigView(NetworkConfigView* parent)
122 : parent_(parent) {}
123 virtual ~ChildNetworkConfigView() {}
124 117
125 // Get the title to show for the dialog. 118 // Get the title to show for the dialog.
126 virtual string16 GetTitle() const = 0; 119 virtual string16 GetTitle() const = 0;
127 120
128 // Returns view that should be focused on dialog activation. 121 // Returns view that should be focused on dialog activation.
129 virtual views::View* GetInitiallyFocusedView() = 0; 122 virtual views::View* GetInitiallyFocusedView() = 0;
130 123
131 // Called to determine if "Connect" button should be enabled. 124 // Called to determine if "Connect" button should be enabled.
132 virtual bool CanLogin() = 0; 125 virtual bool CanLogin() = 0;
133 126
134 // Called when "Connect" button is clicked. 127 // Called when "Connect" button is clicked.
135 // Should return false if dialog should remain open. 128 // Should return false if dialog should remain open.
136 virtual bool Login() = 0; 129 virtual bool Login() = 0;
137 130
138 // Called when "Cancel" button is clicked. 131 // Called when "Cancel" button is clicked.
139 virtual void Cancel() = 0; 132 virtual void Cancel() = 0;
140 133
141 // Called to set focus when view is recreated with the same dialog 134 // Called to set focus when view is recreated with the same dialog
142 // being active. For example, clicking on "Advanced" button. 135 // being active. For example, clicking on "Advanced" button.
143 virtual void InitFocus() = 0; 136 virtual void InitFocus() = 0;
144 137
145 // Minimum with of input fields / combo boxes. 138 // Minimum with of input fields / combo boxes.
146 static const int kInputFieldMinWidth; 139 static const int kInputFieldMinWidth;
147 140
148 protected: 141 protected:
142 NetworkConfigView* parent_;
149 std::string service_path_; 143 std::string service_path_;
150 NetworkConfigView* parent_;
151 144
152 private: 145 private:
153 DISALLOW_COPY_AND_ASSIGN(ChildNetworkConfigView); 146 DISALLOW_COPY_AND_ASSIGN(ChildNetworkConfigView);
154 }; 147 };
155 148
156 // Shows an icon with tooltip indicating whether a setting is under policy 149 // Shows an icon with tooltip indicating whether a setting is under policy
157 // control. 150 // control.
158 class ControlledSettingIndicatorView : public views::View { 151 class ControlledSettingIndicatorView : public views::View {
159 public: 152 public:
160 ControlledSettingIndicatorView(); 153 ControlledSettingIndicatorView();
(...skipping 18 matching lines...) Expand all
179 views::ImageView* image_view_; 172 views::ImageView* image_view_;
180 const gfx::ImageSkia* gray_image_; 173 const gfx::ImageSkia* gray_image_;
181 const gfx::ImageSkia* color_image_; 174 const gfx::ImageSkia* color_image_;
182 175
183 DISALLOW_COPY_AND_ASSIGN(ControlledSettingIndicatorView); 176 DISALLOW_COPY_AND_ASSIGN(ControlledSettingIndicatorView);
184 }; 177 };
185 178
186 } // namespace chromeos 179 } // namespace chromeos
187 180
188 #endif // CHROME_BROWSER_CHROMEOS_OPTIONS_NETWORK_CONFIG_VIEW_H_ 181 #endif // CHROME_BROWSER_CHROMEOS_OPTIONS_NETWORK_CONFIG_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698