1 // Copyright 2020 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 5 #ifndef CHROME_BROWSER_CHROMEOS_POLICY_INSTALL_EVENT_LOG_UTIL_H_ 6 #define CHROME_BROWSER_CHROMEOS_POLICY_INSTALL_EVENT_LOG_UTIL_H_ 7 8 #include "components/policy/proto/device_management_backend.pb.h" 9 #include "extensions/common/extension_id.h" 10 11 namespace base { 12 class Value; 13 } // namespace base 14 15 namespace em = enterprise_management; 16 17 namespace policy { 18 19 // Return serial number of the device. 20 std::string GetSerialNumber(); 21 22 // Converts ExtensionInstallReportRequest proto defined in 23 // components/policy/proto/device_management_backend.proto to a dictionary value 24 // that corresponds to the definition of Event defined in 25 // google3/google/internal/chrome/reporting/v1/chromereporting.proto. This is 26 // done because events to Chrome Reporting API are sent as json over HTTP, and 27 // has different proto definition compare to the proto used to store events 28 // locally. 29 base::Value ConvertExtensionProtoToValue( 30 const em::ExtensionInstallReportRequest* extension_install_report_request, 31 const base::Value& context); 32 33 // Converts ExtensionInstallReportLogEvent proto defined in 34 // components/policy/proto/device_management_backend.proto to a dictionary value 35 // that corresponds to the definition of ExtensionAppInstallEvent defined in 36 // google3/chrome/cros/reporting/proto/chrome_extension_install_events.proto. 37 // Appends event_id to the event by calculating hash of the (event, 38 // |context|) pair, so long as the calculation is possible. 39 base::Value ConvertExtensionEventToValue( 40 const extensions::ExtensionId& extension_id, 41 const em::ExtensionInstallReportLogEvent& 42 extension_install_report_log_event, 43 const base::Value& context); 44 45 // Converts AppInstallReportRequest proto defined in 46 // components/policy/proto/device_management_backend.proto to a dictionary value 47 // that corresponds to the definition of Event defined in 48 // google3/google/internal/chrome/reporting/v1/chromereporting.proto. This is 49 // done because events to Chrome Reporting API are sent as json over HTTP, and 50 // has different proto definition compare to the proto used to store events 51 // locally. 52 base::Value ConvertArcAppProtoToValue( 53 const em::AppInstallReportRequest* app_install_report_request, 54 const base::Value& context); 55 56 // Converts AppInstallReportLogEvent proto defined in 57 // components/policy/proto/device_management_backend.proto to a dictionary value 58 // that corresponds to the definition of AndroidAppInstallEvent defined in 59 // google3/chrome/cros/reporting/proto/chrome_app_install_events.proto. 60 // Appends event_id to the event by calculating hash of the (event, 61 // |context|) pair, so long as the calculation is possible. 62 base::Value ConvertArcAppEventToValue( 63 const std::string& package, 64 const em::AppInstallReportLogEvent& app_install_report_log_event, 65 const base::Value& context); 66 67 } // namespace policy 68 69 #endif // CHROME_BROWSER_CHROMEOS_POLICY_INSTALL_EVENT_LOG_UTIL_H_ 70