diff options
author | stevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-15 20:49:58 +0000 |
---|---|---|
committer | stevenjb@chromium.org <stevenjb@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-01-15 20:49:58 +0000 |
commit | d45aa1f5cf91d7f0840f66cfcb1d00ed9ba64c6b (patch) | |
tree | 69f4709b4856a0fd5043a24aa6367ae4d3e5a65c /ash | |
parent | 76b5e7ed4caf688621f6539a0ff4c5b1e4c45b4e (diff) | |
download | chromium_src-d45aa1f5cf91d7f0840f66cfcb1d00ed9ba64c6b.zip chromium_src-d45aa1f5cf91d7f0840f66cfcb1d00ed9ba64c6b.tar.gz chromium_src-d45aa1f5cf91d7f0840f66cfcb1d00ed9ba64c6b.tar.bz2 |
Add cellular_initialized state and UI
The goal is to provide connecting icon and text while the cellular network is initializing.
Cellular initializing is defined as:
Cellular technology is enabled, but no powered device present.
BUG=169979
For ash_strings.gyp:
TBR=sky@chromium.org
Review URL: https://codereview.chromium.org/11878034
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@176966 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/ash_strings.grd | 3 | ||||
-rw-r--r-- | ash/system/chromeos/network/network_list_detailed_view_base.cc | 70 | ||||
-rw-r--r-- | ash/system/chromeos/network/network_list_detailed_view_base.h | 5 | ||||
-rw-r--r-- | ash/system/tray/system_tray_delegate.h | 5 | ||||
-rw-r--r-- | ash/system/tray/test_system_tray_delegate.cc | 4 | ||||
-rw-r--r-- | ash/system/tray/test_system_tray_delegate.h | 1 |
6 files changed, 62 insertions, 26 deletions
diff --git a/ash/ash_strings.grd b/ash/ash_strings.grd index e46f84b..ce4e08e 100644 --- a/ash/ash_strings.grd +++ b/ash/ash_strings.grd @@ -317,6 +317,9 @@ Press Ctrl+Alt+Z to disable. <message name="IDS_ASH_STATUS_TRAY_WIFI_SCANNING_MESSAGE" desc="Scanning for wifi networks"> Searching for Wi-Fi networks... </message> + <message name="IDS_ASH_STATUS_TRAY_INITIALIZING_CELLULAR" desc="Message for the status area when initializing the cellular device."> + Initializing cellular modem... + </message> <message name="IDS_ASH_STATUS_TRAY_UPDATE" desc="The label used in the tray popup to notify that the user should restart to get system updates."> Restart to update </message> diff --git a/ash/system/chromeos/network/network_list_detailed_view_base.cc b/ash/system/chromeos/network/network_list_detailed_view_base.cc index 7d50b5b..f457ce5 100644 --- a/ash/system/chromeos/network/network_list_detailed_view_base.cc +++ b/ash/system/chromeos/network/network_list_detailed_view_base.cc @@ -91,7 +91,8 @@ NetworkListDetailedViewBase::NetworkListDetailedViewBase( info_icon_(NULL), settings_(NULL), proxy_settings_(NULL), - scanning_view_(NULL), + status_view_(NULL), + no_networks_view_(NULL), info_bubble_(NULL) { } @@ -200,7 +201,7 @@ void NetworkListDetailedViewBase::UpdateAvailableNetworkList() { GetAvailableNetworkList(&network_list_); } -void NetworkListDetailedViewBase::RefreshNetworkScrollWithUpdatedNetworkList() { +void NetworkListDetailedViewBase::RefreshNetworkList() { network_map_.clear(); std::set<std::string> new_service_paths; @@ -209,29 +210,37 @@ void NetworkListDetailedViewBase::RefreshNetworkScrollWithUpdatedNetworkList() { if (service_path_map_.empty()) { scroll_content()->RemoveAllChildViews(true); - scanning_view_ = NULL; + status_view_ = NULL; + no_networks_view_ = NULL; } + SystemTrayDelegate* delegate = Shell::GetInstance()->system_tray_delegate(); + // Insert child views. Order is: // * Highlit networks (connected and connecting) - // * "Scanning..." + // * "Initializing cellular modem..." or "Searching for Wi-Fi networks..." // * Un-highlit networks (not connected). Usually empty while scanning. - - bool wifi_scanning = - Shell::GetInstance()->system_tray_delegate()->GetWifiScanning(); - if (wifi_scanning && scanning_view_ == NULL) { - scanning_view_ = new views::Label( - ui::ResourceBundle::GetSharedInstance(). - GetLocalizedString(IDS_ASH_STATUS_TRAY_WIFI_SCANNING_MESSAGE)); - scanning_view_->set_border(views::Border::CreateEmptyBorder(20, 0, 10, 0)); - scanning_view_->SetFont( - scanning_view_->font().DeriveFont(0, gfx::Font::ITALIC)); + // * "Wi-Fi is turned off" if wifi disabled and no networks + + int status_message_id = 0; + if (delegate->GetCellularInitializing()) + status_message_id = IDS_ASH_STATUS_TRAY_INITIALIZING_CELLULAR; + else if (delegate->GetWifiScanning()) + status_message_id = IDS_ASH_STATUS_TRAY_WIFI_SCANNING_MESSAGE; + if (status_message_id && status_view_ == NULL) { + status_view_ = new views::Label( + ui::ResourceBundle::GetSharedInstance().GetLocalizedString( + status_message_id)); + status_view_->set_border(views::Border::CreateEmptyBorder(20, 20, 10, 0)); + status_view_->SetFont( + status_view_->font().DeriveFont(0, gfx::Font::ITALIC)); + status_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); // Initially insert "scanning" first. - scroll_content()->AddChildViewAt(scanning_view_, 0); + scroll_content()->AddChildViewAt(status_view_, 0); needs_relayout = true; - } else if (!wifi_scanning && scanning_view_ != NULL) { - scroll_content()->RemoveChildView(scanning_view_); - scanning_view_ = NULL; + } else if (!status_message_id && status_view_ != NULL) { + scroll_content()->RemoveChildView(status_view_); + status_view_ = NULL; needs_relayout = true; } @@ -239,7 +248,7 @@ void NetworkListDetailedViewBase::RefreshNetworkScrollWithUpdatedNetworkList() { for (size_t i = 0; i < network_list_.size(); ++i) { const bool highlight = network_list_[i].connected || network_list_[i].connecting; - if (scanning_view_ && child_index_offset == 0 && !highlight) + if (status_view_ && child_index_offset == 0 && !highlight) child_index_offset = 1; // |child_index| determines the position of the view, which is the same // as the list index for highlit views, and offset by one for any @@ -300,6 +309,24 @@ void NetworkListDetailedViewBase::RefreshNetworkScrollWithUpdatedNetworkList() { service_path_map_.erase(*remove_it); } + if (network_list_.empty() && no_networks_view_ == NULL) { + int message_id = delegate->GetWifiEnabled() ? + IDS_ASH_STATUS_TRAY_NETWORK_WIFI_ENABLED : + IDS_ASH_STATUS_TRAY_NETWORK_WIFI_DISABLED; + no_networks_view_ = new views::Label( + ui::ResourceBundle::GetSharedInstance().GetLocalizedString( + message_id)); + no_networks_view_->set_border( + views::Border::CreateEmptyBorder(20, 20, 10, 0)); + no_networks_view_->SetHorizontalAlignment(gfx::ALIGN_LEFT); + scroll_content()->AddChildViewAt(no_networks_view_, 0); + needs_relayout = true; + } else if (no_networks_view_) { + scroll_content()->RemoveChildView(no_networks_view_); + no_networks_view_ = NULL; + needs_relayout = true; + } + if (needs_relayout) { scroll_content()->SizeToPreferredSize(); static_cast<views::View*>(scroller())->Layout(); @@ -315,10 +342,7 @@ void NetworkListDetailedViewBase::ClearNetworkScrollWithEmptyNetworkList() { } void NetworkListDetailedViewBase::RefreshNetworkScrollWithUpdatedNetworkData() { - if (network_list_.size() > 0 ) - RefreshNetworkScrollWithUpdatedNetworkList(); - else - RefreshNetworkScrollWithEmptyNetworkList(); + RefreshNetworkList(); } bool NetworkListDetailedViewBase::IsNetworkListEmpty() const { diff --git a/ash/system/chromeos/network/network_list_detailed_view_base.h b/ash/system/chromeos/network/network_list_detailed_view_base.h index 4a04cc9..ee9ec9d 100644 --- a/ash/system/chromeos/network/network_list_detailed_view_base.h +++ b/ash/system/chromeos/network/network_list_detailed_view_base.h @@ -73,7 +73,7 @@ class NetworkListDetailedViewBase : public NetworkDetailedView, void UpdateAvailableNetworkList(); void AppendHeaderEntry(int header_string_id); void AppendNetworkExtra(); - void RefreshNetworkScrollWithUpdatedNetworkList(); + void RefreshNetworkList(); // Adds a settings entry when logged in, and an entry for changing proxy // settings otherwise. void CreateSettingsEntry(); @@ -90,7 +90,8 @@ class NetworkListDetailedViewBase : public NetworkDetailedView, TrayPopupHeaderButton* info_icon_; TrayPopupLabelButton* settings_; TrayPopupLabelButton* proxy_settings_; - views::Label* scanning_view_; + views::Label* status_view_; + views::Label* no_networks_view_; views::BubbleDelegateView* info_bubble_; DISALLOW_COPY_AND_ASSIGN(NetworkListDetailedViewBase); diff --git a/ash/system/tray/system_tray_delegate.h b/ash/system/tray/system_tray_delegate.h index 5960484..5f80a99 100644 --- a/ash/system/tray/system_tray_delegate.h +++ b/ash/system/tray/system_tray_delegate.h @@ -298,9 +298,12 @@ class SystemTrayDelegate { std::string* topup_url, std::string* setup_url) = 0; - // Returns whether or not the network manager is scanning for wifi networks. + // Returns whether the network manager is scanning for wifi networks. virtual bool GetWifiScanning() = 0; + // Returns whether the network manager is initializing the cellular modem. + virtual bool GetCellularInitializing() = 0; + // Opens the cellular network specific URL. virtual void ShowCellularURL(const std::string& url) = 0; diff --git a/ash/system/tray/test_system_tray_delegate.cc b/ash/system/tray/test_system_tray_delegate.cc index 4a5015a..48aaa96 100644 --- a/ash/system/tray/test_system_tray_delegate.cc +++ b/ash/system/tray/test_system_tray_delegate.cc @@ -301,6 +301,10 @@ bool TestSystemTrayDelegate::GetWifiScanning() { return false; } +bool TestSystemTrayDelegate::GetCellularInitializing() { + return false; +} + void TestSystemTrayDelegate::ShowCellularURL(const std::string& url) { } diff --git a/ash/system/tray/test_system_tray_delegate.h b/ash/system/tray/test_system_tray_delegate.h index 47d182c..23648ee 100644 --- a/ash/system/tray/test_system_tray_delegate.h +++ b/ash/system/tray/test_system_tray_delegate.h @@ -93,6 +93,7 @@ class TestSystemTrayDelegate : public SystemTrayDelegate { std::string* topup_url, std::string* setup_url) OVERRIDE; virtual bool GetWifiScanning() OVERRIDE; + virtual bool GetCellularInitializing() OVERRIDE; virtual void ShowCellularURL(const std::string& url) OVERRIDE; virtual void ChangeProxySettings() OVERRIDE; virtual VolumeControlDelegate* GetVolumeControlDelegate() const OVERRIDE; |