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

Side by Side Diff: ash/system/chromeos/network/network_icon.cc

Issue 12387065: Convert TrayVPN to use new NetworkState code (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix browser_tests Created 7 years, 9 months 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
OLDNEW
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 "ash/system/chromeos/network/network_icon.h" 5 #include "ash/system/chromeos/network/network_icon.h"
6 6
7 #include "ash/shell.h" 7 #include "ash/shell.h"
8 #include "ash/system/chromeos/network/network_icon_animation.h" 8 #include "ash/system/chromeos/network/network_icon_animation.h"
9 #include "ash/system/chromeos/network/network_icon_animation_observer.h" 9 #include "ash/system/chromeos/network/network_icon_animation_observer.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
280 return gfx::ImageSkia(); 280 return gfx::ImageSkia();
281 gfx::ImageSkia* images = BaseImageForType(image_type, icon_type); 281 gfx::ImageSkia* images = BaseImageForType(image_type, icon_type);
282 int width = images->width(); 282 int width = images->width();
283 int height = images->height() / num_images; 283 int height = images->height() / num_images;
284 return gfx::ImageSkiaOperations::ExtractSubset(*images, 284 return gfx::ImageSkiaOperations::ExtractSubset(*images,
285 gfx::Rect(0, index * height, width, height)); 285 gfx::Rect(0, index * height, width, height));
286 } 286 }
287 287
288 const gfx::ImageSkia GetDisconnectedImage(const std::string& type, 288 const gfx::ImageSkia GetDisconnectedImage(const std::string& type,
289 IconType icon_type) { 289 IconType icon_type) {
290 if (type == flimflam::kTypeVPN) {
291 // Note: same as connected image, shouldn't normally be seen.
292 return *ui::ResourceBundle::GetSharedInstance().GetImageSkiaNamed(
293 IDR_AURA_UBER_TRAY_NETWORK_VPN);
294 }
290 ImageType image_type = ImageTypeForNetworkType(type); 295 ImageType image_type = ImageTypeForNetworkType(type);
291 const int disconnected_index = 0; 296 const int disconnected_index = 0;
292 return GetImageForIndex(image_type, icon_type, disconnected_index); 297 return GetImageForIndex(image_type, icon_type, disconnected_index);
293 } 298 }
294 299
295 int StrengthIndex(int strength, int count) { 300 int StrengthIndex(int strength, int count) {
296 // Return an index in the range [1, count-1]. 301 // Return an index in the range [1, count-1].
297 const float findex = (static_cast<float>(strength) / 100.0f) * 302 const float findex = (static_cast<float>(strength) / 100.0f) *
298 nextafter(static_cast<float>(count - 1), 0); 303 nextafter(static_cast<float>(count - 1), 0);
299 int index = 1 + static_cast<int>(findex); 304 int index = 1 + static_cast<int>(findex);
(...skipping 290 matching lines...) Expand 10 before | Expand all | Expand 10 after
590 IDS_ASH_STATUS_TRAY_NETWORK_CONNECTED, UTF8ToUTF16(network->name())); 595 IDS_ASH_STATUS_TRAY_NETWORK_CONNECTED, UTF8ToUTF16(network->name()));
591 } 596 }
592 if (network->IsConnectingState()) { 597 if (network->IsConnectingState()) {
593 return l10n_util::GetStringFUTF16( 598 return l10n_util::GetStringFUTF16(
594 IDS_ASH_STATUS_TRAY_NETWORK_CONNECTING, UTF8ToUTF16(network->name())); 599 IDS_ASH_STATUS_TRAY_NETWORK_CONNECTING, UTF8ToUTF16(network->name()));
595 } 600 }
596 } 601 }
597 return UTF8ToUTF16(network->name()); 602 return UTF8ToUTF16(network->name());
598 } 603 }
599 604
605 int GetCellularUninitializedMsg() {
606 static base::Time s_uninitialized_state_time;
607 static int s_uninitialized_msg(0);
608
609 NetworkStateHandler* handler = NetworkStateHandler::Get();
610 if (handler->TechnologyUninitialized(
611 NetworkStateHandler::kMatchTypeMobile)) {
612 s_uninitialized_msg = IDS_ASH_STATUS_TRAY_INITIALIZING_CELLULAR;
613 s_uninitialized_state_time = base::Time::Now();
614 return s_uninitialized_msg;
615 } else if (handler->GetScanningByType(
616 NetworkStateHandler::kMatchTypeMobile)) {
617 s_uninitialized_msg = IDS_ASH_STATUS_TRAY_CELLULAR_SCANNING;
618 s_uninitialized_state_time = base::Time::Now();
619 return s_uninitialized_msg;
620 }
621 // There can be a delay between leaving the Initializing state and when
622 // a Cellular device shows up, so keep showing the initializing
623 // animation for a bit to avoid flashing the disconnect icon.
624 const int kInitializingDelaySeconds = 1;
625 base::TimeDelta dtime = base::Time::Now() - s_uninitialized_state_time;
626 if (dtime.InSeconds() < kInitializingDelaySeconds)
627 return s_uninitialized_msg;
628 return 0;
629 }
630
600 } // namespace network_icon 631 } // namespace network_icon
601 } // namespace ash 632 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/chromeos/network/network_icon.h ('k') | ash/system/chromeos/network/network_state_list_detailed_view.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698