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_STATUS_NETWORK_MENU_H_ 6#define CHROME_BROWSER_CHROMEOS_STATUS_NETWORK_MENU_H_ 7 8#include <string> 9#include <vector> 10 11#include "base/memory/scoped_ptr.h" 12#include "base/memory/weak_ptr.h" 13#include "base/strings/string16.h" 14#include "ui/gfx/native_widget_types.h" // gfx::NativeWindow 15 16class Browser; 17 18namespace ui { 19class MenuModel; 20} 21 22namespace views { 23class MenuItemView; 24class MenuButton; 25class MenuRunner; 26} 27 28namespace chromeos { 29 30class NetworkMenuModel; 31 32// This class builds and manages a ui::MenuModel used to build network 33// menus. It does not represent an actual menu widget. The menu is populated 34// with the list of wifi and mobile networks, and handles connecting to 35// existing networks or spawning UI to configure a new network. 36// 37// This class is now only used to build the dropdown menu in the oobe and 38// other web based login screen UI. See ash::NetworkStateListDetailedView for 39// the status area network list. TODO(stevenjb): Integrate this with the 40// login UI code. 41// 42// The network menu model looks like this: 43// 44// <icon> Ethernet 45// <icon> Wifi Network A 46// <icon> Wifi Network B 47// <icon> Wifi Network C 48// <icon> Cellular Network A 49// <icon> Cellular Network B 50// <icon> Cellular Network C 51// <icon> Other Wi-Fi network... 52// -------------------------------- 53// Disable Wifi 54// Disable Celluar 55// -------------------------------- 56// <IP Address> 57// Proxy settings... 58// 59// <icon> will show the strength of the wifi/cellular networks. 60// The label will be BOLD if the network is currently connected. 61 62class NetworkMenu { 63 public: 64 class Delegate { 65 public: 66 virtual ~Delegate(); 67 virtual gfx::NativeWindow GetNativeWindow() const = 0; 68 virtual void OpenButtonOptions() = 0; 69 virtual bool ShouldOpenButtonOptions() const = 0; 70 virtual void OnConnectToNetworkRequested() = 0; 71 }; 72 73 explicit NetworkMenu(Delegate* delegate); 74 virtual ~NetworkMenu(); 75 76 // Access to menu definition. 77 ui::MenuModel* GetMenuModel(); 78 79 // Update the menu (e.g. when the network list or status has changed). 80 virtual void UpdateMenu(); 81 82 private: 83 friend class NetworkMenuModel; 84 85 // Getters. 86 Delegate* delegate() const { return delegate_; } 87 88 // Weak ptr to delegate. 89 Delegate* delegate_; 90 91 // Set to true if we are currently refreshing the menu. 92 bool refreshing_menu_; 93 94 // The network menu. 95 scoped_ptr<NetworkMenuModel> main_menu_model_; 96 97 // Weak pointer factory so we can start connections at a later time 98 // without worrying that they will actually try to happen after the lifetime 99 // of this object. 100 base::WeakPtrFactory<NetworkMenu> weak_pointer_factory_; 101 102 DISALLOW_COPY_AND_ASSIGN(NetworkMenu); 103}; 104 105} // namespace chromeos 106 107#endif // CHROME_BROWSER_CHROMEOS_STATUS_NETWORK_MENU_H_ 108