Commit ac3a53a6 authored by Alan Cutter's avatar Alan Cutter Committed by Commit Bot

Rename launch_url to start_url in WebAppSpecifics proto

This CL is a mechanical change that renames launch_url to start_url
in the WebAppSpecifics proto.

This is to make "start_url" more closely match the app manifest field
and to make room for a separate "launch_url" in a follow up CL that
includes additional query params added to the start_url.

Bug: 1045537
Change-Id: I76c079d3b2b930ecc781536b95977591529b2438
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2374189
Auto-Submit: Alan Cutter <alancutter@chromium.org>
Reviewed-by: default avatarEric Willigers <ericwilligers@chromium.org>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Commit-Queue: Alan Cutter <alancutter@chromium.org>
Cr-Commit-Position: refs/heads/master@{#802638}
parent 74a0b448
......@@ -69,10 +69,10 @@ void TestWebAppDatabaseFactory::WriteProtos(
store_->CreateWriteBatch();
for (const std::unique_ptr<WebAppProto>& proto : protos) {
GURL launch_url(proto->sync_data().launch_url());
DCHECK(!launch_url.is_empty());
DCHECK(launch_url.is_valid());
AppId app_id = GenerateAppIdFromURL(launch_url);
GURL start_url(proto->sync_data().start_url());
DCHECK(!start_url.is_empty());
DCHECK(start_url.is_valid());
AppId app_id = GenerateAppIdFromURL(start_url);
write_batch->WriteData(app_id, proto->SerializeAsString());
}
......
......@@ -237,18 +237,18 @@ std::unique_ptr<WebApp> WebAppDatabase::CreateWebApp(
const sync_pb::WebAppSpecifics& sync_data = local_data.sync_data();
// AppId is a hash of launch_url. Read launch_url first:
GURL launch_url(sync_data.launch_url());
if (launch_url.is_empty() || !launch_url.is_valid()) {
DLOG(ERROR) << "WebApp proto launch_url parse error: "
<< launch_url.possibly_invalid_spec();
// AppId is a hash of start_url. Read start_url first:
GURL start_url(sync_data.start_url());
if (start_url.is_empty() || !start_url.is_valid()) {
DLOG(ERROR) << "WebApp proto start_url parse error: "
<< start_url.possibly_invalid_spec();
return nullptr;
}
const AppId app_id = GenerateAppIdFromURL(launch_url);
const AppId app_id = GenerateAppIdFromURL(start_url);
auto web_app = std::make_unique<WebApp>(app_id);
web_app->SetLaunchUrl(launch_url);
web_app->SetLaunchUrl(start_url);
// Required fields:
if (!local_data.has_sources()) {
......
......@@ -157,8 +157,8 @@ class WebAppDatabaseTest : public WebAppTest {
RandomHelper random(seed);
const std::string seed_str = base::NumberToString(seed);
const auto launch_url = base_url + seed_str;
const AppId app_id = GenerateAppIdFromURL(GURL(launch_url));
const auto start_url = base_url + seed_str;
const AppId app_id = GenerateAppIdFromURL(GURL(start_url));
const std::string name = "Name" + seed_str;
const std::string description = "Description" + seed_str;
const std::string scope = base_url + "/scope" + seed_str;
......@@ -184,7 +184,7 @@ class WebAppDatabaseTest : public WebAppTest {
app->SetName(name);
app->SetDescription(description);
app->SetLaunchUrl(GURL(launch_url));
app->SetLaunchUrl(GURL(start_url));
app->SetScope(GURL(scope));
app->SetThemeColor(theme_color);
app->SetBackgroundColor(background_color);
......@@ -436,8 +436,8 @@ TEST_F(WebAppDatabaseTest, OpenDatabaseAndReadRegistry) {
}
TEST_F(WebAppDatabaseTest, BackwardCompatibility_WebAppWithOnlyRequiredFields) {
const GURL launch_url{"https://example.com/"};
const AppId app_id = GenerateAppIdFromURL(launch_url);
const GURL start_url{"https://example.com/"};
const AppId app_id = GenerateAppIdFromURL(start_url);
const std::string name = "App Name";
const auto user_display_mode = DisplayMode::kBrowser;
const bool is_locally_installed = true;
......@@ -449,7 +449,7 @@ TEST_F(WebAppDatabaseTest, BackwardCompatibility_WebAppWithOnlyRequiredFields) {
auto proto = std::make_unique<WebAppProto>();
{
sync_pb::WebAppSpecifics sync_proto;
sync_proto.set_launch_url(launch_url.spec());
sync_proto.set_start_url(start_url.spec());
sync_proto.set_user_display_mode(
ToWebAppSpecificsUserDisplayMode(user_display_mode));
*(proto->mutable_sync_data()) = std::move(sync_proto);
......@@ -480,7 +480,7 @@ TEST_F(WebAppDatabaseTest, BackwardCompatibility_WebAppWithOnlyRequiredFields) {
const WebApp* app = registrar().GetAppById(app_id);
EXPECT_EQ(app_id, app->app_id());
EXPECT_EQ(launch_url, app->launch_url());
EXPECT_EQ(start_url, app->launch_url());
EXPECT_EQ(name, app->name());
EXPECT_EQ(user_display_mode, app->user_display_mode());
EXPECT_EQ(is_locally_installed, app->is_locally_installed());
......@@ -500,15 +500,15 @@ TEST_F(WebAppDatabaseTest, BackwardCompatibility_WebAppWithOnlyRequiredFields) {
TEST_F(WebAppDatabaseTest, WebAppWithoutOptionalFields) {
controller().Init();
const auto launch_url = GURL("https://example.com/");
const AppId app_id = GenerateAppIdFromURL(GURL(launch_url));
const auto start_url = GURL("https://example.com/");
const AppId app_id = GenerateAppIdFromURL(GURL(start_url));
const std::string name = "Name";
const auto user_display_mode = DisplayMode::kBrowser;
auto app = std::make_unique<WebApp>(app_id);
// Required fields:
app->SetLaunchUrl(launch_url);
app->SetLaunchUrl(start_url);
app->SetName(name);
app->SetUserDisplayMode(user_display_mode);
app->SetIsLocallyInstalled(false);
......@@ -555,7 +555,7 @@ TEST_F(WebAppDatabaseTest, WebAppWithoutOptionalFields) {
// Required fields were serialized:
EXPECT_EQ(app_id, app_copy->app_id());
EXPECT_EQ(launch_url, app_copy->launch_url());
EXPECT_EQ(start_url, app_copy->launch_url());
EXPECT_EQ(name, app_copy->name());
EXPECT_EQ(user_display_mode, app_copy->user_display_mode());
EXPECT_FALSE(app_copy->is_locally_installed());
......
......@@ -79,7 +79,7 @@ base::Optional<std::vector<WebApplicationIconInfo>> ParseWebAppIconInfos(
sync_pb::WebAppSpecifics WebAppToSyncProto(const WebApp& app) {
sync_pb::WebAppSpecifics sync_proto;
sync_proto.set_launch_url(app.launch_url().spec());
sync_proto.set_start_url(app.launch_url().spec());
sync_proto.set_user_display_mode(
ToWebAppSpecificsUserDisplayMode(app.user_display_mode()));
sync_proto.set_name(app.sync_fallback_data().name);
......
......@@ -19,7 +19,7 @@ namespace {
using Purpose = blink::Manifest::ImageResource::Purpose;
const char kLaunchUrl[] = "https://example.com/launchurl";
const char kStartUrl[] = "https://example.com/launchurl";
const char kAppName[] = "Test name";
const char kScope[] = "https://example.com/scope";
const char kUserPageOrdinal[] = "fake_user_page_ordinal";
......@@ -32,7 +32,7 @@ const int kIconSizePx = 128;
// Test that a M85 serialized proto parses correctly in the current version.
TEST(WebAppProtoUtilsTest, M85SpecificsProtoParse) {
// Serialized in branch 4183 (M85) using:
// sync_proto.set_launch_url(kLaunchUrl);
// sync_proto.set_launch_url(kStartUrl);
// sync_proto.set_name(kAppName);
// sync_proto.set_user_display_mode(sync_pb::WebAppSpecifics::BROWSER);
// sync_pb::WebAppIconInfo* icon_info = sync_proto.add_icon_infos();
......@@ -52,7 +52,7 @@ TEST(WebAppProtoUtilsTest, M85SpecificsProtoParse) {
// Check the proto was parsed.
ASSERT_TRUE(parsed);
EXPECT_EQ(kLaunchUrl, sync_proto.launch_url());
EXPECT_EQ(kStartUrl, sync_proto.start_url());
EXPECT_EQ(kAppName, sync_proto.name());
EXPECT_EQ(sync_pb::WebAppSpecifics::BROWSER, sync_proto.user_display_mode());
......@@ -72,7 +72,7 @@ TEST(WebAppProtoUtilsTest, M85SpecificsProtoParse) {
TEST(WebAppProtoUtilsTest, M85SpecificsProtoToWebApp_Minimal) {
// Set the minimal proto fields.
sync_pb::WebAppSpecifics sync_proto;
sync_proto.set_launch_url(kLaunchUrl);
sync_proto.set_start_url(kStartUrl);
sync_proto.set_name(kAppName);
sync_proto.set_user_display_mode(sync_pb::WebAppSpecifics::BROWSER);
......@@ -91,7 +91,7 @@ TEST(WebAppProtoUtilsTest, M85SpecificsProtoToWebApp_Minimal) {
TEST(WebAppProtoUtilsTest, M85SpecificsProtoToWebApp_FullyPopulated) {
// Set all proto fields.
sync_pb::WebAppSpecifics sync_proto;
sync_proto.set_launch_url(kLaunchUrl);
sync_proto.set_start_url(kStartUrl);
sync_proto.set_name(kAppName);
sync_proto.set_user_display_mode(sync_pb::WebAppSpecifics::STANDALONE);
sync_proto.set_theme_color(SK_ColorRED);
......
......@@ -66,21 +66,21 @@ void ApplySyncDataToApp(const sync_pb::WebAppSpecifics& sync_data,
app->AddSource(Source::kSync);
// app_id is a hash of launch_url. Parse launch_url first:
GURL launch_url(sync_data.launch_url());
if (launch_url.is_empty() || !launch_url.is_valid()) {
DLOG(ERROR) << "ApplySyncDataToApp: launch_url parse error.";
GURL start_url(sync_data.start_url());
if (start_url.is_empty() || !start_url.is_valid()) {
DLOG(ERROR) << "ApplySyncDataToApp: start_url parse error.";
return;
}
if (app->app_id() != GenerateAppIdFromURL(launch_url)) {
DLOG(ERROR) << "ApplySyncDataToApp: app_id doesn't match launch_url.";
if (app->app_id() != GenerateAppIdFromURL(start_url)) {
DLOG(ERROR) << "ApplySyncDataToApp: app_id doesn't match start_url.";
return;
}
if (app->launch_url().is_empty()) {
app->SetLaunchUrl(std::move(launch_url));
} else if (app->launch_url() != launch_url) {
app->SetLaunchUrl(std::move(start_url));
} else if (app->launch_url() != start_url) {
DLOG(ERROR)
<< "ApplySyncDataToApp: existing launch_url doesn't match launch_url.";
<< "ApplySyncDataToApp: existing start_url doesn't match start_url.";
return;
}
......@@ -618,11 +618,11 @@ std::string WebAppSyncBridge::GetClientTag(
const syncer::EntityData& entity_data) {
DCHECK(entity_data.specifics.has_web_app());
const GURL launch_url(entity_data.specifics.web_app().launch_url());
DCHECK(!launch_url.is_empty());
DCHECK(launch_url.is_valid());
const GURL start_url(entity_data.specifics.web_app().start_url());
DCHECK(!start_url.is_empty());
DCHECK(start_url.is_valid());
return GenerateAppIdFromURL(launch_url);
return GenerateAppIdFromURL(start_url);
}
std::string WebAppSyncBridge::GetStorageKey(
......
......@@ -49,8 +49,8 @@ bool IsSyncDataEqualIfApplied(const WebApp& expected_app,
if (!entity_data.specifics.has_web_app())
return false;
const GURL sync_launch_url(entity_data.specifics.web_app().launch_url());
if (expected_app.app_id() != GenerateAppIdFromURL(sync_launch_url))
const GURL sync_start_url(entity_data.specifics.web_app().start_url());
if (expected_app.app_id() != GenerateAppIdFromURL(sync_start_url))
return false;
// ApplySyncDataToApp enforces kSync source on |app_to_apply_sync_data|.
......@@ -88,23 +88,23 @@ bool RegistryContainsSyncDataBatchChanges(
}
std::unique_ptr<WebApp> CreateWebApp(const std::string& url) {
const GURL launch_url(url);
const AppId app_id = GenerateAppIdFromURL(launch_url);
const GURL start_url(url);
const AppId app_id = GenerateAppIdFromURL(start_url);
auto web_app = std::make_unique<WebApp>(app_id);
web_app->SetLaunchUrl(launch_url);
web_app->SetLaunchUrl(start_url);
web_app->SetUserDisplayMode(DisplayMode::kStandalone);
web_app->SetName("Name");
return web_app;
}
std::unique_ptr<WebApp> CreateWebAppWithSyncOnlyFields(const std::string& url) {
const GURL launch_url(url);
const AppId app_id = GenerateAppIdFromURL(launch_url);
const GURL start_url(url);
const AppId app_id = GenerateAppIdFromURL(start_url);
auto web_app = std::make_unique<WebApp>(app_id);
web_app->AddSource(Source::kSync);
web_app->SetLaunchUrl(launch_url);
web_app->SetLaunchUrl(start_url);
web_app->SetName("Name");
web_app->SetUserDisplayMode(DisplayMode::kStandalone);
return web_app;
......
......@@ -1162,7 +1162,7 @@ VISIT_PROTO_FIELDS(const sync_pb::WalletSyncFlags& proto) {
}
VISIT_PROTO_FIELDS(const sync_pb::WebAppSpecifics& proto) {
VISIT(launch_url);
VISIT(start_url);
VISIT(name);
VISIT_ENUM(user_display_mode);
VISIT(theme_color);
......
......@@ -44,7 +44,7 @@ message WebAppSpecifics {
// FULLSCREEN is never serialized.
}
optional string launch_url = 1;
optional string start_url = 1;
optional string name = 2;
optional UserDisplayMode user_display_mode = 3;
optional uint32 theme_color = 4;
......
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