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
|
// Copyright 2022 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_CHROMEOS_WEB_APP_EXPERIMENTS_H_
#define CHROME_BROWSER_WEB_APPLICATIONS_CHROMEOS_WEB_APP_EXPERIMENTS_H_
#include <optional>
#include <string_view>
#include <vector>
#include "base/containers/span.h"
#include "chrome/browser/web_applications/scope_extension_info.h"
#include "components/webapps/common/web_app_id.h"
#include "content/public/browser/render_frame_host.h"
#include "third_party/blink/public/common/manifest/manifest.h"
#include "third_party/skia/include/core/SkColor.h"
#include "url/gurl.h"
static_assert(BUILDFLAG(IS_CHROMEOS), "For Chrome OS only");
class Profile;
namespace web_app {
// This class contains short-term experiments to specific web apps for testing
// improvements to the user experience of notable web apps.
// These are not intended for public release; this is for testing capabilities
// that will be available to websites at a later date. All experiments should be
// behind a disabled-by-default feature flag. All experiments should eventually
// be replaced by server-side changes made by the specific web app and/or
// improvements to existing web app APIs.
class ChromeOsWebAppExperiments {
public:
// Extensions to the app's primary scope. This may include scopes outside
// of the web app's primary origin.
// This is intended to be available to websites using the proposed
// https://github.com/WICG/manifest-incubations/blob/gh-pages/scope_extensions-explainer.md.
// At the moment, we are enabling testing of the proposed feature for
// certain hard-coded web apps.
static ScopeExtensions GetScopeExtensions(const webapps::AppId& app_id);
// Certain hard-coded apps should be configured to open supported links inside
// the app instead of inside a browser tab by default.
static bool ShouldAddLinkPreference(const webapps::AppId& app_id,
Profile* profile);
// Returns the max scope score (similar to
// WebAppRegistrar::GetUrlInAppScopeScore()) for the experimental extended
// scopes.
static int GetExtendedScopeScore(const webapps::AppId& app_id,
std::string_view url_spec);
// Whether the manifest theme_color and background_color should be ignored for
// `app_id`.
static bool IgnoreManifestColor(const webapps::AppId& app_id);
// Whether the Navigation Capturing Reimplementation behavior should be
// enabled when navigating to a URL controlled by the given app.
static bool IsNavigationCapturingReimplEnabledForTargetApp(
const webapps::AppId& target_app_id);
// Whether the Navigation Capturing Reimplementation behavior should be
// enabled when navigating from the given app's window to the given URL.
static bool IsNavigationCapturingReimplEnabledForSourceApp(
const webapps::AppId& source_app_id,
const GURL& url);
// Whether the app should be launched if a navigation goes to a URL controlled
// by the given app after one or multiple redirections.
static bool ShouldLaunchForRedirectedNavigation(
const webapps::AppId& target_app_id);
// Override the manifest id with predefined query params if the start URL in
// the manifest matches certain URLs controlled via a finch parameter.
static void MaybeOverrideManifest(content::RenderFrameHost* frame_host,
blink::mojom::ManifestPtr& manifest);
static void SetAlwaysEnabledForTesting();
static void SetScopeExtensionsForTesting(
std::vector<const char*> scope_extensions_override);
static void ClearOverridesForTesting();
ChromeOsWebAppExperiments() = delete;
~ChromeOsWebAppExperiments() = delete;
};
} // namespace web_app
#endif // CHROME_BROWSER_WEB_APPLICATIONS_CHROMEOS_WEB_APP_EXPERIMENTS_H_
|