summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchocobo@chromium.org <chocobo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-01 17:54:36 +0000
committerchocobo@chromium.org <chocobo@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-06-01 17:54:36 +0000
commit39216bee9402bb343519cdb4cd517dc5120531b4 (patch)
tree654b9f6087aef8f8c4b616201c496d16bb4af127
parent6aa2cf2f5587562974b60eb0a4aa847942d67a49 (diff)
downloadchromium_src-39216bee9402bb343519cdb4cd517dc5120531b4.zip
chromium_src-39216bee9402bb343519cdb4cd517dc5120531b4.tar.gz
chromium_src-39216bee9402bb343519cdb4cd517dc5120531b4.tar.bz2
Added notification for network message.
BUG=chromium-os:2556 TEST=manually connect to network with wrong password and see notification. Review URL: http://codereview.chromium.org/2074017 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@48641 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/app/generated_resources.grd6
-rw-r--r--chrome/app/theme/notification_battery_low.pngbin0 -> 1507 bytes
-rw-r--r--chrome/app/theme/notification_low_battery.pngbin676 -> 0 bytes
-rw-r--r--chrome/app/theme/notification_network_failed.pngbin0 -> 1447 bytes
-rw-r--r--chrome/app/theme/notification_network_open.pngbin0 -> 1595 bytes
-rw-r--r--chrome/app/theme/notification_network_warning.pngbin0 -> 1561 bytes
-rw-r--r--chrome/app/theme/theme_resources.grd5
-rw-r--r--chrome/browser/browser_init.cc14
-rw-r--r--chrome/browser/chromeos/network_message_observer.cc80
-rw-r--r--chrome/browser/chromeos/network_message_observer.h40
-rw-r--r--chrome/chrome_browser.gypi2
11 files changed, 143 insertions, 4 deletions
diff --git a/chrome/app/generated_resources.grd b/chrome/app/generated_resources.grd
index 7a5256b..573e388 100644
--- a/chrome/app/generated_resources.grd
+++ b/chrome/app/generated_resources.grd
@@ -7353,6 +7353,12 @@ Keep your key file in a safe place. You will need it to create new versions of y
<!-- Chrome OS Strings -->
<if expr="pp_ifdef('chromeos')">
+ <message name="IDS_NETWORK_CONNECTION_ERROR_TITLE" desc="Title for network connection error notification">
+ Network Connection Error
+ </message>
+ <message name="IDS_NETWORK_CONNECTION_ERROR_MESSAGE" desc="Message for network connection error notification">
+ Failed to connect to network '<ph name="name">$1<ex>GoogleGuest</ex></ph>'.
+ </message>
<message name="IDS_LOW_BATTERY_TITLE" desc="Title for low battery notification">
Battery Low
</message>
diff --git a/chrome/app/theme/notification_battery_low.png b/chrome/app/theme/notification_battery_low.png
new file mode 100644
index 0000000..ae4fa26
--- /dev/null
+++ b/chrome/app/theme/notification_battery_low.png
Binary files differ
diff --git a/chrome/app/theme/notification_low_battery.png b/chrome/app/theme/notification_low_battery.png
deleted file mode 100644
index 4251f87..0000000
--- a/chrome/app/theme/notification_low_battery.png
+++ /dev/null
Binary files differ
diff --git a/chrome/app/theme/notification_network_failed.png b/chrome/app/theme/notification_network_failed.png
new file mode 100644
index 0000000..fc1cc73
--- /dev/null
+++ b/chrome/app/theme/notification_network_failed.png
Binary files differ
diff --git a/chrome/app/theme/notification_network_open.png b/chrome/app/theme/notification_network_open.png
new file mode 100644
index 0000000..aeda157
--- /dev/null
+++ b/chrome/app/theme/notification_network_open.png
Binary files differ
diff --git a/chrome/app/theme/notification_network_warning.png b/chrome/app/theme/notification_network_warning.png
new file mode 100644
index 0000000..16011fd
--- /dev/null
+++ b/chrome/app/theme/notification_network_warning.png
Binary files differ
diff --git a/chrome/app/theme/theme_resources.grd b/chrome/app/theme/theme_resources.grd
index 41ca582..2c9e811 100644
--- a/chrome/app/theme/theme_resources.grd
+++ b/chrome/app/theme/theme_resources.grd
@@ -519,7 +519,10 @@
<include name="IDR_MEDIAPLAYER_VOL_HIGH" file="mediaplayer_vol_high.png" type="BINDATA" />
<include name="IDR_MEDIAPLAYER_FULL_SCREEN" file="mediaplayer_full_screen.png" type="BINDATA" />
<include name="IDR_MEDIAPLAYER_PLAYLIST" file="mediaplayer_playlist.png" type="BINDATA" />
- <include name="IDR_NOTIFICATION_LOW_BATTERY" file="notification_low_battery.png" type="BINDATA" />
+ <include name="IDR_NOTIFICATION_LOW_BATTERY" file="notification_battery_low.png" type="BINDATA" />
+ <include name="IDR_NOTIFICATION_NETWORK_FAILED" file="notification_network_failed.png" type="BINDATA" />
+ <include name="IDR_NOTIFICATION_NETWORK_OPEN" file="notification_network_open.png" type="BINDATA" />
+ <include name="IDR_NOTIFICATION_NETWORK_WARNING" file="notification_network_warning.png" type="BINDATA" />
<include name="IDR_LOGIN_DEFAULT_USER" file="login_default.png" type="BINDATA" />
<include name="IDR_LOGIN_OTHER_USER" file="login_other.png" type="BINDATA" />
</if>
diff --git a/chrome/browser/browser_init.cc b/chrome/browser/browser_init.cc
index 7e5b2fd..9213502 100644
--- a/chrome/browser/browser_init.cc
+++ b/chrome/browser/browser_init.cc
@@ -69,9 +69,11 @@
#include "chrome/browser/chromeos/browser_notification_observers.h"
#include "chrome/browser/chromeos/cros/cros_library.h"
#include "chrome/browser/chromeos/cros/mount_library.h"
-#include "chrome/browser/chromeos/cros/power_library.h"
+#include "chrome/browser/chromeos/cros/network_library.h"
+#include "chrome/browser/chromeos/cros/mount_library.h"
#include "chrome/browser/chromeos/gview_request_interceptor.h"
#include "chrome/browser/chromeos/low_battery_observer.h"
+#include "chrome/browser/chromeos/network_message_observer.h"
#include "chrome/browser/chromeos/system_key_event_listener.h"
#include "chrome/browser/chromeos/usb_mount_observer.h"
#include "chrome/browser/chromeos/wm_message_listener.h"
@@ -420,9 +422,15 @@ bool BrowserInit::LaunchBrowser(
// This observer is a singleton. It is never deleted but the pointer is kept
// in a global so that it isn't reported as a leak.
- static chromeos::LowBatteryObserver* observer =
+ static chromeos::LowBatteryObserver* low_battery_observer =
new chromeos::LowBatteryObserver(profile);
- chromeos::CrosLibrary::Get()->GetPowerLibrary()->AddObserver(observer);
+ chromeos::CrosLibrary::Get()->GetPowerLibrary()->AddObserver(
+ low_battery_observer);
+
+ static chromeos::NetworkMessageObserver* network_message_observer =
+ new chromeos::NetworkMessageObserver(profile);
+ chromeos::CrosLibrary::Get()->GetNetworkLibrary()->AddObserver(
+ network_message_observer);
// Creates the SystemKeyEventListener to listen for keypress messages
// regardless of what window has focus.
diff --git a/chrome/browser/chromeos/network_message_observer.cc b/chrome/browser/chromeos/network_message_observer.cc
new file mode 100644
index 0000000..d722212
--- /dev/null
+++ b/chrome/browser/chromeos/network_message_observer.cc
@@ -0,0 +1,80 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "chrome/browser/chromeos/network_message_observer.h"
+
+#include "app/l10n_util.h"
+#include "chrome/browser/chromeos/cros/cros_library.h"
+#include "chrome/browser/chromeos/cros/network_library.h"
+#include "grit/generated_resources.h"
+#include "grit/theme_resources.h"
+
+namespace chromeos {
+
+NetworkMessageObserver::NetworkMessageObserver(Profile* profile)
+ : notification_(profile, "network_connection.chromeos",
+ IDR_NOTIFICATION_NETWORK_FAILED,
+ l10n_util::GetStringUTF16(IDS_NETWORK_CONNECTION_ERROR_TITLE)) {
+ // On startup, we may already have failed netorks.
+ // So marked these as known failed.
+ NetworkLibrary* cros = CrosLibrary::Get()->GetNetworkLibrary();
+ const WifiNetworkVector& wifi_networks = cros->wifi_networks();
+ for (WifiNetworkVector::const_iterator it = wifi_networks.begin();
+ it < wifi_networks.end(); it++) {
+ const WifiNetwork& wifi = *it;
+ if (wifi.failed())
+ failed_networks_.insert(wifi.name());
+ }
+ const CellularNetworkVector& cellular_networks = cros->cellular_networks();
+ for (CellularNetworkVector::const_iterator it = cellular_networks.begin();
+ it < cellular_networks.end(); it++) {
+ const CellularNetwork& cellular = *it;
+ if (cellular.failed())
+ failed_networks_.insert(cellular.name());
+ }
+}
+
+NetworkMessageObserver::~NetworkMessageObserver() {
+ notification_.Hide();
+}
+
+void NetworkMessageObserver::NetworkChanged(NetworkLibrary* obj) {
+ std::set<std::string> failed;
+ std::string new_failed_network;
+
+ // For each call to NetworkChanged, we expect at most 1 new failed network.
+ // So we just keep track of it if we find a newly failed network by comparing
+ // against or stored failed networks. And we only display notification if we
+ // find a newly failed network.
+ const WifiNetworkVector& wifi_networks = obj->wifi_networks();
+ for (WifiNetworkVector::const_iterator it = wifi_networks.begin();
+ it < wifi_networks.end(); it++) {
+ const WifiNetwork& wifi = *it;
+ if (wifi.failed()) {
+ failed.insert(wifi.name());
+ if (failed_networks_.find(wifi.name())
+ == failed_networks_.end())
+ new_failed_network = wifi.name();
+ }
+ }
+ const CellularNetworkVector& cellular_networks = obj->cellular_networks();
+ for (CellularNetworkVector::const_iterator it = cellular_networks.begin();
+ it < cellular_networks.end(); it++) {
+ const CellularNetwork& cellular = *it;
+ if (cellular.failed()) {
+ failed.insert(cellular.name());
+ if (failed_networks_.find(cellular.name())
+ == failed_networks_.end())
+ new_failed_network = cellular.name();
+ }
+ }
+
+ failed_networks_ = failed;
+ if (!new_failed_network.empty())
+ notification_.Show(l10n_util::GetStringFUTF16(
+ IDS_NETWORK_CONNECTION_ERROR_MESSAGE,
+ ASCIIToUTF16(new_failed_network)), true);
+}
+
+} // namespace chromeos
diff --git a/chrome/browser/chromeos/network_message_observer.h b/chrome/browser/chromeos/network_message_observer.h
new file mode 100644
index 0000000..3834cc3
--- /dev/null
+++ b/chrome/browser/chromeos/network_message_observer.h
@@ -0,0 +1,40 @@
+// Copyright (c) 2010 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CHROME_BROWSER_CHROMEOS_NETWORK_MESSAGE_OBSERVER_H_
+#define CHROME_BROWSER_CHROMEOS_NETWORK_MESSAGE_OBSERVER_H_
+
+#include <set>
+#include <string>
+
+#include "base/basictypes.h"
+#include "chrome/browser/chromeos/cros/network_library.h"
+#include "chrome/browser/chromeos/notifications/system_notification.h"
+
+class Profile;
+
+namespace chromeos {
+
+// The network message observer displays a system notification for network
+// messages.
+
+class NetworkMessageObserver : public NetworkLibrary::Observer {
+ public:
+ explicit NetworkMessageObserver(Profile* profile);
+ virtual ~NetworkMessageObserver();
+
+ private:
+ virtual void NetworkChanged(NetworkLibrary* obj);
+ virtual void NetworkTraffic(NetworkLibrary* obj, int traffic_type) {}
+
+ SystemNotification notification_;
+ std::set<std::string> failed_networks_;
+
+ DISALLOW_COPY_AND_ASSIGN(NetworkMessageObserver);
+};
+
+} // namespace chromeos
+
+#endif // CHROME_BROWSER_CHROMEOS_NETWORK_MESSAGE_OBSERVER_H_
+
diff --git a/chrome/chrome_browser.gypi b/chrome/chrome_browser.gypi
index cc2147c..a7b1133 100644
--- a/chrome/chrome_browser.gypi
+++ b/chrome/chrome_browser.gypi
@@ -460,6 +460,8 @@
'browser/chromeos/native_dialog_window.h',
'browser/chromeos/network_list.cc',
'browser/chromeos/network_list.h',
+ 'browser/chromeos/network_message_observer.cc',
+ 'browser/chromeos/network_message_observer.h',
'browser/chromeos/options/internet_page_view.cc',
'browser/chromeos/options/internet_page_view.h',
'browser/chromeos/options/ip_config_view.cc',