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

Side by Side Diff: ash/system/network/tray_network.cc

Issue 10206016: ash: Make sure the network info bubble is closed when clicking on other items. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 8 years, 8 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
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 IDS_ASH_STATUS_TRAY_IP), ip_address)); 372 IDS_ASH_STATUS_TRAY_IP), ip_address));
373 container->AddChildView(CreateTextLabels(bundle.GetLocalizedString( 373 container->AddChildView(CreateTextLabels(bundle.GetLocalizedString(
374 IDS_ASH_STATUS_TRAY_ETHERNET), ethernet_address)); 374 IDS_ASH_STATUS_TRAY_ETHERNET), ethernet_address));
375 container->AddChildView(CreateTextLabels(bundle.GetLocalizedString( 375 container->AddChildView(CreateTextLabels(bundle.GetLocalizedString(
376 IDS_ASH_STATUS_TRAY_WIFI), wifi_address)); 376 IDS_ASH_STATUS_TRAY_WIFI), wifi_address));
377 377
378 return container; 378 return container;
379 } 379 }
380 380
381 void ToggleInfoBubble() { 381 void ToggleInfoBubble() {
382 if (info_bubble_) { 382 if (ResetInfoBubble())
383 info_bubble_->GetWidget()->CloseNow();
384 info_bubble_ = NULL;
385 return; 383 return;
386 } 384
387 info_bubble_ = new NonActivatableSettingsBubble( 385 info_bubble_ = new NonActivatableSettingsBubble(
388 info_icon_, CreateNetworkInfoView()); 386 info_icon_, CreateNetworkInfoView());
389 views::BubbleDelegateView::CreateBubble(info_bubble_); 387 views::BubbleDelegateView::CreateBubble(info_bubble_);
390 info_bubble_->Show(); 388 info_bubble_->Show();
391 } 389 }
392 390
391 // Returns whether an existing info-bubble was closed.
392 bool ResetInfoBubble() {
393 if (!info_bubble_)
394 return false;
395 info_bubble_->GetWidget()->Close();
396 info_bubble_ = NULL;
397 return true;
398 }
399
393 // Overridden from views::View. 400 // Overridden from views::View.
394 virtual void Layout() OVERRIDE { 401 virtual void Layout() OVERRIDE {
395 views::View::Layout(); 402 views::View::Layout();
396 403
397 // Align the network info view and icon. 404 // Align the network info view and icon.
398 gfx::Rect header_bounds = header_->bounds(); 405 gfx::Rect header_bounds = header_->bounds();
399 gfx::Size buttons_size = header_buttons_->size(); 406 gfx::Size buttons_size = header_buttons_->size();
400 407
401 header_buttons_->SetBounds( 408 header_buttons_->SetBounds(
402 header_->width() - buttons_size.width(), 0, 409 header_->width() - buttons_size.width(), 0,
403 buttons_size.width(), header_->height()); 410 buttons_size.width(), header_->height());
404 header_text_->SetBounds(0, 0, 411 header_text_->SetBounds(0, 0,
405 header_->width() - buttons_size.width(), header_->height()); 412 header_->width() - buttons_size.width(), header_->height());
406 } 413 }
407 414
408 // Overridden from ButtonListener. 415 // Overridden from ButtonListener.
409 virtual void ButtonPressed(views::Button* sender, 416 virtual void ButtonPressed(views::Button* sender,
410 const views::Event& event) OVERRIDE { 417 const views::Event& event) OVERRIDE {
411 ash::SystemTrayDelegate* delegate = 418 ash::SystemTrayDelegate* delegate =
412 ash::Shell::GetInstance()->tray_delegate(); 419 ash::Shell::GetInstance()->tray_delegate();
413 if (sender == info_icon_) 420 if (sender == info_icon_) {
414 ToggleInfoBubble(); 421 ToggleInfoBubble();
415 else if (sender == button_wifi_) 422 return;
423 }
424
425 // If the info bubble was visible, close it when some other item is clicked
426 // on.
427 ResetInfoBubble();
428 if (sender == button_wifi_)
416 delegate->ToggleWifi(); 429 delegate->ToggleWifi();
417 else if (sender == button_cellular_) 430 else if (sender == button_cellular_)
418 delegate->ToggleCellular(); 431 delegate->ToggleCellular();
419 else if (sender == settings_) 432 else if (sender == settings_)
420 delegate->ShowNetworkSettings(); 433 delegate->ShowNetworkSettings();
421 else if (sender == proxy_settings_) 434 else if (sender == proxy_settings_)
422 delegate->ChangeProxySettings(); 435 delegate->ChangeProxySettings();
423 else if (sender == other_mobile_) 436 else if (sender == other_mobile_)
424 delegate->ShowOtherCellular(); 437 delegate->ShowOtherCellular();
425 else if (sender == other_wifi_) 438 else if (sender == other_wifi_)
426 delegate->ShowOtherWifi(); 439 delegate->ShowOtherWifi();
427 else 440 else
428 NOTREACHED(); 441 NOTREACHED();
429 } 442 }
430 443
431 // Overridden from ViewClickListener. 444 // Overridden from ViewClickListener.
432 virtual void ClickedOn(views::View* sender) OVERRIDE { 445 virtual void ClickedOn(views::View* sender) OVERRIDE {
433 ash::SystemTrayDelegate* delegate = 446 ash::SystemTrayDelegate* delegate =
434 ash::Shell::GetInstance()->tray_delegate(); 447 ash::Shell::GetInstance()->tray_delegate();
435 // If the info bubble was visible, close it when some other item is clicked 448 // If the info bubble was visible, close it when some other item is clicked
436 // on. 449 // on.
437 if (info_bubble_) { 450 ResetInfoBubble();
438 info_bubble_->GetWidget()->Close();
439 info_bubble_ = NULL;
440 }
441 451
442 if (sender == header_text_) 452 if (sender == header_text_)
443 Shell::GetInstance()->tray()->ShowDefaultView(); 453 Shell::GetInstance()->tray()->ShowDefaultView();
444 454
445 if (login_ == user::LOGGED_IN_LOCKED) 455 if (login_ == user::LOGGED_IN_LOCKED)
446 return; 456 return;
447 457
448 if (sender == mobile_account_) { 458 if (sender == mobile_account_) {
449 delegate->ShowCellularTopupURL(topup_url_); 459 delegate->ShowCellularTopupURL(topup_url_);
450 } else if (sender == airplane_) { 460 } else if (sender == airplane_) {
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
521 if (tray_.get()) 531 if (tray_.get())
522 tray_->Update(info); 532 tray_->Update(info);
523 if (default_.get()) 533 if (default_.get())
524 default_->Update(); 534 default_->Update();
525 if (detailed_.get()) 535 if (detailed_.get())
526 detailed_->Update(); 536 detailed_->Update();
527 } 537 }
528 538
529 } // namespace internal 539 } // namespace internal
530 } // namespace ash 540 } // namespace ash
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698