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
118
119
120
121
122
123
|
// Copyright (c) 2010 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 "app/combobox_model.h"
#include "base/gtest_prod_util.h"
#include "base/string16.h"
#include "chrome/browser/chromeos/cros/network_library.h"
#include "chrome/browser/shell_dialogs.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.h"
#include "views/view.h"
class FilePath;
namespace chromeos {
class NetworkConfigView;
// A dialog box for showing a password textfield.
class WifiConfigView : public views::View,
public views::Textfield::Controller,
public views::ButtonListener,
public views::Combobox::Listener,
public SelectFileDialog::Listener {
public:
WifiConfigView(NetworkConfigView* parent, const WifiNetwork* wifi);
explicit WifiConfigView(NetworkConfigView* parent);
virtual ~WifiConfigView();
// views::Textfield::Controller methods.
virtual void ContentsChanged(views::Textfield* sender,
const string16& new_contents);
virtual bool HandleKeystroke(views::Textfield* sender,
const views::Textfield::Keystroke& keystroke);
// 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);
// SelectFileDialog::Listener implementation.
virtual void FileSelected(const FilePath& path, int index, void* params);
// Login to network.
virtual bool Login();
// Save network information.
virtual bool Save();
// Get the typed in ssid.
const std::string GetSSID() const;
// Get the typed in passphrase.
const std::string GetPassphrase() const;
// Returns true if the textfields are non-empty and we can login.
bool can_login() const { return can_login_; }
// Focus the first field in the UI.
void FocusFirstField();
private:
FRIEND_TEST_ALL_PREFIXES(WifiConfigViewTest, NoChangeSaveTest);
FRIEND_TEST_ALL_PREFIXES(WifiConfigViewTest, ChangeAutoConnectSaveTest);
FRIEND_TEST_ALL_PREFIXES(WifiConfigViewTest, ChangePasswordSaveTest);
class SecurityComboboxModel : public ComboboxModel {
public:
SecurityComboboxModel() {}
virtual ~SecurityComboboxModel() {}
virtual int GetItemCount();
virtual string16 GetItemAt(int index);
private:
DISALLOW_COPY_AND_ASSIGN(SecurityComboboxModel);
};
// Initializes UI.
void Init();
// Updates state of the Login button.
void UpdateCanLogin();
// Updates state of the "view password" button.
void UpdateCanViewPassword();
NetworkConfigView* parent_;
bool other_network_;
// Whether or not we can log in. This gets recalculated when textfield
// contents change.
bool can_login_;
scoped_ptr<WifiNetwork> wifi_;
views::Textfield* ssid_textfield_;
views::Textfield* identity_textfield_;
views::NativeButton* certificate_browse_button_;
scoped_refptr<SelectFileDialog> select_file_dialog_;
std::string certificate_path_;
views::Combobox* security_combobox_;
views::Textfield* passphrase_textfield_;
views::ImageButton* passphrase_visible_button_;
views::Checkbox* autoconnect_checkbox_;
DISALLOW_COPY_AND_ASSIGN(WifiConfigView);
};
} // namespace chromeos
#endif // CHROME_BROWSER_CHROMEOS_OPTIONS_WIFI_CONFIG_VIEW_H_
|