list_item_position.h 1.2 KB

123456789101112131415161718192021222324252627282930313233343536
  1. // Copyright 2017 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_BLOCKED_CONTENT_LIST_ITEM_POSITION_H_
  5. #define COMPONENTS_BLOCKED_CONTENT_LIST_ITEM_POSITION_H_
  6. #include <cstddef>
  7. namespace blocked_content {
  8. // This enum backs a histogram. Make sure you update enums.xml if you make
  9. // any changes.
  10. //
  11. // Identifies an element's position in an ordered list. Used by both the
  12. // framebust and popup UI on desktop platforms to indicate which element was
  13. // clicked.
  14. enum class ListItemPosition : int {
  15. kOnlyItem = 0,
  16. kFirstItem = 1,
  17. kMiddleItem = 2,
  18. kLastItem = 3,
  19. // Any new values should go before this one.
  20. kMaxValue = kLastItem,
  21. };
  22. // Gets the list item position from the given distance/index and the total size
  23. // of the collection. Distance is the measure from the beginning of the
  24. // collection to the given element.
  25. ListItemPosition GetListItemPositionFromDistance(size_t distance,
  26. size_t total_size);
  27. } // namespace blocked_content
  28. #endif // COMPONENTS_BLOCKED_CONTENT_LIST_ITEM_POSITION_H_