OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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_session_manager.h" | 5 #include "chrome/browser/chromeos/arc/arc_session_manager.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 486 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
497 } | 497 } |
498 ShutdownSession(); | 498 ShutdownSession(); |
499 if (support_host_) | 499 if (support_host_) |
500 support_host_->Close(); | 500 support_host_->Close(); |
501 } | 501 } |
502 | 502 |
503 void ArcSessionManager::OnOptInPreferenceChanged() { | 503 void ArcSessionManager::OnOptInPreferenceChanged() { |
504 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); | 504 DCHECK_CURRENTLY_ON(content::BrowserThread::UI); |
505 DCHECK(profile_); | 505 DCHECK(profile_); |
506 | 506 |
507 PrefService* const prefs = profile_->GetPrefs(); | |
508 | |
507 const bool arc_enabled = IsArcEnabled(); | 509 const bool arc_enabled = IsArcEnabled(); |
508 if (!IsArcManaged()) { | 510 if (!IsArcManaged()) { |
509 // Update UMA only for non-Managed cases. | 511 // Update UMA only for non-Managed cases. |
510 UpdateOptInActionUMA(arc_enabled ? OptInActionType::OPTED_IN | 512 UpdateOptInActionUMA(arc_enabled ? OptInActionType::OPTED_IN |
511 : OptInActionType::OPTED_OUT); | 513 : OptInActionType::OPTED_OUT); |
512 | 514 |
513 if (!arc_enabled) { | 515 if (!arc_enabled) { |
514 // Remove the pinned Play Store icon launcher in Shelf. | 516 // Remove the pinned Play Store icon launcher in Shelf. |
515 // This is only for non-Managed cases. In managed cases, it is expected | 517 // This is only for non-Managed cases. In managed cases, it is expected |
516 // to be "disabled" rather than "removed", so keep it here. | 518 // to be "disabled" rather than "removed", so keep it here. |
517 ash::ShelfDelegate* shelf_delegate = GetShelfDelegate(); | 519 ash::ShelfDelegate* shelf_delegate = GetShelfDelegate(); |
518 if (shelf_delegate) | 520 if (shelf_delegate) |
519 shelf_delegate->UnpinAppWithID(ArcSupportHost::kHostAppId); | 521 shelf_delegate->UnpinAppWithID(ArcSupportHost::kHostAppId); |
520 } | 522 } |
521 } | 523 } |
522 | 524 |
523 for (auto& observer : observer_list_) | 525 for (auto& observer : observer_list_) |
524 observer.OnArcOptInChanged(arc_enabled); | 526 observer.OnArcOptInChanged(arc_enabled); |
525 | 527 |
526 // Hide auth notification if it was opened before and arc.enabled pref was | 528 // Hide auth notification if it was opened before and arc.enabled pref was |
527 // explicitly set to true or false. | 529 // explicitly set to true or false. |
528 if (!g_disable_ui_for_testing && | 530 if (!g_disable_ui_for_testing && prefs->HasPrefPath(prefs::kArcEnabled)) { |
hidehiko
2017/02/09 15:28:04
Style: Could you elide the brace for one-line if-b
emaxx
2017/02/10 15:40:15
Done.
| |
529 profile_->GetPrefs()->HasPrefPath(prefs::kArcEnabled)) { | |
530 ArcAuthNotification::Hide(); | 531 ArcAuthNotification::Hide(); |
531 } | 532 } |
532 | 533 |
533 if (!arc_enabled) { | 534 if (!arc_enabled) { |
534 // Reset any pending request to re-enable ARC. | 535 // Reset any pending request to re-enable ARC. |
535 VLOG(1) << "ARC opt-out. Removing user data."; | 536 VLOG(1) << "ARC opt-out. Removing user data."; |
536 reenable_arc_ = false; | 537 reenable_arc_ = false; |
537 StopArc(); | 538 StopArc(); |
538 RemoveArcData(); | 539 RemoveArcData(); |
539 return; | 540 return; |
540 } | 541 } |
541 | 542 |
542 if (state_ == State::ACTIVE) | 543 if (state_ == State::ACTIVE) |
543 return; | 544 return; |
544 | 545 |
545 if (state_ == State::REMOVING_DATA_DIR) { | 546 if (state_ == State::REMOVING_DATA_DIR) { |
546 // Data removal request is in progress. Set flag to re-enable Arc once it is | 547 // Data removal request is in progress. Set flag to re-enable Arc once it is |
547 // finished. | 548 // finished. |
548 reenable_arc_ = true; | 549 reenable_arc_ = true; |
549 return; | 550 return; |
550 } | 551 } |
551 | 552 |
552 if (support_host_) | 553 if (support_host_) |
553 support_host_->SetArcManaged(IsArcManaged()); | 554 support_host_->SetArcManaged(IsArcManaged()); |
554 | 555 |
555 // For ARC Kiosk we skip ToS because it is very likely that near the device | 556 // For ARC Kiosk we skip ToS because it is very likely that near the device |
556 // there will be no one who is eligible to accept them. | 557 // there will be no one who is eligible to accept them. |
557 // TODO(poromov): Move to more Kiosk dedicated set-up phase. | 558 // TODO(poromov): Move to more Kiosk dedicated set-up phase. |
558 if (IsArcKioskMode()) | 559 if (IsArcKioskMode()) |
559 profile_->GetPrefs()->SetBoolean(prefs::kArcTermsAccepted, true); | 560 prefs->SetBoolean(prefs::kArcTermsAccepted, true); |
561 | |
562 // Skip ToS when all displayed preferences are managed by the admin policy. | |
563 if (IsArcManaged() && | |
564 prefs->IsManagedPreference(prefs::kArcBackupRestoreEnabled) && | |
565 prefs->IsManagedPreference(prefs::kArcLocationServiceEnabled)) { | |
566 prefs->SetBoolean(prefs::kArcTermsAccepted, true); | |
hidehiko
2017/02/09 15:28:04
How about:
// Skip to show UI asking users to ena
emaxx
2017/02/10 15:40:15
Done, with a slight modification of the second sen
| |
567 } | |
560 | 568 |
561 // If it is marked that sign in has been successfully done, then directly | 569 // If it is marked that sign in has been successfully done, then directly |
562 // start ARC. | 570 // start ARC. |
563 // For testing, and for Kisok mode, we also skip ToS negotiation procedure. | 571 // For testing, and for Kisok mode, we also skip ToS negotiation procedure. |
564 // For backward compatibility, this check needs to be prior to the | 572 // For backward compatibility, this check needs to be prior to the |
565 // kArcTermsAccepted check below. | 573 // kArcTermsAccepted check below. |
566 if (profile_->GetPrefs()->GetBoolean(prefs::kArcSignedIn) || | 574 if (prefs->GetBoolean(prefs::kArcSignedIn) || |
567 IsArcOptInVerificationDisabled() || IsArcKioskMode()) { | 575 IsArcOptInVerificationDisabled() || IsArcKioskMode()) { |
568 StartArc(); | 576 StartArc(); |
569 | 577 |
570 // Skip Android management check for testing. | 578 // Skip Android management check for testing. |
571 // We also skip if Android management check for Kiosk mode, | 579 // We also skip if Android management check for Kiosk mode, |
572 // because there are no managed human users for Kiosk exist. | 580 // because there are no managed human users for Kiosk exist. |
573 if (IsArcOptInVerificationDisabled() || IsArcKioskMode() || | 581 if (IsArcOptInVerificationDisabled() || IsArcKioskMode() || |
574 (g_disable_ui_for_testing && | 582 (g_disable_ui_for_testing && |
575 !g_enable_check_android_management_for_testing)) { | 583 !g_enable_check_android_management_for_testing)) { |
576 return; | 584 return; |
(...skipping 13 matching lines...) Expand all Loading... | |
590 return; | 598 return; |
591 } | 599 } |
592 | 600 |
593 // If it is marked that the Terms of service is accepted already, | 601 // If it is marked that the Terms of service is accepted already, |
594 // just skip the negotiation with user, and start Android management | 602 // just skip the negotiation with user, and start Android management |
595 // check directly. | 603 // check directly. |
596 // This happens, e.g., when; | 604 // This happens, e.g., when; |
597 // 1) User accepted the Terms of service on OOBE flow. | 605 // 1) User accepted the Terms of service on OOBE flow. |
598 // 2) User accepted the Terms of service on Opt-in flow, but logged out | 606 // 2) User accepted the Terms of service on Opt-in flow, but logged out |
599 // before ARC sign in procedure was done. Then, logs in again. | 607 // before ARC sign in procedure was done. Then, logs in again. |
600 if (profile_->GetPrefs()->GetBoolean(prefs::kArcTermsAccepted)) { | 608 if (prefs->GetBoolean(prefs::kArcTermsAccepted)) { |
601 // Don't show UI for this progress if it was not shown. | 609 // Don't show UI for this progress if it was not shown. |
602 if (support_host_->ui_page() != ArcSupportHost::UIPage::NO_PAGE) | 610 if (support_host_ && |
hidehiko
2017/02/09 15:28:04
Good catch! Thank you for fix.
emaxx
2017/02/10 15:40:15
Acknowledged.
| |
611 support_host_->ui_page() != ArcSupportHost::UIPage::NO_PAGE) { | |
603 support_host_->ShowArcLoading(); | 612 support_host_->ShowArcLoading(); |
613 } | |
604 StartArcAndroidManagementCheck(); | 614 StartArcAndroidManagementCheck(); |
605 return; | 615 return; |
606 } | 616 } |
607 | 617 |
608 // Need user's explicit Terms Of Service agreement. Prevent race condition | 618 // Need user's explicit Terms Of Service agreement. Prevent race condition |
609 // when ARC can be enabled before profile is synced. In last case | 619 // when ARC can be enabled before profile is synced. In last case |
610 // OnOptInPreferenceChanged is called twice. | 620 // OnOptInPreferenceChanged is called twice. |
611 // TODO(crbug.com/687185): Remove the condition. | 621 // TODO(crbug.com/687185): Remove the condition. |
612 if (state_ != State::SHOWING_TERMS_OF_SERVICE) | 622 if (state_ != State::SHOWING_TERMS_OF_SERVICE) |
613 StartTermsOfServiceNegotiation(); | 623 StartTermsOfServiceNegotiation(); |
(...skipping 359 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
973 | 983 |
974 #undef MAP_STATE | 984 #undef MAP_STATE |
975 | 985 |
976 // Some compilers report an error even if all values of an enum-class are | 986 // Some compilers report an error even if all values of an enum-class are |
977 // covered exhaustively in a switch statement. | 987 // covered exhaustively in a switch statement. |
978 NOTREACHED() << "Invalid value " << static_cast<int>(state); | 988 NOTREACHED() << "Invalid value " << static_cast<int>(state); |
979 return os; | 989 return os; |
980 } | 990 } |
981 | 991 |
982 } // namespace arc | 992 } // namespace arc |
OLD | NEW |