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/network/tray_network.h" | 5 #include "ash/system/network/tray_network.h" |
6 | 6 |
7 #include "ash/shell.h" | 7 #include "ash/shell.h" |
8 #include "ash/shell_window_ids.h" | 8 #include "ash/shell_window_ids.h" |
9 #include "ash/system/tray/system_tray.h" | 9 #include "ash/system/tray/system_tray.h" |
10 #include "ash/system/tray/system_tray_delegate.h" | 10 #include "ash/system/tray/system_tray_delegate.h" |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
161 public: | 161 public: |
162 explicit NetworkDetailedView(user::LoginStatus login) | 162 explicit NetworkDetailedView(user::LoginStatus login) |
163 : login_(login), | 163 : login_(login), |
164 header_(NULL), | 164 header_(NULL), |
165 header_text_(NULL), | 165 header_text_(NULL), |
166 header_buttons_(NULL), | 166 header_buttons_(NULL), |
167 airplane_(NULL), | 167 airplane_(NULL), |
168 info_icon_(NULL), | 168 info_icon_(NULL), |
169 button_wifi_(NULL), | 169 button_wifi_(NULL), |
170 button_cellular_(NULL), | 170 button_cellular_(NULL), |
171 mobile_account_(NULL), | 171 view_mobile_account_(NULL), |
| 172 setup_mobile_account_(NULL), |
172 other_wifi_(NULL), | 173 other_wifi_(NULL), |
173 other_mobile_(NULL), | 174 other_mobile_(NULL), |
174 settings_(NULL), | 175 settings_(NULL), |
175 proxy_settings_(NULL), | 176 proxy_settings_(NULL), |
176 info_bubble_(NULL) { | 177 info_bubble_(NULL) { |
177 SetLayoutManager(new views::BoxLayout( | 178 SetLayoutManager(new views::BoxLayout( |
178 views::BoxLayout::kVertical, 0, 0, 0)); | 179 views::BoxLayout::kVertical, 0, 0, 0)); |
179 set_background(views::Background::CreateSolidBackground(kBackgroundColor)); | 180 set_background(views::Background::CreateSolidBackground(kBackgroundColor)); |
180 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); | 181 SystemTrayDelegate* delegate = Shell::GetInstance()->tray_delegate(); |
181 delegate->RequestNetworkScan(); | 182 delegate->RequestNetworkScan(); |
182 Update(); | 183 Update(); |
183 } | 184 } |
184 | 185 |
185 virtual ~NetworkDetailedView() { | 186 virtual ~NetworkDetailedView() { |
186 if (info_bubble_) | 187 if (info_bubble_) |
187 info_bubble_->GetWidget()->CloseNow(); | 188 info_bubble_->GetWidget()->CloseNow(); |
188 } | 189 } |
189 | 190 |
190 void Update() { | 191 void Update() { |
191 RemoveAllChildViews(true); | 192 RemoveAllChildViews(true); |
192 | 193 |
193 header_ = NULL; | 194 header_ = NULL; |
194 header_text_ = NULL; | 195 header_text_ = NULL; |
195 header_buttons_ = NULL; | 196 header_buttons_ = NULL; |
196 airplane_ = NULL; | 197 airplane_ = NULL; |
197 info_icon_ = NULL; | 198 info_icon_ = NULL; |
198 button_wifi_ = NULL; | 199 button_wifi_ = NULL; |
199 button_cellular_ = NULL; | 200 button_cellular_ = NULL; |
200 mobile_account_ = NULL; | 201 view_mobile_account_ = NULL; |
| 202 setup_mobile_account_ = NULL; |
201 other_wifi_ = NULL; | 203 other_wifi_ = NULL; |
202 other_mobile_ = NULL; | 204 other_mobile_ = NULL; |
203 settings_ = NULL; | 205 settings_ = NULL; |
204 proxy_settings_ = NULL; | 206 proxy_settings_ = NULL; |
205 | 207 |
206 AppendHeaderEntry(); | 208 AppendHeaderEntry(); |
207 AppendHeaderButtons(); | 209 AppendHeaderButtons(); |
208 AppendNetworkEntries(); | 210 AppendNetworkEntries(); |
209 | 211 |
210 if (login_ != user::LOGGED_IN_LOCKED) | 212 if (login_ != user::LOGGED_IN_LOCKED) |
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
267 container->AddIconAndLabel(list[i].image, | 269 container->AddIconAndLabel(list[i].image, |
268 list[i].description.empty() ? list[i].name : list[i].description, | 270 list[i].description.empty() ? list[i].name : list[i].description, |
269 list[i].highlight ? gfx::Font::BOLD : gfx::Font::NORMAL); | 271 list[i].highlight ? gfx::Font::BOLD : gfx::Font::NORMAL); |
270 networks->AddChildView(container); | 272 networks->AddChildView(container); |
271 container->set_border(views::Border::CreateEmptyBorder(0, | 273 container->set_border(views::Border::CreateEmptyBorder(0, |
272 kTrayPopupDetailsIconWidth, 0, 0)); | 274 kTrayPopupDetailsIconWidth, 0, 0)); |
273 network_map_[container] = list[i].service_path; | 275 network_map_[container] = list[i].service_path; |
274 } | 276 } |
275 | 277 |
276 if (login_ != user::LOGGED_IN_NONE) { | 278 if (login_ != user::LOGGED_IN_NONE) { |
277 std::string carrier_id, topup_url; | 279 std::string carrier_id, topup_url, setup_url; |
278 if (delegate->GetCellularCarrierInfo(&carrier_id, &topup_url)) { | 280 if (delegate->GetCellularCarrierInfo(&carrier_id, |
| 281 &topup_url, |
| 282 &setup_url)) { |
279 if (carrier_id != carrier_id_) { | 283 if (carrier_id != carrier_id_) { |
280 carrier_id_ = carrier_id; | 284 carrier_id_ = carrier_id; |
281 if (!topup_url.empty()) | 285 if (!topup_url.empty()) |
282 topup_url_ = topup_url; | 286 topup_url_ = topup_url; |
283 } | 287 } |
| 288 if (!setup_url.empty()) |
| 289 setup_url_ = setup_url; |
284 if (!topup_url_.empty()) { | 290 if (!topup_url_.empty()) { |
285 HoverHighlightView* container = new HoverHighlightView(this); | 291 HoverHighlightView* container = new HoverHighlightView(this); |
286 container->set_fixed_height(kTrayPopupItemHeight); | 292 container->set_fixed_height(kTrayPopupItemHeight); |
287 container->AddLabel(ui::ResourceBundle::GetSharedInstance(). | 293 container->AddLabel(ui::ResourceBundle::GetSharedInstance(). |
288 GetLocalizedString(IDS_ASH_STATUS_TRAY_MOBILE_VIEW_ACCOUNT), | 294 GetLocalizedString(IDS_ASH_STATUS_TRAY_MOBILE_VIEW_ACCOUNT), |
289 gfx::Font::NORMAL); | 295 gfx::Font::NORMAL); |
290 AddChildView(container); | 296 AddChildView(container); |
291 mobile_account_ = container; | 297 view_mobile_account_ = container; |
| 298 } |
| 299 if (!setup_url_.empty()) { |
| 300 HoverHighlightView* container = new HoverHighlightView(this); |
| 301 container->set_fixed_height(kTrayPopupItemHeight); |
| 302 container->AddLabel(ui::ResourceBundle::GetSharedInstance(). |
| 303 GetLocalizedString(IDS_ASH_STATUS_TRAY_SETUP_MOBILE), |
| 304 gfx::Font::NORMAL); |
| 305 AddChildView(container); |
| 306 setup_mobile_account_ = container; |
292 } | 307 } |
293 } | 308 } |
294 } | 309 } |
295 | 310 |
296 scroller->set_border(views::Border::CreateSolidSidedBorder(1, 0, 1, 0, | 311 scroller->set_border(views::Border::CreateSolidSidedBorder(1, 0, 1, 0, |
297 SkColorSetARGB(25, 0, 0, 0))); | 312 SkColorSetARGB(25, 0, 0, 0))); |
298 scroller->set_fixed_size( | 313 scroller->set_fixed_size( |
299 gfx::Size(networks->GetPreferredSize().width() + | 314 gfx::Size(networks->GetPreferredSize().width() + |
300 scroller->GetScrollBarWidth(), | 315 scroller->GetScrollBarWidth(), |
301 kNetworkListHeight)); | 316 kNetworkListHeight)); |
(...skipping 146 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
448 // If the info bubble was visible, close it when some other item is clicked | 463 // If the info bubble was visible, close it when some other item is clicked |
449 // on. | 464 // on. |
450 ResetInfoBubble(); | 465 ResetInfoBubble(); |
451 | 466 |
452 if (sender == header_text_) | 467 if (sender == header_text_) |
453 Shell::GetInstance()->tray()->ShowDefaultView(); | 468 Shell::GetInstance()->tray()->ShowDefaultView(); |
454 | 469 |
455 if (login_ == user::LOGGED_IN_LOCKED) | 470 if (login_ == user::LOGGED_IN_LOCKED) |
456 return; | 471 return; |
457 | 472 |
458 if (sender == mobile_account_) { | 473 if (sender == view_mobile_account_) { |
459 delegate->ShowCellularTopupURL(topup_url_); | 474 delegate->ShowCellularURL(topup_url_); |
| 475 } else if (sender == setup_mobile_account_) { |
| 476 delegate->ShowCellularURL(setup_url_); |
460 } else if (sender == airplane_) { | 477 } else if (sender == airplane_) { |
461 delegate->ToggleAirplaneMode(); | 478 delegate->ToggleAirplaneMode(); |
462 } else { | 479 } else { |
463 std::map<views::View*, std::string>::iterator find; | 480 std::map<views::View*, std::string>::iterator find; |
464 find = network_map_.find(sender); | 481 find = network_map_.find(sender); |
465 if (find != network_map_.end()) { | 482 if (find != network_map_.end()) { |
466 std::string network_id = find->second; | 483 std::string network_id = find->second; |
467 delegate->ConnectToNetwork(network_id); | 484 delegate->ConnectToNetwork(network_id); |
468 } | 485 } |
469 } | 486 } |
470 } | 487 } |
471 | 488 |
472 std::string carrier_id_; | 489 std::string carrier_id_; |
473 std::string topup_url_; | 490 std::string topup_url_; |
| 491 std::string setup_url_; |
474 | 492 |
475 user::LoginStatus login_; | 493 user::LoginStatus login_; |
476 std::map<views::View*, std::string> network_map_; | 494 std::map<views::View*, std::string> network_map_; |
477 views::View* header_; | 495 views::View* header_; |
478 views::View* header_text_; | 496 views::View* header_text_; |
479 views::View* header_buttons_; | 497 views::View* header_buttons_; |
480 views::View* airplane_; | 498 views::View* airplane_; |
481 views::ImageButton* info_icon_; | 499 views::ImageButton* info_icon_; |
482 views::ToggleImageButton* button_wifi_; | 500 views::ToggleImageButton* button_wifi_; |
483 views::ToggleImageButton* button_cellular_; | 501 views::ToggleImageButton* button_cellular_; |
484 views::View* mobile_account_; | 502 views::View* view_mobile_account_; |
| 503 views::View* setup_mobile_account_; |
485 TrayPopupTextButton* other_wifi_; | 504 TrayPopupTextButton* other_wifi_; |
486 TrayPopupTextButton* other_mobile_; | 505 TrayPopupTextButton* other_mobile_; |
487 TrayPopupTextButton* settings_; | 506 TrayPopupTextButton* settings_; |
488 TrayPopupTextButton* proxy_settings_; | 507 TrayPopupTextButton* proxy_settings_; |
489 | 508 |
490 views::BubbleDelegateView* info_bubble_; | 509 views::BubbleDelegateView* info_bubble_; |
491 | 510 |
492 DISALLOW_COPY_AND_ASSIGN(NetworkDetailedView); | 511 DISALLOW_COPY_AND_ASSIGN(NetworkDetailedView); |
493 }; | 512 }; |
494 | 513 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 if (tray_.get()) | 553 if (tray_.get()) |
535 tray_->Update(info); | 554 tray_->Update(info); |
536 if (default_.get()) | 555 if (default_.get()) |
537 default_->Update(); | 556 default_->Update(); |
538 if (detailed_.get()) | 557 if (detailed_.get()) |
539 detailed_->Update(); | 558 detailed_->Update(); |
540 } | 559 } |
541 | 560 |
542 } // namespace internal | 561 } // namespace internal |
543 } // namespace ash | 562 } // namespace ash |
OLD | NEW |