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

Unified Diff: chrome/browser/chromeos/dom_ui/internet_options_handler.cc

Issue 4482003: Landing change for ers@chromium.org: http://codereview.chromium.org/4134012/s... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 10 years, 1 month 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
Index: chrome/browser/chromeos/dom_ui/internet_options_handler.cc
===================================================================
--- chrome/browser/chromeos/dom_ui/internet_options_handler.cc (revision 65103)
+++ chrome/browser/chromeos/dom_ui/internet_options_handler.cc (working copy)
@@ -56,11 +56,19 @@
} // namespace
InternetOptionsHandler::InternetOptionsHandler() {
- chromeos::CrosLibrary::Get()->GetNetworkLibrary()->AddObserver(this);
+ chromeos::NetworkLibrary* netlib =
+ chromeos::CrosLibrary::Get()->GetNetworkLibrary();
+ netlib->AddNetworkManagerObserver(this);
+ netlib->AddCellularDataPlanObserver(this);
+ MonitorActiveNetwork(netlib);
}
InternetOptionsHandler::~InternetOptionsHandler() {
- chromeos::CrosLibrary::Get()->GetNetworkLibrary()->RemoveObserver(this);
+ chromeos::NetworkLibrary *netlib =
+ chromeos::CrosLibrary::Get()->GetNetworkLibrary();
+ netlib->RemoveNetworkManagerObserver(this);
+ netlib->RemoveCellularDataPlanObserver(this);
+ netlib->RemoveObserverForAllNetworks(this);
}
void InternetOptionsHandler::GetLocalizedValues(
@@ -267,7 +275,7 @@
l10n_util::GetStringFUTF16(
IDS_STATUSBAR_NETWORK_DEVICE_DISABLE,
l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_DEVICE_WIFI)));
- localized_strings->SetString("enableCellular",
+ localized_strings->SetString("enableCellular",
l10n_util::GetStringFUTF16(
IDS_STATUSBAR_NETWORK_DEVICE_ENABLE,
l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_DEVICE_CELLULAR)));
@@ -357,10 +365,8 @@
browser->OpenMobilePlanTabAndActivate();
}
-void InternetOptionsHandler::NetworkChanged(chromeos::NetworkLibrary* cros) {
- if (!dom_ui_)
- return;
-
+void InternetOptionsHandler::RefreshNetworkData(
+ chromeos::NetworkLibrary* cros) {
DictionaryValue dictionary;
dictionary.Set("wiredList", GetWiredList());
dictionary.Set("wirelessList", GetWirelessList());
@@ -373,7 +379,45 @@
L"options.InternetOptions.refreshNetworkData", dictionary);
}
-void InternetOptionsHandler::CellularDataPlanChanged(
+void InternetOptionsHandler::OnNetworkManagerChanged(
+ chromeos::NetworkLibrary* cros) {
+ if (!dom_ui_)
+ return;
+ MonitorActiveNetwork(cros);
+ RefreshNetworkData(cros);
+}
+
+void InternetOptionsHandler::OnNetworkChanged(
+ chromeos::NetworkLibrary* cros,
+ const chromeos::Network* network) {
+ if (dom_ui_)
+ RefreshNetworkData(cros);
+}
+
+// Add an observer for the active network, if any, so
+// that we can dynamically display the correct icon for
+// that network's signal strength.
+// TODO(ers) Ideally, on this page we'd monitor all networks for
+// signal strength changes, not just the active network.
+void InternetOptionsHandler::MonitorActiveNetwork(
+ chromeos::NetworkLibrary* cros) {
+ const chromeos::Network* network = cros->active_network();
+ if (active_network_.empty() || network == NULL ||
+ active_network_ != network->service_path()) {
+ if (!active_network_.empty()) {
+ cros->RemoveNetworkObserver(active_network_, this);
+ }
+ if (network != NULL) {
+ cros->AddNetworkObserver(network->service_path(), this);
+ }
+ }
+ if (network != NULL)
+ active_network_ = network->service_path();
+ else
+ active_network_ = "";
+}
+
+void InternetOptionsHandler::OnCellularDataPlanChanged(
chromeos::NetworkLibrary* obj) {
if (!dom_ui_)
return;
@@ -580,7 +624,7 @@
LOG(WARNING) << "Cannot find network " << net->service_path();
} else {
dictionary.SetString("ssid", wireless->name());
- dictionary.SetBoolean("autoConnect",wireless->auto_connect());
+ dictionary.SetBoolean("autoConnect", wireless->auto_connect());
if (wireless->encrypted()) {
dictionary.SetBoolean("encrypted", true);
if (wireless->encryption() == chromeos::SECURITY_8021X) {
@@ -591,10 +635,10 @@
} else {
dictionary.SetBoolean("certInPkcs", false);
}
- dictionary.SetString("certPath",wireless->cert_path());
- dictionary.SetString("ident",wireless->identity());
+ dictionary.SetString("certPath", wireless->cert_path());
+ dictionary.SetString("ident", wireless->identity());
dictionary.SetBoolean("certNeeded", true);
- dictionary.SetString("certPass",wireless->passphrase());
+ dictionary.SetString("certPass", wireless->passphrase());
} else {
dictionary.SetBoolean("certNeeded", false);
}
@@ -655,7 +699,7 @@
void InternetOptionsHandler::PopupWirelessPassword(
const chromeos::WifiNetwork* network) {
DictionaryValue dictionary;
- dictionary.SetString("servicePath",network->service_path());
+ dictionary.SetString("servicePath", network->service_path());
if (network->encryption() == chromeos::SECURITY_8021X) {
dictionary.SetBoolean("certNeeded", true);
dictionary.SetString("ident", network->identity());
@@ -668,7 +712,6 @@
}
void InternetOptionsHandler::LoginCallback(const ListValue* args) {
-
std::string service_path;
std::string password;
@@ -693,7 +736,6 @@
}
void InternetOptionsHandler::LoginCertCallback(const ListValue* args) {
-
std::string service_path;
std::string identity;
std::string certpath;
@@ -934,7 +976,7 @@
cellular_networks.begin(); it != cellular_networks.end(); ++it) {
SkBitmap icon = chromeos::NetworkMenu::IconForNetworkStrength(
(*it)->strength(), true);
- SkBitmap badge = *rb.GetBitmapNamed(IDR_STATUSBAR_NETWORK_3G);
+ SkBitmap badge = chromeos::NetworkMenu::BadgeForNetworkTechnology(*it);
icon = chromeos::NetworkMenu::IconForDisplay(icon, badge);
list->Append(GetNetwork(
(*it)->service_path(),
« no previous file with comments | « chrome/browser/chromeos/dom_ui/internet_options_handler.h ('k') | chrome/browser/chromeos/dom_ui/mobile_setup_ui.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698