Home | History | Annotate | Download | only in network
      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 ASH_SYSTEM_CHROMEOS_NETWORK_NETWORK_STATE_LIST_DETAILED_VIEW_H
      6 #define ASH_SYSTEM_CHROMEOS_NETWORK_NETWORK_STATE_LIST_DETAILED_VIEW_H
      7 
      8 #include <string>
      9 
     10 #include "ash/system/chromeos/network/network_detailed_view.h"
     11 #include "ash/system/tray/view_click_listener.h"
     12 #include "ash/system/user/login_status.h"
     13 #include "base/memory/scoped_vector.h"
     14 #include "base/memory/weak_ptr.h"
     15 #include "ui/chromeos/network/network_list.h"
     16 #include "ui/chromeos/network/network_list_delegate.h"
     17 #include "ui/views/controls/button/button.h"
     18 
     19 namespace chromeos {
     20 class NetworkTypePattern;
     21 }
     22 
     23 namespace views {
     24 class BubbleDelegateView;
     25 }
     26 
     27 namespace ash {
     28 class HoverHighlightView;
     29 class SystemTrayItem;
     30 class TrayPopupLabelButton;
     31 
     32 namespace tray {
     33 
     34 class NetworkStateListDetailedView
     35     : public NetworkDetailedView,
     36       public views::ButtonListener,
     37       public ViewClickListener,
     38       public ui::NetworkListDelegate,
     39       public base::SupportsWeakPtr<NetworkStateListDetailedView> {
     40  public:
     41   enum ListType {
     42     LIST_TYPE_NETWORK,
     43     LIST_TYPE_VPN
     44   };
     45 
     46   NetworkStateListDetailedView(SystemTrayItem* owner,
     47                                ListType list_type,
     48                                user::LoginStatus login);
     49   virtual ~NetworkStateListDetailedView();
     50 
     51   // Overridden from NetworkDetailedView:
     52   virtual void Init() OVERRIDE;
     53   virtual DetailedViewType GetViewType() const OVERRIDE;
     54   virtual void ManagerChanged() OVERRIDE;
     55   virtual void NetworkListChanged() OVERRIDE;
     56   virtual void NetworkServiceChanged(
     57       const chromeos::NetworkState* network) OVERRIDE;
     58 
     59  protected:
     60   // Overridden from ButtonListener.
     61   virtual void ButtonPressed(views::Button* sender,
     62                              const ui::Event& event) OVERRIDE;
     63 
     64   // Overridden from ViewClickListener.
     65   virtual void OnViewClicked(views::View* sender) OVERRIDE;
     66 
     67  private:
     68   class InfoBubble;
     69 
     70   // Create UI components.
     71   void CreateHeaderEntry();
     72   void CreateHeaderButtons();
     73   void CreateNetworkExtra();
     74 
     75   // Update UI components.
     76   void UpdateHeaderButtons();
     77   void UpdateTechnologyButton(TrayPopupHeaderButton* button,
     78                               const chromeos::NetworkTypePattern& technology);
     79 
     80   void UpdateNetworkList();
     81 
     82   bool OrderChild(views::View* view, int index);
     83 
     84   void UpdateNetworkExtra();
     85 
     86   // Adds a settings entry when logged in, and an entry for changing proxy
     87   // settings otherwise.
     88   void CreateSettingsEntry();
     89 
     90   // Create and manage the network info bubble.
     91   void ToggleInfoBubble();
     92   bool ResetInfoBubble();
     93   void OnInfoBubbleDestroyed();
     94   views::View* CreateNetworkInfoView();
     95 
     96   // Periodically request a network scan.
     97   void CallRequestScan();
     98 
     99   // Handle toggile mobile action
    100   void ToggleMobile();
    101 
    102   // ui::NetworkListDelegate:
    103   virtual views::View* CreateViewForNetwork(
    104       const ui::NetworkInfo& info) OVERRIDE;
    105   virtual bool IsViewHovered(views::View* view) OVERRIDE;
    106   virtual chromeos::NetworkTypePattern GetNetworkTypePattern() const OVERRIDE;
    107   virtual void UpdateViewForNetwork(views::View* view,
    108                                     const ui::NetworkInfo& info) OVERRIDE;
    109   virtual views::Label* CreateInfoLabel() OVERRIDE;
    110   virtual void RelayoutScrollList() OVERRIDE;
    111 
    112   // Type of list (all networks or vpn)
    113   ListType list_type_;
    114 
    115   // Track login state.
    116   user::LoginStatus login_;
    117 
    118   // Child views.
    119   TrayPopupHeaderButton* info_icon_;
    120   TrayPopupHeaderButton* button_wifi_;
    121   TrayPopupHeaderButton* button_mobile_;
    122   TrayPopupLabelButton* other_wifi_;
    123   TrayPopupLabelButton* turn_on_wifi_;
    124   TrayPopupLabelButton* other_mobile_;
    125   TrayPopupLabelButton* other_vpn_;
    126   TrayPopupLabelButton* settings_;
    127   TrayPopupLabelButton* proxy_settings_;
    128 
    129   // A small bubble for displaying network info.
    130   views::BubbleDelegateView* info_bubble_;
    131 
    132   ui::NetworkListView network_list_view_;
    133 
    134   DISALLOW_COPY_AND_ASSIGN(NetworkStateListDetailedView);
    135 };
    136 
    137 }  // namespace tray
    138 }  // namespace ash
    139 
    140 #endif  // ASH_SYSTEM_CHROMEOS_NETWORK_NETWORK_STATE_LIST_DETAILED_VIEW
    141