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, |
49 public base::SupportsWeakPtr<WifiConfigView> { | |
45 public: | 50 public: |
46 // Wifi login dialog for wifi network |wifi|. |wifi| must be a non NULL | 51 WifiConfigView(NetworkConfigView* parent, |
47 // pointer to a WifiNetwork in NetworkLibrary. | 52 const std::string& service_path, |
48 WifiConfigView(NetworkConfigView* parent, WifiNetwork* wifi); | 53 bool show_8021x); |
49 // Wifi login dialog for "Joining other network..." | |
50 WifiConfigView(NetworkConfigView* parent, bool show_8021x); | |
51 virtual ~WifiConfigView(); | 54 virtual ~WifiConfigView(); |
52 | 55 |
53 // views::TextfieldController: | 56 // views::TextfieldController: |
54 virtual void ContentsChanged(views::Textfield* sender, | 57 virtual void ContentsChanged(views::Textfield* sender, |
55 const string16& new_contents) OVERRIDE; | 58 const string16& new_contents) OVERRIDE; |
56 virtual bool HandleKeyEvent(views::Textfield* sender, | 59 virtual bool HandleKeyEvent(views::Textfield* sender, |
57 const ui::KeyEvent& key_event) OVERRIDE; | 60 const ui::KeyEvent& key_event) OVERRIDE; |
58 | 61 |
59 // views::ButtonListener: | 62 // views::ButtonListener: |
60 virtual void ButtonPressed(views::Button* sender, | 63 virtual void ButtonPressed(views::Button* sender, |
61 const ui::Event& event) OVERRIDE; | 64 const ui::Event& event) OVERRIDE; |
62 | 65 |
63 // views::ComboboxListener: | 66 // views::ComboboxListener: |
64 virtual void OnSelectedIndexChanged(views::Combobox* combobox) OVERRIDE; | 67 virtual void OnSelectedIndexChanged(views::Combobox* combobox) OVERRIDE; |
65 | 68 |
66 // CertLibrary::Observer: | 69 // CertLibrary::Observer: |
67 virtual void OnCertificatesLoaded(bool initial_load) OVERRIDE; | 70 virtual void OnCertificatesLoaded(bool initial_load) OVERRIDE; |
68 | 71 |
69 // ChildNetworkConfigView: | 72 // ChildNetworkConfigView: |
70 virtual string16 GetTitle() const OVERRIDE; | 73 virtual string16 GetTitle() const OVERRIDE; |
71 virtual views::View* GetInitiallyFocusedView() OVERRIDE; | 74 virtual views::View* GetInitiallyFocusedView() OVERRIDE; |
72 virtual bool CanLogin() OVERRIDE; | 75 virtual bool CanLogin() OVERRIDE; |
73 virtual bool Login() OVERRIDE; | 76 virtual bool Login() OVERRIDE; |
74 virtual void Cancel() OVERRIDE; | 77 virtual void Cancel() OVERRIDE; |
75 virtual void InitFocus() OVERRIDE; | 78 virtual void InitFocus() OVERRIDE; |
76 | 79 |
77 // Parses a WiFi UI |property| from the ONC associated with |network|. |key| | 80 // Parses a WiFi UI |property| from the ONC associated with |network|. |key| |
78 // is the property name within the ONC WiFi dictionary. | 81 // is the property name within the ONC WiFi dictionary. |
79 static void ParseWiFiUIProperty(NetworkPropertyUIData* property_ui_data, | 82 static void ParseWiFiUIProperty(NetworkPropertyUIData* property_ui_data, |
80 Network* network, | 83 const NetworkState* network, |
81 const std::string& key); | 84 const std::string& key); |
82 | 85 |
83 // Parses a WiFi EAP UI |property| from the ONC associated with |network|. | 86 // Parses a WiFi EAP UI |property| from the ONC associated with |network|. |
84 // |key| is the property name within the ONC WiFi.EAP dictionary. | 87 // |key| is the property name within the ONC WiFi.EAP dictionary. |
85 static void ParseWiFiEAPUIProperty(NetworkPropertyUIData* property_ui_data, | 88 static void ParseWiFiEAPUIProperty(NetworkPropertyUIData* property_ui_data, |
86 Network* network, | 89 const NetworkState* network, |
87 const std::string& key); | 90 const std::string& key); |
88 | 91 |
89 private: | 92 private: |
90 // Initializes UI. If |show_8021x| includes 802.1x config options. | 93 // Initializes UI. If |show_8021x| includes 802.1x config options. |
91 void Init(WifiNetwork* wifi, bool show_8021x); | 94 void Init(const std::string& service_path, bool show_8021x); |
pneubeck (no reviews)
2013/08/06 15:45:19
service_path arg not required, use ChildNetworkCon
stevenjb
2013/08/06 20:23:55
Done.
| |
95 | |
96 // Callback to initialize fields from uncached network properties. | |
97 void InitFromProperties(bool show_8021x, | |
98 const std::string& service_path, | |
pneubeck (no reviews)
2013/08/06 15:45:19
service_path arg not required, use ChildNetworkCon
stevenjb
2013/08/06 20:23:55
Here, service_path is part of the callback signatu
| |
99 const base::DictionaryValue& dictionary); | |
92 | 100 |
93 // Get input values. | 101 // Get input values. |
94 std::string GetSsid() const; | 102 std::string GetSsid() const; |
95 std::string GetPassphrase() const; | 103 std::string GetPassphrase() const; |
96 bool GetSaveCredentials() const; | 104 bool GetSaveCredentials() const; |
97 bool GetShareNetwork(bool share_default) const; | 105 bool GetShareNetwork(bool share_default) const; |
98 | 106 |
99 // Get various 802.1X EAP values from the widgets. | 107 // Get various 802.1X EAP values from the widgets. |
100 EAPMethod GetEapMethod() const; | 108 std::string GetEapMethod() const; |
101 EAPPhase2Auth GetEapPhase2Auth() const; | 109 std::string GetEapPhase2Auth() const; |
102 std::string GetEapServerCaCertPEM() const; | 110 std::string GetEapServerCaCertPEM() const; |
103 bool GetEapUseSystemCas() const; | 111 bool GetEapUseSystemCas() const; |
104 std::string GetEapClientCertPkcs11Id() const; | 112 std::string GetEapClientCertPkcs11Id() const; |
105 std::string GetEapIdentity() const; | 113 std::string GetEapIdentity() const; |
106 std::string GetEapAnonymousIdentity() const; | 114 std::string GetEapAnonymousIdentity() const; |
107 | 115 |
116 // Fill in |properties| with the appropriate values. | |
117 void SetEapProperties(base::DictionaryValue* properties); | |
118 | |
108 // Returns true if the EAP method requires a user certificate. | 119 // Returns true if the EAP method requires a user certificate. |
109 bool UserCertRequired() const; | 120 bool UserCertRequired() const; |
110 | 121 |
111 // Returns true if at least one user certificate is installed. | 122 // Returns true if at least one user certificate is installed. |
112 bool HaveUserCerts() const; | 123 bool HaveUserCerts() const; |
113 | 124 |
114 // Returns true if there is a selected user certificate and it is valid. | 125 // Returns true if there is a selected user certificate and it is valid. |
115 bool IsUserCertValid() const; | 126 bool IsUserCertValid() const; |
116 | 127 |
117 // Returns true if the phase 2 auth is relevant. | 128 // Returns true if the phase 2 auth is relevant. |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
173 views::Textfield* passphrase_textfield_; | 184 views::Textfield* passphrase_textfield_; |
174 views::ToggleImageButton* passphrase_visible_button_; | 185 views::ToggleImageButton* passphrase_visible_button_; |
175 views::Label* error_label_; | 186 views::Label* error_label_; |
176 | 187 |
177 DISALLOW_COPY_AND_ASSIGN(WifiConfigView); | 188 DISALLOW_COPY_AND_ASSIGN(WifiConfigView); |
178 }; | 189 }; |
179 | 190 |
180 } // namespace chromeos | 191 } // namespace chromeos |
181 | 192 |
182 #endif // CHROME_BROWSER_CHROMEOS_OPTIONS_WIFI_CONFIG_VIEW_H_ | 193 #endif // CHROME_BROWSER_CHROMEOS_OPTIONS_WIFI_CONFIG_VIEW_H_ |
OLD | NEW |