traffic_counters_resource_provider.cc 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. // Copyright 2021 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 "ash/webui/network_ui/traffic_counters_resource_provider.h"
  5. #include "ash/constants/ash_features.h"
  6. #include "chromeos/strings/grit/chromeos_strings.h"
  7. #include "content/public/browser/web_ui_data_source.h"
  8. #include "ui/base/webui/web_ui_util.h"
  9. #include "ui/resources/grit/webui_generated_resources.h"
  10. namespace ash {
  11. namespace traffic_counters {
  12. namespace {
  13. constexpr webui::LocalizedString kLocalizedStrings[] = {
  14. {"TrafficCountersUnknown", IDS_TRAFFIC_COUNTERS_UNKNOWN},
  15. {"TrafficCountersChrome", IDS_TRAFFIC_COUNTERS_CHROME},
  16. {"TrafficCountersUser", IDS_TRAFFIC_COUNTERS_USER},
  17. {"TrafficCountersArc", IDS_TRAFFIC_COUNTERS_ARC},
  18. {"TrafficCountersCrosvm", IDS_TRAFFIC_COUNTERS_CROSVM},
  19. {"TrafficCountersPluginvm", IDS_TRAFFIC_COUNTERS_PLUGINVM},
  20. {"TrafficCountersUpdateEngine", IDS_TRAFFIC_COUNTERS_UPDATE_ENGINE},
  21. {"TrafficCountersVpn", IDS_TRAFFIC_COUNTERS_VPN},
  22. {"TrafficCountersSystem", IDS_TRAFFIC_COUNTERS_SYSTEM},
  23. {"TrafficCountersGuid", IDS_TRAFFIC_COUNTERS_GUID},
  24. {"TrafficCountersName", IDS_TRAFFIC_COUNTERS_NAME},
  25. {"TrafficCountersTrafficCounters", IDS_TRAFFIC_COUNTERS_TRAFFIC_COUNTERS},
  26. {"TrafficCountersRequestTrafficCounters",
  27. IDS_TRAFFIC_COUNTERS_REQUEST_TRAFFIC_COUNTERS},
  28. {"TrafficCountersResetTrafficCounters",
  29. IDS_TRAFFIC_COUNTERS_RESET_TRAFFIC_COUNTERS},
  30. {"TrafficCountersLastResetTime", IDS_TRAFFIC_COUNTERS_LAST_RESET_TIME},
  31. // Settings UI
  32. {"TrafficCountersDataUsageLabel", IDS_TRAFFIC_COUNTERS_DATA_USAGE_LABEL},
  33. {"TrafficCountersDataUsageSinceLabel",
  34. IDS_TRAFFIC_COUNTERS_DATA_USAGE_SINCE_LABEL},
  35. {"TrafficCountersDataUsageResetButtonLabel",
  36. IDS_TRAFFIC_COUNTERS_DATA_USAGE_RESET_BUTTON_LABEL},
  37. {"TrafficCountersDataUsageResetLabel",
  38. IDS_TRAFFIC_COUNTERS_DATA_USAGE_RESET_LABEL},
  39. {"TrafficCountersDataUsageEnableAutoResetLabel",
  40. IDS_TRAFFIC_COUNTERS_DATA_USAGE_ENABLE_AUTO_RESET_LABEL},
  41. {"TrafficCountersDataUsageLastResetDateUnavailableLabel",
  42. IDS_TRAFFIC_COUNTERS_DATA_USAGE_LAST_RESET_DATE_UNAVAILABLE_LABEL},
  43. {"TrafficCountersDataUsageEnableAutoResetSublabel",
  44. IDS_TRAFFIC_COUNTERS_DATA_USAGE_ENABLE_AUTO_RESET_SUBLABEL},
  45. {"TrafficCountersDataUsageAutoResetDayOfMonthLabel",
  46. IDS_TRAFFIC_COUNTERS_DATA_USAGE_AUTO_RESET_DAY_OF_MONTH_LABEL},
  47. };
  48. } // namespace
  49. void AddResources(content::WebUIDataSource* html_source) {
  50. html_source->AddLocalizedStrings(kLocalizedStrings);
  51. html_source->AddBoolean("trafficCountersEnabled",
  52. ash::features::IsTrafficCountersEnabled());
  53. }
  54. } // namespace traffic_counters
  55. } // namespace ash