Commit 0128c5e6 authored by Jiewei Qian's avatar Jiewei Qian Committed by Chromium LUCI CQ

dpwa: expose App's start_url as AppService publisher_id

This CL exposes Web App's start_url as publisher_id to AppService.

Web App start_url is used to calculate AppId, and can be used to launch
(navigate to) the App.

App Service publisher_id is the platform-specific identifier for an App.
Using start_url as publisher_id gives AppService users more flexibility
in interacting with the App. This is useful in tests. For example,
performing checks after navigating to the App's url in a browser tab.

Bug: 1155337
Change-Id: Ie5d8796e178322ebd634386565d2c312c1fcec00
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2581340
Commit-Queue: Jiewei Qian  <qjw@chromium.org>
Reviewed-by: default avatarAlexey Baskakov <loyso@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#835558}
parent 5f170e84
...@@ -154,6 +154,9 @@ apps::mojom::AppPtr WebAppsBase::ConvertImpl(const web_app::WebApp* web_app, ...@@ -154,6 +154,9 @@ apps::mojom::AppPtr WebAppsBase::ConvertImpl(const web_app::WebApp* web_app,
app->last_launch_time = web_app->last_launch_time(); app->last_launch_time = web_app->last_launch_time();
app->install_time = web_app->install_time(); app->install_time = web_app->install_time();
// Web App's publisher_id the start url.
app->publisher_id = web_app->start_url().spec();
// app->version is left empty here. // app->version is left empty here.
PopulatePermissions(web_app, &app->permissions); PopulatePermissions(web_app, &app->permissions);
......
...@@ -262,4 +262,26 @@ IN_PROC_BROWSER_TEST_F(WebAppsBaseBrowserTest, LaunchWithIntent) { ...@@ -262,4 +262,26 @@ IN_PROC_BROWSER_TEST_F(WebAppsBaseBrowserTest, LaunchWithIntent) {
run_loop.Run(); run_loop.Run();
} }
IN_PROC_BROWSER_TEST_F(WebAppsBaseBrowserTest, ExposeAppServicePublisherId) {
ASSERT_TRUE(embedded_test_server()->Start());
const GURL app_url(embedded_test_server()->GetURL("/web_apps/basic.html"));
// Install file handling web app.
const web_app::AppId app_id =
web_app::InstallWebAppFromManifest(browser(), app_url);
const web_app::WebAppRegistrar* registrar =
web_app::WebAppProvider::Get(browser()->profile())
->registrar()
.AsWebAppRegistrar();
const web_app::WebApp* web_app = registrar->GetAppById(app_id);
ASSERT_TRUE(web_app);
// Check the publisher_id is the app's start url.
apps::AppServiceProxyFactory::GetForProfile(browser()->profile())
->AppRegistryCache()
.ForOneApp(app_id, [&](const apps::AppUpdate& update) {
EXPECT_EQ(web_app->start_url().spec(), update.PublisherId());
});
}
} // namespace apps } // namespace apps
...@@ -20,9 +20,9 @@ struct App { ...@@ -20,9 +20,9 @@ struct App {
string? name; string? name;
string? short_name; string? short_name;
// The publisher-specific ID for this app, e.g. for Android apps, this field // An optional, publisher-specific ID for this app, e.g. for Android apps,
// contains the Android package name. May be empty if AppId() should be // this field contains the Android package name, and for web apps, it
// considered as the canonical publisher ID. // contains the start URL.
string? publisher_id; string? publisher_id;
string? description; string? description;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment