remove_uninstalled_apps_task_posix.cc 908 B

1234567891011121314151617181920212223242526272829303132
  1. // Copyright 2022 The Chromium Authors. All rights reserved.
  2. // Use of this source code is governed by a BSD-style license that can be
  3. // found in the LICENSE file.
  4. #include "chrome/updater/remove_uninstalled_apps_task.h"
  5. #include <string>
  6. #include "base/files/file_path.h"
  7. #include "base/files/file_util.h"
  8. #include "chrome/updater/constants.h"
  9. #include "chrome/updater/util.h"
  10. #include "third_party/abseil-cpp/absl/types/optional.h"
  11. namespace updater {
  12. absl::optional<int> RemoveUninstalledAppsTask::GetUnregisterReason(
  13. const std::string& /*app_id*/,
  14. const base::FilePath& ecp) const {
  15. if (ecp.empty()) {
  16. return absl::nullopt;
  17. }
  18. if (!base::PathExists(ecp)) {
  19. return absl::make_optional(kUninstallPingReasonUninstalled);
  20. }
  21. if (!PathOwnedByUser(ecp)) {
  22. return absl::make_optional(kUninstallPingReasonUserNotAnOwner);
  23. }
  24. return absl::nullopt;
  25. }
  26. } // namespace updater