summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchocobo@chromium.org <chocobo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-14 01:00:39 +0000
committerchocobo@chromium.org <chocobo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-01-14 01:00:39 +0000
commit38d387cd9015ff2e95abbb0ea5abfbcf6b05c1df (patch)
tree1d97005e8a205cec4129092c42042e92bcb41a41
parent708ac0e590e24193d8f7e099cf73d4f08fcfe378 (diff)
downloadchromium_src-38d387cd9015ff2e95abbb0ea5abfbcf6b05c1df.zip
chromium_src-38d387cd9015ff2e95abbb0ea5abfbcf6b05c1df.tar.gz
chromium_src-38d387cd9015ff2e95abbb0ea5abfbcf6b05c1df.tar.bz2
Add cellular networks to network menu button.
TEST=none BUG=none Review URL: http://codereview.chromium.org/536055 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@36206 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/generated_resources.grd5
-rw-r--r--chrome/browser/chromeos/network_library.cc75
-rw-r--r--chrome/browser/chromeos/network_library.h62
-rw-r--r--chrome/browser/chromeos/network_menu_button.cc88
-rw-r--r--chrome/browser/chromeos/network_menu_button.h34
5 files changed, 213 insertions, 51 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 9c7438b..bdd021b 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -6175,6 +6175,9 @@ Keep your key file in a safe place. You will need it to create new versions of y
<message name="IDS_STATUSBAR_NETWORK_DEVICE_WIFI" desc="The wifi network device.">
Wifi
</message>
+ <message name="IDS_STATUSBAR_NETWORK_DEVICE_CELLULAR" desc="The cellular network device.">
+ Cellular
+ </message>
<message name="IDS_STATUSBAR_NETWORK_DEVICE_CONNECTING" desc="The network device status connecting.">
Connecting
</message>
@@ -6185,7 +6188,7 @@ Keep your key file in a safe place. You will need it to create new versions of y
Disconnected
</message>
<message name="IDS_STATUSBAR_NETWORK_DEVICE_DISABLED" desc="The network device status disabled.">
- Disabled
+ Off
</message>
<message name="IDS_STATUSBAR_NETWORK_DEVICE_ENABLE" desc="Enable the network device.">
Turn <ph name="NETWORKDEVICE">$1<ex>Wifi</ex></ph> On
diff --git a/chrome/browser/chromeos/network_library.cc b/chrome/browser/chromeos/network_library.cc
index 828e899..899e1ae 100644
--- a/chrome/browser/chromeos/network_library.cc
+++ b/chrome/browser/chromeos/network_library.cc
@@ -113,6 +113,14 @@ void NetworkLibrary::ConnectToWifiNetwork(WifiNetwork network,
}
}
+void NetworkLibrary::ConnectToCellularNetwork(CellularNetwork network) {
+ if (CrosLibrary::EnsureLoaded()) {
+ // This call kicks off a request to connect to this network, the results of
+ // which we'll hear about through the monitoring we've set up in Init();
+ chromeos::ConnectToWifiNetwork(network.name.c_str(), NULL, NULL);
+ }
+}
+
void NetworkLibrary::EnableEthernetNetworkDevice(bool enable) {
EnableNetworkDevice(chromeos::TYPE_ETHERNET, enable);
}
@@ -121,6 +129,10 @@ void NetworkLibrary::EnableWifiNetworkDevice(bool enable) {
EnableNetworkDevice(chromeos::TYPE_WIFI, enable);
}
+void NetworkLibrary::EnableCellularNetworkDevice(bool enable) {
+ EnableNetworkDevice(chromeos::TYPE_CELLULAR, enable);
+}
+
void NetworkLibrary::EnableOfflineMode(bool enable) {
if (!CrosLibrary::EnsureLoaded())
return;
@@ -144,38 +156,46 @@ void NetworkLibrary::EnableOfflineMode(bool enable) {
void NetworkLibrary::NetworkStatusChangedHandler(void* object,
const chromeos::ServiceStatus& service_status) {
NetworkLibrary* network = static_cast<NetworkLibrary*>(object);
- WifiNetworkVector networks;
EthernetNetwork ethernet;
- ParseNetworks(service_status, &networks, &ethernet);
- network->UpdateNetworkStatus(networks, ethernet);
+ WifiNetworkVector wifi_networks;
+ CellularNetworkVector cellular_networks;
+ ParseNetworks(service_status, &ethernet, &wifi_networks, &cellular_networks);
+ network->UpdateNetworkStatus(ethernet, wifi_networks, cellular_networks);
}
// static
void NetworkLibrary::ParseNetworks(
- const chromeos::ServiceStatus& service_status, WifiNetworkVector* networks,
- EthernetNetwork* ethernet) {
+ const chromeos::ServiceStatus& service_status, EthernetNetwork* ethernet,
+ WifiNetworkVector* wifi_networks,
+ CellularNetworkVector* cellular_networks) {
DLOG(INFO) << "ParseNetworks:";
for (int i = 0; i < service_status.size; i++) {
const chromeos::ServiceInfo& service = service_status.services[i];
- DLOG(INFO) << " " << service.ssid <<
- " typ=" << service.type <<
+ DLOG(INFO) << " (" << service.type <<
+ ") " << service.ssid <<
" sta=" << service.state <<
" pas=" << service.needs_passphrase <<
" enc=" << service.encryption <<
" sig=" << service.signal_strength;
bool connecting = service.state == chromeos::STATE_ASSOCIATION ||
- service.state == chromeos::STATE_CONFIGURATION;
+ service.state == chromeos::STATE_CONFIGURATION ||
+ service.state == chromeos::STATE_CARRIER;
bool connected = service.state == chromeos::STATE_READY;
if (service.type == chromeos::TYPE_ETHERNET) {
ethernet->connecting = connecting;
ethernet->connected = connected;
} else if (service.type == chromeos::TYPE_WIFI) {
- networks->push_back(WifiNetwork(service.ssid,
- service.needs_passphrase,
- service.encryption,
- service.signal_strength,
- connecting,
- connected));
+ wifi_networks->push_back(WifiNetwork(service.ssid,
+ service.needs_passphrase,
+ service.encryption,
+ service.signal_strength,
+ connecting,
+ connected));
+ } else if (service.type == chromeos::TYPE_CELLULAR) {
+ cellular_networks->push_back(CellularNetwork(service.ssid,
+ service.signal_strength,
+ connecting,
+ connected));
}
}
}
@@ -186,10 +206,12 @@ void NetworkLibrary::Init() {
chromeos::ServiceStatus* service_status = chromeos::GetAvailableNetworks();
if (service_status) {
LOG(INFO) << "Getting initial CrOS network info.";
- WifiNetworkVector networks;
EthernetNetwork ethernet;
- ParseNetworks(*service_status, &networks, &ethernet);
- UpdateNetworkStatus(networks, ethernet);
+ WifiNetworkVector wifi_networks;
+ CellularNetworkVector cellular_networks;
+ ParseNetworks(*service_status, &ethernet, &wifi_networks,
+ &cellular_networks);
+ UpdateNetworkStatus(ethernet, wifi_networks, cellular_networks);
chromeos::FreeServiceStatus(service_status);
}
LOG(INFO) << "Registering for network status updates.";
@@ -231,19 +253,21 @@ void NetworkLibrary::EnableNetworkDevice(chromeos::ConnectionType device,
}
}
-void NetworkLibrary::UpdateNetworkStatus(
- const WifiNetworkVector& networks, const EthernetNetwork& ethernet) {
+void NetworkLibrary::UpdateNetworkStatus(const EthernetNetwork& ethernet,
+ const WifiNetworkVector& wifi_networks,
+ const CellularNetworkVector& cellular_networks) {
// Make sure we run on UI thread.
if (!ChromeThread::CurrentlyOn(ChromeThread::UI)) {
ChromeThread::PostTask(
ChromeThread::UI, FROM_HERE,
NewRunnableMethod(this,
- &NetworkLibrary::UpdateNetworkStatus, networks, ethernet));
+ &NetworkLibrary::UpdateNetworkStatus, ethernet, wifi_networks,
+ cellular_networks));
return;
}
ethernet_ = ethernet;
- wifi_networks_ = networks;
+ wifi_networks_ = wifi_networks;
// Sort the list of wifi networks by ssid.
std::sort(wifi_networks_.begin(), wifi_networks_.end());
wifi_ = WifiNetwork();
@@ -253,6 +277,15 @@ void NetworkLibrary::UpdateNetworkStatus(
break; // There is only one connected or connecting wifi network.
}
}
+ cellular_networks_ = cellular_networks;
+ std::sort(cellular_networks_.begin(), cellular_networks_.end());
+ cellular_ = CellularNetwork();
+ for (size_t i = 0; i < cellular_networks_.size(); i++) {
+ if (cellular_networks_[i].connecting || cellular_networks_[i].connected) {
+ cellular_ = cellular_networks_[i];
+ break; // There is only one connected or connecting cellular network.
+ }
+ }
FOR_EACH_OBSERVER(Observer, observers_, NetworkChanged(this));
}
diff --git a/chrome/browser/chromeos/network_library.h b/chrome/browser/chromeos/network_library.h
index 021fd7d..a9ab7a8 100644
--- a/chrome/browser/chromeos/network_library.h
+++ b/chrome/browser/chromeos/network_library.h
@@ -61,6 +61,30 @@ struct WifiNetwork {
};
typedef std::vector<WifiNetwork> WifiNetworkVector;
+struct CellularNetwork {
+ CellularNetwork()
+ : strength(strength),
+ connecting(false),
+ connected(false) {}
+ CellularNetwork(const std::string& name, int strength, bool connecting,
+ bool connected)
+ : name(name),
+ strength(strength),
+ connecting(connecting),
+ connected(connected) {}
+
+ // CellularNetworks are sorted by name.
+ bool operator< (const CellularNetwork& other) const {
+ return name < other.name;
+ }
+
+ std::string name;
+ int strength;
+ bool connecting;
+ bool connected;
+};
+typedef std::vector<CellularNetwork> CellularNetworkVector;
+
// This class handles the interaction with the ChromeOS network library APIs.
// Classes can add themselves as observers. Users can get an instance of this
// library class like this: NetworkLibrary::Get()
@@ -106,15 +130,28 @@ class NetworkLibrary : public URLRequestJobTracker::JobObserver {
bool wifi_connecting() const { return wifi_.connecting; }
bool wifi_connected() const { return wifi_.connected; }
int wifi_strength() const { return wifi_.strength; }
+ const std::string& cellular_name() const { return cellular_.name; }
+ bool cellular_connecting() const { return cellular_.connecting; }
+ bool cellular_connected() const { return cellular_.connected; }
+ int cellular_strength() const { return cellular_.strength; }
// Returns the current list of wifi networks.
const WifiNetworkVector& wifi_networks() const { return wifi_networks_; }
+ // Returns the current list of cellular networks.
+ const CellularNetworkVector& cellular_networks() const {
+ return cellular_networks_;
+ }
+
// Connect to the specified wireless network with password.
void ConnectToWifiNetwork(WifiNetwork network, const string16& password);
+ // Connect to the specified cellular network.
+ void ConnectToCellularNetwork(CellularNetwork network);
+
bool ethernet_enabled() const { return network_devices_ & TYPE_ETHERNET; }
bool wifi_enabled() const { return network_devices_ & TYPE_WIFI; }
+ bool cellular_enabled() const { return network_devices_ & TYPE_CELLULAR; }
bool offline_mode() const { return offline_mode_; }
// Enables/disables the ethernet network device.
@@ -123,6 +160,9 @@ class NetworkLibrary : public URLRequestJobTracker::JobObserver {
// Enables/disables the wifi network device.
void EnableWifiNetworkDevice(bool enable);
+ // Enables/disables the cellular network device.
+ void EnableCellularNetworkDevice(bool enable);
+
// Enables/disables offline mode.
void EnableOfflineMode(bool enable);
@@ -137,11 +177,13 @@ class NetworkLibrary : public URLRequestJobTracker::JobObserver {
static void NetworkStatusChangedHandler(void* object,
const chromeos::ServiceStatus& service_status);
- // This parses ServiceStatus and creates a WifiNetworkVector of wifi networks.
+ // This parses ServiceStatus and creates a WifiNetworkVector of wifi networks
+ // and a CellularNetworkVector of cellular networks.
// It also sets the ethernet connecting/connected status.
static void ParseNetworks(const chromeos::ServiceStatus& service_status,
- WifiNetworkVector* networks,
- EthernetNetwork* ethernet);
+ EthernetNetwork* ethernet,
+ WifiNetworkVector* wifi_networks,
+ CellularNetworkVector* ceullular_networks);
// This methods loads the initial list of networks on startup and starts the
// monitoring of network changes.
@@ -150,10 +192,12 @@ class NetworkLibrary : public URLRequestJobTracker::JobObserver {
// Enables/disables the specified network device.
void EnableNetworkDevice(chromeos::ConnectionType device, bool enable);
- // Update the network with the a list of wifi networks and ethernet status.
+ // Update the network with the ethernet status and a list of wifi and cellular
+ // networks.
// This will notify all the Observers.
- void UpdateNetworkStatus(const WifiNetworkVector& networks,
- const EthernetNetwork& ethernet);
+ void UpdateNetworkStatus(const EthernetNetwork& ethernet,
+ const WifiNetworkVector& wifi_networks,
+ const CellularNetworkVector& cellular_networks);
// Checks network traffic to see if there is any uploading.
// If there is download traffic, then true is passed in for download.
@@ -196,6 +240,12 @@ class NetworkLibrary : public URLRequestJobTracker::JobObserver {
// The current connected (or connecting) wifi network.
WifiNetwork wifi_;
+ // The list of available cellular networks.
+ CellularNetworkVector cellular_networks_;
+
+ // The current connected (or connecting) cellular network.
+ CellularNetwork cellular_;
+
// The current enabled network devices. This is a bitwise flag of
// ConnectionTypes.
int network_devices_;
diff --git a/chrome/browser/chromeos/network_menu_button.cc b/chrome/browser/chromeos/network_menu_button.cc
index 92c6845..78acbfa 100644
--- a/chrome/browser/chromeos/network_menu_button.cc
+++ b/chrome/browser/chromeos/network_menu_button.cc
@@ -115,9 +115,11 @@ void NetworkMenuButton::ActivatedAt(int index) {
cros->EnableEthernetNetworkDevice(!cros->ethernet_enabled());
} else if (menu_items_[index].flags & FLAG_TOGGLE_WIFI) {
cros->EnableWifiNetworkDevice(!cros->wifi_enabled());
+ } else if (menu_items_[index].flags & FLAG_TOGGLE_CELLULAR) {
+ cros->EnableCellularNetworkDevice(!cros->cellular_enabled());
} else if (menu_items_[index].flags & FLAG_TOGGLE_OFFLINE) {
cros->EnableOfflineMode(!cros->offline_mode());
- } else {
+ } else if (menu_items_[index].flags & FLAG_ACTIVATE_WIFI) {
activated_wifi_network_ = menu_items_[index].wifi_network;
// If clicked on a network that we are already connected to or we are
@@ -142,6 +144,8 @@ void NetworkMenuButton::ActivatedAt(int index) {
window->SetBounds(gfx::Rect(point, size), browser_window_);
window->Show();
}
+ } else if (menu_items_[index].flags & FLAG_ACTIVATE_CELLULAR) {
+ cros->ConnectToCellularNetwork(menu_items_[index].cellular_network);
}
}
@@ -318,6 +322,12 @@ SkBitmap NetworkMenuButton::IconForWifiStrength(int strength) {
return menu_wifi_icons_[index];
}
+// static
+SkBitmap NetworkMenuButton::IconForCellularStrength(int strength) {
+ // TODO(chocobo): need to switch to cellular icons when they are ready.
+ return IconForWifiStrength(strength);
+}
+
////////////////////////////////////////////////////////////////////////////////
// NetworkMenuButton, views::ViewMenuDelegate implementation:
@@ -352,7 +362,7 @@ void NetworkMenuButton::InitMenuItems() {
IconForWifiStrength(cros->wifi_strength()) :
*menu_disconnected_icon_;
menu_items_.push_back(MenuItem(menus::MenuModel::TYPE_COMMAND, label,
- icon, WifiNetwork(), FLAG_DISABLED));
+ icon, WifiNetwork(), CellularNetwork(), FLAG_DISABLED));
// Turn Wifi Off.
if (!offline_mode) {
@@ -362,7 +372,7 @@ void NetworkMenuButton::InitMenuItems() {
l10n_util::GetStringFUTF16(IDS_STATUSBAR_NETWORK_DEVICE_ENABLE,
l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_DEVICE_WIFI));
menu_items_.push_back(MenuItem(menus::MenuModel::TYPE_COMMAND, label,
- SkBitmap(), WifiNetwork(), FLAG_TOGGLE_WIFI));
+ SkBitmap(), WifiNetwork(), CellularNetwork(), FLAG_TOGGLE_WIFI));
const WifiNetworkVector& networks = cros->wifi_networks();
// Wifi networks ssids.
@@ -372,7 +382,7 @@ void NetworkMenuButton::InitMenuItems() {
l10n_util::GetStringFUTF16(IDS_STATUSBAR_NETWORK_MENU_ITEM_INDENT,
l10n_util::GetStringUTF16(IDS_STATUSBAR_NO_NETWORKS_MESSAGE));
menu_items_.push_back(MenuItem(menus::MenuModel::TYPE_COMMAND, label,
- SkBitmap(), WifiNetwork(), FLAG_DISABLED));
+ SkBitmap(), WifiNetwork(), CellularNetwork(), FLAG_DISABLED));
} else {
for (size_t i = 0; i < networks.size(); ++i) {
label =
@@ -380,14 +390,66 @@ void NetworkMenuButton::InitMenuItems() {
ASCIIToUTF16(networks[i].ssid));
if (networks[i].ssid == cros->wifi_ssid()) {
menu_items_.push_back(MenuItem(menus::MenuModel::TYPE_CHECK, label,
- SkBitmap(), networks[i], 0));
+ SkBitmap(), networks[i], CellularNetwork(), FLAG_ACTIVATE_WIFI));
+ } else {
+ menu_items_.push_back(MenuItem(menus::MenuModel::TYPE_COMMAND, label,
+ SkBitmap(), networks[i], CellularNetwork(), FLAG_ACTIVATE_WIFI));
+ }
+ }
+ }
+
+ // Separator.
+ menu_items_.push_back(MenuItem());
+ }
+
+ // Cellular: Status.
+ status = IDS_STATUSBAR_NETWORK_DEVICE_DISABLED;
+ if (cros->cellular_connecting())
+ status = IDS_STATUSBAR_NETWORK_DEVICE_CONNECTING;
+ else if (cros->cellular_connected())
+ status = IDS_STATUSBAR_NETWORK_DEVICE_CONNECTED;
+ else if (cros->cellular_enabled())
+ status = IDS_STATUSBAR_NETWORK_DEVICE_DISCONNECTED;
+ label =
+ l10n_util::GetStringFUTF16(IDS_STATUSBAR_NETWORK_DEVICE_STATUS,
+ l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_DEVICE_CELLULAR),
+ l10n_util::GetStringUTF16(status));
+ icon = cros->cellular_connected() ?
+ IconForCellularStrength(cros->cellular_strength()) :
+ *menu_disconnected_icon_;
+ menu_items_.push_back(MenuItem(menus::MenuModel::TYPE_COMMAND, label,
+ icon, WifiNetwork(), CellularNetwork(), FLAG_DISABLED));
+
+ // Turn Cellular Off.
+ if (!offline_mode) {
+ label = cros->cellular_enabled() ?
+ l10n_util::GetStringFUTF16(IDS_STATUSBAR_NETWORK_DEVICE_DISABLE,
+ l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_DEVICE_CELLULAR)) :
+ l10n_util::GetStringFUTF16(IDS_STATUSBAR_NETWORK_DEVICE_ENABLE,
+ l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_DEVICE_CELLULAR));
+ menu_items_.push_back(MenuItem(menus::MenuModel::TYPE_COMMAND, label,
+ SkBitmap(), WifiNetwork(), CellularNetwork(), FLAG_TOGGLE_CELLULAR));
+
+ const CellularNetworkVector& networks = cros->cellular_networks();
+ // Cellular networks ssids.
+ if (networks.empty()) {
+ // No networks available message.
+ label =
+ l10n_util::GetStringFUTF16(IDS_STATUSBAR_NETWORK_MENU_ITEM_INDENT,
+ l10n_util::GetStringUTF16(IDS_STATUSBAR_NO_NETWORKS_MESSAGE));
+ menu_items_.push_back(MenuItem(menus::MenuModel::TYPE_COMMAND, label,
+ SkBitmap(), WifiNetwork(), CellularNetwork(), FLAG_DISABLED));
+ } else {
+ for (size_t i = 0; i < networks.size(); ++i) {
+ label =
+ l10n_util::GetStringFUTF16(IDS_STATUSBAR_NETWORK_MENU_ITEM_INDENT,
+ ASCIIToUTF16(networks[i].name));
+ if (networks[i].name == cros->cellular_name()) {
+ menu_items_.push_back(MenuItem(menus::MenuModel::TYPE_CHECK, label,
+ SkBitmap(), WifiNetwork(), networks[i], FLAG_ACTIVATE_CELLULAR));
} else {
menu_items_.push_back(MenuItem(menus::MenuModel::TYPE_COMMAND, label,
- SkBitmap(), networks[i], 0));
- // TODO(chocobo): Once we have better icons and more reliable strength
- // data, show icons for wifi ssids.
-// menu_items_.push_back(MenuItem(menus::MenuModel::TYPE_COMMAND, label,
-// IconForWifiStrength(networks[i].strength), networks[i], 0));
+ SkBitmap(), WifiNetwork(), networks[i], FLAG_ACTIVATE_CELLULAR));
}
}
}
@@ -410,7 +472,7 @@ void NetworkMenuButton::InitMenuItems() {
icon = cros->ethernet_connected() ? *menu_wired_icon_ :
*menu_disconnected_icon_;
menu_items_.push_back(MenuItem(menus::MenuModel::TYPE_COMMAND, label,
- icon, WifiNetwork(), FLAG_DISABLED));
+ icon, WifiNetwork(), CellularNetwork(), FLAG_DISABLED));
// Turn Ethernet Off.
if (!offline_mode) {
@@ -420,7 +482,7 @@ void NetworkMenuButton::InitMenuItems() {
l10n_util::GetStringFUTF16(IDS_STATUSBAR_NETWORK_DEVICE_ENABLE,
l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET));
menu_items_.push_back(MenuItem(menus::MenuModel::TYPE_COMMAND, label,
- SkBitmap(), WifiNetwork(), FLAG_TOGGLE_ETHERNET));
+ SkBitmap(), WifiNetwork(), CellularNetwork(), FLAG_TOGGLE_ETHERNET));
// Separator.
menu_items_.push_back(MenuItem());
@@ -430,7 +492,7 @@ void NetworkMenuButton::InitMenuItems() {
menu_items_.push_back(MenuItem(offline_mode ?
menus::MenuModel::TYPE_CHECK : menus::MenuModel::TYPE_COMMAND,
l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_OFFLINE_MODE),
- SkBitmap(), WifiNetwork(), FLAG_TOGGLE_OFFLINE));
+ SkBitmap(), WifiNetwork(), CellularNetwork(), FLAG_TOGGLE_OFFLINE));
}
} // namespace chromeos
diff --git a/chrome/browser/chromeos/network_menu_button.h b/chrome/browser/chromeos/network_menu_button.h
index f42c3b4..ba93ff9 100644
--- a/chrome/browser/chromeos/network_menu_button.h
+++ b/chrome/browser/chromeos/network_menu_button.h
@@ -28,23 +28,29 @@ namespace chromeos {
// The network menu button in the status area.
// This class will handle getting the wifi networks and populating the menu.
// It will also handle the status icon changing and connecting to another
-// wifi network.
+// wifi/cellular network.
//
// The network menu looks like this:
//
-// <icon> Wifi: <status> (disabled)
+// <icon> Wifi: <status>
// Turn Wifi <action>
// <icon> Wifi Network A
// <check> Wifi Network B
// <icon> Wifi Network C
// --------------------------------
-// <icon> Ethernet: <status> (disabled)
+// <icon> Cellular: <status>
+// Turn Cellular <action>
+// <icon> Cellular Network A
+// <check> Cellular Network B
+// <icon> Cellular Network C
+// --------------------------------
+// <icon> Ethernet: <status>
// Turn Ethernet <action>
//
// <icon> will show the current state of the network device and the strength of
-// the wifi networks.
+// the wifi/cellular networks.
// <check> will be a check mark icon for the currently connected wifi.
-// <status> will be one of: Connected, Connecting, Disconnected, or Disabled.
+// <status> will be one of: Connected, Connecting, Disconnected, or Off.
// <action> will be either On or Off depending on the current state.
class NetworkMenuButton : public StatusAreaButton,
public views::ViewMenuDelegate,
@@ -91,10 +97,13 @@ class NetworkMenuButton : public StatusAreaButton,
private:
enum MenuItemFlags {
- FLAG_DISABLED = 1 << 0,
- FLAG_TOGGLE_ETHERNET = 1 << 1,
- FLAG_TOGGLE_WIFI = 1 << 2,
- FLAG_TOGGLE_OFFLINE = 1 << 3
+ FLAG_DISABLED = 1 << 0,
+ FLAG_TOGGLE_ETHERNET = 1 << 1,
+ FLAG_TOGGLE_WIFI = 1 << 2,
+ FLAG_TOGGLE_CELLULAR = 1 << 3,
+ FLAG_TOGGLE_OFFLINE = 1 << 4,
+ FLAG_ACTIVATE_WIFI = 1 << 5,
+ FLAG_ACTIVATE_CELLULAR = 1 << 6
};
struct MenuItem {
@@ -102,23 +111,28 @@ class NetworkMenuButton : public StatusAreaButton,
: type(menus::MenuModel::TYPE_SEPARATOR),
flags(0) {}
MenuItem(menus::MenuModel::ItemType type, string16 label, SkBitmap icon,
- WifiNetwork wifi_network, int flags)
+ WifiNetwork wifi_network, CellularNetwork cellular_network,
+ int flags)
: type(type),
label(label),
icon(icon),
wifi_network(wifi_network),
+ cellular_network(cellular_network),
flags(flags) {}
menus::MenuModel::ItemType type;
string16 label;
SkBitmap icon;
WifiNetwork wifi_network;
+ CellularNetwork cellular_network;
int flags;
};
typedef std::vector<MenuItem> MenuItemVector;
static SkBitmap IconForWifiStrength(int strength);
+ static SkBitmap IconForCellularStrength(int strength);
+
// views::ViewMenuDelegate implementation.
virtual void RunMenu(views::View* source, const gfx::Point& pt);