| 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 "ui/chromeos/network/network_icon.h" | 5 #include "ui/chromeos/network/network_icon.h" |
| 6 | 6 |
| 7 #include "base/strings/utf_string_conversions.h" | 7 #include "base/strings/utf_string_conversions.h" |
| 8 #include "chromeos/network/device_state.h" | 8 #include "chromeos/network/device_state.h" |
| 9 #include "chromeos/network/network_connection_handler.h" | 9 #include "chromeos/network/network_connection_handler.h" |
| 10 #include "chromeos/network/network_state.h" | 10 #include "chromeos/network/network_state.h" |
| (...skipping 196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 207 (*s_empty_bitmaps)[key] = empty; | 207 (*s_empty_bitmaps)[key] = empty; |
| 208 return empty; | 208 return empty; |
| 209 } | 209 } |
| 210 | 210 |
| 211 class EmptyImageSource: public gfx::ImageSkiaSource { | 211 class EmptyImageSource: public gfx::ImageSkiaSource { |
| 212 public: | 212 public: |
| 213 explicit EmptyImageSource(const gfx::Size& size) | 213 explicit EmptyImageSource(const gfx::Size& size) |
| 214 : size_(size) { | 214 : size_(size) { |
| 215 } | 215 } |
| 216 | 216 |
| 217 virtual gfx::ImageSkiaRep GetImageForScale(float scale) OVERRIDE { | 217 virtual gfx::ImageSkiaRep GetImageForScale(float scale) override { |
| 218 gfx::Size pixel_size = gfx::ToFlooredSize(gfx::ScaleSize(size_, scale)); | 218 gfx::Size pixel_size = gfx::ToFlooredSize(gfx::ScaleSize(size_, scale)); |
| 219 SkBitmap empty_bitmap = GetEmptyBitmap(pixel_size); | 219 SkBitmap empty_bitmap = GetEmptyBitmap(pixel_size); |
| 220 return gfx::ImageSkiaRep(empty_bitmap, scale); | 220 return gfx::ImageSkiaRep(empty_bitmap, scale); |
| 221 } | 221 } |
| 222 | 222 |
| 223 private: | 223 private: |
| 224 const gfx::Size size_; | 224 const gfx::Size size_; |
| 225 | 225 |
| 226 DISALLOW_COPY_AND_ASSIGN(EmptyImageSource); | 226 DISALLOW_COPY_AND_ASSIGN(EmptyImageSource); |
| 227 }; | 227 }; |
| 228 | 228 |
| 229 // This defines how we assemble a network icon. | 229 // This defines how we assemble a network icon. |
| 230 class NetworkIconImageSource : public gfx::ImageSkiaSource { | 230 class NetworkIconImageSource : public gfx::ImageSkiaSource { |
| 231 public: | 231 public: |
| 232 NetworkIconImageSource(const gfx::ImageSkia& icon, const Badges& badges) | 232 NetworkIconImageSource(const gfx::ImageSkia& icon, const Badges& badges) |
| 233 : icon_(icon), | 233 : icon_(icon), |
| 234 badges_(badges) { | 234 badges_(badges) { |
| 235 } | 235 } |
| 236 virtual ~NetworkIconImageSource() {} | 236 virtual ~NetworkIconImageSource() {} |
| 237 | 237 |
| 238 // TODO(pkotwicz): Figure out what to do when a new image resolution becomes | 238 // TODO(pkotwicz): Figure out what to do when a new image resolution becomes |
| 239 // available. | 239 // available. |
| 240 virtual gfx::ImageSkiaRep GetImageForScale(float scale) OVERRIDE { | 240 virtual gfx::ImageSkiaRep GetImageForScale(float scale) override { |
| 241 gfx::ImageSkiaRep icon_rep = icon_.GetRepresentation(scale); | 241 gfx::ImageSkiaRep icon_rep = icon_.GetRepresentation(scale); |
| 242 if (icon_rep.is_null()) | 242 if (icon_rep.is_null()) |
| 243 return gfx::ImageSkiaRep(); | 243 return gfx::ImageSkiaRep(); |
| 244 gfx::Canvas canvas(icon_rep, false); | 244 gfx::Canvas canvas(icon_rep, false); |
| 245 if (badges_.top_left) | 245 if (badges_.top_left) |
| 246 canvas.DrawImageInt(*badges_.top_left, 0, 0); | 246 canvas.DrawImageInt(*badges_.top_left, 0, 0); |
| 247 if (badges_.top_right) | 247 if (badges_.top_right) |
| 248 canvas.DrawImageInt(*badges_.top_right, | 248 canvas.DrawImageInt(*badges_.top_right, |
| 249 icon_.width() - badges_.top_right->width(), 0); | 249 icon_.width() - badges_.top_right->width(), 0); |
| 250 if (badges_.bottom_left) { | 250 if (badges_.bottom_left) { |
| (...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 953 iter != networks.end(); ++iter) { | 953 iter != networks.end(); ++iter) { |
| 954 network_paths.insert((*iter)->path()); | 954 network_paths.insert((*iter)->path()); |
| 955 } | 955 } |
| 956 PurgeIconMap(ICON_TYPE_TRAY, network_paths); | 956 PurgeIconMap(ICON_TYPE_TRAY, network_paths); |
| 957 PurgeIconMap(ICON_TYPE_DEFAULT_VIEW, network_paths); | 957 PurgeIconMap(ICON_TYPE_DEFAULT_VIEW, network_paths); |
| 958 PurgeIconMap(ICON_TYPE_LIST, network_paths); | 958 PurgeIconMap(ICON_TYPE_LIST, network_paths); |
| 959 } | 959 } |
| 960 | 960 |
| 961 } // namespace network_icon | 961 } // namespace network_icon |
| 962 } // namespace ui | 962 } // namespace ui |
| OLD | NEW |