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

Side by Side Diff: chrome/browser/chromeos/status/network_menu_icon.cc

Issue 8400057: Revert 107689 - Speak a message when accessibility is on and the network state changes (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: Created 9 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « chrome/browser/chromeos/accessibility_util.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/chromeos/status/network_menu_icon.h" 5 #include "chrome/browser/chromeos/status/network_menu_icon.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 9
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
11 #include "chrome/browser/chromeos/accessibility_util.h"
12 #include "chrome/browser/chromeos/cros/cros_library.h" 11 #include "chrome/browser/chromeos/cros/cros_library.h"
13 #include "grit/generated_resources.h" 12 #include "grit/generated_resources.h"
14 #include "grit/theme_resources.h" 13 #include "grit/theme_resources.h"
15 #include "ui/base/l10n/l10n_util.h" 14 #include "ui/base/l10n/l10n_util.h"
16 #include "ui/base/resource/resource_bundle.h" 15 #include "ui/base/resource/resource_bundle.h"
17 #include "ui/gfx/canvas_skia.h" 16 #include "ui/gfx/canvas_skia.h"
18 #include "ui/gfx/skbitmap_operations.h" 17 #include "ui/gfx/skbitmap_operations.h"
19 18
20 using std::max; 19 using std::max;
21 using std::min; 20 using std::min;
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
201 const Network* network = cros->FindNetworkByPath(service_path_); 200 const Network* network = cros->FindNetworkByPath(service_path_);
202 if (!network) { 201 if (!network) {
203 // If not a visible network, check for a remembered network. 202 // If not a visible network, check for a remembered network.
204 network = cros->FindRememberedNetworkByPath(service_path_); 203 network = cros->FindRememberedNetworkByPath(service_path_);
205 if (!network) { 204 if (!network) {
206 LOG(WARNING) << "Unable to find network:" << service_path_; 205 LOG(WARNING) << "Unable to find network:" << service_path_;
207 return; 206 return;
208 } 207 }
209 } 208 }
210 bool dirty = bitmap_.empty(); 209 bool dirty = bitmap_.empty();
211 bool speak = false;
212 if ((Network::IsConnectedState(state_) && !network->connected()) ||
213 (Network::IsConnectingState(state_) && !network->connecting()) ||
214 (Network::IsDisconnectedState(state_) && !network->disconnected())) {
215 speak = true;
216 }
217 if (state_ != network->state()) { 210 if (state_ != network->state()) {
218 state_ = network->state(); 211 state_ = network->state();
219 dirty = true; 212 dirty = true;
220 } 213 }
221 ConnectionType type = network->type(); 214 ConnectionType type = network->type();
222 if (type == TYPE_WIFI || type == TYPE_CELLULAR) { 215 if (type == TYPE_WIFI || type == TYPE_CELLULAR) {
223 int index = 0; 216 int index = 0;
224 if (type == TYPE_WIFI) { 217 if (type == TYPE_WIFI) {
225 index = WifiStrengthIndex( 218 index = WifiStrengthIndex(
226 static_cast<const WifiNetwork*>(network)); 219 static_cast<const WifiNetwork*>(network));
(...skipping 20 matching lines...) Expand all
247 if (type == TYPE_VPN) { 240 if (type == TYPE_VPN) {
248 if (cros->connected_network() != connected_network_) { 241 if (cros->connected_network() != connected_network_) {
249 connected_network_ = cros->connected_network(); 242 connected_network_ = cros->connected_network();
250 dirty = true; 243 dirty = true;
251 } 244 }
252 } 245 }
253 if (dirty) { 246 if (dirty) {
254 UpdateIcon(network); 247 UpdateIcon(network);
255 GenerateBitmap(); 248 GenerateBitmap();
256 } 249 }
257 if (speak) {
258 std::string connection_string;
259 if (Network::IsConnectedState(state_)) {
260 switch (network->type()) {
261 case TYPE_ETHERNET:
262 connection_string = l10n_util::GetStringFUTF8(
263 IDS_STATUSBAR_NETWORK_CONNECTED_TOOLTIP,
264 l10n_util::GetStringUTF16(
265 IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET));
266 break;
267 default:
268 connection_string = l10n_util::GetStringFUTF8(
269 IDS_STATUSBAR_NETWORK_CONNECTED_TOOLTIP,
270 UTF8ToUTF16(network->name()));
271 break;
272 }
273 } else if (Network::IsConnectingState(state_)) {
274 const Network* connecting_network = cros->connecting_network();
275 if (connecting_network && connecting_network->type() != TYPE_ETHERNET) {
276 connection_string = l10n_util::GetStringFUTF8(
277 IDS_STATUSBAR_NETWORK_CONNECTING_TOOLTIP,
278 UTF8ToUTF16(connecting_network->name()));
279 }
280 } else if (Network::IsDisconnectedState(state_)) {
281 connection_string = l10n_util::GetStringUTF8(
282 IDS_STATUSBAR_NETWORK_NO_NETWORK_TOOLTIP);
283 }
284 if (!connection_string.empty()) {
285 accessibility::MaybeSpeak(connection_string.c_str(), true, false);
286 }
287 }
288 } 250 }
289 251
290 // Sets up the base icon image. 252 // Sets up the base icon image.
291 void SetIcon(const Network* network) { 253 void SetIcon(const Network* network) {
292 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); 254 ResourceBundle& rb = ResourceBundle::GetSharedInstance();
293 255
294 switch (network->type()) { 256 switch (network->type()) {
295 case TYPE_ETHERNET: { 257 case TYPE_ETHERNET: {
296 icon_ = *rb.GetBitmapNamed(IDR_STATUSBAR_WIRED); 258 icon_ = *rb.GetBitmapNamed(IDR_STATUSBAR_WIRED);
297 break; 259 break;
(...skipping 497 matching lines...) Expand 10 before | Expand all | Expand 10 after
795 757
796 const SkBitmap NetworkMenuIcon::GetConnectedBitmap(BitmapType type) { 758 const SkBitmap NetworkMenuIcon::GetConnectedBitmap(BitmapType type) {
797 return GetBitmap(type, NumBitmaps(type) - 1); 759 return GetBitmap(type, NumBitmaps(type) - 1);
798 } 760 }
799 761
800 int NetworkMenuIcon::NumBitmaps(BitmapType type) { 762 int NetworkMenuIcon::NumBitmaps(BitmapType type) {
801 return (type == ARCS) ? kNumArcsImages : kNumBarsImages; 763 return (type == ARCS) ? kNumArcsImages : kNumBarsImages;
802 } 764 }
803 765
804 } // chromeos 766 } // chromeos
OLDNEW
« no previous file with comments | « chrome/browser/chromeos/accessibility_util.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698