| OLD | NEW |
| (Empty) |
| 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_BUTTON_H_ | |
| 6 #define CHROME_BROWSER_CHROMEOS_STATUS_NETWORK_MENU_BUTTON_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include <string> | |
| 10 | |
| 11 #include "base/memory/weak_ptr.h" | |
| 12 #include "base/timer.h" | |
| 13 #include "chrome/browser/chromeos/cros/network_library.h" | |
| 14 #include "chrome/browser/chromeos/login/message_bubble.h" | |
| 15 #include "chrome/browser/chromeos/status/network_menu.h" | |
| 16 #include "chrome/browser/chromeos/status/network_menu_icon.h" | |
| 17 #include "chrome/browser/chromeos/status/status_area_button.h" | |
| 18 | |
| 19 class PrefService; | |
| 20 | |
| 21 namespace chromeos { | |
| 22 | |
| 23 class DataPromoNotification; | |
| 24 | |
| 25 // The network menu button in the status area. | |
| 26 // This class will handle getting the wifi networks and populating the menu. | |
| 27 // It will also handle the status icon changing and connecting to another | |
| 28 // wifi/cellular network. | |
| 29 // | |
| 30 // The network menu looks like this: | |
| 31 // | |
| 32 // <icon> Ethernet | |
| 33 // <icon> Wifi Network A | |
| 34 // <icon> Wifi Network B | |
| 35 // <icon> Wifi Network C | |
| 36 // <icon> Cellular Network A | |
| 37 // <icon> Cellular Network B | |
| 38 // <icon> Cellular Network C | |
| 39 // <icon> Other... | |
| 40 // -------------------------------- | |
| 41 // Disable Wifi | |
| 42 // Disable Celluar | |
| 43 // -------------------------------- | |
| 44 // <IP Address> | |
| 45 // Network settings... | |
| 46 // | |
| 47 // <icon> will show the strength of the wifi/cellular networks. | |
| 48 // The label will be BOLD if the network is currently connected. | |
| 49 class NetworkMenuButton : public StatusAreaButton, | |
| 50 public views::MenuButtonListener, | |
| 51 public NetworkMenu::Delegate, | |
| 52 public NetworkMenuIcon::Delegate, | |
| 53 public NetworkLibrary::NetworkDeviceObserver, | |
| 54 public NetworkLibrary::NetworkManagerObserver, | |
| 55 public NetworkLibrary::NetworkObserver, | |
| 56 public NetworkLibrary::CellularDataPlanObserver, | |
| 57 public MessageBubbleLinkListener { | |
| 58 public: | |
| 59 explicit NetworkMenuButton(StatusAreaButton::Delegate* delegate); | |
| 60 virtual ~NetworkMenuButton(); | |
| 61 | |
| 62 static void RegisterPrefs(PrefService* local_state); | |
| 63 | |
| 64 // NetworkLibrary::NetworkDeviceObserver implementation. | |
| 65 virtual void OnNetworkDeviceChanged(NetworkLibrary* cros, | |
| 66 const NetworkDevice* device) OVERRIDE; | |
| 67 | |
| 68 // NetworkLibrary::NetworkManagerObserver implementation. | |
| 69 virtual void OnNetworkManagerChanged(NetworkLibrary* cros) OVERRIDE; | |
| 70 | |
| 71 // NetworkLibrary::NetworkObserver implementation. | |
| 72 virtual void OnNetworkChanged(NetworkLibrary* cros, | |
| 73 const Network* network) OVERRIDE; | |
| 74 | |
| 75 // NetworkLibrary::CellularDataPlanObserver implementation. | |
| 76 virtual void OnCellularDataPlanChanged(NetworkLibrary* cros) OVERRIDE; | |
| 77 | |
| 78 // NetworkMenu::Delegate implementation: | |
| 79 virtual views::MenuButton* GetMenuButton() OVERRIDE; | |
| 80 virtual gfx::NativeWindow GetNativeWindow() const OVERRIDE; | |
| 81 virtual void OpenButtonOptions() OVERRIDE; | |
| 82 virtual bool ShouldOpenButtonOptions() const OVERRIDE; | |
| 83 | |
| 84 // NetworkMenuIcon::Delegate implementation: | |
| 85 virtual void NetworkMenuIconChanged() OVERRIDE; | |
| 86 | |
| 87 // views::View | |
| 88 virtual void OnLocaleChanged() OVERRIDE; | |
| 89 | |
| 90 // views::MenuButtonListener implementation. | |
| 91 virtual void OnMenuButtonClicked(views::View* source, | |
| 92 const gfx::Point& point) OVERRIDE; | |
| 93 | |
| 94 // MessageBubbleLinkListener implementation: | |
| 95 virtual void OnLinkActivated(size_t index) OVERRIDE; | |
| 96 | |
| 97 private: | |
| 98 // Set the network icon based on the status of the |network| | |
| 99 void SetNetworkIcon(); | |
| 100 | |
| 101 // Called when the list of devices has possibly changed. This will remove | |
| 102 // old network device observers and add a network observers | |
| 103 // for the new devices. | |
| 104 void RefreshNetworkDeviceObserver(NetworkLibrary* cros); | |
| 105 | |
| 106 // Called when the active network has possibly changed. This will remove | |
| 107 // old network observer and add a network observer for the active network. | |
| 108 void RefreshNetworkObserver(NetworkLibrary* cros); | |
| 109 | |
| 110 void SetTooltipAndAccessibleName(const string16& label); | |
| 111 | |
| 112 // The Network menu. | |
| 113 scoped_ptr<NetworkMenu> network_menu_; | |
| 114 | |
| 115 // Path of the Cellular device that we monitor property updates from. | |
| 116 std::string cellular_device_path_; | |
| 117 | |
| 118 // The network icon and associated data. | |
| 119 scoped_ptr<NetworkMenuIcon> network_icon_; | |
| 120 | |
| 121 // If any network is currently active, this is the service path of the one | |
| 122 // whose status is displayed in the network menu button. | |
| 123 std::string active_network_; | |
| 124 | |
| 125 scoped_ptr<DataPromoNotification> data_promo_notification_; | |
| 126 | |
| 127 DISALLOW_COPY_AND_ASSIGN(NetworkMenuButton); | |
| 128 }; | |
| 129 | |
| 130 } // namespace chromeos | |
| 131 | |
| 132 #endif // CHROME_BROWSER_CHROMEOS_STATUS_NETWORK_MENU_BUTTON_H_ | |
| OLD | NEW |