| 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; |
| 287 if (!setup_url.empty()) |
| 288 setup_url_ = setup_url; |
| 283 } | 289 } |
| 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 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 438 info_bubble_->GetWidget()->Close(); | 453 info_bubble_->GetWidget()->Close(); |
| 439 info_bubble_ = NULL; | 454 info_bubble_ = NULL; |
| 440 } | 455 } |
| 441 | 456 |
| 442 if (sender == header_text_) | 457 if (sender == header_text_) |
| 443 Shell::GetInstance()->tray()->ShowDefaultView(); | 458 Shell::GetInstance()->tray()->ShowDefaultView(); |
| 444 | 459 |
| 445 if (login_ == user::LOGGED_IN_LOCKED) | 460 if (login_ == user::LOGGED_IN_LOCKED) |
| 446 return; | 461 return; |
| 447 | 462 |
| 448 if (sender == mobile_account_) { | 463 if (sender == view_mobile_account_) { |
| 449 delegate->ShowCellularTopupURL(topup_url_); | 464 delegate->ShowCellularURL(topup_url_); |
| 465 } else if (sender == setup_mobile_account_) { |
| 466 delegate->ShowCellularURL(setup_url_); |
| 450 } else if (sender == airplane_) { | 467 } else if (sender == airplane_) { |
| 451 delegate->ToggleAirplaneMode(); | 468 delegate->ToggleAirplaneMode(); |
| 452 } else { | 469 } else { |
| 453 std::map<views::View*, std::string>::iterator find; | 470 std::map<views::View*, std::string>::iterator find; |
| 454 find = network_map_.find(sender); | 471 find = network_map_.find(sender); |
| 455 if (find != network_map_.end()) { | 472 if (find != network_map_.end()) { |
| 456 std::string network_id = find->second; | 473 std::string network_id = find->second; |
| 457 delegate->ConnectToNetwork(network_id); | 474 delegate->ConnectToNetwork(network_id); |
| 458 } | 475 } |
| 459 } | 476 } |
| 460 } | 477 } |
| 461 | 478 |
| 462 std::string carrier_id_; | 479 std::string carrier_id_; |
| 463 std::string topup_url_; | 480 std::string topup_url_; |
| 481 std::string setup_url_; |
| 464 | 482 |
| 465 user::LoginStatus login_; | 483 user::LoginStatus login_; |
| 466 std::map<views::View*, std::string> network_map_; | 484 std::map<views::View*, std::string> network_map_; |
| 467 views::View* header_; | 485 views::View* header_; |
| 468 views::View* header_text_; | 486 views::View* header_text_; |
| 469 views::View* header_buttons_; | 487 views::View* header_buttons_; |
| 470 views::View* airplane_; | 488 views::View* airplane_; |
| 471 views::ImageButton* info_icon_; | 489 views::ImageButton* info_icon_; |
| 472 views::ToggleImageButton* button_wifi_; | 490 views::ToggleImageButton* button_wifi_; |
| 473 views::ToggleImageButton* button_cellular_; | 491 views::ToggleImageButton* button_cellular_; |
| 474 views::View* mobile_account_; | 492 views::View* view_mobile_account_; |
| 493 views::View* setup_mobile_account_; |
| 475 TrayPopupTextButton* other_wifi_; | 494 TrayPopupTextButton* other_wifi_; |
| 476 TrayPopupTextButton* other_mobile_; | 495 TrayPopupTextButton* other_mobile_; |
| 477 TrayPopupTextButton* settings_; | 496 TrayPopupTextButton* settings_; |
| 478 TrayPopupTextButton* proxy_settings_; | 497 TrayPopupTextButton* proxy_settings_; |
| 479 | 498 |
| 480 views::BubbleDelegateView* info_bubble_; | 499 views::BubbleDelegateView* info_bubble_; |
| 481 | 500 |
| 482 DISALLOW_COPY_AND_ASSIGN(NetworkDetailedView); | 501 DISALLOW_COPY_AND_ASSIGN(NetworkDetailedView); |
| 483 }; | 502 }; |
| 484 | 503 |
| (...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 521 if (tray_.get()) | 540 if (tray_.get()) |
| 522 tray_->Update(info); | 541 tray_->Update(info); |
| 523 if (default_.get()) | 542 if (default_.get()) |
| 524 default_->Update(); | 543 default_->Update(); |
| 525 if (detailed_.get()) | 544 if (detailed_.get()) |
| 526 detailed_->Update(); | 545 detailed_->Update(); |
| 527 } | 546 } |
| 528 | 547 |
| 529 } // namespace internal | 548 } // namespace internal |
| 530 } // namespace ash | 549 } // namespace ash |
| OLD | NEW |