| Index: chrome/browser/chromeos/system/ash_system_tray_delegate.cc
|
| diff --git a/chrome/browser/chromeos/system/ash_system_tray_delegate.cc b/chrome/browser/chromeos/system/ash_system_tray_delegate.cc
|
| index 6c7712fa1d12d979a2eb3bcd6a750b3caf08b9f5..d02f3ebdb54df7ba00c18823d43ad60257d70eea 100644
|
| --- a/chrome/browser/chromeos/system/ash_system_tray_delegate.cc
|
| +++ b/chrome/browser/chromeos/system/ash_system_tray_delegate.cc
|
| @@ -12,6 +12,7 @@
|
| #include "ash/system/tray/system_tray.h"
|
| #include "ash/system/tray/system_tray_delegate.h"
|
| #include "base/logging.h"
|
| +#include "base/utf_string_conversions.h"
|
| #include "chrome/browser/chromeos/audio/audio_handler.h"
|
| #include "chrome/browser/chromeos/cros/cros_library.h"
|
| #include "chrome/browser/chromeos/cros/network_library.h"
|
| @@ -19,21 +20,34 @@
|
| #include "chrome/browser/chromeos/dbus/power_manager_client.h"
|
| #include "chrome/browser/chromeos/login/user.h"
|
| #include "chrome/browser/chromeos/login/user_manager.h"
|
| +#include "chrome/browser/chromeos/status/network_menu.h"
|
| #include "chrome/browser/chromeos/status/network_menu_icon.h"
|
| #include "chrome/browser/ui/browser.h"
|
| #include "chrome/browser/ui/browser_list.h"
|
| #include "chrome/common/chrome_notification_types.h"
|
| #include "content/public/browser/notification_observer.h"
|
| #include "content/public/browser/notification_service.h"
|
| +#include "grit/generated_resources.h"
|
| +#include "ui/base/l10n/l10n_util.h"
|
|
|
| namespace chromeos {
|
|
|
| namespace {
|
|
|
| +ash::NetworkIconInfo CreateNetworkIconInfo(const Network* network,
|
| + NetworkMenuIcon* network_icon) {
|
| + ash::NetworkIconInfo info;
|
| + info.name = UTF8ToUTF16(network->name());
|
| + info.image = network_icon->GetBitmap(network, NetworkMenuIcon::SIZE_SMALL);
|
| + info.unique_id = network->unique_id();
|
| + return info;
|
| +}
|
| +
|
| class SystemTrayDelegate : public ash::SystemTrayDelegate,
|
| public AudioHandler::VolumeObserver,
|
| public PowerManagerClient::Observer,
|
| public NetworkMenuIcon::Delegate,
|
| + public NetworkMenu::Delegate,
|
| public NetworkLibrary::NetworkManagerObserver,
|
| public NetworkLibrary::NetworkObserver,
|
| public NetworkLibrary::CellularDataPlanObserver,
|
| @@ -42,7 +56,10 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
|
| explicit SystemTrayDelegate(ash::SystemTray* tray)
|
| : tray_(tray),
|
| network_icon_(ALLOW_THIS_IN_INITIALIZER_LIST(
|
| - new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE))) {
|
| + new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE))),
|
| + network_icon_large_(ALLOW_THIS_IN_INITIALIZER_LIST(
|
| + new NetworkMenuIcon(this, NetworkMenuIcon::MENU_MODE))),
|
| + network_menu_(ALLOW_THIS_IN_INITIALIZER_LIST(new NetworkMenu(this))) {
|
| AudioHandler::GetInstance()->AddVolumeObserver(this);
|
| DBusThreadManager::Get()->GetPowerManagerClient()->AddObserver(this);
|
| DBusThreadManager::Get()->GetPowerManagerClient()->RequestStatusUpdate(
|
| @@ -56,6 +73,8 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
|
| registrar_.Add(this,
|
| chrome::NOTIFICATION_LOGIN_USER_CHANGED,
|
| content::NotificationService::AllSources());
|
| +
|
| + network_icon_large_->SetResourceSize(NetworkMenuIcon::SIZE_LARGE);
|
| }
|
|
|
| virtual ~SystemTrayDelegate() {
|
| @@ -90,15 +109,27 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
|
| }
|
|
|
| virtual void ShowSettings() OVERRIDE {
|
| - BrowserList::GetLastActive()->OpenOptionsDialog();
|
| + Browser* browser = BrowserList::GetLastActive();
|
| + if (browser)
|
| + browser->OpenOptionsDialog();
|
| }
|
|
|
| virtual void ShowDateSettings() OVERRIDE {
|
| - BrowserList::GetLastActive()->OpenAdvancedOptionsDialog();
|
| + Browser* browser = BrowserList::GetLastActive();
|
| + if (browser)
|
| + browser->OpenAdvancedOptionsDialog();
|
| + }
|
| +
|
| + virtual void ShowNetworkSettings() OVERRIDE {
|
| + Browser* browser = BrowserList::GetLastActive();
|
| + if (browser)
|
| + browser->OpenInternetOptionsDialog();
|
| }
|
|
|
| virtual void ShowHelp() OVERRIDE {
|
| - BrowserList::GetLastActive()->ShowHelpTab();
|
| + Browser* browser = BrowserList::GetLastActive();
|
| + if (browser)
|
| + browser->ShowHelpTab();
|
| }
|
|
|
| virtual bool IsAudioMuted() const OVERRIDE {
|
| @@ -130,12 +161,71 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
|
| NotifyScreenLockRequested();
|
| }
|
|
|
| - virtual ash::NetworkIconInfo GetMostRelevantNetworkIcon() OVERRIDE {
|
| + virtual ash::NetworkIconInfo GetMostRelevantNetworkIcon(bool large) OVERRIDE {
|
| ash::NetworkIconInfo info;
|
| - info.image = network_icon_->GetIconAndText(&info.description);
|
| + info.image = !large ? network_icon_->GetIconAndText(&info.description) :
|
| + network_icon_large_->GetIconAndText(&info.description);
|
| return info;
|
| }
|
|
|
| + virtual void GetAvailableNetworks(
|
| + std::vector<ash::NetworkIconInfo>* list) OVERRIDE {
|
| + NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary();
|
| + crosnet->RequestNetworkScan();
|
| +
|
| + // Ethernet.
|
| + if (crosnet->ethernet_enabled()) {
|
| + const EthernetNetwork* ethernet_network = crosnet->ethernet_network();
|
| + if (ethernet_network) {
|
| + ash::NetworkIconInfo info;
|
| + info.image = network_icon_->GetBitmap(ethernet_network,
|
| + NetworkMenuIcon::SIZE_SMALL);
|
| + if (!ethernet_network->name().empty())
|
| + info.name = UTF8ToUTF16(ethernet_network->name());
|
| + else
|
| + info.name =
|
| + l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET);
|
| + info.unique_id = ethernet_network->unique_id();
|
| + list->push_back(info);
|
| + }
|
| + }
|
| +
|
| + // Wifi.
|
| + if (crosnet->wifi_available() && crosnet->wifi_enabled()) {
|
| + const WifiNetworkVector& wifi = crosnet->wifi_networks();
|
| + for (size_t i = 0; i < wifi.size(); ++i)
|
| + list->push_back(CreateNetworkIconInfo(wifi[i], network_icon_.get()));
|
| + }
|
| +
|
| + // Cellular.
|
| + if (crosnet->cellular_available() && crosnet->cellular_enabled()) {
|
| + const CellularNetworkVector& cell = crosnet->cellular_networks();
|
| + for (size_t i = 0; i < cell.size(); ++i)
|
| + list->push_back(CreateNetworkIconInfo(cell[i], network_icon_.get()));
|
| + }
|
| +
|
| + // VPN (only if logged in).
|
| + if (GetUserLoginStatus() == ash::user::LOGGED_IN_NONE)
|
| + return;
|
| + if (crosnet->connected_network() || crosnet->virtual_network_connected()) {
|
| + const VirtualNetworkVector& vpns = crosnet->virtual_networks();
|
| + for (size_t i = 0; i < vpns.size(); ++i)
|
| + list->push_back(CreateNetworkIconInfo(vpns[i], network_icon_.get()));
|
| + }
|
| + }
|
| +
|
| + virtual void ConnectToNetwork(const std::string& network_id) OVERRIDE {
|
| + NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary();
|
| + Network* network = crosnet->FindNetworkByUniqueId(network_id);
|
| + if (network)
|
| + network_menu_->ConnectToNetwork(network);
|
| + }
|
| +
|
| + virtual void ToggleAirplaneMode() OVERRIDE {
|
| + NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary();
|
| + crosnet->EnableOfflineMode(!crosnet->offline_mode());
|
| + }
|
| +
|
| private:
|
| void NotifyRefreshNetwork() {
|
| ash::NetworkController* controller =
|
| @@ -197,11 +287,27 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
|
| // TODO(sad): Override more from PowerManagerClient::Observer here (e.g.
|
| // PowerButtonStateChanged etc.).
|
|
|
| - // Overridden from StatusMenuIcon::Delegate.
|
| + // Overridden from NetworkMenuIcon::Delegate.
|
| virtual void NetworkMenuIconChanged() OVERRIDE {
|
| NotifyRefreshNetwork();
|
| }
|
|
|
| + // Overridden from NetworkMenu::Delegate.
|
| + virtual views::MenuButton* GetMenuButton() OVERRIDE {
|
| + return NULL;
|
| + }
|
| +
|
| + virtual gfx::NativeWindow GetNativeWindow() const OVERRIDE {
|
| + return NULL;
|
| + }
|
| +
|
| + virtual void OpenButtonOptions() OVERRIDE {
|
| + }
|
| +
|
| + virtual bool ShouldOpenButtonOptions() const OVERRIDE {
|
| + return false;
|
| + }
|
| +
|
| // Overridden from NetworkLibrary::NetworkManagerObserver.
|
| virtual void OnNetworkManagerChanged(NetworkLibrary* crosnet) OVERRIDE {
|
| RefreshNetworkObserver(crosnet);
|
| @@ -239,6 +345,8 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
|
|
|
| ash::SystemTray* tray_;
|
| scoped_ptr<NetworkMenuIcon> network_icon_;
|
| + scoped_ptr<NetworkMenuIcon> network_icon_large_;
|
| + scoped_ptr<NetworkMenu> network_menu_;
|
| content::NotificationRegistrar registrar_;
|
| std::string cellular_device_path_;
|
| std::string active_network_path_;
|
|
|