OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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_dropdown_button.h" | 5 #include "chrome/browser/chromeos/status/network_dropdown_button.h" |
6 | 6 |
7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
8 #include "chrome/browser/chromeos/cros/cros_library.h" | 8 #include "chrome/browser/chromeos/cros/cros_library.h" |
9 #include "chrome/browser/chromeos/options/network_config_view.h" | 9 #include "chrome/browser/chromeos/options/network_config_view.h" |
10 #include "chrome/browser/chromeos/status/status_area_host.h" | 10 #include "chrome/browser/chromeos/status/status_area_host.h" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 NetworkDropdownButton::~NetworkDropdownButton() { | 43 NetworkDropdownButton::~NetworkDropdownButton() { |
44 CrosLibrary::Get()->GetNetworkLibrary()->RemoveNetworkManagerObserver(this); | 44 CrosLibrary::Get()->GetNetworkLibrary()->RemoveNetworkManagerObserver(this); |
45 } | 45 } |
46 | 46 |
47 //////////////////////////////////////////////////////////////////////////////// | 47 //////////////////////////////////////////////////////////////////////////////// |
48 // NetworkMenuButton, ui::AnimationDelegate implementation: | 48 // NetworkMenuButton, ui::AnimationDelegate implementation: |
49 | 49 |
50 void NetworkDropdownButton::AnimationProgressed( | 50 void NetworkDropdownButton::AnimationProgressed( |
51 const ui::Animation* animation) { | 51 const ui::Animation* animation) { |
52 if (animation == &animation_connecting_) { | 52 if (animation == &animation_connecting_) { |
53 SetIcon(IconForNetworkConnecting(animation_connecting_.GetCurrentValue(), | 53 SetIcon(*IconForNetworkConnecting(animation_connecting_.GetCurrentValue(), |
54 true)); | 54 true)); |
55 SchedulePaint(); | 55 SchedulePaint(); |
56 } else { | 56 } else { |
57 MenuButton::AnimationProgressed(animation); | 57 MenuButton::AnimationProgressed(animation); |
58 } | 58 } |
59 } | 59 } |
60 | 60 |
61 void NetworkDropdownButton::Refresh() { | 61 void NetworkDropdownButton::Refresh() { |
62 OnNetworkManagerChanged(CrosLibrary::Get()->GetNetworkLibrary()); | 62 OnNetworkManagerChanged(CrosLibrary::Get()->GetNetworkLibrary()); |
63 } | 63 } |
64 | 64 |
(...skipping 14 matching lines...) Expand all Loading... |
79 const Network* active_network = cros->active_network(); | 79 const Network* active_network = cros->active_network(); |
80 if (active_network != NULL) { | 80 if (active_network != NULL) { |
81 animation_connecting_.Stop(); | 81 animation_connecting_.Stop(); |
82 if (active_network->type() == TYPE_ETHERNET) { | 82 if (active_network->type() == TYPE_ETHERNET) { |
83 SetIcon(*rb.GetBitmapNamed(IDR_STATUSBAR_WIRED)); | 83 SetIcon(*rb.GetBitmapNamed(IDR_STATUSBAR_WIRED)); |
84 SetText(UTF16ToWide( | 84 SetText(UTF16ToWide( |
85 l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET))); | 85 l10n_util::GetStringUTF16(IDS_STATUSBAR_NETWORK_DEVICE_ETHERNET))); |
86 } else if (active_network->type() == TYPE_WIFI) { | 86 } else if (active_network->type() == TYPE_WIFI) { |
87 const WifiNetwork* wifi = | 87 const WifiNetwork* wifi = |
88 static_cast<const WifiNetwork*>(active_network); | 88 static_cast<const WifiNetwork*>(active_network); |
89 SetIcon(IconForNetworkStrength(wifi, true)); | 89 SetIcon(*IconForNetworkStrength(wifi, true)); |
90 SetText(ASCIIToWide(wifi->name())); | 90 SetText(ASCIIToWide(wifi->name())); |
91 } else if (active_network->type() == TYPE_CELLULAR) { | 91 } else if (active_network->type() == TYPE_CELLULAR) { |
92 const CellularNetwork* cellular = | 92 const CellularNetwork* cellular = |
93 static_cast<const CellularNetwork*>(active_network); | 93 static_cast<const CellularNetwork*>(active_network); |
94 SetIcon(IconForNetworkStrength(cellular, true)); | 94 SetIcon(*IconForNetworkStrength(cellular, true)); |
95 SetText(ASCIIToWide(cellular->name())); | 95 SetText(ASCIIToWide(cellular->name())); |
96 } else { | 96 } else { |
97 NOTREACHED(); | 97 NOTREACHED(); |
98 } | 98 } |
99 } else if (cros->wifi_connecting() || cros->cellular_connecting()) { | 99 } else if (cros->wifi_connecting() || cros->cellular_connecting()) { |
100 if (!animation_connecting_.is_animating()) { | 100 if (!animation_connecting_.is_animating()) { |
101 animation_connecting_.Reset(); | 101 animation_connecting_.Reset(); |
102 animation_connecting_.StartThrobbing(-1); | 102 animation_connecting_.StartThrobbing(-1); |
103 SetIcon(IconForNetworkConnecting(0, true)); | 103 SetIcon(*IconForNetworkConnecting(0, true)); |
104 } | 104 } |
105 if (cros->wifi_connecting()) | 105 if (cros->wifi_connecting()) |
106 SetText(ASCIIToWide(cros->wifi_network()->name())); | 106 SetText(ASCIIToWide(cros->wifi_network()->name())); |
107 else if (cros->cellular_connecting()) | 107 else if (cros->cellular_connecting()) |
108 SetText(ASCIIToWide(cros->cellular_network()->name())); | 108 SetText(ASCIIToWide(cros->cellular_network()->name())); |
109 } | 109 } |
110 | 110 |
111 if (!cros->Connected() && !cros->Connecting()) { | 111 if (!cros->Connected() && !cros->Connecting()) { |
112 animation_connecting_.Stop(); | 112 animation_connecting_.Stop(); |
113 SetIcon(SkBitmap()); | 113 SetIcon(SkBitmap()); |
114 SetText(UTF16ToWide( | 114 SetText(UTF16ToWide( |
115 l10n_util::GetStringUTF16(IDS_NETWORK_SELECTION_NONE))); | 115 l10n_util::GetStringUTF16(IDS_NETWORK_SELECTION_NONE))); |
116 } | 116 } |
117 } else { | 117 } else { |
118 animation_connecting_.Stop(); | 118 animation_connecting_.Stop(); |
119 SetIcon(SkBitmap()); | 119 SetIcon(SkBitmap()); |
120 SetText(UTF16ToWide( | 120 SetText(UTF16ToWide( |
121 l10n_util::GetStringUTF16(IDS_STATUSBAR_NO_NETWORKS_MESSAGE))); | 121 l10n_util::GetStringUTF16(IDS_STATUSBAR_NO_NETWORKS_MESSAGE))); |
122 } | 122 } |
123 | 123 |
124 SchedulePaint(); | 124 SchedulePaint(); |
125 UpdateMenu(); | 125 UpdateMenu(); |
126 } | 126 } |
127 | 127 |
128 } // namespace chromeos | 128 } // namespace chromeos |
OLD | NEW |