Commit 172a7a2b authored by Alan Cutter's avatar Alan Cutter Committed by Commit Bot

dpwas: Don't add launch_query_params to start_url if they're already there

This CL updates how a web app's launch URL is computed given a
launch_query_params configuration. If the launch_query_params are
already present in the start_url then they are not appended a second
time.

Bug: 1142701
Change-Id: I394c8d96ee5e6a3776ed0c3555167b672b5e50b6
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2501107
Commit-Queue: Alan Cutter <alancutter@chromium.org>
Reviewed-by: default avatarGlen Robertson <glenrob@chromium.org>
Cr-Commit-Position: refs/heads/master@{#821638}
parent e5bc3603
...@@ -152,6 +152,11 @@ GURL AppRegistrar::GetAppLaunchUrl(const AppId& app_id) const { ...@@ -152,6 +152,11 @@ GURL AppRegistrar::GetAppLaunchUrl(const AppId& app_id) const {
return start_url.ReplaceComponents(replacements); return start_url.ReplaceComponents(replacements);
} }
if (start_url.query_piece().find(*launch_query_params) !=
base::StringPiece::npos) {
return start_url;
}
std::string query_params = start_url.query() + "&" + *launch_query_params; std::string query_params = start_url.query() + "&" + *launch_query_params;
replacements.SetQueryStr(query_params); replacements.SetQueryStr(query_params);
return start_url.ReplaceComponents(replacements); return start_url.ReplaceComponents(replacements);
......
...@@ -72,7 +72,12 @@ constexpr char kLaunchContainerTab[] = "tab"; ...@@ -72,7 +72,12 @@ constexpr char kLaunchContainerTab[] = "tab";
constexpr char kLaunchContainerWindow[] = "window"; constexpr char kLaunchContainerWindow[] = "window";
// kLaunchQueryParams is an optional string which specifies query parameters to // kLaunchQueryParams is an optional string which specifies query parameters to
// add to the start_url when launching the app. // add to the start_url when launching the app. If the provided params are a
// substring of start_url's existing params then it will not be added a second
// time.
// Note that substring matches include "param=a" matching in "some_param=abc".
// Extend the implementation in AppRegistrar::GetAppLaunchUrl() if this edge
// case needs to be handled differently.
constexpr char kLaunchQueryParams[] = "launch_query_params"; constexpr char kLaunchQueryParams[] = "launch_query_params";
// kLoadAndAwaitServiceWorkerRegistration is an optional bool that specifies // kLoadAndAwaitServiceWorkerRegistration is an optional bool that specifies
......
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