summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/options/wifi_config_view.h
blob: 4f857fe91159f6dbad73df9be5fb81c1185831b4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef CHROME_BROWSER_CHROMEOS_OPTIONS_WIFI_CONFIG_VIEW_H_
#define CHROME_BROWSER_CHROMEOS_OPTIONS_WIFI_CONFIG_VIEW_H_
#pragma once

#include <string>

#include "base/gtest_prod_util.h"
#include "base/memory/scoped_ptr.h"
#include "base/string16.h"
#include "chrome/browser/chromeos/cros/network_library.h"
#include "chrome/browser/ui/shell_dialogs.h"
#include "ui/base/models/combobox_model.h"
#include "views/controls/button/button.h"
#include "views/controls/button/checkbox.h"
#include "views/controls/button/image_button.h"
#include "views/controls/button/native_button.h"
#include "views/controls/combobox/combobox.h"
#include "views/controls/textfield/textfield_controller.h"
#include "views/view.h"

class FilePath;

namespace chromeos {

class NetworkConfigView;
class WifiConfigModel;

// A dialog box for showing a password textfield.
class WifiConfigView : public views::View,
                       public views::TextfieldController,
                       public views::ButtonListener,
                       public views::Combobox::Listener {
 public:
  // Wifi login dialog for wifi network |wifi|. |wifi| must be a non NULL
  // pointer to a WifiNetwork in NetworkLibrary.
  WifiConfigView(NetworkConfigView* parent, WifiNetwork* wifi);
  // Wifi login dialog for "Joining other network..."
  explicit WifiConfigView(NetworkConfigView* parent);
  virtual ~WifiConfigView();

  // views::TextfieldController:
  virtual void ContentsChanged(views::Textfield* sender,
                               const string16& new_contents);
  virtual bool HandleKeyEvent(views::Textfield* sender,
                              const views::KeyEvent& key_event);

  // views::ButtonListener:
  virtual void ButtonPressed(views::Button* sender, const views::Event& event);

  // views::Combobox::Listener:
  virtual void ItemChanged(views::Combobox* combo_box,
                           int prev_index, int new_index);

  // Login to network. Returns false if the dialog should remain open.
  virtual bool Login();

  // Cancel the dialog.
  virtual void Cancel();

  // Get the typed in ssid.
  std::string GetSSID() const;
  // Get the typed in passphrase.
  std::string GetPassphrase() const;

  // Returns whether or not we can login.
  bool CanLogin();

 private:
  // Initializes UI.
  void Init(WifiNetwork* wifi);

  // Updates state of the Login button.
  void UpdateDialogButtons();

  // Enable/Disable EAP fields as appropriate based on selected EAP method.
  void RefreshEAPFields();

  // Updates the error text label.
  void UpdateErrorLabel(bool failed);

  NetworkConfigView* parent_;

  scoped_ptr<WifiConfigModel> wifi_config_model_;

  // Whether or not it is an 802.1x network.
  bool is_8021x_;

  std::string service_path_;

  views::Textfield* ssid_textfield_;
  views::Combobox* eap_method_combobox_;
  views::Label* phase_2_auth_label_;
  views::Combobox* phase_2_auth_combobox_;
  views::Label* client_cert_label_;
  views::Combobox* client_cert_combobox_;
  views::Label* server_ca_cert_label_;
  views::Combobox* server_ca_cert_combobox_;
  views::Label* identity_label_;
  views::Textfield* identity_textfield_;
  views::Label* identity_anonymous_label_;
  views::Textfield* identity_anonymous_textfield_;
  views::Combobox* security_combobox_;
  views::Label* passphrase_label_;
  views::Textfield* passphrase_textfield_;
  views::ImageButton* passphrase_visible_button_;
  views::Label* error_label_;

  DISALLOW_COPY_AND_ASSIGN(WifiConfigView);
};

}  // namespace chromeos

#endif  // CHROME_BROWSER_CHROMEOS_OPTIONS_WIFI_CONFIG_VIEW_H_