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

Side by Side Diff: ash/system/cast/tray_cast.cc

Issue 2041233005: Moves ash::user::LoginStatus to ash/common (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix test Created 4 years, 6 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
« no previous file with comments | « ash/system/cast/tray_cast.h ('k') | ash/system/chromeos/audio/tray_audio_chromeos.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/cast/tray_cast.h" 5 #include "ash/system/cast/tray_cast.h"
6 6
7 #include "ash/common/session/session_state_delegate.h" 7 #include "ash/common/session/session_state_delegate.h"
8 #include "ash/common/shelf/shelf_types.h" 8 #include "ash/common/shelf/shelf_types.h"
9 #include "ash/common/shelf/wm_shelf_util.h" 9 #include "ash/common/shelf/wm_shelf_util.h"
10 #include "ash/shelf/shelf_util.h" 10 #include "ash/shelf/shelf_util.h"
(...skipping 354 matching lines...) Expand 10 before | Expand all | Expand 10 after
365 SetLayoutManager(new views::BoxLayout(layout, 0, 0, 0)); 365 SetLayoutManager(new views::BoxLayout(layout, 0, 0, 0));
366 Layout(); 366 Layout();
367 } 367 }
368 368
369 // This view displays a list of cast receivers that can be clicked on and casted 369 // This view displays a list of cast receivers that can be clicked on and casted
370 // to. It is activated by clicking on the chevron inside of 370 // to. It is activated by clicking on the chevron inside of
371 // |CastSelectDefaultView|. 371 // |CastSelectDefaultView|.
372 class CastDetailedView : public TrayDetailsView, public ViewClickListener { 372 class CastDetailedView : public TrayDetailsView, public ViewClickListener {
373 public: 373 public:
374 CastDetailedView(SystemTrayItem* owner, 374 CastDetailedView(SystemTrayItem* owner,
375 user::LoginStatus login, 375 LoginStatus login,
376 const CastConfigDelegate::ReceiversAndActivities& 376 const CastConfigDelegate::ReceiversAndActivities&
377 receivers_and_activities); 377 receivers_and_activities);
378 ~CastDetailedView() override; 378 ~CastDetailedView() override;
379 379
380 // Makes the detail view think the view associated with the given receiver_id 380 // Makes the detail view think the view associated with the given receiver_id
381 // was clicked. This will start a cast. 381 // was clicked. This will start a cast.
382 void SimulateViewClickedForTest(const std::string& receiver_id); 382 void SimulateViewClickedForTest(const std::string& receiver_id);
383 383
384 // Updates the list of available receivers. 384 // Updates the list of available receivers.
385 void UpdateReceiverList(const CastConfigDelegate::ReceiversAndActivities& 385 void UpdateReceiverList(const CastConfigDelegate::ReceiversAndActivities&
386 new_receivers_and_activities); 386 new_receivers_and_activities);
387 387
388 private: 388 private:
389 void CreateItems(); 389 void CreateItems();
390 390
391 void UpdateReceiverListFromCachedData(); 391 void UpdateReceiverListFromCachedData();
392 views::View* AddToReceiverList( 392 views::View* AddToReceiverList(
393 const CastConfigDelegate::ReceiverAndActivity& receiverActivity); 393 const CastConfigDelegate::ReceiverAndActivity& receiverActivity);
394 394
395 void AppendSettingsEntries(); 395 void AppendSettingsEntries();
396 void AppendHeaderEntry(); 396 void AppendHeaderEntry();
397 397
398 // Overridden from ViewClickListener. 398 // Overridden from ViewClickListener.
399 void OnViewClicked(views::View* sender) override; 399 void OnViewClicked(views::View* sender) override;
400 400
401 user::LoginStatus login_; 401 LoginStatus login_;
402 views::View* options_ = nullptr; 402 views::View* options_ = nullptr;
403 // A mapping from the receiver id to the receiver/activity data. 403 // A mapping from the receiver id to the receiver/activity data.
404 std::map<std::string, CastConfigDelegate::ReceiverAndActivity> 404 std::map<std::string, CastConfigDelegate::ReceiverAndActivity>
405 receivers_and_activities_; 405 receivers_and_activities_;
406 // A mapping from the view pointer to the associated activity id. 406 // A mapping from the view pointer to the associated activity id.
407 std::map<views::View*, std::string> receiver_activity_map_; 407 std::map<views::View*, std::string> receiver_activity_map_;
408 408
409 DISALLOW_COPY_AND_ASSIGN(CastDetailedView); 409 DISALLOW_COPY_AND_ASSIGN(CastDetailedView);
410 }; 410 };
411 411
412 CastDetailedView::CastDetailedView( 412 CastDetailedView::CastDetailedView(
413 SystemTrayItem* owner, 413 SystemTrayItem* owner,
414 user::LoginStatus login, 414 LoginStatus login,
415 const CastConfigDelegate::ReceiversAndActivities& receivers_and_activities) 415 const CastConfigDelegate::ReceiversAndActivities& receivers_and_activities)
416 : TrayDetailsView(owner), login_(login) { 416 : TrayDetailsView(owner), login_(login) {
417 CreateItems(); 417 CreateItems();
418 UpdateReceiverList(receivers_and_activities); 418 UpdateReceiverList(receivers_and_activities);
419 } 419 }
420 420
421 CastDetailedView::~CastDetailedView() { 421 CastDetailedView::~CastDetailedView() {
422 } 422 }
423 423
424 void CastDetailedView::SimulateViewClickedForTest( 424 void CastDetailedView::SimulateViewClickedForTest(
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
499 scroll_content()->AddChildView(container); 499 scroll_content()->AddChildView(container);
500 return container; 500 return container;
501 } 501 }
502 502
503 void CastDetailedView::AppendSettingsEntries() { 503 void CastDetailedView::AppendSettingsEntries() {
504 // Settings requires a browser window, hide it for non logged in user. 504 // Settings requires a browser window, hide it for non logged in user.
505 const bool userAddingRunning = Shell::GetInstance() 505 const bool userAddingRunning = Shell::GetInstance()
506 ->session_state_delegate() 506 ->session_state_delegate()
507 ->IsInSecondaryLoginScreen(); 507 ->IsInSecondaryLoginScreen();
508 508
509 if (login_ == user::LOGGED_IN_NONE || login_ == user::LOGGED_IN_LOCKED || 509 if (login_ == LoginStatus::NOT_LOGGED_IN || login_ == LoginStatus::LOCKED ||
510 userAddingRunning) 510 userAddingRunning)
511 return; 511 return;
512 512
513 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); 513 ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance();
514 HoverHighlightView* container = new HoverHighlightView(this); 514 HoverHighlightView* container = new HoverHighlightView(this);
515 container->AddLabel(rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_CAST_OPTIONS), 515 container->AddLabel(rb.GetLocalizedString(IDS_ASH_STATUS_TRAY_CAST_OPTIONS),
516 gfx::ALIGN_LEFT, false /* highlight */); 516 gfx::ALIGN_LEFT, false /* highlight */);
517 517
518 AddChildView(container); 518 AddChildView(container);
519 options_ = container; 519 options_ = container;
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
563 } 563 }
564 564
565 const std::string& TrayCast::GetDisplayedCastId() { 565 const std::string& TrayCast::GetDisplayedCastId() {
566 return default_->cast_view()->displayed_activity_id(); 566 return default_->cast_view()->displayed_activity_id();
567 } 567 }
568 568
569 const views::View* TrayCast::GetDefaultView() const { 569 const views::View* TrayCast::GetDefaultView() const {
570 return default_; 570 return default_;
571 } 571 }
572 572
573 views::View* TrayCast::CreateTrayView(user::LoginStatus status) { 573 views::View* TrayCast::CreateTrayView(LoginStatus status) {
574 CHECK(tray_ == nullptr); 574 CHECK(tray_ == nullptr);
575 tray_ = new tray::CastTrayView(this); 575 tray_ = new tray::CastTrayView(this);
576 tray_->SetVisible(is_casting_); 576 tray_->SetVisible(is_casting_);
577 return tray_; 577 return tray_;
578 } 578 }
579 579
580 views::View* TrayCast::CreateDefaultView(user::LoginStatus status) { 580 views::View* TrayCast::CreateDefaultView(LoginStatus status) {
581 CHECK(default_ == nullptr); 581 CHECK(default_ == nullptr);
582 582
583 if (HasCastExtension()) { 583 if (HasCastExtension()) {
584 ash::CastConfigDelegate* cast_config_delegate = GetCastConfigDelegate(); 584 ash::CastConfigDelegate* cast_config_delegate = GetCastConfigDelegate();
585 585
586 // Add the cast observer here instead of the ctor for two reasons: 586 // Add the cast observer here instead of the ctor for two reasons:
587 // - The ctor gets called too early in the initialization cycle (at least 587 // - The ctor gets called too early in the initialization cycle (at least
588 // for the tests); the correct profile hasn't been setup yet. 588 // for the tests); the correct profile hasn't been setup yet.
589 // - If we're using the cast extension backend (media router is disabled), 589 // - If we're using the cast extension backend (media router is disabled),
590 // then the user can install the extension at any point in time. The 590 // then the user can install the extension at any point in time. The
591 // return value of HasCastExtension() can change, so only checking it in 591 // return value of HasCastExtension() can change, so only checking it in
592 // the ctor isn't enough. 592 // the ctor isn't enough.
593 if (!added_observer_) { 593 if (!added_observer_) {
594 cast_config_delegate->AddObserver(this); 594 cast_config_delegate->AddObserver(this);
595 added_observer_ = true; 595 added_observer_ = true;
596 } 596 }
597 597
598 // The extension updates its view model whenever the popup is opened, so we 598 // The extension updates its view model whenever the popup is opened, so we
599 // probably should as well. 599 // probably should as well.
600 cast_config_delegate->RequestDeviceRefresh(); 600 cast_config_delegate->RequestDeviceRefresh();
601 } 601 }
602 602
603 default_ = new tray::CastDuplexView(this, status != user::LOGGED_IN_LOCKED, 603 default_ = new tray::CastDuplexView(this, status != LoginStatus::LOCKED,
604 receivers_and_activities_); 604 receivers_and_activities_);
605 default_->set_id(TRAY_VIEW); 605 default_->set_id(TRAY_VIEW);
606 default_->select_view()->set_id(SELECT_VIEW); 606 default_->select_view()->set_id(SELECT_VIEW);
607 default_->cast_view()->set_id(CAST_VIEW); 607 default_->cast_view()->set_id(CAST_VIEW);
608 608
609 UpdatePrimaryView(); 609 UpdatePrimaryView();
610 return default_; 610 return default_;
611 } 611 }
612 612
613 views::View* TrayCast::CreateDetailedView(user::LoginStatus status) { 613 views::View* TrayCast::CreateDetailedView(LoginStatus status) {
614 Shell::GetInstance()->metrics()->RecordUserMetricsAction( 614 Shell::GetInstance()->metrics()->RecordUserMetricsAction(
615 ash::UMA_STATUS_AREA_DETAILED_CAST_VIEW); 615 ash::UMA_STATUS_AREA_DETAILED_CAST_VIEW);
616 CHECK(detailed_ == nullptr); 616 CHECK(detailed_ == nullptr);
617 detailed_ = 617 detailed_ =
618 new tray::CastDetailedView(this, status, receivers_and_activities_); 618 new tray::CastDetailedView(this, status, receivers_and_activities_);
619 return detailed_; 619 return detailed_;
620 } 620 }
621 621
622 void TrayCast::DestroyTrayView() { 622 void TrayCast::DestroyTrayView() {
623 tray_ = nullptr; 623 tray_ = nullptr;
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after
673 is_casting_ = started; 673 is_casting_ = started;
674 UpdatePrimaryView(); 674 UpdatePrimaryView();
675 } 675 }
676 676
677 void TrayCast::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) { 677 void TrayCast::UpdateAfterShelfAlignmentChange(ShelfAlignment alignment) {
678 if (tray_) 678 if (tray_)
679 tray_->UpdateAlignment(alignment); 679 tray_->UpdateAlignment(alignment);
680 } 680 }
681 681
682 } // namespace ash 682 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/cast/tray_cast.h ('k') | ash/system/chromeos/audio/tray_audio_chromeos.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698