1ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen// Copyright (c) 2011 The Chromium Authors. All rights reserved.
2c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// Use of this source code is governed by a BSD-style license that can be
3c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// found in the LICENSE file.
4c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
5c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#ifndef CHROME_BROWSER_CHROMEOS_OPTIONS_WIFI_CONFIG_VIEW_H_
6c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#define CHROME_BROWSER_CHROMEOS_OPTIONS_WIFI_CONFIG_VIEW_H_
73345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick#pragma once
8c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
9c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include <string>
10c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
11c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "base/gtest_prod_util.h"
12ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "base/memory/scoped_ptr.h"
13c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "base/string16.h"
14c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "chrome/browser/chromeos/cros/network_library.h"
15ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "chrome/browser/chromeos/options/network_config_view.h"
1672a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen#include "chrome/browser/ui/shell_dialogs.h"
1772a454cd3513ac24fbdd0e0cb9ad70b86a99b801Kristian Monsen#include "ui/base/models/combobox_model.h"
18c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "views/controls/button/button.h"
19c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "views/controls/button/image_button.h"
20c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "views/controls/button/native_button.h"
21513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch#include "views/controls/combobox/combobox.h"
22ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen#include "views/controls/textfield/textfield_controller.h"
23c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#include "views/view.h"
24c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
25ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsennamespace views {
26ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsenclass Checkbox;
27ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsenclass Label;
28ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen}
293345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrickclass FilePath;
303345a6884c488ff3a535c2c9acdd33d74b37e311Iain Merrick
31c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdochnamespace chromeos {
32c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
33ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsenclass WifiConfigModel;
34c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
35c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch// A dialog box for showing a password textfield.
36ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsenclass WifiConfigView : public ChildNetworkConfigView,
37ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen                       public views::TextfieldController,
38c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                       public views::ButtonListener,
39ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen                       public views::Combobox::Listener {
40c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch public:
41ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // Wifi login dialog for wifi network |wifi|. |wifi| must be a non NULL
42ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // pointer to a WifiNetwork in NetworkLibrary.
43dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen  WifiConfigView(NetworkConfigView* parent, WifiNetwork* wifi);
44dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen  // Wifi login dialog for "Joining other network..."
45c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  explicit WifiConfigView(NetworkConfigView* parent);
46513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch  virtual ~WifiConfigView();
47c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
48ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // views::TextfieldController:
49c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  virtual void ContentsChanged(views::Textfield* sender,
50c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch                               const string16& new_contents);
513f50c38dc070f4bb515c1b64450dae14f316474eKristian Monsen  virtual bool HandleKeyEvent(views::Textfield* sender,
523f50c38dc070f4bb515c1b64450dae14f316474eKristian Monsen                              const views::KeyEvent& key_event);
53c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
54ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // views::ButtonListener:
55c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  virtual void ButtonPressed(views::Button* sender, const views::Event& event);
56c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
57ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // views::Combobox::Listener:
58513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch  virtual void ItemChanged(views::Combobox* combo_box,
59513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch                           int prev_index, int new_index);
60513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch
61ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // ChildNetworkConfigView implementation.
62ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  virtual string16 GetTitle() OVERRIDE;
63ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  virtual bool CanLogin() OVERRIDE;
64ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  virtual bool Login() OVERRIDE;
65ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  virtual void Cancel() OVERRIDE;
66ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  virtual void InitFocus() OVERRIDE;
67201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch
68c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Get the typed in ssid.
69ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  std::string GetSSID() const;
70c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
71ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // Get the typed in passphrase.
72ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  std::string GetPassphrase() const;
73c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
74c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch private:
75c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  // Initializes UI.
76ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  void Init(WifiNetwork* wifi);
77c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
78731df977c0511bca2206b5f333555b1205ff1f43Iain Merrick  // Updates state of the Login button.
79dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen  void UpdateDialogButtons();
80c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
81ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  // Enable/Disable EAP fields as appropriate based on selected EAP method.
82ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  void RefreshEAPFields();
83ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen
84201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  // Updates the error text label.
85ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  void UpdateErrorLabel();
86201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch
87ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  scoped_ptr<WifiConfigModel> wifi_config_model_;
88c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
89dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen  // Whether or not it is an 802.1x network.
90dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen  bool is_8021x_;
91c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
92c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  views::Textfield* ssid_textfield_;
93dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen  views::Combobox* eap_method_combobox_;
94ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  views::Label* phase_2_auth_label_;
95dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen  views::Combobox* phase_2_auth_combobox_;
96ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  views::Label* client_cert_label_;
97ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  views::Combobox* client_cert_combobox_;
98ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  views::Label* server_ca_cert_label_;
99ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  views::Combobox* server_ca_cert_combobox_;
100ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  views::Label* identity_label_;
101c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  views::Textfield* identity_textfield_;
102ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  views::Label* identity_anonymous_label_;
103dc0f95d653279beabeb9817299e2902918ba123eKristian Monsen  views::Textfield* identity_anonymous_textfield_;
104ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  views::Checkbox* save_credentials_checkbox_;
105513209b27ff55e2841eac0e4120199c23acce758Ben Murdoch  views::Combobox* security_combobox_;
106ddb351dbec246cf1fab5ec20d2d5520909041de1Kristian Monsen  views::Label* passphrase_label_;
107c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  views::Textfield* passphrase_textfield_;
108c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  views::ImageButton* passphrase_visible_button_;
109201ade2fbba22bfb27ae029f4d23fca6ded109a0Ben Murdoch  views::Label* error_label_;
110c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
111c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch  DISALLOW_COPY_AND_ASSIGN(WifiConfigView);
112c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch};
113c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
114c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch}  // namespace chromeos
115c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch
116c407dc5cd9bdc5668497f21b26b09d988ab439deBen Murdoch#endif  // CHROME_BROWSER_CHROMEOS_OPTIONS_WIFI_CONFIG_VIEW_H_
117