Home | History | Annotate | Download | only in options
      1 // Copyright (c) 2011 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_WIFI_CONFIG_VIEW_H_
      6 #define CHROME_BROWSER_CHROMEOS_OPTIONS_WIFI_CONFIG_VIEW_H_
      7 #pragma once
      8 
      9 #include <string>
     10 
     11 #include "base/gtest_prod_util.h"
     12 #include "base/memory/scoped_ptr.h"
     13 #include "base/string16.h"
     14 #include "chrome/browser/chromeos/cros/network_library.h"
     15 #include "chrome/browser/chromeos/options/network_config_view.h"
     16 #include "chrome/browser/ui/shell_dialogs.h"
     17 #include "ui/base/models/combobox_model.h"
     18 #include "views/controls/button/button.h"
     19 #include "views/controls/button/image_button.h"
     20 #include "views/controls/button/native_button.h"
     21 #include "views/controls/combobox/combobox.h"
     22 #include "views/controls/textfield/textfield_controller.h"
     23 #include "views/view.h"
     24 
     25 namespace views {
     26 class Checkbox;
     27 class Label;
     28 }
     29 class FilePath;
     30 
     31 namespace chromeos {
     32 
     33 class WifiConfigModel;
     34 
     35 // A dialog box for showing a password textfield.
     36 class WifiConfigView : public ChildNetworkConfigView,
     37                        public views::TextfieldController,
     38                        public views::ButtonListener,
     39                        public views::Combobox::Listener {
     40  public:
     41   // Wifi login dialog for wifi network |wifi|. |wifi| must be a non NULL
     42   // pointer to a WifiNetwork in NetworkLibrary.
     43   WifiConfigView(NetworkConfigView* parent, WifiNetwork* wifi);
     44   // Wifi login dialog for "Joining other network..."
     45   explicit WifiConfigView(NetworkConfigView* parent);
     46   virtual ~WifiConfigView();
     47 
     48   // views::TextfieldController:
     49   virtual void ContentsChanged(views::Textfield* sender,
     50                                const string16& new_contents);
     51   virtual bool HandleKeyEvent(views::Textfield* sender,
     52                               const views::KeyEvent& key_event);
     53 
     54   // views::ButtonListener:
     55   virtual void ButtonPressed(views::Button* sender, const views::Event& event);
     56 
     57   // views::Combobox::Listener:
     58   virtual void ItemChanged(views::Combobox* combo_box,
     59                            int prev_index, int new_index);
     60 
     61   // ChildNetworkConfigView implementation.
     62   virtual string16 GetTitle() OVERRIDE;
     63   virtual bool CanLogin() OVERRIDE;
     64   virtual bool Login() OVERRIDE;
     65   virtual void Cancel() OVERRIDE;
     66   virtual void InitFocus() OVERRIDE;
     67 
     68   // Get the typed in ssid.
     69   std::string GetSSID() const;
     70 
     71   // Get the typed in passphrase.
     72   std::string GetPassphrase() const;
     73 
     74  private:
     75   // Initializes UI.
     76   void Init(WifiNetwork* wifi);
     77 
     78   // Updates state of the Login button.
     79   void UpdateDialogButtons();
     80 
     81   // Enable/Disable EAP fields as appropriate based on selected EAP method.
     82   void RefreshEAPFields();
     83 
     84   // Updates the error text label.
     85   void UpdateErrorLabel();
     86 
     87   scoped_ptr<WifiConfigModel> wifi_config_model_;
     88 
     89   // Whether or not it is an 802.1x network.
     90   bool is_8021x_;
     91 
     92   views::Textfield* ssid_textfield_;
     93   views::Combobox* eap_method_combobox_;
     94   views::Label* phase_2_auth_label_;
     95   views::Combobox* phase_2_auth_combobox_;
     96   views::Label* client_cert_label_;
     97   views::Combobox* client_cert_combobox_;
     98   views::Label* server_ca_cert_label_;
     99   views::Combobox* server_ca_cert_combobox_;
    100   views::Label* identity_label_;
    101   views::Textfield* identity_textfield_;
    102   views::Label* identity_anonymous_label_;
    103   views::Textfield* identity_anonymous_textfield_;
    104   views::Checkbox* save_credentials_checkbox_;
    105   views::Combobox* security_combobox_;
    106   views::Label* passphrase_label_;
    107   views::Textfield* passphrase_textfield_;
    108   views::ImageButton* passphrase_visible_button_;
    109   views::Label* error_label_;
    110 
    111   DISALLOW_COPY_AND_ASSIGN(WifiConfigView);
    112 };
    113 
    114 }  // namespace chromeos
    115 
    116 #endif  // CHROME_BROWSER_CHROMEOS_OPTIONS_WIFI_CONFIG_VIEW_H_
    117