| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 #include <map> | 9 #include <map> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 414 if (!network) { | 414 if (!network) { |
| 415 // If not a visible network, check for a remembered network. | 415 // If not a visible network, check for a remembered network. |
| 416 network = cros->FindRememberedNetworkByPath(service_path_); | 416 network = cros->FindRememberedNetworkByPath(service_path_); |
| 417 if (!network) { | 417 if (!network) { |
| 418 LOG(WARNING) << "Unable to find network:" << service_path_; | 418 LOG(WARNING) << "Unable to find network:" << service_path_; |
| 419 return; | 419 return; |
| 420 } | 420 } |
| 421 } | 421 } |
| 422 | 422 |
| 423 // Determine whether or not we need to update the icon. | 423 // Determine whether or not we need to update the icon. |
| 424 bool dirty = image_.empty(); | 424 bool dirty = image_.isNull(); |
| 425 | 425 |
| 426 // If the network state has changed, the icon needs updating. | 426 // If the network state has changed, the icon needs updating. |
| 427 if (state_ != network->state()) { | 427 if (state_ != network->state()) { |
| 428 state_ = network->state(); | 428 state_ = network->state(); |
| 429 dirty = true; | 429 dirty = true; |
| 430 } | 430 } |
| 431 | 431 |
| 432 type_ = network->type(); | 432 type_ = network->type(); |
| 433 | 433 |
| 434 if (type_ == TYPE_WIFI || type_ == TYPE_WIMAX || type_ == TYPE_CELLULAR) { | 434 if (type_ == TYPE_WIFI || type_ == TYPE_WIMAX || type_ == TYPE_CELLULAR) { |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 554 bottom_left_badge_ = rb.GetImageSkiaNamed(IDR_STATUSBAR_VPN_BADGE); | 554 bottom_left_badge_ = rb.GetImageSkiaNamed(IDR_STATUSBAR_VPN_BADGE); |
| 555 } | 555 } |
| 556 | 556 |
| 557 void NetworkIcon::UpdateIcon(const Network* network) { | 557 void NetworkIcon::UpdateIcon(const Network* network) { |
| 558 ClearIconAndBadges(); | 558 ClearIconAndBadges(); |
| 559 SetIcon(network); | 559 SetIcon(network); |
| 560 SetBadges(network); | 560 SetBadges(network); |
| 561 } | 561 } |
| 562 | 562 |
| 563 void NetworkIcon::GenerateImage() { | 563 void NetworkIcon::GenerateImage() { |
| 564 if (icon_.empty()) | 564 if (icon_.isNull()) |
| 565 return; | 565 return; |
| 566 | 566 |
| 567 image_ = NetworkMenuIcon::GenerateImageFromComponents(icon_, top_left_badge_, | 567 image_ = NetworkMenuIcon::GenerateImageFromComponents(icon_, top_left_badge_, |
| 568 top_right_badge_, bottom_left_badge_, bottom_right_badge_); | 568 top_right_badge_, bottom_left_badge_, bottom_right_badge_); |
| 569 } | 569 } |
| 570 | 570 |
| 571 bool NetworkIcon::ShouldShowInTray() const { | 571 bool NetworkIcon::ShouldShowInTray() const { |
| 572 if (type_ == TYPE_UNKNOWN || type_ == TYPE_VPN) | 572 if (type_ == TYPE_UNKNOWN || type_ == TYPE_VPN) |
| 573 return false; | 573 return false; |
| 574 if (type_ != TYPE_ETHERNET) | 574 if (type_ != TYPE_ETHERNET) |
| (...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 923 const gfx::ImageSkia NetworkMenuIcon::GetConnectedImage(ImageType type, | 923 const gfx::ImageSkia NetworkMenuIcon::GetConnectedImage(ImageType type, |
| 924 ResourceColorTheme color) { | 924 ResourceColorTheme color) { |
| 925 return GetImage(type, NumImages(type) - 1, color); | 925 return GetImage(type, NumImages(type) - 1, color); |
| 926 } | 926 } |
| 927 | 927 |
| 928 int NetworkMenuIcon::NumImages(ImageType type) { | 928 int NetworkMenuIcon::NumImages(ImageType type) { |
| 929 return (type == ARCS) ? kNumArcsImages : kNumBarsImages; | 929 return (type == ARCS) ? kNumArcsImages : kNumBarsImages; |
| 930 } | 930 } |
| 931 | 931 |
| 932 } // chromeos | 932 } // chromeos |
| OLD | NEW |