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

Side by Side Diff: chrome/browser/chromeos/arc/arc_auth_service.cc

Issue 2416633002: Remove FOR_EACH_OBSERVER from arc/ since it's being deprecated (Closed)
Patch Set: remove braces Created 4 years, 2 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
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 "chrome/browser/chromeos/arc/arc_auth_service.h" 5 #include "chrome/browser/chromeos/arc/arc_auth_service.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "ash/common/shelf/shelf_delegate.h" 9 #include "ash/common/shelf/shelf_delegate.h"
10 #include "ash/common/wm_shell.h" 10 #include "ash/common/wm_shell.h"
(...skipping 339 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 new ArcAppLauncher(profile_, kPlayStoreAppId, true)); 350 new ArcAppLauncher(profile_, kPlayStoreAppId, true));
351 } 351 }
352 352
353 profile_->GetPrefs()->SetBoolean(prefs::kArcSignedIn, true); 353 profile_->GetPrefs()->SetBoolean(prefs::kArcSignedIn, true);
354 CloseUI(); 354 CloseUI();
355 UpdateProvisioningTiming(base::Time::Now() - sign_in_time_, true, 355 UpdateProvisioningTiming(base::Time::Now() - sign_in_time_, true,
356 IsAccountManaged(profile_)); 356 IsAccountManaged(profile_));
357 UpdateProvisioningResultUMA(ProvisioningResult::SUCCESS, 357 UpdateProvisioningResultUMA(ProvisioningResult::SUCCESS,
358 IsAccountManaged(profile_)); 358 IsAccountManaged(profile_));
359 359
360 FOR_EACH_OBSERVER(Observer, observer_list_, OnInitialStart()); 360 for (auto& observer : observer_list_)
361 observer.OnInitialStart();
361 } 362 }
362 363
363 void ArcAuthService::OnSignInFailed(arc::mojom::ArcSignInFailureReason reason) { 364 void ArcAuthService::OnSignInFailed(arc::mojom::ArcSignInFailureReason reason) {
364 OnSignInFailedInternal( 365 OnSignInFailedInternal(
365 ConvertArcSignInFailureReasonToProvisioningResult(reason)); 366 ConvertArcSignInFailureReasonToProvisioningResult(reason));
366 } 367 }
367 368
368 void ArcAuthService::OnSignInFailedInternal(ProvisioningResult result) { 369 void ArcAuthService::OnSignInFailedInternal(ProvisioningResult result) {
369 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 370 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
370 DCHECK_EQ(state_, State::ACTIVE); 371 DCHECK_EQ(state_, State::ACTIVE);
(...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after
436 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 437 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
437 438
438 callback.Run(IsAccountManaged(profile_)); 439 callback.Run(IsAccountManaged(profile_));
439 } 440 }
440 441
441 void ArcAuthService::SetState(State state) { 442 void ArcAuthService::SetState(State state) {
442 if (state_ == state) 443 if (state_ == state)
443 return; 444 return;
444 445
445 state_ = state; 446 state_ = state;
446 FOR_EACH_OBSERVER(Observer, observer_list_, OnOptInChanged(state_)); 447 for (auto& observer : observer_list_)
448 observer.OnOptInChanged(state_);
447 } 449 }
448 450
449 bool ArcAuthService::IsAllowed() const { 451 bool ArcAuthService::IsAllowed() const {
450 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 452 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
451 return profile_ != nullptr; 453 return profile_ != nullptr;
452 } 454 }
453 455
454 void ArcAuthService::OnPrimaryUserProfilePrepared(Profile* profile) { 456 void ArcAuthService::OnPrimaryUserProfilePrepared(Profile* profile) {
455 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 457 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
456 DCHECK(profile && profile != profile_); 458 DCHECK(profile && profile != profile_);
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after
589 } 591 }
590 592
591 void ArcAuthService::OnOptInPreferenceChanged() { 593 void ArcAuthService::OnOptInPreferenceChanged() {
592 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 594 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
593 DCHECK(profile_); 595 DCHECK(profile_);
594 596
595 // TODO(dspaid): Move code from OnSyncedPrefChanged into this method. 597 // TODO(dspaid): Move code from OnSyncedPrefChanged into this method.
596 OnSyncedPrefChanged(prefs::kArcEnabled, IsArcManaged()); 598 OnSyncedPrefChanged(prefs::kArcEnabled, IsArcManaged());
597 599
598 const bool arc_enabled = IsArcEnabled(); 600 const bool arc_enabled = IsArcEnabled();
599 FOR_EACH_OBSERVER(Observer, observer_list_, OnOptInEnabled(arc_enabled)); 601 for (auto& observer : observer_list_)
602 observer.OnOptInEnabled(arc_enabled);
600 603
601 if (!arc_enabled) { 604 if (!arc_enabled) {
602 StopArc(); 605 StopArc();
603 RemoveArcData(); 606 RemoveArcData();
604 return; 607 return;
605 } 608 }
606 609
607 if (state_ == State::ACTIVE) 610 if (state_ == State::ACTIVE)
608 return; 611 return;
609 CloseUI(); 612 CloseUI();
(...skipping 19 matching lines...) Expand all
629 void ArcAuthService::ShutdownBridge() { 632 void ArcAuthService::ShutdownBridge() {
630 arc_sign_in_timer_.Stop(); 633 arc_sign_in_timer_.Stop();
631 playstore_launcher_.reset(); 634 playstore_launcher_.reset();
632 auth_callback_.Reset(); 635 auth_callback_.Reset();
633 auth_account_callback_.Reset(); 636 auth_account_callback_.Reset();
634 android_management_checker_.reset(); 637 android_management_checker_.reset();
635 auth_code_fetcher_.reset(); 638 auth_code_fetcher_.reset();
636 arc_bridge_service()->Shutdown(); 639 arc_bridge_service()->Shutdown();
637 if (state_ != State::NOT_INITIALIZED) 640 if (state_ != State::NOT_INITIALIZED)
638 SetState(State::STOPPED); 641 SetState(State::STOPPED);
639 FOR_EACH_OBSERVER(Observer, observer_list_, OnShutdownBridge()); 642 for (auto& observer : observer_list_)
643 observer.OnShutdownBridge();
640 } 644 }
641 645
642 void ArcAuthService::ShutdownBridgeAndCloseUI() { 646 void ArcAuthService::ShutdownBridgeAndCloseUI() {
643 ShutdownBridge(); 647 ShutdownBridge();
644 CloseUI(); 648 CloseUI();
645 } 649 }
646 650
647 void ArcAuthService::ShutdownBridgeAndShowUI(UIPage page, 651 void ArcAuthService::ShutdownBridgeAndShowUI(UIPage page,
648 const base::string16& status) { 652 const base::string16& status) {
649 ShutdownBridge(); 653 ShutdownBridge();
650 ShowUI(page, status); 654 ShowUI(page, status);
651 } 655 }
652 656
653 void ArcAuthService::AddObserver(Observer* observer) { 657 void ArcAuthService::AddObserver(Observer* observer) {
654 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 658 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
655 observer_list_.AddObserver(observer); 659 observer_list_.AddObserver(observer);
656 } 660 }
657 661
658 void ArcAuthService::RemoveObserver(Observer* observer) { 662 void ArcAuthService::RemoveObserver(Observer* observer) {
659 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 663 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
660 observer_list_.RemoveObserver(observer); 664 observer_list_.RemoveObserver(observer);
661 } 665 }
662 666
663 void ArcAuthService::CloseUI() { 667 void ArcAuthService::CloseUI() {
664 ui_page_ = UIPage::NO_PAGE; 668 ui_page_ = UIPage::NO_PAGE;
665 ui_page_status_.clear(); 669 ui_page_status_.clear();
666 FOR_EACH_OBSERVER(Observer, observer_list_, OnOptInUIClose()); 670 for (auto& observer : observer_list_)
671 observer.OnOptInUIClose();
667 if (!g_disable_ui_for_testing) 672 if (!g_disable_ui_for_testing)
668 ArcAuthNotification::Hide(); 673 ArcAuthNotification::Hide();
669 } 674 }
670 675
671 void ArcAuthService::SetUIPage(UIPage page, const base::string16& status) { 676 void ArcAuthService::SetUIPage(UIPage page, const base::string16& status) {
672 ui_page_ = page; 677 ui_page_ = page;
673 ui_page_status_ = status; 678 ui_page_status_ = status;
674 FOR_EACH_OBSERVER(Observer, observer_list_, 679 for (auto& observer : observer_list_)
675 OnOptInUIShowPage(ui_page_, ui_page_status_)); 680 observer.OnOptInUIShowPage(ui_page_, ui_page_status_);
676 } 681 }
677 682
678 // This is the special method to support enterprise mojo API. 683 // This is the special method to support enterprise mojo API.
679 // TODO(hidehiko): Remove this. 684 // TODO(hidehiko): Remove this.
680 void ArcAuthService::StopAndEnableArc() { 685 void ArcAuthService::StopAndEnableArc() {
681 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); 686 DCHECK_CURRENTLY_ON(content::BrowserThread::UI);
682 DCHECK(!arc_bridge_service()->stopped()); 687 DCHECK(!arc_bridge_service()->stopped());
683 reenable_arc_ = true; 688 reenable_arc_ = true;
684 StopArc(); 689 StopArc();
685 } 690 }
(...skipping 252 matching lines...) Expand 10 before | Expand all | Expand 10 after
938 return os << kStateFetchingCode; 943 return os << kStateFetchingCode;
939 case ArcAuthService::State::ACTIVE: 944 case ArcAuthService::State::ACTIVE:
940 return os << kStateActive; 945 return os << kStateActive;
941 default: 946 default:
942 NOTREACHED(); 947 NOTREACHED();
943 return os; 948 return os;
944 } 949 }
945 } 950 }
946 951
947 } // namespace arc 952 } // namespace arc
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/ui/app_list/arc/arc_app_list_prefs.cc » ('j') | components/arc/arc_bridge_service.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698