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 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135
|
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_FLAGS_ANDROID_CHROME_SESSION_STATE_H_
#define CHROME_BROWSER_FLAGS_ANDROID_CHROME_SESSION_STATE_H_
#include <jni.h>
#include "base/feature_list.h"
class PrefRegistrySimple;
class PrefService;
namespace chrome {
namespace android {
enum CustomTabsVisibilityHistogram {
VISIBLE_CUSTOM_TAB,
VISIBLE_CHROME_TAB,
NO_VISIBLE_TAB,
kMaxValue = NO_VISIBLE_TAB,
};
// Following enum should always be in sync with ChromeActivityType defined in
// tools/metrics/histograms/metadata/android/enums.xml
// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.flags
enum class ActivityType {
// Chrome is running as the Chrome Android Browser App (i.e., traditional
// Chrome).
kTabbed,
// Chrome is running embedded in another application as a Custom Tab.
// See:
// - https://developer.chrome.com/docs/android/custom-tabs/
kCustomTab,
// Chrome is running as a Trusted Web Activity.
//
// See:
// - https://developer.chrome.com/docs/android/trusted-web-activity/
kTrustedWebActivity,
// Chrome is running as a Web App
//
// See
// -
// https://chromium.googlesource.com/chromium/src/+/HEAD/docs/webapps/README.md
kWebapp,
// Chrome is running as a WebAPK.
//
// See:
// - https://web.dev/webapks/
// -
// https://chromium.googlesource.com/chromium/src/+/refs/heads/main/chrome/android/webapk/README.md
kWebApk,
// Chrome has started running, but no tab has yet become visible (for example:
// warm-up,
// FRE, downloads manager shown in response to a notification click, etc).
kPreFirstTab,
// Chrome is running embedded in another application as auth-dedicated tab.
// TODO(b/353517557): Add a link to a developer guide
kAuthTab,
kMaxValue = kAuthTab,
};
// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.flags
enum class DarkModeState {
kUnknown,
// Both system and browser are in dark mode.
kDarkModeSystem,
// Browser is in dark mode, system is not/cannot be determined.
kDarkModeApp,
// Both system and browser are in light mode.
kLightModeSystem,
// Browser is in light mode, system is not/cannot be determined.
kLightModeApp,
kMaxValue = kLightModeApp,
};
// These values are persisted to logs. Entries should not be renumbered and
// numeric values should never be reused. See MultipleUserProfilesState in
// enums.xml.
// GENERATED_JAVA_ENUM_PACKAGE: org.chromium.chrome.browser.flags
enum class MultipleUserProfilesState {
kUnknown = 0,
kSingleProfile = 1,
kMultipleProfiles = 2,
kMaxValue = kMultipleProfiles,
};
// Returns the CustomTabs.Visible histogram value that corresponde to |type|.
CustomTabsVisibilityHistogram GetCustomTabsVisibleValue(ActivityType type);
// Gets/sets the raw underlying activity type without triggering any additional
// side-effects.
ActivityType GetInitialActivityTypeForTesting();
void SetInitialActivityTypeForTesting(ActivityType type);
// Sets the activity type and emits associated metrics as needed.
void SetActivityType(PrefService* local_state, ActivityType type);
// Returns the current activity type.
ActivityType GetActivityType();
DarkModeState GetDarkModeState();
bool GetIsInMultiWindowModeValue();
// Helper to emit Browser/CCT activity type histograms.
void EmitActivityTypeHistograms(ActivityType type);
// Registers prefs to store the most recent activity type in Local State.
void RegisterActivityTypePrefs(PrefRegistrySimple* registry);
// Retrieves the activity type from |local_state|.
std::optional<chrome::android::ActivityType> GetActivityTypeFromLocalState(
PrefService* local_state);
// Saves the activity type |value| to |local_state|.
void SaveActivityTypeToLocalState(PrefService* local_state,
chrome::android::ActivityType value);
// Returns whether there are multiple user profiles.
MultipleUserProfilesState GetMultipleUserProfilesState();
} // namespace android
} // namespace chrome
#endif // CHROME_BROWSER_FLAGS_ANDROID_CHROME_SESSION_STATE_H_
|