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

Treat unknown web app UserDisplayModes as standalone

This CL follows protobuf enum best practices and adds "UNSPECIFIED = 0"
to UserDisplayMode.
https://developers.google.com/protocol-buffers/docs/style#enums

The behavioural change here is that old Chrome clients will interpret
new user display modes (e.g. hypothetically a tabbed window mode) from
the sync server as standalone window mode.
We a more likely to extend the set of window modes rather than browser
tab modes so this is a reasonable fallback.

Change-Id: Ibe989693a6b8fa6b826a0dd8107c5ec71aeb7544
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2377671
Commit-Queue: Alan Cutter <alancutter@chromium.org>
Reviewed-by: default avatarMarc Treib <treib@chromium.org>
Cr-Commit-Position: refs/heads/master@{#802170}
parent 1ef687cf
...@@ -604,6 +604,10 @@ DisplayMode ToMojomDisplayMode( ...@@ -604,6 +604,10 @@ DisplayMode ToMojomDisplayMode(
switch (user_display_mode) { switch (user_display_mode) {
case ::sync_pb::WebAppSpecifics::BROWSER: case ::sync_pb::WebAppSpecifics::BROWSER:
return DisplayMode::kBrowser; return DisplayMode::kBrowser;
// New display modes will most likely be of the window variety than the
// browser tab variety so default to windowed if it's an enum value we don't
// know about.
case ::sync_pb::WebAppSpecifics::UNSPECIFIED:
case ::sync_pb::WebAppSpecifics::STANDALONE: case ::sync_pb::WebAppSpecifics::STANDALONE:
return DisplayMode::kStandalone; return DisplayMode::kStandalone;
} }
......
...@@ -512,9 +512,10 @@ const char* ProtoEnumToString( ...@@ -512,9 +512,10 @@ const char* ProtoEnumToString(
const char* ProtoEnumToString( const char* ProtoEnumToString(
sync_pb::WebAppSpecifics::UserDisplayMode user_display_mode) { sync_pb::WebAppSpecifics::UserDisplayMode user_display_mode) {
ASSERT_ENUM_BOUNDS(sync_pb::WebAppSpecifics, UserDisplayMode, BROWSER, ASSERT_ENUM_BOUNDS(sync_pb::WebAppSpecifics, UserDisplayMode, UNSPECIFIED,
STANDALONE); STANDALONE);
switch (user_display_mode) { switch (user_display_mode) {
ENUM_CASE(sync_pb::WebAppSpecifics, UNSPECIFIED);
ENUM_CASE(sync_pb::WebAppSpecifics, BROWSER); ENUM_CASE(sync_pb::WebAppSpecifics, BROWSER);
ENUM_CASE(sync_pb::WebAppSpecifics, STANDALONE); ENUM_CASE(sync_pb::WebAppSpecifics, STANDALONE);
} }
......
...@@ -37,7 +37,7 @@ message WebAppSpecifics { ...@@ -37,7 +37,7 @@ message WebAppSpecifics {
// chrome/browser/web_applications/proto/web_app.proto and // chrome/browser/web_applications/proto/web_app.proto and
// third_party/blink/public/mojom/manifest/display_mode.mojom // third_party/blink/public/mojom/manifest/display_mode.mojom
enum UserDisplayMode { enum UserDisplayMode {
// UNDEFINED is never serialized. UNSPECIFIED = 0;
BROWSER = 1; BROWSER = 1;
// MINIMAL_UI is never serialized. // MINIMAL_UI is never serialized.
STANDALONE = 3; STANDALONE = 3;
......
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