sync_service_utils.h 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  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
  3. // found in the LICENSE file.
  4. #ifndef COMPONENTS_SYNC_DRIVER_SYNC_SERVICE_UTILS_H_
  5. #define COMPONENTS_SYNC_DRIVER_SYNC_SERVICE_UTILS_H_
  6. #include "components/sync/base/model_type.h"
  7. namespace syncer {
  8. class SyncService;
  9. // Indicates whether uploading of data to Google is enabled, i.e. the user has
  10. // given consent to upload this data. Since this enum is used for logging
  11. // histograms, entries must not be removed or reordered.
  12. // A Java counterpart will be generated for this enum.
  13. // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.components.sync
  14. enum class UploadState {
  15. // Syncing is enabled in principle, but the sync service is not actually
  16. // active yet. Either it's still initializing (in which case we e.g. don't
  17. // know about any auth errors yet), or it's in a transient auth error state.
  18. INITIALIZING,
  19. // We are not syncing to Google, and the caller should assume that we do not
  20. // have consent to do so. This can have a number of reasons, e.g.: sync as a
  21. // whole is disabled, or the given model type is disabled, or we're in
  22. // "local sync" mode, or this data type is encrypted with a custom passphrase
  23. // (in which case we're technically still uploading, but Google can't inspect
  24. // the data), or we're in a persistent auth error state. As one special case
  25. // of an auth error, sync may be "paused" because the user signed out of the
  26. // content area.
  27. NOT_ACTIVE,
  28. // We're actively syncing data to Google servers, in a form that is readable
  29. // by Google.
  30. ACTIVE,
  31. // Used when logging histograms. Must have this exact name.
  32. kMaxValue = ACTIVE
  33. };
  34. // Used for UMA histogram, do not reorder. Represents the UI elements which
  35. // contain trusted vault error button.
  36. // GENERATED_JAVA_ENUM_PACKAGE: org.chromium.components.sync
  37. enum class TrustedVaultUserActionTriggerForUMA {
  38. // Settings pages, used on all platforms except ChromeOS.
  39. kSettings,
  40. // Used on desktop platform only.
  41. kProfileMenu,
  42. // Used on Android and ChromeOS, represents OS-level notification.
  43. kNotification,
  44. // Used on iOS only. Represents Infobar on the New Tab Page.
  45. // TODO(crbug.com/1083973): record this bucket bucket on Android once
  46. // corresponding UI added.
  47. kNewTabPageInfobar,
  48. kMaxValue = kNewTabPageInfobar
  49. };
  50. // Returns whether |type| is being uploaded to Google. This is useful for
  51. // features that depend on user consent for uploading data (e.g. history) to
  52. // Google.
  53. UploadState GetUploadToGoogleState(const SyncService* sync_service,
  54. ModelType type);
  55. void RecordKeyRetrievalTrigger(TrustedVaultUserActionTriggerForUMA trigger);
  56. void RecordRecoverabilityDegradedFixTrigger(
  57. TrustedVaultUserActionTriggerForUMA trigger);
  58. // Whether the user should be offered to opt in to trusted vault encryption.
  59. bool ShouldOfferTrustedVaultOptIn(const SyncService* service);
  60. } // namespace syncer
  61. #endif // COMPONENTS_SYNC_DRIVER_SYNC_SERVICE_UTILS_H_