// 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 CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_CONSTANTS_H_ #define CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_CONSTANTS_H_ #include <stddef.h> #include <stdint.h> #include <initializer_list> #include <iosfwd> #include <optional> #include <string> #include "base/containers/enum_set.h" #include "base/functional/callback_forward.h" #include "build/build_config.h" #include "third_party/blink/public/common/manifest/manifest.h" #include "third_party/blink/public/mojom/manifest/display_mode.mojom-forward.h" namespace webapps { enum class WebappUninstallSource; } namespace web_app { // Installations of Web Apps have different sources of management. Apps can be // installed by different management systems - for example an app can be both // installed by the user and by policy. Keeping track of which installation // managers have installed a web app allows for them to be installed by multiple // managers at the same time, and uninstalls from one manager doesn't affect // another - the app will stay installed as long as at least one management // source has it installed. // // This enum is also used to rank installation sources, so the ordering matters. // This enum should be zero based: values are used as index in a bitset. // We don't use this enum values in prefs or metrics: enumerators can be // reordered. This enum is not a strongly typed enum class: it supports implicit // conversion to int and <> comparison operators. namespace WebAppManagement { enum Type { … }; std::ostream& operator<<(std::ostream& os, WebAppManagement::Type type); bool IsIwaType(WebAppManagement::Type type); } // namespace WebAppManagement WebAppManagementTypes; // ExternallyManagedAppManager: Where an app was installed from. This affects // what flags will be used when installing the app. // // Internal means that the set of apps to install is defined statically, and // can be determined solely by 'first party' data: the Chromium binary, // stored user preferences (assumed to have been edited only by Chromiums // past and present) and the like. External means that the set of apps to // install is defined dynamically, depending on 'third party' data that can // change from session to session even if those sessions are for the same // user running the same binary on the same hardware. // // Third party data sources can include configuration files in well known // directories on the file system, entries (or the lack of) in the Windows // registry, or centrally configured sys-admin policy. // // The internal versus external distinction matters because, for external // install sources, the code that installs apps based on those external data // sources can also need to *un*install apps if those external data sources // change, either by an explicit uninstall request or an implicit uninstall // of a previously-listed no-longer-listed app. // // Without the distinction between e.g. kInternalDefault and kExternalXxx, the // code that manages external-xxx apps might inadvertently uninstall internal // apps that it otherwise doesn't recognize. // // In practice, every kExternalXxx enum definition should correspond to // exactly one place in the code where // ExternallyManagedAppManager::SynchronizeInstalledApps is called. // TODO(dmurph): Remove this and merge it into WebAppManagement after it has a // new source for the AndroidSmsAppSetupControllerImpl. // https://crbug.com/1314055 enum class ExternalInstallSource { … }; // Icon size in pixels. // Small icons are used in confirmation dialogs and app windows. constexpr int kWebAppIconSmall = …; // Limit on the number of jump list entries per web app. constexpr size_t kMaxApplicationDockMenuItems = …; DisplayMode; // The operation mode for Run on OS Login. enum class RunOnOsLoginMode { … }; std::ostream& operator<<(std::ostream& os, RunOnOsLoginMode mode); // Command line parameter representing RunOnOsLoginMode::kWindowed. extern const char kRunOnOsLoginModeWindowed[]; enum class RunOnOsLoginPolicy { … }; // Default threshold for site engagement score if it's not set by field trial // param. constexpr int kIphFieldTrialParamDefaultSiteEngagementThreshold = …; // Expected file handler update actions to be taken by OsIntegrationManager // during UpdateOsHooks. enum class FileHandlerUpdateAction { … }; // Reflects the user's decision to allow or disallow an API such as File // Handling. APIs should generally start off as kRequiresPrompt. enum class ApiApprovalState { … }; std::ostream& operator<<(std::ostream& os, ApiApprovalState state); // TODO(b/274172447): Remove these and the manifest.h include after refactoring // away blink::Manifest and moving the inner classes to regular classes LaunchHandler; TabStrip; // A result how `WebAppIconDownloader` processed the list of icon urls. // // Entries should not be renumbered and numeric values should never be reused. // Update corresponding enums.xml entry when making changes here. enum class IconsDownloadedResult { … }; // Generic result enumeration to be used for operations that can fail. If more // information is needed in a return value, we can move to something similar to // `base::FileErrorOr` in the future. enum class Result { … }; #if BUILDFLAG(IS_CHROMEOS) // Represents the exit states of the PWABubbleView. To be used for CrOS events // logging. // // Do not re-use values. enum class WebAppInstallStatus : int64_t { kCancelled = 0, kAccepted = 1, }; #endif ResultCallback; // Management types that can be uninstalled by the user. // Note: These work directly with the `webapps::IsUserUninstall` function - any // source that returns true there can uninstall these types but not others, and // will CHECK-fail in RemoveWebAppJob otherwise. // All WebAppManagement::Types must be listed in either this constant or // kNotUserUninstallableSources (located in the cc file). constexpr WebAppManagementTypes kUserUninstallableSources = …; // Management types that resulted from a user web app install. constexpr WebAppManagementTypes kUserDrivenInstallSources = …; } // namespace web_app #endif // CHROME_BROWSER_WEB_APPLICATIONS_WEB_APP_CONSTANTS_H_