Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(683)

Unified Diff: chrome/browser/chromeos/system/ash_system_tray_delegate.cc

Issue 12779022: Add Ash notification UI for OutOfCredits network property (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add support for R26 Created 7 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/chromeos/status/network_menu.cc ('k') | chromeos/network/network_state.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1ed1c08a2ab9bf934e6c0d3cfde8c8a7cc8a6913..66c5f38f3dad9a5cf69b12e613b591bc3d53e60c 100644
--- a/chrome/browser/chromeos/system/ash_system_tray_delegate.cc
+++ b/chrome/browser/chromeos/system/ash_system_tray_delegate.cc
@@ -14,6 +14,7 @@
#include "ash/system/bluetooth/bluetooth_observer.h"
#include "ash/system/brightness/brightness_observer.h"
#include "ash/system/chromeos/network/network_observer.h"
+#include "ash/system/chromeos/network/network_tray_delegate.h"
#include "ash/system/date/clock_observer.h"
#include "ash/system/drive/drive_observer.h"
#include "ash/system/ime/ime_observer.h"
@@ -186,6 +187,14 @@ void BluetoothDeviceConnectError(
// TODO(sad): Do something?
}
+ash::NetworkObserver::NetworkType NetworkTypeForCellular(
+ const CellularNetwork* cellular) {
+ if (cellular->network_technology() == NETWORK_TECHNOLOGY_LTE ||
+ cellular->network_technology() == NETWORK_TECHNOLOGY_LTE_ADVANCED)
+ return ash::NetworkObserver::NETWORK_CELLULAR_LTE;
+ return ash::NetworkObserver::NETWORK_CELLULAR;
+}
+
class SystemTrayDelegate : public ash::SystemTrayDelegate,
public AudioHandler::VolumeObserver,
public PowerManagerClient::Observer,
@@ -219,6 +228,7 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
screen_locked_(false),
data_promo_notification_(new DataPromoNotification()),
cellular_activating_(false),
+ cellular_out_of_credits_(false),
volume_control_delegate_(new VolumeController()) {
// Register notifications on construction so that events such as
// PROFILE_CREATED do not get missed if they happen before Initialize().
@@ -747,18 +757,10 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
virtual void ConnectToNetwork(const std::string& network_id) OVERRIDE {
NetworkLibrary* crosnet = CrosLibrary::Get()->GetNetworkLibrary();
Network* network = crosnet->FindNetworkByPath(network_id);
- if (!CommandLine::ForCurrentProcess()->HasSwitch(
- ash::switches::kAshDisableNewNetworkStatusArea)) {
- // If the new network handlers are enabled, this should always trigger
- // displaying the network settings UI.
- if (network)
- network_menu_->ShowTabbedNetworkSettings(network);
- else
- ShowNetworkSettings();
- } else {
- if (network)
- network_menu_->ConnectToNetwork(network);
- }
+ if (network)
+ network_menu_->ConnectToNetwork(network); // Shows settings if connected
+ else
+ ShowNetworkSettings();
}
virtual void RequestNetworkScan() OVERRIDE {
@@ -1020,14 +1022,6 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
}
}
- void RefreshNetworkDeviceObserver(NetworkLibrary* crosnet) {
- const NetworkDevice* cellular = crosnet->FindCellularDevice();
- std::string new_cellular_device_path = cellular ?
- cellular->device_path() : std::string();
- if (cellular_device_path_ != new_cellular_device_path)
- cellular_device_path_ = new_cellular_device_path;
- }
-
void AddNetworkToList(std::vector<ash::NetworkIconInfo>* list,
std::set<const Network*>* added,
const Network* network) {
@@ -1147,10 +1141,9 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
// Overridden from NetworkLibrary::NetworkManagerObserver.
virtual void OnNetworkManagerChanged(NetworkLibrary* crosnet) OVERRIDE {
RefreshNetworkObserver(crosnet);
- RefreshNetworkDeviceObserver(crosnet);
data_promo_notification_->ShowOptionalMobileDataPromoNotification(
crosnet, GetPrimarySystemTray(), this);
- UpdateCellularActivation();
+ UpdateCellular();
NotifyRefreshNetwork();
}
@@ -1356,7 +1349,19 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
}
// Overridden from ash::NetworkTrayDelegate
- virtual void NotificationLinkClicked(size_t index) OVERRIDE {
+ virtual void NotificationLinkClicked(
+ ash::NetworkObserver::MessageType message_type,
+ size_t link_index) OVERRIDE {
+ if (message_type == ash::NetworkObserver::ERROR_OUT_OF_CREDITS) {
+ const CellularNetwork* cellular =
+ CrosLibrary::Get()->GetNetworkLibrary()->cellular_network();
+ if (cellular)
+ ConnectToNetwork(cellular->service_path());
+ ash::Shell::GetInstance()->system_tray_notifier()->
+ NotifyClearNetworkMessage(message_type);
+ }
+ if (message_type != ash::NetworkObserver::MESSAGE_DATA_PROMO)
+ return;
// If we have deal info URL defined that means that there're
// 2 links in bubble. Let the user close it manually then thus giving
// ability to navigate to second link.
@@ -1367,7 +1372,7 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
data_promo_notification_->CloseNotification();
std::string deal_url_to_open;
- if (index == 0) {
+ if (link_index == 0) {
if (!deal_topup_url.empty()) {
deal_url_to_open = deal_topup_url;
} else {
@@ -1378,7 +1383,7 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
network_menu_->ShowTabbedNetworkSettings(cellular);
return;
}
- } else if (index == 1) {
+ } else if (link_index == 1) {
deal_url_to_open = deal_info_url;
}
@@ -1408,7 +1413,7 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
UpdateEnterpriseDomain();
}
- void UpdateCellularActivation() {
+ void UpdateCellular() {
const CellularNetworkVector& cellular_networks =
CrosLibrary::Get()->GetNetworkLibrary()->cellular_networks();
if (cellular_networks.empty())
@@ -1420,15 +1425,7 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
cellular_activating_ = true;
} else if (cellular->activated() && cellular_activating_) {
cellular_activating_ = false;
-
- // Detect which icon to show, 3G or LTE.
- ash::NetworkObserver::NetworkType type =
- (cellular->network_technology() == NETWORK_TECHNOLOGY_LTE ||
- cellular->network_technology() == NETWORK_TECHNOLOGY_LTE_ADVANCED)
- ? ash::NetworkObserver::NETWORK_CELLULAR_LTE
- : ash::NetworkObserver::NETWORK_CELLULAR;
-
- // Show the notification.
+ ash::NetworkObserver::NetworkType type = NetworkTypeForCellular(cellular);
ash::Shell::GetInstance()->system_tray_notifier()->
NotifySetNetworkMessage(
NULL,
@@ -1441,6 +1438,27 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
UTF8ToUTF16((cellular->name()))),
std::vector<string16>());
}
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(
+ ash::switches::kAshDisableNewNetworkStatusArea)) {
+ return;
+ }
+ // Trigger "Out of credits" notification (for NetworkLibrary impl)
+ if (cellular->out_of_credits() && !cellular_out_of_credits_) {
+ cellular_out_of_credits_ = true;
+ ash::NetworkObserver::NetworkType type = NetworkTypeForCellular(cellular);
+ std::vector<string16> links;
+ links.push_back(
+ l10n_util::GetStringFUTF16(IDS_NETWORK_OUT_OF_CREDITS_LINK,
+ UTF8ToUTF16(cellular->name())));
+ ash::Shell::GetInstance()->system_tray_notifier()->
+ NotifySetNetworkMessage(
+ this, ash::NetworkObserver::ERROR_OUT_OF_CREDITS, type,
+ l10n_util::GetStringUTF16(IDS_NETWORK_OUT_OF_CREDITS_TITLE),
+ l10n_util::GetStringUTF16(IDS_NETWORK_OUT_OF_CREDITS_BODY),
+ links);
+ } else if (!cellular->out_of_credits() && cellular_out_of_credits_) {
+ cellular_out_of_credits_ = false;
+ }
}
scoped_ptr<base::WeakPtrFactory<SystemTrayDelegate> > ui_weak_ptr_factory_;
@@ -1451,7 +1469,6 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
content::NotificationRegistrar registrar_;
PrefChangeRegistrar local_state_registrar_;
scoped_ptr<PrefChangeRegistrar> user_pref_registrar_;
- std::string cellular_device_path_;
std::string active_network_path_;
PowerSupplyStatus power_supply_status_;
base::HourClockType clock_type_;
@@ -1465,6 +1482,7 @@ class SystemTrayDelegate : public ash::SystemTrayDelegate,
scoped_ptr<DataPromoNotification> data_promo_notification_;
bool cellular_activating_;
+ bool cellular_out_of_credits_;
scoped_ptr<ash::VolumeControlDelegate> volume_control_delegate_;
« no previous file with comments | « chrome/browser/chromeos/status/network_menu.cc ('k') | chromeos/network/network_state.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698