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 "ash/system/chromeos/network/network_state_list_detailed_view.h" | 5 #include "ash/system/chromeos/network/network_state_list_detailed_view.h" |
6 | 6 |
7 #include <vector> | 7 #include <vector> |
8 | 8 |
9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
10 #include "ash/metrics/user_metrics_recorder.h" | 10 #include "ash/metrics/user_metrics_recorder.h" |
11 #include "ash/networking_config_delegate.h" | 11 #include "ash/networking_config_delegate.h" |
12 #include "ash/root_window_controller.h" | 12 #include "ash/root_window_controller.h" |
13 #include "ash/shell.h" | 13 #include "ash/shell.h" |
14 #include "ash/shell_delegate.h" | 14 #include "ash/shell_delegate.h" |
15 #include "ash/shell_window_ids.h" | 15 #include "ash/shell_window_ids.h" |
16 #include "ash/system/chromeos/network/tray_network_state_observer.h" | 16 #include "ash/system/chromeos/network/tray_network_state_observer.h" |
17 #include "ash/system/chromeos/network/vpn_list_view.h" | 17 #include "ash/system/chromeos/network/vpn_list_view.h" |
18 #include "ash/system/tray/fixed_sized_image_view.h" | 18 #include "ash/system/tray/fixed_sized_image_view.h" |
19 #include "ash/system/tray/fixed_sized_scroll_view.h" | 19 #include "ash/system/tray/fixed_sized_scroll_view.h" |
20 #include "ash/system/tray/hover_highlight_view.h" | 20 #include "ash/system/tray/hover_highlight_view.h" |
21 #include "ash/system/tray/system_tray.h" | 21 #include "ash/system/tray/system_tray.h" |
22 #include "ash/system/tray/system_tray_delegate.h" | 22 #include "ash/system/tray/system_tray_delegate.h" |
| 23 #include "ash/system/tray/throbber_view.h" |
23 #include "ash/system/tray/tray_constants.h" | 24 #include "ash/system/tray/tray_constants.h" |
24 #include "ash/system/tray/tray_details_view.h" | 25 #include "ash/system/tray/tray_details_view.h" |
25 #include "ash/system/tray/tray_popup_header_button.h" | 26 #include "ash/system/tray/tray_popup_header_button.h" |
26 #include "ash/system/tray/tray_popup_label_button.h" | 27 #include "ash/system/tray/tray_popup_label_button.h" |
27 #include "base/command_line.h" | 28 #include "base/command_line.h" |
28 #include "base/message_loop/message_loop.h" | 29 #include "base/message_loop/message_loop.h" |
29 #include "base/strings/string_number_conversions.h" | 30 #include "base/strings/string_number_conversions.h" |
30 #include "base/strings/utf_string_conversions.h" | 31 #include "base/strings/utf_string_conversions.h" |
31 #include "base/time/time.h" | 32 #include "base/time/time.h" |
32 #include "chromeos/chromeos_switches.h" | 33 #include "chromeos/chromeos_switches.h" |
33 #include "chromeos/network/device_state.h" | 34 #include "chromeos/network/device_state.h" |
34 #include "chromeos/network/network_state.h" | 35 #include "chromeos/network/network_state.h" |
35 #include "chromeos/network/network_state_handler.h" | 36 #include "chromeos/network/network_state_handler.h" |
36 #include "grit/ash_resources.h" | 37 #include "grit/ash_resources.h" |
37 #include "grit/ash_strings.h" | 38 #include "grit/ash_strings.h" |
38 #include "grit/ui_chromeos_strings.h" | 39 #include "grit/ui_chromeos_strings.h" |
39 #include "third_party/cros_system_api/dbus/service_constants.h" | 40 #include "third_party/cros_system_api/dbus/service_constants.h" |
40 #include "ui/aura/window.h" | 41 #include "ui/aura/window.h" |
41 #include "ui/base/l10n/l10n_util.h" | 42 #include "ui/base/l10n/l10n_util.h" |
42 #include "ui/base/resource/resource_bundle.h" | 43 #include "ui/base/resource/resource_bundle.h" |
43 #include "ui/chromeos/network/network_connect.h" | 44 #include "ui/chromeos/network/network_connect.h" |
44 #include "ui/chromeos/network/network_icon.h" | 45 #include "ui/chromeos/network/network_icon.h" |
45 #include "ui/chromeos/network/network_icon_animation.h" | 46 #include "ui/chromeos/network/network_icon_animation.h" |
46 #include "ui/chromeos/network/network_info.h" | 47 #include "ui/chromeos/network/network_info.h" |
47 #include "ui/chromeos/network/network_list.h" | 48 #include "ui/chromeos/network/network_list.h" |
48 #include "ui/chromeos/network/network_list_view_base.h" | 49 #include "ui/chromeos/network/network_list_view_base.h" |
49 #include "ui/chromeos/resources/grit/ui_chromeos_resources.h" | 50 #include "ui/chromeos/resources/grit/ui_chromeos_resources.h" |
| 51 #include "ui/compositor/layer.h" |
| 52 #include "ui/compositor/scoped_layer_animation_settings.h" |
50 #include "ui/gfx/text_constants.h" | 53 #include "ui/gfx/text_constants.h" |
51 #include "ui/views/bubble/bubble_delegate.h" | 54 #include "ui/views/bubble/bubble_delegate.h" |
52 #include "ui/views/controls/label.h" | 55 #include "ui/views/controls/label.h" |
53 #include "ui/views/layout/box_layout.h" | 56 #include "ui/views/layout/box_layout.h" |
54 #include "ui/views/layout/fill_layout.h" | 57 #include "ui/views/layout/fill_layout.h" |
| 58 #include "ui/views/layout/layout_manager.h" |
55 #include "ui/views/widget/widget.h" | 59 #include "ui/views/widget/widget.h" |
56 | 60 |
57 using chromeos::DeviceState; | 61 using chromeos::DeviceState; |
58 using chromeos::NetworkHandler; | 62 using chromeos::NetworkHandler; |
59 using chromeos::NetworkState; | 63 using chromeos::NetworkState; |
60 using chromeos::NetworkStateHandler; | 64 using chromeos::NetworkStateHandler; |
61 using chromeos::NetworkTypePattern; | 65 using chromeos::NetworkTypePattern; |
62 using ui::NetworkInfo; | 66 using ui::NetworkInfo; |
63 | 67 |
64 namespace ash { | 68 namespace ash { |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 ~InfoBubble() override { detailed_view_->OnInfoBubbleDestroyed(); } | 117 ~InfoBubble() override { detailed_view_->OnInfoBubbleDestroyed(); } |
114 | 118 |
115 private: | 119 private: |
116 // Not owned. | 120 // Not owned. |
117 NetworkStateListDetailedView* detailed_view_; | 121 NetworkStateListDetailedView* detailed_view_; |
118 | 122 |
119 DISALLOW_COPY_AND_ASSIGN(InfoBubble); | 123 DISALLOW_COPY_AND_ASSIGN(InfoBubble); |
120 }; | 124 }; |
121 | 125 |
122 //------------------------------------------------------------------------------ | 126 //------------------------------------------------------------------------------ |
| 127 |
| 128 // A throbber button that can also be clicked on. |
| 129 class ThrobberButton : public ThrobberView { |
| 130 public: |
| 131 explicit ThrobberButton(NetworkStateListDetailedView* owner) |
| 132 : owner_(owner) {} |
| 133 ~ThrobberButton() override {} |
| 134 |
| 135 // views::View |
| 136 bool OnMousePressed(const ui::MouseEvent& event) override { |
| 137 return owner_->ThrobberPressed(this, event); |
| 138 } |
| 139 |
| 140 private: |
| 141 NetworkStateListDetailedView* owner_; |
| 142 |
| 143 DISALLOW_COPY_AND_ASSIGN(ThrobberButton); |
| 144 }; |
| 145 |
| 146 //------------------------------------------------------------------------------ |
| 147 |
| 148 const int kFadeIconMs = 500; |
| 149 |
| 150 // A TrayPopupHeaderButton that fades in/out when shown/hidden. |
| 151 class InfoIcon : public TrayPopupHeaderButton { |
| 152 public: |
| 153 explicit InfoIcon(views::ButtonListener* listener) |
| 154 : TrayPopupHeaderButton(listener, |
| 155 IDR_AURA_UBER_TRAY_NETWORK_INFO, |
| 156 IDR_AURA_UBER_TRAY_NETWORK_INFO, |
| 157 IDR_AURA_UBER_TRAY_NETWORK_INFO_HOVER, |
| 158 IDR_AURA_UBER_TRAY_NETWORK_INFO_HOVER, |
| 159 IDS_ASH_STATUS_TRAY_NETWORK_INFO) { |
| 160 SetPaintToLayer(true); |
| 161 layer()->SetFillsBoundsOpaquely(false); |
| 162 layer()->SetOpacity(1.0); |
| 163 } |
| 164 ~InfoIcon() override {} |
| 165 |
| 166 // views::View |
| 167 void SetVisible(bool visible) override { |
| 168 layer()->GetAnimator()->StopAnimating(); // Stop any previous animation. |
| 169 ui::ScopedLayerAnimationSettings animation(layer()->GetAnimator()); |
| 170 animation.SetTransitionDuration( |
| 171 base::TimeDelta::FromMilliseconds(kFadeIconMs)); |
| 172 layer()->SetOpacity(visible ? 1.0 : 0.0); |
| 173 } |
| 174 |
| 175 private: |
| 176 DISALLOW_COPY_AND_ASSIGN(InfoIcon); |
| 177 }; |
| 178 |
| 179 //------------------------------------------------------------------------------ |
| 180 |
| 181 // Special layout to overlap the scanning throbber and the info button. |
| 182 class InfoThrobberLayout : public views::LayoutManager { |
| 183 public: |
| 184 InfoThrobberLayout() {} |
| 185 ~InfoThrobberLayout() override {} |
| 186 |
| 187 // views::LayoutManager |
| 188 void Layout(views::View* host) override { |
| 189 gfx::Size max_size(GetMaxChildSize(host)); |
| 190 // Center each child view within |max_size|. |
| 191 for (int i = 0; i < host->child_count(); ++i) { |
| 192 views::View* child = host->child_at(i); |
| 193 if (!child->visible()) |
| 194 continue; |
| 195 gfx::Size child_size = child->GetPreferredSize(); |
| 196 gfx::Point origin; |
| 197 origin.set_x((max_size.width() - child_size.width()) / 2); |
| 198 origin.set_y((max_size.height() - child_size.height()) / 2); |
| 199 gfx::Rect bounds(origin, child_size); |
| 200 bounds.Inset(-host->GetInsets()); |
| 201 child->SetBoundsRect(bounds); |
| 202 } |
| 203 } |
| 204 |
| 205 gfx::Size GetPreferredSize(const views::View* host) const override { |
| 206 gfx::Point origin; |
| 207 gfx::Rect rect(origin, GetMaxChildSize(host)); |
| 208 rect.Inset(-host->GetInsets()); |
| 209 return rect.size(); |
| 210 } |
| 211 |
| 212 private: |
| 213 gfx::Size GetMaxChildSize(const views::View* host) const { |
| 214 int width = 0, height = 0; |
| 215 for (int i = 0; i < host->child_count(); ++i) { |
| 216 const views::View* child = host->child_at(i); |
| 217 if (!child->visible()) |
| 218 continue; |
| 219 gfx::Size child_size = child->GetPreferredSize(); |
| 220 width = std::max(width, child_size.width()); |
| 221 height = std::max(height, child_size.width()); |
| 222 } |
| 223 return gfx::Size(width, height); |
| 224 } |
| 225 |
| 226 DISALLOW_COPY_AND_ASSIGN(InfoThrobberLayout); |
| 227 }; |
| 228 |
| 229 //------------------------------------------------------------------------------ |
123 // NetworkStateListDetailedView | 230 // NetworkStateListDetailedView |
124 | 231 |
125 NetworkStateListDetailedView::NetworkStateListDetailedView( | 232 NetworkStateListDetailedView::NetworkStateListDetailedView( |
126 SystemTrayItem* owner, | 233 SystemTrayItem* owner, |
127 ListType list_type, | 234 ListType list_type, |
128 user::LoginStatus login) | 235 user::LoginStatus login) |
129 : NetworkDetailedView(owner), | 236 : NetworkDetailedView(owner), |
130 list_type_(list_type), | 237 list_type_(list_type), |
131 login_(login), | 238 login_(login), |
| 239 wifi_scanning_(false), |
132 info_icon_(nullptr), | 240 info_icon_(nullptr), |
133 button_wifi_(nullptr), | 241 button_wifi_(nullptr), |
134 button_mobile_(nullptr), | 242 button_mobile_(nullptr), |
135 other_wifi_(nullptr), | 243 other_wifi_(nullptr), |
136 turn_on_wifi_(nullptr), | 244 turn_on_wifi_(nullptr), |
137 other_mobile_(nullptr), | 245 other_mobile_(nullptr), |
138 settings_(nullptr), | 246 settings_(nullptr), |
139 proxy_settings_(nullptr), | 247 proxy_settings_(nullptr), |
140 info_bubble_(nullptr) { | 248 info_bubble_(nullptr), |
| 249 scanning_throbber_(nullptr) { |
141 if (list_type == LIST_TYPE_VPN) { | 250 if (list_type == LIST_TYPE_VPN) { |
142 // Use a specialized class to list VPNs. | 251 // Use a specialized class to list VPNs. |
143 network_list_view_.reset(new VPNListView(this)); | 252 network_list_view_.reset(new VPNListView(this)); |
144 } else { | 253 } else { |
145 // Use a common class to list any other network types. | 254 // Use a common class to list any other network types. |
146 network_list_view_.reset(new ui::NetworkListView(this)); | 255 network_list_view_.reset(new ui::NetworkListView(this)); |
147 } | 256 } |
148 } | 257 } |
149 | 258 |
150 NetworkStateListDetailedView::~NetworkStateListDetailedView() { | 259 NetworkStateListDetailedView::~NetworkStateListDetailedView() { |
151 if (info_bubble_) | 260 if (info_bubble_) |
152 info_bubble_->GetWidget()->CloseNow(); | 261 info_bubble_->GetWidget()->CloseNow(); |
153 } | 262 } |
154 | 263 |
155 void NetworkStateListDetailedView::Update() { | 264 void NetworkStateListDetailedView::Update() { |
156 UpdateNetworkList(); | 265 UpdateNetworkList(); |
157 UpdateHeaderButtons(); | 266 UpdateHeaderButtons(); |
158 UpdateNetworkExtra(); | 267 UpdateNetworkExtra(); |
159 Layout(); | 268 Layout(); |
160 } | 269 } |
161 | 270 |
162 // Overridden from NetworkDetailedView: | 271 // Overridden from NetworkDetailedView: |
163 | 272 |
164 void NetworkStateListDetailedView::Init() { | 273 void NetworkStateListDetailedView::Init() { |
165 Reset(); | 274 Reset(); |
166 info_icon_ = NULL; | 275 info_icon_ = nullptr; |
167 button_wifi_ = NULL; | 276 button_wifi_ = nullptr; |
168 button_mobile_ = NULL; | 277 button_mobile_ = nullptr; |
169 other_wifi_ = NULL; | 278 other_wifi_ = nullptr; |
170 turn_on_wifi_ = NULL; | 279 turn_on_wifi_ = nullptr; |
171 other_mobile_ = NULL; | 280 other_mobile_ = nullptr; |
172 settings_ = NULL; | 281 settings_ = nullptr; |
173 proxy_settings_ = NULL; | 282 proxy_settings_ = nullptr; |
| 283 scanning_throbber_ = nullptr; |
174 | 284 |
175 CreateScrollableList(); | 285 CreateScrollableList(); |
176 CreateNetworkExtra(); | 286 CreateNetworkExtra(); |
177 CreateHeaderEntry(); | 287 CreateHeaderEntry(); |
178 CreateHeaderButtons(); | |
179 | 288 |
180 network_list_view_->set_container(scroll_content()); | 289 network_list_view_->set_container(scroll_content()); |
181 Update(); | 290 Update(); |
182 | 291 |
183 CallRequestScan(); | 292 CallRequestScan(); |
184 } | 293 } |
185 | 294 |
186 NetworkDetailedView::DetailedViewType | 295 NetworkDetailedView::DetailedViewType |
187 NetworkStateListDetailedView::GetViewType() const { | 296 NetworkStateListDetailedView::GetViewType() const { |
188 return STATE_LIST_VIEW; | 297 return STATE_LIST_VIEW; |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 delegate->ShowOtherNetworkDialog(shill::kTypeCellular); | 333 delegate->ShowOtherNetworkDialog(shill::kTypeCellular); |
225 } else if (sender == other_wifi_) { | 334 } else if (sender == other_wifi_) { |
226 Shell::GetInstance()->metrics()->RecordUserMetricsAction( | 335 Shell::GetInstance()->metrics()->RecordUserMetricsAction( |
227 ash::UMA_STATUS_AREA_NETWORK_JOIN_OTHER_CLICKED); | 336 ash::UMA_STATUS_AREA_NETWORK_JOIN_OTHER_CLICKED); |
228 delegate->ShowOtherNetworkDialog(shill::kTypeWifi); | 337 delegate->ShowOtherNetworkDialog(shill::kTypeWifi); |
229 } else { | 338 } else { |
230 NOTREACHED(); | 339 NOTREACHED(); |
231 } | 340 } |
232 } | 341 } |
233 | 342 |
| 343 bool NetworkStateListDetailedView::ThrobberPressed(views::View* sender, |
| 344 const ui::Event& event) { |
| 345 if (sender != scanning_throbber_) |
| 346 return false; |
| 347 ToggleInfoBubble(); |
| 348 return true; |
| 349 } |
| 350 |
234 void NetworkStateListDetailedView::OnViewClicked(views::View* sender) { | 351 void NetworkStateListDetailedView::OnViewClicked(views::View* sender) { |
235 // If the info bubble was visible, close it when some other item is clicked. | 352 // If the info bubble was visible, close it when some other item is clicked. |
236 ResetInfoBubble(); | 353 ResetInfoBubble(); |
237 | 354 |
238 if (sender == footer()->content()) { | 355 if (sender == footer()->content()) { |
239 TransitionToDefaultView(); | 356 TransitionToDefaultView(); |
240 return; | 357 return; |
241 } | 358 } |
242 | 359 |
243 if (login_ == user::LOGGED_IN_LOCKED) | 360 if (login_ == user::LOGGED_IN_LOCKED) |
(...skipping 19 matching lines...) Expand all Loading... |
263 ? ash::UMA_STATUS_AREA_CONNECT_TO_VPN | 380 ? ash::UMA_STATUS_AREA_CONNECT_TO_VPN |
264 : ash::UMA_STATUS_AREA_CONNECT_TO_CONFIGURED_NETWORK); | 381 : ash::UMA_STATUS_AREA_CONNECT_TO_CONFIGURED_NETWORK); |
265 ui::NetworkConnect::Get()->ConnectToNetwork(service_path); | 382 ui::NetworkConnect::Get()->ConnectToNetwork(service_path); |
266 } | 383 } |
267 } | 384 } |
268 | 385 |
269 // Create UI components. | 386 // Create UI components. |
270 | 387 |
271 void NetworkStateListDetailedView::CreateHeaderEntry() { | 388 void NetworkStateListDetailedView::CreateHeaderEntry() { |
272 CreateSpecialRow(IDS_ASH_STATUS_TRAY_NETWORK, this); | 389 CreateSpecialRow(IDS_ASH_STATUS_TRAY_NETWORK, this); |
273 } | |
274 | 390 |
275 void NetworkStateListDetailedView::CreateHeaderButtons() { | |
276 if (list_type_ != LIST_TYPE_VPN) { | 391 if (list_type_ != LIST_TYPE_VPN) { |
277 button_wifi_ = new TrayPopupHeaderButton( | 392 button_wifi_ = new TrayPopupHeaderButton( |
278 this, IDR_AURA_UBER_TRAY_WIFI_ENABLED, IDR_AURA_UBER_TRAY_WIFI_DISABLED, | 393 this, IDR_AURA_UBER_TRAY_WIFI_ENABLED, IDR_AURA_UBER_TRAY_WIFI_DISABLED, |
279 IDR_AURA_UBER_TRAY_WIFI_ENABLED_HOVER, | 394 IDR_AURA_UBER_TRAY_WIFI_ENABLED_HOVER, |
280 IDR_AURA_UBER_TRAY_WIFI_DISABLED_HOVER, IDS_ASH_STATUS_TRAY_WIFI); | 395 IDR_AURA_UBER_TRAY_WIFI_DISABLED_HOVER, IDS_ASH_STATUS_TRAY_WIFI); |
281 button_wifi_->SetTooltipText( | 396 button_wifi_->SetTooltipText( |
282 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISABLE_WIFI)); | 397 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISABLE_WIFI)); |
283 button_wifi_->SetToggledTooltipText( | 398 button_wifi_->SetToggledTooltipText( |
284 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ENABLE_WIFI)); | 399 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ENABLE_WIFI)); |
285 footer()->AddButton(button_wifi_); | 400 footer()->AddButton(button_wifi_); |
286 | 401 |
287 button_mobile_ = | 402 button_mobile_ = |
288 new TrayPopupHeaderButton(this, IDR_AURA_UBER_TRAY_CELLULAR_ENABLED, | 403 new TrayPopupHeaderButton(this, IDR_AURA_UBER_TRAY_CELLULAR_ENABLED, |
289 IDR_AURA_UBER_TRAY_CELLULAR_DISABLED, | 404 IDR_AURA_UBER_TRAY_CELLULAR_DISABLED, |
290 IDR_AURA_UBER_TRAY_CELLULAR_ENABLED_HOVER, | 405 IDR_AURA_UBER_TRAY_CELLULAR_ENABLED_HOVER, |
291 IDR_AURA_UBER_TRAY_CELLULAR_DISABLED_HOVER, | 406 IDR_AURA_UBER_TRAY_CELLULAR_DISABLED_HOVER, |
292 IDS_ASH_STATUS_TRAY_CELLULAR); | 407 IDS_ASH_STATUS_TRAY_CELLULAR); |
293 button_mobile_->SetTooltipText( | 408 button_mobile_->SetTooltipText( |
294 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISABLE_MOBILE)); | 409 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_DISABLE_MOBILE)); |
295 button_mobile_->SetToggledTooltipText( | 410 button_mobile_->SetToggledTooltipText( |
296 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ENABLE_MOBILE)); | 411 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_ENABLE_MOBILE)); |
297 footer()->AddButton(button_mobile_); | 412 footer()->AddButton(button_mobile_); |
298 } | 413 } |
299 | 414 |
300 info_icon_ = new TrayPopupHeaderButton( | 415 views::View* info_throbber_container = new views::View(); |
301 this, IDR_AURA_UBER_TRAY_NETWORK_INFO, IDR_AURA_UBER_TRAY_NETWORK_INFO, | 416 InfoThrobberLayout* info_throbber_layout = new InfoThrobberLayout; |
302 IDR_AURA_UBER_TRAY_NETWORK_INFO_HOVER, | 417 info_throbber_container->SetLayoutManager(info_throbber_layout); |
303 IDR_AURA_UBER_TRAY_NETWORK_INFO_HOVER, IDS_ASH_STATUS_TRAY_NETWORK_INFO); | 418 footer()->AddView(info_throbber_container, true /* add_separator */); |
304 info_icon_->SetTooltipText( | 419 |
| 420 info_icon_ = new InfoIcon(this); |
| 421 info_throbber_container->AddChildView(info_icon_); |
| 422 |
| 423 scanning_throbber_ = new ThrobberButton(this); |
| 424 // Since the throbber is added last, it will be "on top" of the info button, |
| 425 // so it gets the info tooltip. |
| 426 scanning_throbber_->SetTooltipText( |
305 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_NETWORK_INFO)); | 427 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_NETWORK_INFO)); |
306 footer()->AddButton(info_icon_); | 428 info_throbber_container->AddChildView(scanning_throbber_); |
307 } | 429 } |
308 | 430 |
309 void NetworkStateListDetailedView::CreateNetworkExtra() { | 431 void NetworkStateListDetailedView::CreateNetworkExtra() { |
310 if (login_ == user::LOGGED_IN_LOCKED) | 432 if (login_ == user::LOGGED_IN_LOCKED) |
311 return; | 433 return; |
312 | 434 |
313 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); | 435 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); |
314 | 436 |
315 views::View* bottom_row = new views::View(); | 437 views::View* bottom_row = new views::View(); |
316 views::BoxLayout* layout = new views::BoxLayout( | 438 views::BoxLayout* layout = new views::BoxLayout( |
(...skipping 11 matching lines...) Expand all Loading... |
328 this, rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_TURN_ON_WIFI)); | 450 this, rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_TURN_ON_WIFI)); |
329 bottom_row->AddChildView(turn_on_wifi_); | 451 bottom_row->AddChildView(turn_on_wifi_); |
330 | 452 |
331 other_mobile_ = new TrayPopupLabelButton( | 453 other_mobile_ = new TrayPopupLabelButton( |
332 this, rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_OTHER_MOBILE)); | 454 this, rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_OTHER_MOBILE)); |
333 bottom_row->AddChildView(other_mobile_); | 455 bottom_row->AddChildView(other_mobile_); |
334 } | 456 } |
335 | 457 |
336 CreateSettingsEntry(); | 458 CreateSettingsEntry(); |
337 | 459 |
338 // Both settings_ and proxy_settings_ can be NULL. This happens when | 460 // Both settings_ and proxy_settings_ can be null. This happens when |
339 // we're logged in but showing settings page is not enabled. | 461 // we're logged in but showing settings page is not enabled. |
340 // Example: supervised user creation flow where user session is active | 462 // Example: supervised user creation flow where user session is active |
341 // but all action happens on the login window. | 463 // but all action happens on the login window. |
342 // Allowing opening proxy settigns dialog will break assumption in | 464 // Allowing opening proxy settigns dialog will break assumption in |
343 // SystemTrayDelegateChromeOS::ChangeProxySettings(), see CHECK. | 465 // SystemTrayDelegateChromeOS::ChangeProxySettings(), see CHECK. |
344 if (settings_ || proxy_settings_) | 466 if (settings_ || proxy_settings_) |
345 bottom_row->AddChildView(settings_ ? settings_ : proxy_settings_); | 467 bottom_row->AddChildView(settings_ ? settings_ : proxy_settings_); |
346 | 468 |
347 AddChildView(bottom_row); | 469 AddChildView(bottom_row); |
348 } | 470 } |
349 | 471 |
350 // Update UI components. | 472 // Update UI components. |
351 | 473 |
352 void NetworkStateListDetailedView::UpdateHeaderButtons() { | 474 void NetworkStateListDetailedView::UpdateHeaderButtons() { |
353 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); | 475 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); |
354 if (button_wifi_) | 476 if (button_wifi_) |
355 UpdateTechnologyButton(button_wifi_, NetworkTypePattern::WiFi()); | 477 UpdateTechnologyButton(button_wifi_, NetworkTypePattern::WiFi()); |
356 if (button_mobile_) { | 478 if (button_mobile_) { |
357 UpdateTechnologyButton(button_mobile_, NetworkTypePattern::Mobile()); | 479 UpdateTechnologyButton(button_mobile_, NetworkTypePattern::Mobile()); |
358 } | 480 } |
359 if (proxy_settings_) | 481 if (proxy_settings_) |
360 proxy_settings_->SetEnabled(handler->DefaultNetwork() != NULL); | 482 proxy_settings_->SetEnabled(handler->DefaultNetwork() != nullptr); |
| 483 |
| 484 // Update Wifi Scanning throbber. |
| 485 bool scanning = |
| 486 NetworkHandler::Get()->network_state_handler()->GetScanningByType( |
| 487 NetworkTypePattern::WiFi()); |
| 488 if (scanning != wifi_scanning_) { |
| 489 wifi_scanning_ = scanning; |
| 490 if (scanning) { |
| 491 info_icon_->SetVisible(false); |
| 492 scanning_throbber_->Start(); |
| 493 scanning_throbber_->SetTooltipText( |
| 494 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_WIFI_SCANNING_MESSAGE)); |
| 495 } else { |
| 496 scanning_throbber_->Stop(); |
| 497 scanning_throbber_->SetTooltipText( |
| 498 l10n_util::GetStringUTF16(IDS_ASH_STATUS_TRAY_NETWORK_INFO)); |
| 499 info_icon_->SetVisible(true); |
| 500 } |
| 501 } |
361 | 502 |
362 static_cast<views::View*>(footer())->Layout(); | 503 static_cast<views::View*>(footer())->Layout(); |
363 } | 504 } |
364 | 505 |
365 void NetworkStateListDetailedView::UpdateTechnologyButton( | 506 void NetworkStateListDetailedView::UpdateTechnologyButton( |
366 TrayPopupHeaderButton* button, | 507 TrayPopupHeaderButton* button, |
367 const NetworkTypePattern& technology) { | 508 const NetworkTypePattern& technology) { |
368 NetworkStateHandler::TechnologyState state = | 509 NetworkStateHandler::TechnologyState state = |
369 NetworkHandler::Get()->network_state_handler()->GetTechnologyState( | 510 NetworkHandler::Get()->network_state_handler()->GetTechnologyState( |
370 technology); | 511 technology); |
(...skipping 26 matching lines...) Expand all Loading... |
397 scroll_content()->ReorderChildView(view, index); | 538 scroll_content()->ReorderChildView(view, index); |
398 return true; | 539 return true; |
399 } | 540 } |
400 return false; | 541 return false; |
401 } | 542 } |
402 | 543 |
403 void NetworkStateListDetailedView::UpdateNetworkExtra() { | 544 void NetworkStateListDetailedView::UpdateNetworkExtra() { |
404 if (login_ == user::LOGGED_IN_LOCKED) | 545 if (login_ == user::LOGGED_IN_LOCKED) |
405 return; | 546 return; |
406 | 547 |
407 View* layout_parent = NULL; // All these buttons have the same parent. | 548 View* layout_parent = nullptr; // All these buttons have the same parent. |
408 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); | 549 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); |
409 if (other_wifi_) { | 550 if (other_wifi_) { |
410 DCHECK(turn_on_wifi_); | 551 DCHECK(turn_on_wifi_); |
411 NetworkStateHandler::TechnologyState state = | 552 NetworkStateHandler::TechnologyState state = |
412 handler->GetTechnologyState(NetworkTypePattern::WiFi()); | 553 handler->GetTechnologyState(NetworkTypePattern::WiFi()); |
413 if (state == NetworkStateHandler::TECHNOLOGY_UNAVAILABLE) { | 554 if (state == NetworkStateHandler::TECHNOLOGY_UNAVAILABLE) { |
414 turn_on_wifi_->SetVisible(false); | 555 turn_on_wifi_->SetVisible(false); |
415 other_wifi_->SetVisible(false); | 556 other_wifi_->SetVisible(false); |
416 } else { | 557 } else { |
417 if (state == NetworkStateHandler::TECHNOLOGY_AVAILABLE) { | 558 if (state == NetworkStateHandler::TECHNOLOGY_AVAILABLE) { |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
484 | 625 |
485 info_bubble_ = new InfoBubble(info_icon_, CreateNetworkInfoView(), this); | 626 info_bubble_ = new InfoBubble(info_icon_, CreateNetworkInfoView(), this); |
486 views::BubbleDelegateView::CreateBubble(info_bubble_)->Show(); | 627 views::BubbleDelegateView::CreateBubble(info_bubble_)->Show(); |
487 info_bubble_->NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, false); | 628 info_bubble_->NotifyAccessibilityEvent(ui::AX_EVENT_ALERT, false); |
488 } | 629 } |
489 | 630 |
490 bool NetworkStateListDetailedView::ResetInfoBubble() { | 631 bool NetworkStateListDetailedView::ResetInfoBubble() { |
491 if (!info_bubble_) | 632 if (!info_bubble_) |
492 return false; | 633 return false; |
493 info_bubble_->GetWidget()->Close(); | 634 info_bubble_->GetWidget()->Close(); |
494 info_bubble_ = NULL; | 635 info_bubble_ = nullptr; |
495 return true; | 636 return true; |
496 } | 637 } |
497 | 638 |
498 void NetworkStateListDetailedView::OnInfoBubbleDestroyed() { | 639 void NetworkStateListDetailedView::OnInfoBubbleDestroyed() { |
499 info_bubble_ = NULL; | 640 info_bubble_ = nullptr; |
500 } | 641 } |
501 | 642 |
502 views::View* NetworkStateListDetailedView::CreateNetworkInfoView() { | 643 views::View* NetworkStateListDetailedView::CreateNetworkInfoView() { |
503 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); | 644 ui::ResourceBundle& bundle = ui::ResourceBundle::GetSharedInstance(); |
504 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); | 645 NetworkStateHandler* handler = NetworkHandler::Get()->network_state_handler(); |
505 | 646 |
506 std::string ip_address("0.0.0.0"); | 647 std::string ip_address("0.0.0.0"); |
507 const NetworkState* network = handler->DefaultNetwork(); | 648 const NetworkState* network = handler->DefaultNetwork(); |
508 if (network) | 649 if (network) |
509 ip_address = network->ip_address(); | 650 ip_address = network->ip_address(); |
(...skipping 138 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
648 label->SetEnabledColor(SkColorSetARGB(192, 0, 0, 0)); | 789 label->SetEnabledColor(SkColorSetARGB(192, 0, 0, 0)); |
649 return label; | 790 return label; |
650 } | 791 } |
651 | 792 |
652 void NetworkStateListDetailedView::RelayoutScrollList() { | 793 void NetworkStateListDetailedView::RelayoutScrollList() { |
653 scroller()->Layout(); | 794 scroller()->Layout(); |
654 } | 795 } |
655 | 796 |
656 } // namespace tray | 797 } // namespace tray |
657 } // namespace ash | 798 } // namespace ash |
OLD | NEW |