Commit 234676bc authored by zork@chromium.org's avatar zork@chromium.org

Speak a message when accessibility is on and the network state changes


R=dmazzoni@chromium.org
BUG=chromium-os:21760
TEST=Change the network state with a11y turned on


Review URL: http://codereview.chromium.org/8402023

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@107689 0039d316-1c4b-4281-b951-d872f2087c98
parent 7aeaaa70
...@@ -168,6 +168,14 @@ void Speak(const char* speak_str, bool queue, bool interruptible) { ...@@ -168,6 +168,14 @@ void Speak(const char* speak_str, bool queue, bool interruptible) {
Speak(speak_str); Speak(speak_str);
} }
void MaybeSpeak(const char* speak_str, bool queue, bool interruptible) {
bool accessibility_enabled = g_browser_process &&
g_browser_process->local_state()->GetBoolean(
prefs::kAccessibilityEnabled);
if (accessibility_enabled) {
Speak(speak_str, queue, interruptible);
}
}
} // namespace accessibility } // namespace accessibility
} // namespace chromeos } // namespace chromeos
...@@ -24,6 +24,9 @@ void ToggleAccessibility(WebUI* login_web_ui); ...@@ -24,6 +24,9 @@ void ToggleAccessibility(WebUI* login_web_ui);
// Speaks the specified string. // Speaks the specified string.
void Speak(const char* speak_str, bool queue, bool interruptible); void Speak(const char* speak_str, bool queue, bool interruptible);
// Speaks the specified string if Accessibility is enabled.
void MaybeSpeak(const char* speak_str, bool queue, bool interruptible);
} // namespace accessibility } // namespace accessibility
} // namespace chromeos } // namespace chromeos
......
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
#include <cmath> #include <cmath>
#include "base/utf_string_conversions.h" #include "base/utf_string_conversions.h"
#include "chrome/browser/chromeos/accessibility_util.h"
#include "chrome/browser/chromeos/cros/cros_library.h" #include "chrome/browser/chromeos/cros/cros_library.h"
#include "grit/generated_resources.h" #include "grit/generated_resources.h"
#include "grit/theme_resources.h" #include "grit/theme_resources.h"
...@@ -207,6 +208,12 @@ class NetworkIcon { ...@@ -207,6 +208,12 @@ class NetworkIcon {
} }
} }
bool dirty = bitmap_.empty(); bool dirty = bitmap_.empty();
bool speak = false;
if ((Network::IsConnectedState(state_) && !network->connected()) ||
(Network::IsConnectingState(state_) && !network->connecting()) ||
(Network::IsDisconnectedState(state_) && !network->disconnected())) {
speak = true;
}
if (state_ != network->state()) { if (state_ != network->state()) {
state_ = network->state(); state_ = network->state();
dirty = true; dirty = true;
...@@ -247,6 +254,37 @@ class NetworkIcon { ...@@ -247,6 +254,37 @@ class NetworkIcon {
UpdateIcon(network); UpdateIcon(network);
GenerateBitmap(); GenerateBitmap();
} }
if (speak) {
std::string connection_string;
if (Network::IsConnectedState(state_)) {
switch (network->type()) {
case TYPE_ETHERNET:
connection_string = l10n_util::GetStringFUTF8(
IDS_STATUSBAR_NETWORK_CONNECTED_TOOLTIP,
l10n_util::GetStringUTF16(
IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET));
break;
default:
connection_string = l10n_util::GetStringFUTF8(
IDS_STATUSBAR_NETWORK_CONNECTED_TOOLTIP,
UTF8ToUTF16(network->name()));
break;
}
} else if (Network::IsConnectingState(state_)) {
const Network* connecting_network = cros->connecting_network();
if (connecting_network && connecting_network->type() != TYPE_ETHERNET) {
connection_string = l10n_util::GetStringFUTF8(
IDS_STATUSBAR_NETWORK_CONNECTING_TOOLTIP,
UTF8ToUTF16(connecting_network->name()));
}
} else if (Network::IsDisconnectedState(state_)) {
connection_string = l10n_util::GetStringUTF8(
IDS_STATUSBAR_NETWORK_NO_NETWORK_TOOLTIP);
}
if (!connection_string.empty()) {
accessibility::MaybeSpeak(connection_string.c_str(), true, false);
}
}
} }
// Sets up the base icon image. // Sets up the base icon image.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment