OLD | NEW |
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_WIFI_CONFIG_VIEW_H_ | 5 #ifndef CHROME_BROWSER_CHROMEOS_OPTIONS_WIFI_CONFIG_VIEW_H_ |
6 #define CHROME_BROWSER_CHROMEOS_OPTIONS_WIFI_CONFIG_VIEW_H_ | 6 #define CHROME_BROWSER_CHROMEOS_OPTIONS_WIFI_CONFIG_VIEW_H_ |
7 | 7 |
8 #include <string> | 8 #include <string> |
9 | 9 |
10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
11 #include "base/compiler_specific.h" | 11 #include "base/compiler_specific.h" |
12 #include "base/memory/scoped_ptr.h" | 12 #include "base/memory/scoped_ptr.h" |
| 13 #include "base/memory/weak_ptr.h" |
13 #include "base/strings/string16.h" | 14 #include "base/strings/string16.h" |
14 #include "chrome/browser/chromeos/cros/cert_library.h" | 15 #include "chrome/browser/chromeos/cros/cert_library.h" |
15 #include "chrome/browser/chromeos/cros/network_property_ui_data.h" | 16 #include "chrome/browser/chromeos/cros/network_property_ui_data.h" |
16 #include "chrome/browser/chromeos/options/network_config_view.h" | 17 #include "chrome/browser/chromeos/options/network_config_view.h" |
| 18 #include "third_party/cros_system_api/dbus/service_constants.h" |
17 #include "ui/base/models/combobox_model.h" | 19 #include "ui/base/models/combobox_model.h" |
18 #include "ui/views/controls/button/button.h" | 20 #include "ui/views/controls/button/button.h" |
19 #include "ui/views/controls/combobox/combobox_listener.h" | 21 #include "ui/views/controls/combobox/combobox_listener.h" |
20 #include "ui/views/controls/textfield/textfield_controller.h" | 22 #include "ui/views/controls/textfield/textfield_controller.h" |
21 #include "ui/views/view.h" | 23 #include "ui/views/view.h" |
22 | 24 |
23 namespace views { | 25 namespace views { |
24 class Checkbox; | 26 class Checkbox; |
25 class Label; | 27 class Label; |
26 class ToggleImageButton; | 28 class ToggleImageButton; |
27 } | 29 } |
28 | 30 |
29 namespace chromeos { | 31 namespace chromeos { |
30 | 32 |
| 33 class NetworkState; |
| 34 |
31 namespace internal { | 35 namespace internal { |
32 class EAPMethodComboboxModel; | 36 class EAPMethodComboboxModel; |
33 class Phase2AuthComboboxModel; | 37 class Phase2AuthComboboxModel; |
34 class SecurityComboboxModel; | 38 class SecurityComboboxModel; |
35 class ServerCACertComboboxModel; | 39 class ServerCACertComboboxModel; |
36 class UserCertComboboxModel; | 40 class UserCertComboboxModel; |
37 } | 41 } |
38 | 42 |
39 // A dialog box for showing a password textfield. | 43 // A dialog box for showing a password textfield. |
40 class WifiConfigView : public ChildNetworkConfigView, | 44 class WifiConfigView : public ChildNetworkConfigView, |
41 public views::TextfieldController, | 45 public views::TextfieldController, |
42 public views::ButtonListener, | 46 public views::ButtonListener, |
43 public views::ComboboxListener, | 47 public views::ComboboxListener, |
44 public CertLibrary::Observer { | 48 public CertLibrary::Observer { |
45 public: | 49 public: |
46 // Wifi login dialog for wifi network |wifi|. |wifi| must be a non NULL | 50 WifiConfigView(NetworkConfigView* parent, |
47 // pointer to a WifiNetwork in NetworkLibrary. | 51 const std::string& service_path, |
48 WifiConfigView(NetworkConfigView* parent, WifiNetwork* wifi); | 52 bool show_8021x); |
49 // Wifi login dialog for "Joining other network..." | |
50 WifiConfigView(NetworkConfigView* parent, bool show_8021x); | |
51 virtual ~WifiConfigView(); | 53 virtual ~WifiConfigView(); |
52 | 54 |
53 // views::TextfieldController: | 55 // views::TextfieldController: |
54 virtual void ContentsChanged(views::Textfield* sender, | 56 virtual void ContentsChanged(views::Textfield* sender, |
55 const string16& new_contents) OVERRIDE; | 57 const string16& new_contents) OVERRIDE; |
56 virtual bool HandleKeyEvent(views::Textfield* sender, | 58 virtual bool HandleKeyEvent(views::Textfield* sender, |
57 const ui::KeyEvent& key_event) OVERRIDE; | 59 const ui::KeyEvent& key_event) OVERRIDE; |
58 | 60 |
59 // views::ButtonListener: | 61 // views::ButtonListener: |
60 virtual void ButtonPressed(views::Button* sender, | 62 virtual void ButtonPressed(views::Button* sender, |
61 const ui::Event& event) OVERRIDE; | 63 const ui::Event& event) OVERRIDE; |
62 | 64 |
63 // views::ComboboxListener: | 65 // views::ComboboxListener: |
64 virtual void OnSelectedIndexChanged(views::Combobox* combobox) OVERRIDE; | 66 virtual void OnSelectedIndexChanged(views::Combobox* combobox) OVERRIDE; |
65 | 67 |
66 // CertLibrary::Observer: | 68 // CertLibrary::Observer: |
67 virtual void OnCertificatesLoaded(bool initial_load) OVERRIDE; | 69 virtual void OnCertificatesLoaded(bool initial_load) OVERRIDE; |
68 | 70 |
69 // ChildNetworkConfigView: | 71 // ChildNetworkConfigView: |
70 virtual string16 GetTitle() const OVERRIDE; | 72 virtual string16 GetTitle() const OVERRIDE; |
71 virtual views::View* GetInitiallyFocusedView() OVERRIDE; | 73 virtual views::View* GetInitiallyFocusedView() OVERRIDE; |
72 virtual bool CanLogin() OVERRIDE; | 74 virtual bool CanLogin() OVERRIDE; |
73 virtual bool Login() OVERRIDE; | 75 virtual bool Login() OVERRIDE; |
74 virtual void Cancel() OVERRIDE; | 76 virtual void Cancel() OVERRIDE; |
75 virtual void InitFocus() OVERRIDE; | 77 virtual void InitFocus() OVERRIDE; |
76 | 78 |
77 // Parses a WiFi UI |property| from the ONC associated with |network|. |key| | 79 // Parses a WiFi UI |property| from the ONC associated with |network|. |key| |
78 // is the property name within the ONC WiFi dictionary. | 80 // is the property name within the ONC WiFi dictionary. |
79 static void ParseWiFiUIProperty(NetworkPropertyUIData* property_ui_data, | 81 static void ParseWiFiUIProperty(NetworkPropertyUIData* property_ui_data, |
80 Network* network, | 82 const NetworkState* network, |
81 const std::string& key); | 83 const std::string& key); |
82 | 84 |
83 // Parses a WiFi EAP UI |property| from the ONC associated with |network|. | 85 // Parses a WiFi EAP UI |property| from the ONC associated with |network|. |
84 // |key| is the property name within the ONC WiFi.EAP dictionary. | 86 // |key| is the property name within the ONC WiFi.EAP dictionary. |
85 static void ParseWiFiEAPUIProperty(NetworkPropertyUIData* property_ui_data, | 87 static void ParseWiFiEAPUIProperty(NetworkPropertyUIData* property_ui_data, |
86 Network* network, | 88 const NetworkState* network, |
87 const std::string& key); | 89 const std::string& key); |
88 | 90 |
89 private: | 91 private: |
90 // Initializes UI. If |show_8021x| includes 802.1x config options. | 92 // Initializes UI. If |show_8021x| includes 802.1x config options. |
91 void Init(WifiNetwork* wifi, bool show_8021x); | 93 void Init(bool show_8021x); |
| 94 |
| 95 // Callback to initialize fields from uncached network properties. |
| 96 void InitFromProperties(bool show_8021x, |
| 97 const std::string& service_path, |
| 98 const base::DictionaryValue& dictionary); |
92 | 99 |
93 // Get input values. | 100 // Get input values. |
94 std::string GetSsid() const; | 101 std::string GetSsid() const; |
95 std::string GetPassphrase() const; | 102 std::string GetPassphrase() const; |
96 bool GetSaveCredentials() const; | 103 bool GetSaveCredentials() const; |
97 bool GetShareNetwork(bool share_default) const; | 104 bool GetShareNetwork(bool share_default) const; |
98 | 105 |
99 // Get various 802.1X EAP values from the widgets. | 106 // Get various 802.1X EAP values from the widgets. |
100 EAPMethod GetEapMethod() const; | 107 std::string GetEapMethod() const; |
101 EAPPhase2Auth GetEapPhase2Auth() const; | 108 std::string GetEapPhase2Auth() const; |
102 std::string GetEapServerCaCertPEM() const; | 109 std::string GetEapServerCaCertPEM() const; |
103 bool GetEapUseSystemCas() const; | 110 bool GetEapUseSystemCas() const; |
104 std::string GetEapClientCertPkcs11Id() const; | 111 std::string GetEapClientCertPkcs11Id() const; |
105 std::string GetEapIdentity() const; | 112 std::string GetEapIdentity() const; |
106 std::string GetEapAnonymousIdentity() const; | 113 std::string GetEapAnonymousIdentity() const; |
107 | 114 |
| 115 // Fill in |properties| with the appropriate values. |
| 116 void SetEapProperties(base::DictionaryValue* properties); |
| 117 |
108 // Returns true if the EAP method requires a user certificate. | 118 // Returns true if the EAP method requires a user certificate. |
109 bool UserCertRequired() const; | 119 bool UserCertRequired() const; |
110 | 120 |
111 // Returns true if at least one user certificate is installed. | 121 // Returns true if at least one user certificate is installed. |
112 bool HaveUserCerts() const; | 122 bool HaveUserCerts() const; |
113 | 123 |
114 // Returns true if there is a selected user certificate and it is valid. | 124 // Returns true if there is a selected user certificate and it is valid. |
115 bool IsUserCertValid() const; | 125 bool IsUserCertValid() const; |
116 | 126 |
117 // Returns true if the phase 2 auth is relevant. | 127 // Returns true if the phase 2 auth is relevant. |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
167 views::Checkbox* save_credentials_checkbox_; | 177 views::Checkbox* save_credentials_checkbox_; |
168 views::Checkbox* share_network_checkbox_; | 178 views::Checkbox* share_network_checkbox_; |
169 views::Label* shared_network_label_; | 179 views::Label* shared_network_label_; |
170 scoped_ptr<internal::SecurityComboboxModel> security_combobox_model_; | 180 scoped_ptr<internal::SecurityComboboxModel> security_combobox_model_; |
171 views::Combobox* security_combobox_; | 181 views::Combobox* security_combobox_; |
172 views::Label* passphrase_label_; | 182 views::Label* passphrase_label_; |
173 views::Textfield* passphrase_textfield_; | 183 views::Textfield* passphrase_textfield_; |
174 views::ToggleImageButton* passphrase_visible_button_; | 184 views::ToggleImageButton* passphrase_visible_button_; |
175 views::Label* error_label_; | 185 views::Label* error_label_; |
176 | 186 |
| 187 base::WeakPtrFactory<WifiConfigView> weak_ptr_factory_; |
| 188 |
177 DISALLOW_COPY_AND_ASSIGN(WifiConfigView); | 189 DISALLOW_COPY_AND_ASSIGN(WifiConfigView); |
178 }; | 190 }; |
179 | 191 |
180 } // namespace chromeos | 192 } // namespace chromeos |
181 | 193 |
182 #endif // CHROME_BROWSER_CHROMEOS_OPTIONS_WIFI_CONFIG_VIEW_H_ | 194 #endif // CHROME_BROWSER_CHROMEOS_OPTIONS_WIFI_CONFIG_VIEW_H_ |
OLD | NEW |