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

Side by Side Diff: chrome/browser/chromeos/options/vpn_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_VPN_CONFIG_VIEW_H_ 5 #ifndef CHROME_BROWSER_CHROMEOS_OPTIONS_VPN_CONFIG_VIEW_H_
6 #define CHROME_BROWSER_CHROMEOS_OPTIONS_VPN_CONFIG_VIEW_H_ 6 #define CHROME_BROWSER_CHROMEOS_OPTIONS_VPN_CONFIG_VIEW_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
11 #include "base/strings/string16.h" 11 #include "base/strings/string16.h"
12 #include "chrome/browser/chromeos/cros/cert_library.h" 12 #include "chrome/browser/chromeos/cros/cert_library.h"
13 #include "chrome/browser/chromeos/cros/network_property_ui_data.h" 13 #include "chrome/browser/chromeos/cros/network_property_ui_data.h"
14 #include "chrome/browser/chromeos/options/network_config_view.h" 14 #include "chrome/browser/chromeos/options/network_config_view.h"
15 #include "chrome/browser/chromeos/options/passphrase_textfield.h" 15 #include "chrome/browser/chromeos/options/passphrase_textfield.h"
16 #include "ui/views/controls/button/button.h" 16 #include "ui/views/controls/button/button.h"
17 #include "ui/views/controls/combobox/combobox_listener.h" 17 #include "ui/views/controls/combobox/combobox_listener.h"
18 #include "ui/views/controls/textfield/textfield_controller.h" 18 #include "ui/views/controls/textfield/textfield_controller.h"
19 #include "ui/views/view.h" 19 #include "ui/views/view.h"
20 20
21 namespace base {
22 class DictionaryValue;
23 }
24
21 namespace views { 25 namespace views {
22 class Checkbox; 26 class Checkbox;
27 class GridLayout;
23 class Label; 28 class Label;
24 } 29 }
25 30
26 namespace chromeos { 31 namespace chromeos {
27 32
33 class NetworkState;
34
28 namespace internal { 35 namespace internal {
29 class ProviderTypeComboboxModel; 36 class ProviderTypeComboboxModel;
30 class VpnServerCACertComboboxModel; 37 class VpnServerCACertComboboxModel;
31 class VpnUserCertComboboxModel; 38 class VpnUserCertComboboxModel;
32 } 39 }
33 40
34 // A dialog box to allow configuration of VPN connection. 41 // A dialog box to allow configuration of VPN connection.
35 class VPNConfigView : public ChildNetworkConfigView, 42 class VPNConfigView : public ChildNetworkConfigView,
36 public views::TextfieldController, 43 public views::TextfieldController,
37 public views::ButtonListener, 44 public views::ButtonListener,
38 public views::ComboboxListener, 45 public views::ComboboxListener,
39 public CertLibrary::Observer { 46 public CertLibrary::Observer,
47 public base::SupportsWeakPtr<VPNConfigView> {
pneubeck (no reviews) 2013/08/06 15:45:19 please use the WeakPtrFactory, since it's not used
stevenjb 2013/08/06 20:23:55 Meh. There are no member dependencies and it's mor
40 public: 48 public:
41 VPNConfigView(NetworkConfigView* parent, VirtualNetwork* vpn); 49 VPNConfigView(NetworkConfigView* parent, const std::string& service_path);
42 explicit VPNConfigView(NetworkConfigView* parent);
43 virtual ~VPNConfigView(); 50 virtual ~VPNConfigView();
44 51
45 // views::TextfieldController: 52 // views::TextfieldController:
46 virtual void ContentsChanged(views::Textfield* sender, 53 virtual void ContentsChanged(views::Textfield* sender,
47 const string16& new_contents) OVERRIDE; 54 const string16& new_contents) OVERRIDE;
48 virtual bool HandleKeyEvent(views::Textfield* sender, 55 virtual bool HandleKeyEvent(views::Textfield* sender,
49 const ui::KeyEvent& key_event) OVERRIDE; 56 const ui::KeyEvent& key_event) OVERRIDE;
50 57
51 // views::ButtonListener: 58 // views::ButtonListener:
52 virtual void ButtonPressed(views::Button* sender, 59 virtual void ButtonPressed(views::Button* sender,
53 const ui::Event& event) OVERRIDE; 60 const ui::Event& event) OVERRIDE;
54 61
55 // views::ComboboxListener: 62 // views::ComboboxListener:
56 virtual void OnSelectedIndexChanged(views::Combobox* combobox) OVERRIDE; 63 virtual void OnSelectedIndexChanged(views::Combobox* combobox) OVERRIDE;
57 64
58 // CertLibrary::Observer: 65 // CertLibrary::Observer:
59 virtual void OnCertificatesLoaded(bool initial_load) OVERRIDE; 66 virtual void OnCertificatesLoaded(bool initial_load) OVERRIDE;
60 67
61 // ChildNetworkConfigView: 68 // ChildNetworkConfigView:
62 virtual string16 GetTitle() const OVERRIDE; 69 virtual string16 GetTitle() const OVERRIDE;
63 virtual views::View* GetInitiallyFocusedView() OVERRIDE; 70 virtual views::View* GetInitiallyFocusedView() OVERRIDE;
64 virtual bool CanLogin() OVERRIDE; 71 virtual bool CanLogin() OVERRIDE;
65 virtual bool Login() OVERRIDE; 72 virtual bool Login() OVERRIDE;
66 virtual void Cancel() OVERRIDE; 73 virtual void Cancel() OVERRIDE;
67 virtual void InitFocus() OVERRIDE; 74 virtual void InitFocus() OVERRIDE;
68 75
69 private: 76 private:
70 // Initializes data members and create UI controls. 77 // Initializes data members and create UI controls.
pneubeck (no reviews) 2013/08/06 15:45:19 separate the comment.
stevenjb 2013/08/06 20:23:55 Combined the functions, the separation ended up be
71 void Init(VirtualNetwork* vpn); 78 void Init();
79 void InitControls();
pneubeck (no reviews) 2013/08/06 15:45:19 comment that this sets up all controls but without
stevenjb 2013/08/06 20:23:55 Ditto
80
81 // Callback to initialize fields from uncached network properties.
82 void InitFromProperties(const std::string& service_path,
83 const base::DictionaryValue& dictionary);
84 void ParseUIProperties(const NetworkState* vpn, int provider_type_index);
85 void GetPropertiesError(const std::string& error_name,
86 scoped_ptr<base::DictionaryValue> error_data);
87
88 // Helper function to set credential properties.
89 void SetCredentials(base::DictionaryValue* properties);
72 90
73 // Set and update all control values. 91 // Set and update all control values.
74 void Refresh(); 92 void Refresh();
75 93
76 // Update various controls. 94 // Update various controls.
77 void UpdateControlsToEnable(); 95 void UpdateControlsToEnable();
78 void UpdateControls(); 96 void UpdateControls();
79 void UpdateErrorLabel(); 97 void UpdateErrorLabel();
80 98
81 // Update state of the Login button. 99 // Update state of the Login button.
82 void UpdateCanLogin(); 100 void UpdateCanLogin();
83 101
84 // Returns true if the provider type requires a user certificate.
85 bool UserCertRequired() const;
86
87 // Returns true if there is at least one user certificate installed. 102 // Returns true if there is at least one user certificate installed.
88 bool HaveUserCerts() const; 103 bool HaveUserCerts() const;
89 104
90 // Returns true if there is a selected user certificate and it is valid. 105 // Returns true if there is a selected user certificate and it is valid.
91 bool IsUserCertValid() const; 106 bool IsUserCertValid() const;
92 107
93 // Get text from input field. 108 // Get text from input field.
94 const std::string GetTextFromField(views::Textfield* textfield, 109 const std::string GetTextFromField(views::Textfield* textfield,
95 bool trim_whitespace) const; 110 bool trim_whitespace) const;
96 111
97 // Get passphrase from input field. 112 // Get passphrase from input field.
98 const std::string GetPassphraseFromField( 113 const std::string GetPassphraseFromField(
99 PassphraseTextfield* textfield) const; 114 PassphraseTextfield* textfield) const;
100 115
101 // Convenience methods to get text from input field or cached VirtualNetwork. 116 // Convenience methods to get text from input field or cached VirtualNetwork.
102 const std::string GetService() const; 117 const std::string GetService() const;
103 const std::string GetServer() const; 118 const std::string GetServer() const;
104 const std::string GetPSKPassphrase() const; 119 const std::string GetPSKPassphrase() const;
105 const std::string GetUsername() const; 120 const std::string GetUsername() const;
106 const std::string GetUserPassphrase() const; 121 const std::string GetUserPassphrase() const;
107 const std::string GetOTP() const; 122 const std::string GetOTP() const;
108 const std::string GetGroupName() const; 123 const std::string GetGroupName() const;
109 const std::string GetServerCACertPEM() const; 124 const std::string GetServerCACertPEM() const;
110 const std::string GetUserCertID() const; 125 const std::string GetUserCertID() const;
111 bool GetSaveCredentials() const; 126 bool GetSaveCredentials() const;
127 int GetProviderTypeIndex() const;
128 std::string GetProviderTypeString() const;
112 129
113 // Parses a VPN UI |property| from the given |network|. |key| is the property 130 // Parses a VPN UI |property| from the given |network|. |key| is the property
114 // name within the type-specific VPN subdictionary named |dict_key|. 131 // name within the type-specific VPN subdictionary named |dict_key|.
115 void ParseVPNUIProperty(NetworkPropertyUIData* property_ui_data, 132 void ParseVPNUIProperty(const NetworkState* network,
116 Network* network,
117 const std::string& dict_key, 133 const std::string& dict_key,
118 const std::string& key); 134 const std::string& key,
135 NetworkPropertyUIData* property_ui_data);
119 136
120 std::string server_hostname_;
121 string16 service_name_from_server_; 137 string16 service_name_from_server_;
122 bool service_text_modified_; 138 bool service_text_modified_;
123 139
124 // Initialized in Init(): 140 // Initialized in Init():
125 141
126 ProviderType provider_type_; 142 std::string provider_type_;
pneubeck (no reviews) 2013/08/06 15:45:19 comment that it's only set if modifying an existin
stevenjb 2013/08/06 20:23:55 Done.
127 143
128 bool enable_psk_passphrase_; 144 bool enable_psk_passphrase_;
129 bool enable_user_cert_; 145 bool enable_user_cert_;
130 bool enable_server_ca_cert_; 146 bool enable_server_ca_cert_;
131 bool enable_otp_; 147 bool enable_otp_;
132 bool enable_group_name_; 148 bool enable_group_name_;
133 149
134 NetworkPropertyUIData ca_cert_ui_data_; 150 NetworkPropertyUIData ca_cert_ui_data_;
135 NetworkPropertyUIData psk_passphrase_ui_data_; 151 NetworkPropertyUIData psk_passphrase_ui_data_;
136 NetworkPropertyUIData user_cert_ui_data_; 152 NetworkPropertyUIData user_cert_ui_data_;
137 NetworkPropertyUIData username_ui_data_; 153 NetworkPropertyUIData username_ui_data_;
138 NetworkPropertyUIData user_passphrase_ui_data_; 154 NetworkPropertyUIData user_passphrase_ui_data_;
139 NetworkPropertyUIData group_name_ui_data_; 155 NetworkPropertyUIData group_name_ui_data_;
140 NetworkPropertyUIData save_credentials_ui_data_; 156 NetworkPropertyUIData save_credentials_ui_data_;
141 157
142 int title_; 158 int title_;
143 159
160 views::GridLayout* layout_;
144 views::Textfield* server_textfield_; 161 views::Textfield* server_textfield_;
145 views::Label* service_text_; 162 views::Label* service_text_;
146 views::Textfield* service_textfield_; 163 views::Textfield* service_textfield_;
147 scoped_ptr<internal::ProviderTypeComboboxModel> provider_type_combobox_model_; 164 scoped_ptr<internal::ProviderTypeComboboxModel> provider_type_combobox_model_;
148 views::Combobox* provider_type_combobox_; 165 views::Combobox* provider_type_combobox_;
149 views::Label* provider_type_text_label_; 166 views::Label* provider_type_text_label_;
150 views::Label* psk_passphrase_label_; 167 views::Label* psk_passphrase_label_;
151 PassphraseTextfield* psk_passphrase_textfield_; 168 PassphraseTextfield* psk_passphrase_textfield_;
152 views::Label* user_cert_label_; 169 views::Label* user_cert_label_;
153 scoped_ptr<internal::VpnUserCertComboboxModel> user_cert_combobox_model_; 170 scoped_ptr<internal::VpnUserCertComboboxModel> user_cert_combobox_model_;
154 views::Combobox* user_cert_combobox_; 171 views::Combobox* user_cert_combobox_;
155 views::Label* server_ca_cert_label_; 172 views::Label* server_ca_cert_label_;
156 scoped_ptr<internal::VpnServerCACertComboboxModel> 173 scoped_ptr<internal::VpnServerCACertComboboxModel>
157 server_ca_cert_combobox_model_; 174 server_ca_cert_combobox_model_;
158 views::Combobox* server_ca_cert_combobox_; 175 views::Combobox* server_ca_cert_combobox_;
159 views::Textfield* username_textfield_; 176 views::Textfield* username_textfield_;
160 PassphraseTextfield* user_passphrase_textfield_; 177 PassphraseTextfield* user_passphrase_textfield_;
161 views::Label* otp_label_; 178 views::Label* otp_label_;
162 views::Textfield* otp_textfield_; 179 views::Textfield* otp_textfield_;
163 views::Label* group_name_label_; 180 views::Label* group_name_label_;
164 views::Textfield* group_name_textfield_; 181 views::Textfield* group_name_textfield_;
165 views::Checkbox* save_credentials_checkbox_; 182 views::Checkbox* save_credentials_checkbox_;
166 views::Label* error_label_; 183 views::Label* error_label_;
167 184
185 // Cached VPN properties
pneubeck (no reviews) 2013/08/06 15:45:19 mention, that it's only set if modifying an existi
stevenjb 2013/08/06 20:23:55 Done.
186 std::string ca_cert_pem_;
187 std::string client_cert_id_;
188
168 DISALLOW_COPY_AND_ASSIGN(VPNConfigView); 189 DISALLOW_COPY_AND_ASSIGN(VPNConfigView);
169 }; 190 };
170 191
171 } // namespace chromeos 192 } // namespace chromeos
172 193
173 #endif // CHROME_BROWSER_CHROMEOS_OPTIONS_VPN_CONFIG_VIEW_H_ 194 #endif // CHROME_BROWSER_CHROMEOS_OPTIONS_VPN_CONFIG_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698