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( 71 const std::string& service_path) = 0; 72 }; 73 74 explicit NetworkMenu(Delegate* delegate); 75 virtual ~NetworkMenu(); 76 77 // Access to menu definition. 78 ui::MenuModel* GetMenuModel(); 79 80 // Update the menu (e.g. when the network list or status has changed). 81 virtual void UpdateMenu(); 82 83 private: 84 friend class NetworkMenuModel; 85 86 // Getters. 87 Delegate* delegate() const { return delegate_; } 88 89 // Weak ptr to delegate. 90 Delegate* delegate_; 91 92 // Set to true if we are currently refreshing the menu. 93 bool refreshing_menu_; 94 95 // The network menu. 96 scoped_ptr<NetworkMenuModel> main_menu_model_; 97 98 // Weak pointer factory so we can start connections at a later time 99 // without worrying that they will actually try to happen after the lifetime 100 // of this object. 101 base::WeakPtrFactory<NetworkMenu> weak_pointer_factory_; 102 103 DISALLOW_COPY_AND_ASSIGN(NetworkMenu); 104}; 105 106} // namespace chromeos 107 108#endif // CHROME_BROWSER_CHROMEOS_STATUS_NETWORK_MENU_H_ 109