| OLD | NEW |
| 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" |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 150 public: | 150 public: |
| 151 // Default constructor is used by the status bar icon (NetworkMenuIcon). | 151 // Default constructor is used by the status bar icon (NetworkMenuIcon). |
| 152 NetworkIcon() | 152 NetworkIcon() |
| 153 : state_(STATE_UNKNOWN), | 153 : state_(STATE_UNKNOWN), |
| 154 strength_index_(-1), | 154 strength_index_(-1), |
| 155 top_left_badge_(NULL), | 155 top_left_badge_(NULL), |
| 156 top_right_badge_(NULL), | 156 top_right_badge_(NULL), |
| 157 bottom_left_badge_(NULL), | 157 bottom_left_badge_(NULL), |
| 158 bottom_right_badge_(NULL), | 158 bottom_right_badge_(NULL), |
| 159 is_status_bar_(true), | 159 is_status_bar_(true), |
| 160 connected_network_(NULL) { | 160 connected_network_(NULL), |
| 161 roaming_state_(ROAMING_STATE_UNKNOWN) { |
| 161 } | 162 } |
| 162 | 163 |
| 163 // Service path constructor for cached network service icons. | 164 // Service path constructor for cached network service icons. |
| 164 explicit NetworkIcon(const std::string& service_path) | 165 explicit NetworkIcon(const std::string& service_path) |
| 165 : service_path_(service_path), | 166 : service_path_(service_path), |
| 166 state_(STATE_UNKNOWN), | 167 state_(STATE_UNKNOWN), |
| 167 strength_index_(-1), | 168 strength_index_(-1), |
| 168 top_left_badge_(NULL), | 169 top_left_badge_(NULL), |
| 169 top_right_badge_(NULL), | 170 top_right_badge_(NULL), |
| 170 bottom_left_badge_(NULL), | 171 bottom_left_badge_(NULL), |
| 171 bottom_right_badge_(NULL), | 172 bottom_right_badge_(NULL), |
| 172 is_status_bar_(false), | 173 is_status_bar_(false), |
| 173 connected_network_(NULL) { | 174 connected_network_(NULL), |
| 175 roaming_state_(ROAMING_STATE_UNKNOWN) { |
| 174 } | 176 } |
| 175 | 177 |
| 176 ~NetworkIcon() { | 178 ~NetworkIcon() { |
| 177 } | 179 } |
| 178 | 180 |
| 179 void ClearIconAndBadges() { | 181 void ClearIconAndBadges() { |
| 180 icon_ = SkBitmap(); | 182 icon_ = SkBitmap(); |
| 181 top_left_badge_ = NULL; | 183 top_left_badge_ = NULL; |
| 182 top_right_badge_ = NULL; | 184 top_right_badge_ = NULL; |
| 183 bottom_left_badge_ = NULL; | 185 bottom_left_badge_ = NULL; |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 index = WifiStrengthIndex( | 218 index = WifiStrengthIndex( |
| 217 static_cast<const WifiNetwork*>(network)); | 219 static_cast<const WifiNetwork*>(network)); |
| 218 } else if (type == TYPE_CELLULAR) { | 220 } else if (type == TYPE_CELLULAR) { |
| 219 index = CellularStrengthIndex( | 221 index = CellularStrengthIndex( |
| 220 static_cast<const CellularNetwork*>(network)); | 222 static_cast<const CellularNetwork*>(network)); |
| 221 } | 223 } |
| 222 if (index != strength_index_) { | 224 if (index != strength_index_) { |
| 223 strength_index_ = index; | 225 strength_index_ = index; |
| 224 dirty = true; | 226 dirty = true; |
| 225 } | 227 } |
| 226 } else if (type == TYPE_VPN) { | 228 } |
| 229 if (type == TYPE_CELLULAR) { |
| 230 const CellularNetwork* cellular = |
| 231 static_cast<const CellularNetwork*>(network); |
| 232 const SkBitmap* technology_badge = BadgeForNetworkTechnology(cellular); |
| 233 if (technology_badge != bottom_right_badge_) |
| 234 dirty = true; |
| 235 if (cellular->roaming_state() != roaming_state_) { |
| 236 roaming_state_ = cellular->roaming_state(); |
| 237 dirty = true; |
| 238 } |
| 239 } |
| 240 if (type == TYPE_VPN) { |
| 227 if (cros->connected_network() != connected_network_) { | 241 if (cros->connected_network() != connected_network_) { |
| 228 connected_network_ = cros->connected_network(); | 242 connected_network_ = cros->connected_network(); |
| 229 dirty = true; | 243 dirty = true; |
| 230 } | 244 } |
| 231 } | 245 } |
| 232 if (dirty) { | 246 if (dirty) { |
| 233 UpdateIcon(network); | 247 UpdateIcon(network); |
| 234 GenerateBitmap(); | 248 GenerateBitmap(); |
| 235 } | 249 } |
| 236 } | 250 } |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 384 ConnectionState state_; | 398 ConnectionState state_; |
| 385 int strength_index_; | 399 int strength_index_; |
| 386 SkBitmap bitmap_; | 400 SkBitmap bitmap_; |
| 387 SkBitmap icon_; | 401 SkBitmap icon_; |
| 388 const SkBitmap* top_left_badge_; | 402 const SkBitmap* top_left_badge_; |
| 389 const SkBitmap* top_right_badge_; | 403 const SkBitmap* top_right_badge_; |
| 390 const SkBitmap* bottom_left_badge_; | 404 const SkBitmap* bottom_left_badge_; |
| 391 const SkBitmap* bottom_right_badge_; | 405 const SkBitmap* bottom_right_badge_; |
| 392 bool is_status_bar_; | 406 bool is_status_bar_; |
| 393 const Network* connected_network_; // weak pointer; used for VPN icons. | 407 const Network* connected_network_; // weak pointer; used for VPN icons. |
| 408 NetworkRoamingState roaming_state_; |
| 394 | 409 |
| 395 DISALLOW_COPY_AND_ASSIGN(NetworkIcon); | 410 DISALLOW_COPY_AND_ASSIGN(NetworkIcon); |
| 396 }; | 411 }; |
| 397 | 412 |
| 398 | 413 |
| 399 //////////////////////////////////////////////////////////////////////////////// | 414 //////////////////////////////////////////////////////////////////////////////// |
| 400 // NetworkMenuIcon | 415 // NetworkMenuIcon |
| 401 | 416 |
| 402 NetworkMenuIcon::NetworkMenuIcon(Delegate* delegate, Mode mode) | 417 NetworkMenuIcon::NetworkMenuIcon(Delegate* delegate, Mode mode) |
| 403 : mode_(mode), | 418 : mode_(mode), |
| 404 delegate_(delegate), | 419 delegate_(delegate), |
| 405 ALLOW_THIS_IN_INITIALIZER_LIST(animation_connecting_(this)), | 420 ALLOW_THIS_IN_INITIALIZER_LIST(animation_connecting_(this)), |
| 406 last_network_type_(TYPE_WIFI) { | 421 last_network_type_(TYPE_WIFI), |
| 422 connecting_network_(NULL) { |
| 407 // Generate empty images for blending. | 423 // Generate empty images for blending. |
| 408 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); | 424 ResourceBundle& rb = ResourceBundle::GetSharedInstance(); |
| 409 const SkBitmap* vpn_badge = rb.GetBitmapNamed(kVpnBadgeId); | 425 const SkBitmap* vpn_badge = rb.GetBitmapNamed(kVpnBadgeId); |
| 410 empty_vpn_badge_.setConfig(SkBitmap::kARGB_8888_Config, | 426 empty_vpn_badge_.setConfig(SkBitmap::kARGB_8888_Config, |
| 411 vpn_badge->width(), vpn_badge->height(), 0); | 427 vpn_badge->width(), vpn_badge->height(), 0); |
| 412 empty_vpn_badge_.allocPixels(); | 428 empty_vpn_badge_.allocPixels(); |
| 413 empty_vpn_badge_.eraseARGB(0, 0, 0, 0); | 429 empty_vpn_badge_.eraseARGB(0, 0, 0, 0); |
| 414 | 430 |
| 415 // Set up the connection animation throbber. | 431 // Set up the connection animation throbber. |
| 416 animation_connecting_.SetThrobDuration(kThrobDurationMs); | 432 animation_connecting_.SetThrobDuration(kThrobDurationMs); |
| (...skipping 320 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 737 | 753 |
| 738 const SkBitmap NetworkMenuIcon::GetDisconnectedBitmap(BitmapType type) { | 754 const SkBitmap NetworkMenuIcon::GetDisconnectedBitmap(BitmapType type) { |
| 739 return GetBitmap(type, 0); | 755 return GetBitmap(type, 0); |
| 740 } | 756 } |
| 741 | 757 |
| 742 int NetworkMenuIcon::NumBitmaps(BitmapType type) { | 758 int NetworkMenuIcon::NumBitmaps(BitmapType type) { |
| 743 return (type == ARCS) ? kNumArcsImages : kNumBarsImages; | 759 return (type == ARCS) ? kNumArcsImages : kNumBarsImages; |
| 744 } | 760 } |
| 745 | 761 |
| 746 } // chromeos | 762 } // chromeos |
| OLD | NEW |