• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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
3 // found in the LICENSE file.
4 
5 #ifndef CHROME_BROWSER_CHROMEOS_OPTIONS_WIMAX_CONFIG_VIEW_H_
6 #define CHROME_BROWSER_CHROMEOS_OPTIONS_WIMAX_CONFIG_VIEW_H_
7 
8 #include <string>
9 
10 #include "base/basictypes.h"
11 #include "base/compiler_specific.h"
12 #include "base/memory/weak_ptr.h"
13 #include "base/strings/string16.h"
14 #include "chrome/browser/chromeos/options/network_config_view.h"
15 #include "chrome/browser/chromeos/options/wifi_config_view.h"
16 #include "ui/views/controls/button/button.h"
17 #include "ui/views/controls/textfield/textfield_controller.h"
18 #include "ui/views/view.h"
19 
20 namespace views {
21 class Checkbox;
22 class Label;
23 class ToggleImageButton;
24 }
25 
26 namespace chromeos {
27 
28 // A dialog box for showing a password textfield.
29 class WimaxConfigView : public ChildNetworkConfigView,
30                         public views::TextfieldController,
31                         public views::ButtonListener {
32  public:
33   // Configuration dialog for a WiMax network. If |service_path| is not empty
34   // it identifies the network to be configured.
35   WimaxConfigView(NetworkConfigView* parent, const std::string& service_path);
36   virtual ~WimaxConfigView();
37 
38   // views::TextfieldController:
39   virtual void ContentsChanged(views::Textfield* sender,
40                                const base::string16& new_contents) OVERRIDE;
41   virtual bool HandleKeyEvent(views::Textfield* sender,
42                               const ui::KeyEvent& key_event) OVERRIDE;
43 
44   // views::ButtonListener:
45   virtual void ButtonPressed(views::Button* sender,
46                              const ui::Event& event) OVERRIDE;
47 
48   // ChildNetworkConfigView:
49   virtual base::string16 GetTitle() const OVERRIDE;
50   virtual views::View* GetInitiallyFocusedView() OVERRIDE;
51   virtual bool CanLogin() OVERRIDE;
52   virtual bool Login() OVERRIDE;
53   virtual void Cancel() OVERRIDE;
54   virtual void InitFocus() OVERRIDE;
55 
56  private:
57   // Initializes UI.
58   void Init();
59 
60   // Callback to initialize fields from uncached network properties.
61   void InitFromProperties(const std::string& service_path,
62                           const base::DictionaryValue& dictionary);
63 
64   // Get input values.
65   std::string GetEapIdentity() const;
66   std::string GetEapPassphrase() const;
67   bool GetSaveCredentials() const;
68   bool GetShareNetwork(bool share_default) const;
69 
70   // Updates state of the Login button.
71   void UpdateDialogButtons();
72 
73   // Updates the error text label.
74   void UpdateErrorLabel();
75 
76   NetworkPropertyUIData identity_ui_data_;
77   NetworkPropertyUIData passphrase_ui_data_;
78   NetworkPropertyUIData save_credentials_ui_data_;
79 
80   views::Label* identity_label_;
81   views::Textfield* identity_textfield_;
82   views::Checkbox* save_credentials_checkbox_;
83   views::Checkbox* share_network_checkbox_;
84   views::Label* shared_network_label_;
85   views::Label* passphrase_label_;
86   views::Textfield* passphrase_textfield_;
87   views::ToggleImageButton* passphrase_visible_button_;
88   views::Label* error_label_;
89 
90   base::WeakPtrFactory<WimaxConfigView> weak_ptr_factory_;
91 
92   DISALLOW_COPY_AND_ASSIGN(WimaxConfigView);
93 };
94 
95 }  // namespace chromeos
96 
97 #endif  // CHROME_BROWSER_CHROMEOS_OPTIONS_WIMAX_CONFIG_VIEW_H_
98