summaryrefslogtreecommitdiffstats
path: root/chrome/browser/chromeos/options/wimax_config_view.h
blob: fbe31a954f89d5d6d9f83dbd653bce5212f358f1 (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
// Copyright (c) 2012 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_WIMAX_CONFIG_VIEW_H_
#define CHROME_BROWSER_CHROMEOS_OPTIONS_WIMAX_CONFIG_VIEW_H_

#include <string>

#include "base/basictypes.h"
#include "base/compiler_specific.h"
#include "base/memory/weak_ptr.h"
#include "base/strings/string16.h"
#include "chrome/browser/chromeos/options/network_config_view.h"
#include "chrome/browser/chromeos/options/wifi_config_view.h"
#include "ui/views/controls/button/button.h"
#include "ui/views/controls/textfield/textfield_controller.h"
#include "ui/views/view.h"

namespace views {
class Checkbox;
class Label;
class ToggleImageButton;
}

namespace chromeos {

// A dialog box for showing a password textfield.
class WimaxConfigView : public ChildNetworkConfigView,
                        public views::TextfieldController,
                        public views::ButtonListener {
 public:
  // Configuration dialog for a WiMax network. If |service_path| is not empty
  // it identifies the network to be configured.
  WimaxConfigView(NetworkConfigView* parent, const std::string& service_path);
  ~WimaxConfigView() override;

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

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

  // ChildNetworkConfigView:
  base::string16 GetTitle() const override;
  views::View* GetInitiallyFocusedView() override;
  bool CanLogin() override;
  bool Login() override;
  void Cancel() override;
  void InitFocus() override;

 private:
  // Initializes UI.
  void Init();

  // Callback to initialize fields from uncached network properties.
  void InitFromProperties(const std::string& service_path,
                          const base::DictionaryValue& dictionary);

  // Get input values.
  std::string GetEapIdentity() const;
  std::string GetEapPassphrase() const;
  bool GetSaveCredentials() const;
  bool GetShareNetwork(bool share_default) const;

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

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

  NetworkPropertyUIData identity_ui_data_;
  NetworkPropertyUIData passphrase_ui_data_;
  NetworkPropertyUIData save_credentials_ui_data_;

  views::Label* identity_label_;
  views::Textfield* identity_textfield_;
  views::Checkbox* save_credentials_checkbox_;
  views::Checkbox* share_network_checkbox_;
  views::Label* passphrase_label_;
  views::Textfield* passphrase_textfield_;
  views::ToggleImageButton* passphrase_visible_button_;
  views::Label* error_label_;

  base::WeakPtrFactory<WimaxConfigView> weak_ptr_factory_;

  DISALLOW_COPY_AND_ASSIGN(WimaxConfigView);
};

}  // namespace chromeos

#endif  // CHROME_BROWSER_CHROMEOS_OPTIONS_WIMAX_CONFIG_VIEW_H_