1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119
|
// Copyright 2018 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef COMPONENTS_UKM_APP_SOURCE_URL_RECORDER_H_
#define COMPONENTS_UKM_APP_SOURCE_URL_RECORDER_H_
#include "services/metrics/public/cpp/ukm_recorder.h"
#include "services/metrics/public/cpp/ukm_source_id.h"
#include "base/feature_list.h"
#include <string>
class GURL;
namespace apps {
class AppDiscoveryMetrics;
class AppPlatformMetrics;
}
namespace app_list {
class AppLaunchEventLogger;
} // namespace app_list
namespace arc::input_overlay {
class InputOverlayUkm;
} // namespace arc::input_overlay
namespace badging {
class BadgeManager;
} // namespace badging
namespace web_app {
class DesktopWebAppUkmRecorder;
} // namespace web_app
namespace webapk {
class WebApkUkmRecorder;
} // namespace webapk
namespace ukm {
BASE_FEATURE(kUkmAppLogging, "UkmAppLogging", base::FEATURE_ENABLED_BY_DEFAULT);
class AppSourceUrlRecorder {
private:
friend class apps::AppDiscoveryMetrics;
friend class apps::AppPlatformMetrics;
friend class AppSourceUrlRecorderTest;
friend class app_list::AppLaunchEventLogger;
friend class arc::input_overlay::InputOverlayUkm;
friend class badging::BadgeManager;
friend class web_app::DesktopWebAppUkmRecorder;
friend class webapk::WebApkUkmRecorder;
// Returns the URL to be used for UKM for a Chrome app identified by `app_id`.
//
// This URL will be generated with the prefix "app://" for a Chrome app with
// `app_id`, a unique hash string to identify the app. For example,
// "mgndgikekgjfcpckkfioiadnlibdjbkf" is the `app_id` for Chrome browser, and
// the output SourceId is "app://mgndgikekgjfcpckkfioiadnlibdjbkf".
static GURL GetURLForChromeApp(const std::string& app_id);
// Get a UKM SourceId using the URL generated by GetURLforArcPackageName.
static SourceId GetSourceIdForArcPackageName(const std::string& package_name);
// Returns the URL given a ARC app `package_name` to be used to identify the
// app for UKM.
//
// This URL will be generated with the prefix "app://" for an Arc app with
// `package_name`. For example, for `package_name`, "com.google.play", the
// output SourceId is "app://com.google.play".
//
// This URL will be used to generate the SourceId for
// GetSourceIdForArcPackageName.
static GURL GetURLForArcPackageName(const std::string& package_name);
// Get a UKM SourceId using URL generated by GetURLForPWA.
static SourceId GetSourceIdForPWA(const GURL& url);
// Returns the URL to be used to identify the PWA app given a `url` to be used
// in UKM.
static GURL GetURLForPWA(const GURL& url);
// Returns the URL to be used to identify the Borealis app given name `app` in
// UKM.
//
// This URL is generated with the prefix "app://borealis/" for a Borealis app.
// `app` could be a numeric Borealis App ID, or a string identifying a
// special case such as the main client app or an unregistered app.
static GURL GetURLForBorealis(const std::string& app);
// Returns the URL for the Crostini app to be used in UKM.
//
// This URL is generated with the prefix "app://" for a Crostini app with an
// XDG desktop id of `desktop_id` and app name of `app_name`.
static GURL GetURLForCrostini(const std::string& desktop_id,
const std::string& app_name);
// For internal use only. Generates a SourceId given a `url` generated by one
// of the `GetURLFor{AppType}` functions above.
static SourceId GetSourceIdForUrl(const GURL& url, const AppType);
// Informs UKM service that the source_id is no longer needed nor used by the
// end of the current reporting cycle, and thus can be deleted later.
static void MarkSourceForDeletion(SourceId source_id);
};
} // namespace ukm
#endif // COMPONENTS_UKM_APP_SOURCE_URL_RECORDER_H_
|