Commit 484d2441 authored by Miyoung Shin's avatar Miyoung Shin Committed by Commit Bot

Mark members as mandatory in manifest.mojom to match the web app manifest spec.

This is a follow-up CL for https://crrev.com/c/1597496 that updates
manifest.mojom to make the start_url, icons, related_applications,
splash_screen_url, and scope members non-optional in order to
follow the web app manifest spec
(https://www.w3.org/TR/appmanifest/#processing).

Bug: 704441
Change-Id: I92c6d8c220e05c9394d62a06ca4450191f1c552d
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1633695
Commit-Queue: Miyoung Shin <myid.shin@igalia.com>
Reviewed-by: default avatarKentaro Hara <haraken@chromium.org>
Reviewed-by: default avatarDominick Ng <dominickn@chromium.org>
Cr-Commit-Position: refs/heads/master@{#664499}
parent ab94a58b
...@@ -20,13 +20,13 @@ struct Manifest { ...@@ -20,13 +20,13 @@ struct Manifest {
mojo_base.mojom.String16? short_name; mojo_base.mojom.String16? short_name;
url.mojom.Url? start_url; url.mojom.Url start_url;
DisplayMode display; DisplayMode display;
device.mojom.ScreenOrientationLockType orientation; device.mojom.ScreenOrientationLockType orientation;
array<ManifestImageResource>? icons; array<ManifestImageResource> icons;
// TODO(constantina): This field is non-standard and part of a Chrome // TODO(constantina): This field is non-standard and part of a Chrome
// experiment. See: // experiment. See:
...@@ -40,7 +40,7 @@ struct Manifest { ...@@ -40,7 +40,7 @@ struct Manifest {
// As such, this field should not be exposed to the drive-by web. // As such, this field should not be exposed to the drive-by web.
ManifestFileHandler? file_handler; ManifestFileHandler? file_handler;
array<ManifestRelatedApplication>? related_applications; array<ManifestRelatedApplication> related_applications;
// A boolean that is used as a hint for the user agent to say that related // A boolean that is used as a hint for the user agent to say that related
// applications should be preferred over the web application. False if missing // applications should be preferred over the web application. False if missing
...@@ -56,11 +56,11 @@ struct Manifest { ...@@ -56,11 +56,11 @@ struct Manifest {
uint32 background_color; uint32 background_color;
// A URL of the HTML splash screen. // A URL of the HTML splash screen.
url.mojom.Url? splash_screen_url; url.mojom.Url splash_screen_url;
mojo_base.mojom.String16? gcm_sender_id; mojo_base.mojom.String16? gcm_sender_id;
url.mojom.Url? scope; url.mojom.Url scope;
}; };
// Structure representing an icon as per the Manifest specification, see: // Structure representing an icon as per the Manifest specification, see:
......
...@@ -63,16 +63,13 @@ void InstalledAppController::OnGetManifestForRelatedApps( ...@@ -63,16 +63,13 @@ void InstalledAppController::OnGetManifestForRelatedApps(
const KURL& /*url*/, const KURL& /*url*/,
mojom::blink::ManifestPtr manifest) { mojom::blink::ManifestPtr manifest) {
Vector<mojom::blink::RelatedApplicationPtr> mojo_related_apps; Vector<mojom::blink::RelatedApplicationPtr> mojo_related_apps;
if (manifest->related_applications.has_value()) { for (const auto& related_application : manifest->related_applications) {
for (const auto& related_application : *manifest->related_applications) { auto application = mojom::blink::RelatedApplication::New();
mojom::blink::RelatedApplicationPtr converted_application( application->platform = related_application->platform;
mojom::blink::RelatedApplication::New()); application->id = related_application->id;
converted_application->platform = related_application->platform;
converted_application->id = related_application->id;
if (related_application->url.has_value()) if (related_application->url.has_value())
converted_application->url = related_application->url->GetString(); application->url = related_application->url->GetString();
mojo_related_apps.push_back(std::move(converted_application)); mojo_related_apps.push_back(std::move(application));
}
} }
if (!provider_) { if (!provider_) {
......
...@@ -24,18 +24,6 @@ ...@@ -24,18 +24,6 @@
namespace blink { namespace blink {
namespace {
mojom::blink::ManifestPtr CreateEmptyManifest() {
auto manifest = mojom::blink::Manifest::New();
manifest->start_url = KURL();
manifest->splash_screen_url = KURL();
manifest->scope = KURL();
return manifest;
}
} // namespace
// static // static
const char ManifestManager::kSupplementName[] = "ManifestManager"; const char ManifestManager::kSupplementName[] = "ManifestManager";
...@@ -78,8 +66,8 @@ void ManifestManager::RequestManifest(RequestManifestCallback callback) { ...@@ -78,8 +66,8 @@ void ManifestManager::RequestManifest(RequestManifestCallback callback) {
[](RequestManifestCallback callback, const KURL& manifest_url, [](RequestManifestCallback callback, const KURL& manifest_url,
const mojom::blink::ManifestPtr& manifest, const mojom::blink::ManifestPtr& manifest,
const mojom::blink::ManifestDebugInfo* debug_info) { const mojom::blink::ManifestDebugInfo* debug_info) {
std::move(callback).Run(manifest_url, manifest.is_null() std::move(callback).Run(
? CreateEmptyManifest() manifest_url, manifest.is_null() ? mojom::blink::Manifest::New()
: manifest->Clone()); : manifest->Clone());
}, },
std::move(callback))); std::move(callback)));
......
...@@ -218,15 +218,13 @@ KURL ManifestParser::ParseStartURL(const JSONObject* object) { ...@@ -218,15 +218,13 @@ KURL ManifestParser::ParseStartURL(const JSONObject* object) {
} }
KURL ManifestParser::ParseScope(const JSONObject* object, KURL ManifestParser::ParseScope(const JSONObject* object,
base::Optional<KURL>& start_url) { const KURL& start_url) {
KURL scope = ParseURL(object, "scope", manifest_url_, KURL scope = ParseURL(object, "scope", manifest_url_,
ParseURLOriginRestrictions::kSameOriginOnly); ParseURLOriginRestrictions::kSameOriginOnly);
// This will change to remove the |document_url_| fallback in the future. // This will change to remove the |document_url_| fallback in the future.
// See https://github.com/w3c/manifest/issues/668. // See https://github.com/w3c/manifest/issues/668.
const KURL& default_value = (!start_url.has_value() || start_url->IsEmpty()) const KURL& default_value = start_url.IsEmpty() ? document_url_ : start_url;
? document_url_
: *start_url;
DCHECK(default_value.IsValid()); DCHECK(default_value.IsValid());
if (scope.IsEmpty()) if (scope.IsEmpty())
......
...@@ -97,7 +97,7 @@ class MODULES_EXPORT ManifestParser { ...@@ -97,7 +97,7 @@ class MODULES_EXPORT ManifestParser {
// https://w3c.github.io/manifest/#scope-member. Returns the parsed KURL if // https://w3c.github.io/manifest/#scope-member. Returns the parsed KURL if
// any, or start URL (falling back to document URL) without filename, path, // any, or start URL (falling back to document URL) without filename, path,
// and query if there is no defined scope or if the parsing failed. // and query if there is no defined scope or if the parsing failed.
KURL ParseScope(const JSONObject* object, base::Optional<KURL>& start_url); KURL ParseScope(const JSONObject* object, const KURL& start_url);
// Parses the 'start_url' field of the manifest, as defined in: // Parses the 'start_url' field of the manifest, as defined in:
// https://w3c.github.io/manifest/#dfn-steps-for-processing-the-start_url-member // https://w3c.github.io/manifest/#dfn-steps-for-processing-the-start_url-member
......
...@@ -98,14 +98,14 @@ TEST_F(ManifestParserTest, ValidNoContentParses) { ...@@ -98,14 +98,14 @@ TEST_F(ManifestParserTest, ValidNoContentParses) {
ASSERT_FALSE(IsManifestEmpty(manifest)); ASSERT_FALSE(IsManifestEmpty(manifest));
ASSERT_TRUE(manifest->name.IsNull()); ASSERT_TRUE(manifest->name.IsNull());
ASSERT_TRUE(manifest->short_name.IsNull()); ASSERT_TRUE(manifest->short_name.IsNull());
ASSERT_TRUE(manifest->start_url->IsEmpty()); ASSERT_TRUE(manifest->start_url.IsEmpty());
ASSERT_EQ(manifest->display, kWebDisplayModeUndefined); ASSERT_EQ(manifest->display, kWebDisplayModeUndefined);
ASSERT_EQ(manifest->orientation, kWebScreenOrientationLockDefault); ASSERT_EQ(manifest->orientation, kWebScreenOrientationLockDefault);
ASSERT_FALSE(manifest->has_theme_color); ASSERT_FALSE(manifest->has_theme_color);
ASSERT_FALSE(manifest->has_background_color); ASSERT_FALSE(manifest->has_background_color);
ASSERT_TRUE(manifest->splash_screen_url->IsEmpty()); ASSERT_TRUE(manifest->splash_screen_url.IsEmpty());
ASSERT_TRUE(manifest->gcm_sender_id.IsNull()); ASSERT_TRUE(manifest->gcm_sender_id.IsNull());
ASSERT_EQ(DefaultDocumentUrl().BaseAsString(), manifest->scope->GetString()); ASSERT_EQ(DefaultDocumentUrl().BaseAsString(), manifest->scope.GetString());
} }
TEST_F(ManifestParserTest, MultipleErrorsReporting) { TEST_F(ManifestParserTest, MultipleErrorsReporting) {
...@@ -219,7 +219,7 @@ TEST_F(ManifestParserTest, StartURLParseRules) { ...@@ -219,7 +219,7 @@ TEST_F(ManifestParserTest, StartURLParseRules) {
// Don't parse if property isn't a string. // Don't parse if property isn't a string.
{ {
auto& manifest = ParseManifest("{ \"start_url\": {} }"); auto& manifest = ParseManifest("{ \"start_url\": {} }");
ASSERT_TRUE(manifest->start_url->IsEmpty()); ASSERT_TRUE(manifest->start_url.IsEmpty());
EXPECT_EQ(1u, GetErrorCount()); EXPECT_EQ(1u, GetErrorCount());
EXPECT_EQ("property 'start_url' ignored, type string expected.", EXPECT_EQ("property 'start_url' ignored, type string expected.",
errors()[0]); errors()[0]);
...@@ -228,7 +228,7 @@ TEST_F(ManifestParserTest, StartURLParseRules) { ...@@ -228,7 +228,7 @@ TEST_F(ManifestParserTest, StartURLParseRules) {
// Don't parse if property isn't a string. // Don't parse if property isn't a string.
{ {
auto& manifest = ParseManifest("{ \"start_url\": 42 }"); auto& manifest = ParseManifest("{ \"start_url\": 42 }");
ASSERT_TRUE(manifest->start_url->IsEmpty()); ASSERT_TRUE(manifest->start_url.IsEmpty());
EXPECT_EQ(1u, GetErrorCount()); EXPECT_EQ(1u, GetErrorCount());
EXPECT_EQ("property 'start_url' ignored, type string expected.", EXPECT_EQ("property 'start_url' ignored, type string expected.",
errors()[0]); errors()[0]);
...@@ -238,7 +238,7 @@ TEST_F(ManifestParserTest, StartURLParseRules) { ...@@ -238,7 +238,7 @@ TEST_F(ManifestParserTest, StartURLParseRules) {
{ {
auto& manifest = auto& manifest =
ParseManifest("{ \"start_url\": \"http://www.google.ca:a\" }"); ParseManifest("{ \"start_url\": \"http://www.google.ca:a\" }");
ASSERT_TRUE(manifest->start_url->IsEmpty()); ASSERT_TRUE(manifest->start_url.IsEmpty());
EXPECT_EQ(1u, GetErrorCount()); EXPECT_EQ(1u, GetErrorCount());
EXPECT_EQ("property 'start_url' ignored, URL is invalid.", errors()[0]); EXPECT_EQ("property 'start_url' ignored, URL is invalid.", errors()[0]);
} }
...@@ -249,7 +249,7 @@ TEST_F(ManifestParserTest, StartURLParseRules) { ...@@ -249,7 +249,7 @@ TEST_F(ManifestParserTest, StartURLParseRules) {
ParseManifestWithURLs("{ \"start_url\": \"http://foo.com/land.html\" }", ParseManifestWithURLs("{ \"start_url\": \"http://foo.com/land.html\" }",
KURL("http://foo.com/manifest.json"), KURL("http://foo.com/manifest.json"),
KURL("http://foo.com/index.html")); KURL("http://foo.com/index.html"));
ASSERT_EQ(manifest->start_url->GetString(), "http://foo.com/land.html"); ASSERT_EQ(manifest->start_url.GetString(), "http://foo.com/land.html");
EXPECT_EQ(0u, GetErrorCount()); EXPECT_EQ(0u, GetErrorCount());
} }
...@@ -259,7 +259,7 @@ TEST_F(ManifestParserTest, StartURLParseRules) { ...@@ -259,7 +259,7 @@ TEST_F(ManifestParserTest, StartURLParseRules) {
ParseManifestWithURLs("{ \"start_url\": \"http://bar.com/land.html\" }", ParseManifestWithURLs("{ \"start_url\": \"http://bar.com/land.html\" }",
KURL("http://foo.com/manifest.json"), KURL("http://foo.com/manifest.json"),
KURL("http://foo.com/index.html")); KURL("http://foo.com/index.html"));
ASSERT_TRUE(manifest->start_url->IsEmpty()); ASSERT_TRUE(manifest->start_url.IsEmpty());
EXPECT_EQ(1u, GetErrorCount()); EXPECT_EQ(1u, GetErrorCount());
EXPECT_EQ( EXPECT_EQ(
"property 'start_url' ignored, should " "property 'start_url' ignored, should "
...@@ -273,7 +273,7 @@ TEST_F(ManifestParserTest, StartURLParseRules) { ...@@ -273,7 +273,7 @@ TEST_F(ManifestParserTest, StartURLParseRules) {
ParseManifestWithURLs("{ \"start_url\": \"land.html\" }", ParseManifestWithURLs("{ \"start_url\": \"land.html\" }",
KURL("http://foo.com/landing/manifest.json"), KURL("http://foo.com/landing/manifest.json"),
KURL("http://foo.com/index.html")); KURL("http://foo.com/index.html"));
ASSERT_EQ(manifest->start_url->GetString(), ASSERT_EQ(manifest->start_url.GetString(),
"http://foo.com/landing/land.html"); "http://foo.com/landing/land.html");
EXPECT_EQ(0u, GetErrorCount()); EXPECT_EQ(0u, GetErrorCount());
} }
...@@ -300,8 +300,7 @@ TEST_F(ManifestParserTest, ScopeParseRules) { ...@@ -300,8 +300,7 @@ TEST_F(ManifestParserTest, ScopeParseRules) {
// Return the default value if the property isn't a string. // Return the default value if the property isn't a string.
{ {
auto& manifest = ParseManifest("{ \"scope\": {} }"); auto& manifest = ParseManifest("{ \"scope\": {} }");
ASSERT_EQ(manifest->scope->GetString(), ASSERT_EQ(manifest->scope.GetString(), DefaultDocumentUrl().BaseAsString());
DefaultDocumentUrl().BaseAsString());
EXPECT_EQ(1u, GetErrorCount()); EXPECT_EQ(1u, GetErrorCount());
EXPECT_EQ("property 'scope' ignored, type string expected.", errors()[0]); EXPECT_EQ("property 'scope' ignored, type string expected.", errors()[0]);
} }
...@@ -323,7 +322,7 @@ TEST_F(ManifestParserTest, ScopeParseRules) { ...@@ -323,7 +322,7 @@ TEST_F(ManifestParserTest, ScopeParseRules) {
"\"start_url\": \"http://foo.com/land/landing.html\" }", "\"start_url\": \"http://foo.com/land/landing.html\" }",
KURL("http://foo.com/manifest.json"), KURL("http://foo.com/manifest.json"),
KURL("http://foo.com/index.html")); KURL("http://foo.com/index.html"));
ASSERT_EQ(manifest->scope->GetString(), "http://foo.com/land"); ASSERT_EQ(manifest->scope.GetString(), "http://foo.com/land");
EXPECT_EQ(0u, GetErrorCount()); EXPECT_EQ(0u, GetErrorCount());
} }
...@@ -334,8 +333,7 @@ TEST_F(ManifestParserTest, ScopeParseRules) { ...@@ -334,8 +333,7 @@ TEST_F(ManifestParserTest, ScopeParseRules) {
"\"start_url\": \"http://foo.com/index.html\" }", "\"start_url\": \"http://foo.com/index.html\" }",
KURL("http://foo.com/manifest.json"), KURL("http://foo.com/manifest.json"),
KURL("http://foo.com/index.html")); KURL("http://foo.com/index.html"));
ASSERT_EQ(manifest->scope->GetString(), ASSERT_EQ(manifest->scope.GetString(), DefaultDocumentUrl().BaseAsString());
DefaultDocumentUrl().BaseAsString());
EXPECT_EQ(1u, GetErrorCount()); EXPECT_EQ(1u, GetErrorCount());
EXPECT_EQ( EXPECT_EQ(
"property 'scope' ignored. Start url should be within scope " "property 'scope' ignored. Start url should be within scope "
...@@ -350,8 +348,7 @@ TEST_F(ManifestParserTest, ScopeParseRules) { ...@@ -350,8 +348,7 @@ TEST_F(ManifestParserTest, ScopeParseRules) {
"\"start_url\": \"http://bar.com/land/landing.html\" }", "\"start_url\": \"http://bar.com/land/landing.html\" }",
KURL("http://foo.com/manifest.json"), KURL("http://foo.com/manifest.json"),
KURL("http://foo.com/index.html")); KURL("http://foo.com/index.html"));
ASSERT_EQ(manifest->scope->GetString(), ASSERT_EQ(manifest->scope.GetString(), DefaultDocumentUrl().BaseAsString());
DefaultDocumentUrl().BaseAsString());
ASSERT_EQ(2u, GetErrorCount()); ASSERT_EQ(2u, GetErrorCount());
EXPECT_EQ( EXPECT_EQ(
"property 'start_url' ignored, should be same origin as document.", "property 'start_url' ignored, should be same origin as document.",
...@@ -369,7 +366,7 @@ TEST_F(ManifestParserTest, ScopeParseRules) { ...@@ -369,7 +366,7 @@ TEST_F(ManifestParserTest, ScopeParseRules) {
"{ \"scope\": \"http://foo.com/land\", " "{ \"scope\": \"http://foo.com/land\", "
"\"start_url\": \"http://foo.com/land/landing.html\" }", "\"start_url\": \"http://foo.com/land/landing.html\" }",
KURL("http://foo.com/manifest.json"), document_url); KURL("http://foo.com/manifest.json"), document_url);
ASSERT_EQ(manifest->scope->GetString(), document_url.BaseAsString()); ASSERT_EQ(manifest->scope.GetString(), document_url.BaseAsString());
ASSERT_EQ(2u, GetErrorCount()); ASSERT_EQ(2u, GetErrorCount());
EXPECT_EQ( EXPECT_EQ(
"property 'start_url' ignored, should be same origin as document.", "property 'start_url' ignored, should be same origin as document.",
...@@ -384,7 +381,7 @@ TEST_F(ManifestParserTest, ScopeParseRules) { ...@@ -384,7 +381,7 @@ TEST_F(ManifestParserTest, ScopeParseRules) {
ParseManifestWithURLs("{ \"scope\": \"http://foo.com/land\" }", ParseManifestWithURLs("{ \"scope\": \"http://foo.com/land\" }",
KURL("http://foo.com/manifest.json"), KURL("http://foo.com/manifest.json"),
KURL("http://foo.com/land/index.html")); KURL("http://foo.com/land/index.html"));
ASSERT_EQ(manifest->scope->GetString(), "http://foo.com/land"); ASSERT_EQ(manifest->scope.GetString(), "http://foo.com/land");
ASSERT_EQ(0u, GetErrorCount()); ASSERT_EQ(0u, GetErrorCount());
} }
...@@ -395,7 +392,7 @@ TEST_F(ManifestParserTest, ScopeParseRules) { ...@@ -395,7 +392,7 @@ TEST_F(ManifestParserTest, ScopeParseRules) {
ParseManifestWithURLs("{ \"scope\": \"http://foo.com/land\" }", ParseManifestWithURLs("{ \"scope\": \"http://foo.com/land\" }",
KURL("http://foo.com/manifest.json"), KURL("http://foo.com/manifest.json"),
KURL("http://foo.com/index.html")); KURL("http://foo.com/index.html"));
ASSERT_EQ(manifest->scope->GetString(), document_url.BaseAsString()); ASSERT_EQ(manifest->scope.GetString(), document_url.BaseAsString());
ASSERT_EQ(1u, GetErrorCount()); ASSERT_EQ(1u, GetErrorCount());
EXPECT_EQ( EXPECT_EQ(
"property 'scope' ignored. Start url should be within scope " "property 'scope' ignored. Start url should be within scope "
...@@ -408,7 +405,7 @@ TEST_F(ManifestParserTest, ScopeParseRules) { ...@@ -408,7 +405,7 @@ TEST_F(ManifestParserTest, ScopeParseRules) {
auto& manifest = ParseManifestWithURLs( auto& manifest = ParseManifestWithURLs(
"{ \"scope\": \"treasure\" }", KURL("http://foo.com/map/manifest.json"), "{ \"scope\": \"treasure\" }", KURL("http://foo.com/map/manifest.json"),
KURL("http://foo.com/map/treasure/island/index.html")); KURL("http://foo.com/map/treasure/island/index.html"));
ASSERT_EQ(manifest->scope->GetString(), "http://foo.com/map/treasure"); ASSERT_EQ(manifest->scope.GetString(), "http://foo.com/map/treasure");
EXPECT_EQ(0u, GetErrorCount()); EXPECT_EQ(0u, GetErrorCount());
} }
...@@ -417,7 +414,7 @@ TEST_F(ManifestParserTest, ScopeParseRules) { ...@@ -417,7 +414,7 @@ TEST_F(ManifestParserTest, ScopeParseRules) {
auto& manifest = ParseManifestWithURLs( auto& manifest = ParseManifestWithURLs(
"{ \"scope\": \"..\" }", KURL("http://foo.com/map/manifest.json"), "{ \"scope\": \"..\" }", KURL("http://foo.com/map/manifest.json"),
KURL("http://foo.com/index.html")); KURL("http://foo.com/index.html"));
ASSERT_EQ(manifest->scope->GetString(), "http://foo.com/"); ASSERT_EQ(manifest->scope.GetString(), "http://foo.com/");
EXPECT_EQ(0u, GetErrorCount()); EXPECT_EQ(0u, GetErrorCount());
} }
...@@ -426,7 +423,7 @@ TEST_F(ManifestParserTest, ScopeParseRules) { ...@@ -426,7 +423,7 @@ TEST_F(ManifestParserTest, ScopeParseRules) {
auto& manifest = ParseManifestWithURLs( auto& manifest = ParseManifestWithURLs(
"{ \"scope\": \"../..\" }", KURL("http://foo.com/map/manifest.json"), "{ \"scope\": \"../..\" }", KURL("http://foo.com/map/manifest.json"),
KURL("http://foo.com/index.html")); KURL("http://foo.com/index.html"));
ASSERT_EQ(manifest->scope->GetString(), "http://foo.com/"); ASSERT_EQ(manifest->scope.GetString(), "http://foo.com/");
EXPECT_EQ(0u, GetErrorCount()); EXPECT_EQ(0u, GetErrorCount());
} }
...@@ -649,30 +646,30 @@ TEST_F(ManifestParserTest, IconsParseRules) { ...@@ -649,30 +646,30 @@ TEST_F(ManifestParserTest, IconsParseRules) {
// Smoke test: if no icon, no value. // Smoke test: if no icon, no value.
{ {
auto& manifest = ParseManifest("{ \"icons\": [] }"); auto& manifest = ParseManifest("{ \"icons\": [] }");
EXPECT_TRUE(manifest->icons->IsEmpty()); EXPECT_TRUE(manifest->icons.IsEmpty());
EXPECT_EQ(0u, GetErrorCount()); EXPECT_EQ(0u, GetErrorCount());
} }
// Smoke test: if empty icon, no value. // Smoke test: if empty icon, no value.
{ {
auto& manifest = ParseManifest("{ \"icons\": [ {} ] }"); auto& manifest = ParseManifest("{ \"icons\": [ {} ] }");
EXPECT_TRUE(manifest->icons->IsEmpty()); EXPECT_TRUE(manifest->icons.IsEmpty());
EXPECT_EQ(0u, GetErrorCount()); EXPECT_EQ(0u, GetErrorCount());
} }
// Smoke test: icon with invalid src, no value. // Smoke test: icon with invalid src, no value.
{ {
auto& manifest = ParseManifest("{ \"icons\": [ { \"icons\": [] } ] }"); auto& manifest = ParseManifest("{ \"icons\": [ { \"icons\": [] } ] }");
EXPECT_TRUE(manifest->icons->IsEmpty()); EXPECT_TRUE(manifest->icons.IsEmpty());
EXPECT_EQ(0u, GetErrorCount()); EXPECT_EQ(0u, GetErrorCount());
} }
// Smoke test: if icon with empty src, it will be present in the list. // Smoke test: if icon with empty src, it will be present in the list.
{ {
auto& manifest = ParseManifest("{ \"icons\": [ { \"src\": \"\" } ] }"); auto& manifest = ParseManifest("{ \"icons\": [ { \"src\": \"\" } ] }");
EXPECT_TRUE(manifest->icons.has_value()); EXPECT_FALSE(manifest->icons.IsEmpty());
auto& icons = manifest->icons.value(); auto& icons = manifest->icons;
EXPECT_EQ(icons.size(), 1u); EXPECT_EQ(icons.size(), 1u);
EXPECT_EQ(icons[0]->src.GetString(), "http://foo.com/manifest.json"); EXPECT_EQ(icons[0]->src.GetString(), "http://foo.com/manifest.json");
EXPECT_FALSE(IsManifestEmpty(manifest)); EXPECT_FALSE(IsManifestEmpty(manifest));
...@@ -682,9 +679,9 @@ TEST_F(ManifestParserTest, IconsParseRules) { ...@@ -682,9 +679,9 @@ TEST_F(ManifestParserTest, IconsParseRules) {
// Smoke test: if one icons with valid src, it will be present in the list. // Smoke test: if one icons with valid src, it will be present in the list.
{ {
auto& manifest = ParseManifest("{ \"icons\": [{ \"src\": \"foo.jpg\" }] }"); auto& manifest = ParseManifest("{ \"icons\": [{ \"src\": \"foo.jpg\" }] }");
EXPECT_TRUE(manifest->icons.has_value()); EXPECT_FALSE(manifest->icons.IsEmpty());
auto& icons = manifest->icons.value(); auto& icons = manifest->icons;
EXPECT_EQ(icons.size(), 1u); EXPECT_EQ(icons.size(), 1u);
EXPECT_EQ(icons[0]->src.GetString(), "http://foo.com/foo.jpg"); EXPECT_EQ(icons[0]->src.GetString(), "http://foo.com/foo.jpg");
EXPECT_FALSE(IsManifestEmpty(manifest)); EXPECT_FALSE(IsManifestEmpty(manifest));
...@@ -697,9 +694,8 @@ TEST_F(ManifestParserTest, IconSrcParseRules) { ...@@ -697,9 +694,8 @@ TEST_F(ManifestParserTest, IconSrcParseRules) {
{ {
auto& manifest = auto& manifest =
ParseManifest("{ \"icons\": [ {\"src\": \"foo.png\" } ] }"); ParseManifest("{ \"icons\": [ {\"src\": \"foo.png\" } ] }");
EXPECT_TRUE(manifest->icons.has_value()); EXPECT_FALSE(manifest->icons.IsEmpty());
EXPECT_EQ(manifest->icons.value()[0]->src, EXPECT_EQ(manifest->icons[0]->src, KURL(DefaultDocumentUrl(), "foo.png"));
KURL(DefaultDocumentUrl(), "foo.png"));
EXPECT_EQ(0u, GetErrorCount()); EXPECT_EQ(0u, GetErrorCount());
} }
...@@ -707,16 +703,15 @@ TEST_F(ManifestParserTest, IconSrcParseRules) { ...@@ -707,16 +703,15 @@ TEST_F(ManifestParserTest, IconSrcParseRules) {
{ {
auto& manifest = auto& manifest =
ParseManifest("{ \"icons\": [ {\"src\": \" foo.png \" } ] }"); ParseManifest("{ \"icons\": [ {\"src\": \" foo.png \" } ] }");
EXPECT_TRUE(manifest->icons.has_value()); EXPECT_FALSE(manifest->icons.IsEmpty());
EXPECT_EQ(manifest->icons.value()[0]->src, EXPECT_EQ(manifest->icons[0]->src, KURL(DefaultDocumentUrl(), "foo.png"));
KURL(DefaultDocumentUrl(), "foo.png"));
EXPECT_EQ(0u, GetErrorCount()); EXPECT_EQ(0u, GetErrorCount());
} }
// Don't parse if property isn't a string. // Don't parse if property isn't a string.
{ {
auto& manifest = ParseManifest("{ \"icons\": [ {\"src\": {} } ] }"); auto& manifest = ParseManifest("{ \"icons\": [ {\"src\": {} } ] }");
EXPECT_TRUE(manifest->icons->IsEmpty()); EXPECT_TRUE(manifest->icons.IsEmpty());
EXPECT_EQ(1u, GetErrorCount()); EXPECT_EQ(1u, GetErrorCount());
EXPECT_EQ("property 'src' ignored, type string expected.", errors()[0]); EXPECT_EQ("property 'src' ignored, type string expected.", errors()[0]);
} }
...@@ -724,7 +719,7 @@ TEST_F(ManifestParserTest, IconSrcParseRules) { ...@@ -724,7 +719,7 @@ TEST_F(ManifestParserTest, IconSrcParseRules) {
// Don't parse if property isn't a string. // Don't parse if property isn't a string.
{ {
auto& manifest = ParseManifest("{ \"icons\": [ {\"src\": 42 } ] }"); auto& manifest = ParseManifest("{ \"icons\": [ {\"src\": 42 } ] }");
EXPECT_TRUE(manifest->icons->IsEmpty()); EXPECT_TRUE(manifest->icons.IsEmpty());
EXPECT_EQ(1u, GetErrorCount()); EXPECT_EQ(1u, GetErrorCount());
EXPECT_EQ("property 'src' ignored, type string expected.", errors()[0]); EXPECT_EQ("property 'src' ignored, type string expected.", errors()[0]);
} }
...@@ -734,8 +729,8 @@ TEST_F(ManifestParserTest, IconSrcParseRules) { ...@@ -734,8 +729,8 @@ TEST_F(ManifestParserTest, IconSrcParseRules) {
auto& manifest = ParseManifestWithURLs( auto& manifest = ParseManifestWithURLs(
"{ \"icons\": [ {\"src\": \"icons/foo.png\" } ] }", "{ \"icons\": [ {\"src\": \"icons/foo.png\" } ] }",
KURL("http://foo.com/landing/index.html"), DefaultManifestUrl()); KURL("http://foo.com/landing/index.html"), DefaultManifestUrl());
EXPECT_TRUE(manifest->icons.has_value()); EXPECT_FALSE(manifest->icons.IsEmpty());
EXPECT_EQ(manifest->icons.value()[0]->src.GetString(), EXPECT_EQ(manifest->icons[0]->src.GetString(),
"http://foo.com/landing/icons/foo.png"); "http://foo.com/landing/icons/foo.png");
EXPECT_EQ(0u, GetErrorCount()); EXPECT_EQ(0u, GetErrorCount());
} }
...@@ -746,8 +741,8 @@ TEST_F(ManifestParserTest, IconTypeParseRules) { ...@@ -746,8 +741,8 @@ TEST_F(ManifestParserTest, IconTypeParseRules) {
{ {
auto& manifest = auto& manifest =
ParseManifest("{ \"icons\": [ {\"src\": \"\", \"type\": \"foo\" } ] }"); ParseManifest("{ \"icons\": [ {\"src\": \"\", \"type\": \"foo\" } ] }");
EXPECT_TRUE(manifest->icons.has_value()); EXPECT_FALSE(manifest->icons.IsEmpty());
EXPECT_EQ(manifest->icons.value()[0]->type, "foo"); EXPECT_EQ(manifest->icons[0]->type, "foo");
EXPECT_EQ(0u, GetErrorCount()); EXPECT_EQ(0u, GetErrorCount());
} }
...@@ -756,8 +751,8 @@ TEST_F(ManifestParserTest, IconTypeParseRules) { ...@@ -756,8 +751,8 @@ TEST_F(ManifestParserTest, IconTypeParseRules) {
auto& manifest = ParseManifest( auto& manifest = ParseManifest(
"{ \"icons\": [ {\"src\": \"\"," "{ \"icons\": [ {\"src\": \"\","
" \"type\": \" foo \" } ] }"); " \"type\": \" foo \" } ] }");
EXPECT_TRUE(manifest->icons.has_value()); EXPECT_FALSE(manifest->icons.IsEmpty());
EXPECT_EQ(manifest->icons.value()[0]->type, "foo"); EXPECT_EQ(manifest->icons[0]->type, "foo");
EXPECT_EQ(0u, GetErrorCount()); EXPECT_EQ(0u, GetErrorCount());
} }
...@@ -765,8 +760,8 @@ TEST_F(ManifestParserTest, IconTypeParseRules) { ...@@ -765,8 +760,8 @@ TEST_F(ManifestParserTest, IconTypeParseRules) {
{ {
auto& manifest = auto& manifest =
ParseManifest("{ \"icons\": [ {\"src\": \"\", \"type\": {} } ] }"); ParseManifest("{ \"icons\": [ {\"src\": \"\", \"type\": {} } ] }");
EXPECT_TRUE(manifest->icons.has_value()); EXPECT_FALSE(manifest->icons.IsEmpty());
EXPECT_TRUE(manifest->icons.value()[0]->type.IsEmpty()); EXPECT_TRUE(manifest->icons[0]->type.IsEmpty());
EXPECT_EQ(1u, GetErrorCount()); EXPECT_EQ(1u, GetErrorCount());
EXPECT_EQ("property 'type' ignored, type string expected.", errors()[0]); EXPECT_EQ("property 'type' ignored, type string expected.", errors()[0]);
} }
...@@ -775,8 +770,8 @@ TEST_F(ManifestParserTest, IconTypeParseRules) { ...@@ -775,8 +770,8 @@ TEST_F(ManifestParserTest, IconTypeParseRules) {
{ {
auto& manifest = auto& manifest =
ParseManifest("{ \"icons\": [ {\"src\": \"\", \"type\": 42 } ] }"); ParseManifest("{ \"icons\": [ {\"src\": \"\", \"type\": 42 } ] }");
EXPECT_TRUE(manifest->icons.has_value()); EXPECT_FALSE(manifest->icons.IsEmpty());
EXPECT_TRUE(manifest->icons.value()[0]->type.IsEmpty()); EXPECT_TRUE(manifest->icons[0]->type.IsEmpty());
EXPECT_EQ(1u, GetErrorCount()); EXPECT_EQ(1u, GetErrorCount());
EXPECT_EQ("property 'type' ignored, type string expected.", errors()[0]); EXPECT_EQ("property 'type' ignored, type string expected.", errors()[0]);
} }
...@@ -788,8 +783,8 @@ TEST_F(ManifestParserTest, IconSizesParseRules) { ...@@ -788,8 +783,8 @@ TEST_F(ManifestParserTest, IconSizesParseRules) {
auto& manifest = ParseManifest( auto& manifest = ParseManifest(
"{ \"icons\": [ {\"src\": \"\"," "{ \"icons\": [ {\"src\": \"\","
"\"sizes\": \"42x42\" } ] }"); "\"sizes\": \"42x42\" } ] }");
EXPECT_TRUE(manifest->icons.has_value()); EXPECT_FALSE(manifest->icons.IsEmpty());
EXPECT_EQ(manifest->icons.value()[0]->sizes.size(), 1u); EXPECT_EQ(manifest->icons[0]->sizes.size(), 1u);
EXPECT_EQ(0u, GetErrorCount()); EXPECT_EQ(0u, GetErrorCount());
} }
...@@ -798,8 +793,8 @@ TEST_F(ManifestParserTest, IconSizesParseRules) { ...@@ -798,8 +793,8 @@ TEST_F(ManifestParserTest, IconSizesParseRules) {
auto& manifest = ParseManifest( auto& manifest = ParseManifest(
"{ \"icons\": [ {\"src\": \"\"," "{ \"icons\": [ {\"src\": \"\","
"\"sizes\": \" 42x42 \" } ] }"); "\"sizes\": \" 42x42 \" } ] }");
EXPECT_TRUE(manifest->icons.has_value()); EXPECT_FALSE(manifest->icons.IsEmpty());
EXPECT_EQ(manifest->icons.value()[0]->sizes.size(), 1u); EXPECT_EQ(manifest->icons[0]->sizes.size(), 1u);
EXPECT_EQ(0u, GetErrorCount()); EXPECT_EQ(0u, GetErrorCount());
} }
...@@ -808,8 +803,8 @@ TEST_F(ManifestParserTest, IconSizesParseRules) { ...@@ -808,8 +803,8 @@ TEST_F(ManifestParserTest, IconSizesParseRules) {
auto& manifest = ParseManifest( auto& manifest = ParseManifest(
"{ \"icons\": [ {\"src\": \"\"," "{ \"icons\": [ {\"src\": \"\","
"\"sizes\": {} } ] }"); "\"sizes\": {} } ] }");
EXPECT_TRUE(manifest->icons.has_value()); EXPECT_FALSE(manifest->icons.IsEmpty());
EXPECT_EQ(manifest->icons.value()[0]->sizes.size(), 0u); EXPECT_EQ(manifest->icons[0]->sizes.size(), 0u);
EXPECT_EQ(1u, GetErrorCount()); EXPECT_EQ(1u, GetErrorCount());
EXPECT_EQ("property 'sizes' ignored, type string expected.", errors()[0]); EXPECT_EQ("property 'sizes' ignored, type string expected.", errors()[0]);
} }
...@@ -819,8 +814,8 @@ TEST_F(ManifestParserTest, IconSizesParseRules) { ...@@ -819,8 +814,8 @@ TEST_F(ManifestParserTest, IconSizesParseRules) {
auto& manifest = ParseManifest( auto& manifest = ParseManifest(
"{ \"icons\": [ {\"src\": \"\"," "{ \"icons\": [ {\"src\": \"\","
"\"sizes\": 42 } ] }"); "\"sizes\": 42 } ] }");
EXPECT_TRUE(manifest->icons.has_value()); EXPECT_FALSE(manifest->icons.IsEmpty());
EXPECT_EQ(manifest->icons.value()[0]->sizes.size(), 0u); EXPECT_EQ(manifest->icons[0]->sizes.size(), 0u);
EXPECT_EQ(1u, GetErrorCount()); EXPECT_EQ(1u, GetErrorCount());
EXPECT_EQ("property 'sizes' ignored, type string expected.", errors()[0]); EXPECT_EQ("property 'sizes' ignored, type string expected.", errors()[0]);
} }
...@@ -830,9 +825,9 @@ TEST_F(ManifestParserTest, IconSizesParseRules) { ...@@ -830,9 +825,9 @@ TEST_F(ManifestParserTest, IconSizesParseRules) {
auto& manifest = ParseManifest( auto& manifest = ParseManifest(
"{ \"icons\": [ {\"src\": \"\"," "{ \"icons\": [ {\"src\": \"\","
"\"sizes\": \"42x42 48x48\" } ] }"); "\"sizes\": \"42x42 48x48\" } ] }");
EXPECT_TRUE(manifest->icons.has_value()); EXPECT_FALSE(manifest->icons.IsEmpty());
auto& icons = manifest->icons.value(); auto& icons = manifest->icons;
EXPECT_EQ(icons[0]->sizes[0], WebSize(42, 42)); EXPECT_EQ(icons[0]->sizes[0], WebSize(42, 42));
EXPECT_EQ(icons[0]->sizes[1], WebSize(48, 48)); EXPECT_EQ(icons[0]->sizes[1], WebSize(48, 48));
EXPECT_EQ(0u, GetErrorCount()); EXPECT_EQ(0u, GetErrorCount());
...@@ -843,9 +838,9 @@ TEST_F(ManifestParserTest, IconSizesParseRules) { ...@@ -843,9 +838,9 @@ TEST_F(ManifestParserTest, IconSizesParseRules) {
auto& manifest = ParseManifest( auto& manifest = ParseManifest(
"{ \"icons\": [ {\"src\": \"\"," "{ \"icons\": [ {\"src\": \"\","
"\"sizes\": \"42X42 48X48\" } ] }"); "\"sizes\": \"42X42 48X48\" } ] }");
EXPECT_TRUE(manifest->icons.has_value()); EXPECT_FALSE(manifest->icons.IsEmpty());
auto& icons = manifest->icons.value(); auto& icons = manifest->icons;
EXPECT_EQ(icons[0]->sizes[0], WebSize(42, 42)); EXPECT_EQ(icons[0]->sizes[0], WebSize(42, 42));
EXPECT_EQ(icons[0]->sizes[1], WebSize(48, 48)); EXPECT_EQ(icons[0]->sizes[1], WebSize(48, 48));
EXPECT_EQ(0u, GetErrorCount()); EXPECT_EQ(0u, GetErrorCount());
...@@ -856,9 +851,9 @@ TEST_F(ManifestParserTest, IconSizesParseRules) { ...@@ -856,9 +851,9 @@ TEST_F(ManifestParserTest, IconSizesParseRules) {
auto& manifest = ParseManifest( auto& manifest = ParseManifest(
"{ \"icons\": [ {\"src\": \"\"," "{ \"icons\": [ {\"src\": \"\","
"\"sizes\": \"42X42 42x42\" } ] }"); "\"sizes\": \"42X42 42x42\" } ] }");
EXPECT_TRUE(manifest->icons.has_value()); EXPECT_FALSE(manifest->icons.IsEmpty());
auto& icons = manifest->icons.value(); auto& icons = manifest->icons;
EXPECT_EQ(icons[0]->sizes[0], WebSize(42, 42)); EXPECT_EQ(icons[0]->sizes[0], WebSize(42, 42));
EXPECT_EQ(icons[0]->sizes[1], WebSize(42, 42)); EXPECT_EQ(icons[0]->sizes[1], WebSize(42, 42));
EXPECT_EQ(0u, GetErrorCount()); EXPECT_EQ(0u, GetErrorCount());
...@@ -869,8 +864,8 @@ TEST_F(ManifestParserTest, IconSizesParseRules) { ...@@ -869,8 +864,8 @@ TEST_F(ManifestParserTest, IconSizesParseRules) {
auto& manifest = ParseManifest( auto& manifest = ParseManifest(
"{ \"icons\": [ {\"src\": \"\"," "{ \"icons\": [ {\"src\": \"\","
"\"sizes\": \"004X007 042x00\" } ] }"); "\"sizes\": \"004X007 042x00\" } ] }");
EXPECT_TRUE(manifest->icons.has_value()); EXPECT_FALSE(manifest->icons.IsEmpty());
EXPECT_EQ(manifest->icons.value()[0]->sizes.size(), 0u); EXPECT_EQ(manifest->icons[0]->sizes.size(), 0u);
EXPECT_EQ(1u, GetErrorCount()); EXPECT_EQ(1u, GetErrorCount());
EXPECT_EQ("found icon with no valid size.", errors()[0]); EXPECT_EQ("found icon with no valid size.", errors()[0]);
} }
...@@ -880,8 +875,8 @@ TEST_F(ManifestParserTest, IconSizesParseRules) { ...@@ -880,8 +875,8 @@ TEST_F(ManifestParserTest, IconSizesParseRules) {
auto& manifest = ParseManifest( auto& manifest = ParseManifest(
"{ \"icons\": [ {\"src\": \"\"," "{ \"icons\": [ {\"src\": \"\","
"\"sizes\": \"e4X1.0 55ax1e10\" } ] }"); "\"sizes\": \"e4X1.0 55ax1e10\" } ] }");
EXPECT_TRUE(manifest->icons.has_value()); EXPECT_FALSE(manifest->icons.IsEmpty());
EXPECT_EQ(manifest->icons.value()[0]->sizes.size(), 0u); EXPECT_EQ(manifest->icons[0]->sizes.size(), 0u);
EXPECT_EQ(1u, GetErrorCount()); EXPECT_EQ(1u, GetErrorCount());
EXPECT_EQ("found icon with no valid size.", errors()[0]); EXPECT_EQ("found icon with no valid size.", errors()[0]);
} }
...@@ -892,9 +887,9 @@ TEST_F(ManifestParserTest, IconSizesParseRules) { ...@@ -892,9 +887,9 @@ TEST_F(ManifestParserTest, IconSizesParseRules) {
"{ \"icons\": [ {\"src\": \"\"," "{ \"icons\": [ {\"src\": \"\","
"\"sizes\": \"any AnY ANY aNy\" } ] }"); "\"sizes\": \"any AnY ANY aNy\" } ] }");
WebSize any = WebSize(0, 0); WebSize any = WebSize(0, 0);
EXPECT_TRUE(manifest->icons.has_value()); EXPECT_FALSE(manifest->icons.IsEmpty());
auto& icons = manifest->icons.value(); auto& icons = manifest->icons;
EXPECT_EQ(icons[0]->sizes.size(), 4u); EXPECT_EQ(icons[0]->sizes.size(), 4u);
EXPECT_EQ(icons[0]->sizes[0], any); EXPECT_EQ(icons[0]->sizes[0], any);
EXPECT_EQ(icons[0]->sizes[1], any); EXPECT_EQ(icons[0]->sizes[1], any);
...@@ -908,8 +903,8 @@ TEST_F(ManifestParserTest, IconSizesParseRules) { ...@@ -908,8 +903,8 @@ TEST_F(ManifestParserTest, IconSizesParseRules) {
auto& manifest = ParseManifest( auto& manifest = ParseManifest(
"{ \"icons\": [ {\"src\": \"\"," "{ \"icons\": [ {\"src\": \"\","
"\"sizes\": \"x 40xx 1x2x3 x42 42xx42\" } ] }"); "\"sizes\": \"x 40xx 1x2x3 x42 42xx42\" } ] }");
EXPECT_TRUE(manifest->icons.has_value()); EXPECT_FALSE(manifest->icons.IsEmpty());
EXPECT_EQ(manifest->icons.value()[0]->sizes.size(), 0u); EXPECT_EQ(manifest->icons[0]->sizes.size(), 0u);
EXPECT_EQ(1u, GetErrorCount()); EXPECT_EQ(1u, GetErrorCount());
EXPECT_EQ("found icon with no valid size.", errors()[0]); EXPECT_EQ("found icon with no valid size.", errors()[0]);
} }
...@@ -929,8 +924,8 @@ TEST_F(ManifestParserTest, IconPurposeParseRules) { ...@@ -929,8 +924,8 @@ TEST_F(ManifestParserTest, IconPurposeParseRules) {
auto& manifest = ParseManifest( auto& manifest = ParseManifest(
"{ \"icons\": [ {\"src\": \"\"," "{ \"icons\": [ {\"src\": \"\","
"\"purpose\": \"any\" } ] }"); "\"purpose\": \"any\" } ] }");
EXPECT_TRUE(manifest->icons.has_value()); EXPECT_FALSE(manifest->icons.IsEmpty());
EXPECT_EQ(manifest->icons.value()[0]->purpose.size(), 1u); EXPECT_EQ(manifest->icons[0]->purpose.size(), 1u);
EXPECT_EQ(0u, GetErrorCount()); EXPECT_EQ(0u, GetErrorCount());
} }
...@@ -939,17 +934,17 @@ TEST_F(ManifestParserTest, IconPurposeParseRules) { ...@@ -939,17 +934,17 @@ TEST_F(ManifestParserTest, IconPurposeParseRules) {
auto& manifest = ParseManifest( auto& manifest = ParseManifest(
"{ \"icons\": [ {\"src\": \"\"," "{ \"icons\": [ {\"src\": \"\","
"\"purpose\": \" any \" } ] }"); "\"purpose\": \" any \" } ] }");
EXPECT_TRUE(manifest->icons.has_value()); EXPECT_FALSE(manifest->icons.IsEmpty());
EXPECT_EQ(manifest->icons.value()[0]->purpose.size(), 1u); EXPECT_EQ(manifest->icons[0]->purpose.size(), 1u);
EXPECT_EQ(0u, GetErrorCount()); EXPECT_EQ(0u, GetErrorCount());
} }
// 'any' is added when property isn't present. // 'any' is added when property isn't present.
{ {
auto& manifest = ParseManifest("{ \"icons\": [ {\"src\": \"\" } ] }"); auto& manifest = ParseManifest("{ \"icons\": [ {\"src\": \"\" } ] }");
EXPECT_TRUE(manifest->icons.has_value()); EXPECT_FALSE(manifest->icons.IsEmpty());
auto& icons = manifest->icons.value(); auto& icons = manifest->icons;
EXPECT_EQ(icons[0]->purpose.size(), 1u); EXPECT_EQ(icons[0]->purpose.size(), 1u);
EXPECT_EQ(icons[0]->purpose[0], EXPECT_EQ(icons[0]->purpose[0],
mojom::blink::ManifestImageResource::Purpose::ANY); mojom::blink::ManifestImageResource::Purpose::ANY);
...@@ -962,9 +957,9 @@ TEST_F(ManifestParserTest, IconPurposeParseRules) { ...@@ -962,9 +957,9 @@ TEST_F(ManifestParserTest, IconPurposeParseRules) {
auto& manifest = ParseManifest( auto& manifest = ParseManifest(
"{ \"icons\": [ {\"src\": \"\"," "{ \"icons\": [ {\"src\": \"\","
"\"purpose\": 42 } ] }"); "\"purpose\": 42 } ] }");
EXPECT_TRUE(manifest->icons.has_value()); EXPECT_FALSE(manifest->icons.IsEmpty());
auto& icons = manifest->icons.value(); auto& icons = manifest->icons;
EXPECT_EQ(icons[0]->purpose.size(), 1u); EXPECT_EQ(icons[0]->purpose.size(), 1u);
EXPECT_EQ(icons[0]->purpose[0], EXPECT_EQ(icons[0]->purpose[0],
mojom::blink::ManifestImageResource::Purpose::ANY); mojom::blink::ManifestImageResource::Purpose::ANY);
...@@ -978,9 +973,9 @@ TEST_F(ManifestParserTest, IconPurposeParseRules) { ...@@ -978,9 +973,9 @@ TEST_F(ManifestParserTest, IconPurposeParseRules) {
auto& manifest = ParseManifest( auto& manifest = ParseManifest(
"{ \"icons\": [ {\"src\": \"\"," "{ \"icons\": [ {\"src\": \"\","
"\"purpose\": {} } ] }"); "\"purpose\": {} } ] }");
EXPECT_TRUE(manifest->icons.has_value()); EXPECT_FALSE(manifest->icons.IsEmpty());
auto& icons = manifest->icons.value(); auto& icons = manifest->icons;
EXPECT_EQ(icons[0]->purpose.size(), 1u); EXPECT_EQ(icons[0]->purpose.size(), 1u);
EXPECT_EQ(icons[0]->purpose[0], EXPECT_EQ(icons[0]->purpose[0],
mojom::blink::ManifestImageResource::Purpose::ANY); mojom::blink::ManifestImageResource::Purpose::ANY);
...@@ -993,9 +988,9 @@ TEST_F(ManifestParserTest, IconPurposeParseRules) { ...@@ -993,9 +988,9 @@ TEST_F(ManifestParserTest, IconPurposeParseRules) {
auto& manifest = ParseManifest( auto& manifest = ParseManifest(
"{ \"icons\": [ {\"src\": \"\"," "{ \"icons\": [ {\"src\": \"\","
"\"purpose\": \"Any Badge Maskable\" } ] }"); "\"purpose\": \"Any Badge Maskable\" } ] }");
EXPECT_TRUE(manifest->icons.has_value()); EXPECT_FALSE(manifest->icons.IsEmpty());
auto& icons = manifest->icons.value(); auto& icons = manifest->icons;
ASSERT_EQ(icons[0]->purpose.size(), 3u); ASSERT_EQ(icons[0]->purpose.size(), 3u);
EXPECT_EQ(icons[0]->purpose[0], EXPECT_EQ(icons[0]->purpose[0],
mojom::blink::ManifestImageResource::Purpose::ANY); mojom::blink::ManifestImageResource::Purpose::ANY);
...@@ -1011,9 +1006,9 @@ TEST_F(ManifestParserTest, IconPurposeParseRules) { ...@@ -1011,9 +1006,9 @@ TEST_F(ManifestParserTest, IconPurposeParseRules) {
auto& manifest = ParseManifest( auto& manifest = ParseManifest(
"{ \"icons\": [ {\"src\": \"\"," "{ \"icons\": [ {\"src\": \"\","
"\"purpose\": \" Any Badge \" } ] }"); "\"purpose\": \" Any Badge \" } ] }");
EXPECT_TRUE(manifest->icons.has_value()); EXPECT_FALSE(manifest->icons.IsEmpty());
auto& icons = manifest->icons.value(); auto& icons = manifest->icons;
ASSERT_EQ(icons[0]->purpose.size(), 2u); ASSERT_EQ(icons[0]->purpose.size(), 2u);
EXPECT_EQ(icons[0]->purpose[0], EXPECT_EQ(icons[0]->purpose[0],
mojom::blink::ManifestImageResource::Purpose::ANY); mojom::blink::ManifestImageResource::Purpose::ANY);
...@@ -1027,9 +1022,9 @@ TEST_F(ManifestParserTest, IconPurposeParseRules) { ...@@ -1027,9 +1022,9 @@ TEST_F(ManifestParserTest, IconPurposeParseRules) {
auto& manifest = ParseManifest( auto& manifest = ParseManifest(
"{ \"icons\": [ {\"src\": \"\"," "{ \"icons\": [ {\"src\": \"\","
"\"purpose\": \"badge badge\" } ] }"); "\"purpose\": \"badge badge\" } ] }");
EXPECT_TRUE(manifest->icons.has_value()); EXPECT_FALSE(manifest->icons.IsEmpty());
auto& icons = manifest->icons.value(); auto& icons = manifest->icons;
ASSERT_EQ(icons[0]->purpose.size(), 2u); ASSERT_EQ(icons[0]->purpose.size(), 2u);
EXPECT_EQ(icons[0]->purpose[0], EXPECT_EQ(icons[0]->purpose[0],
mojom::blink::ManifestImageResource::Purpose::BADGE); mojom::blink::ManifestImageResource::Purpose::BADGE);
...@@ -1043,9 +1038,9 @@ TEST_F(ManifestParserTest, IconPurposeParseRules) { ...@@ -1043,9 +1038,9 @@ TEST_F(ManifestParserTest, IconPurposeParseRules) {
auto& manifest = ParseManifest( auto& manifest = ParseManifest(
"{ \"icons\": [ {\"src\": \"\"," "{ \"icons\": [ {\"src\": \"\","
"\"purpose\": \"badge fizzbuzz\" } ] }"); "\"purpose\": \"badge fizzbuzz\" } ] }");
EXPECT_TRUE(manifest->icons.has_value()); EXPECT_FALSE(manifest->icons.IsEmpty());
auto& icons = manifest->icons.value(); auto& icons = manifest->icons;
ASSERT_EQ(icons[0]->purpose.size(), 1u); ASSERT_EQ(icons[0]->purpose.size(), 1u);
EXPECT_EQ(icons[0]->purpose[0], EXPECT_EQ(icons[0]->purpose[0],
mojom::blink::ManifestImageResource::Purpose::BADGE); mojom::blink::ManifestImageResource::Purpose::BADGE);
...@@ -1058,7 +1053,7 @@ TEST_F(ManifestParserTest, IconPurposeParseRules) { ...@@ -1058,7 +1053,7 @@ TEST_F(ManifestParserTest, IconPurposeParseRules) {
auto& manifest = ParseManifest( auto& manifest = ParseManifest(
"{ \"icons\": [ {\"src\": \"\"," "{ \"icons\": [ {\"src\": \"\","
"\"purpose\": \"fizzbuzz\" } ] }"); "\"purpose\": \"fizzbuzz\" } ] }");
ASSERT_TRUE(manifest->icons->IsEmpty()); ASSERT_TRUE(manifest->icons.IsEmpty());
ASSERT_EQ(1u, GetErrorCount()); ASSERT_EQ(1u, GetErrorCount());
EXPECT_EQ(kPurposeInvalidValueError, errors()[0]); EXPECT_EQ(kPurposeInvalidValueError, errors()[0]);
} }
...@@ -1068,9 +1063,9 @@ TEST_F(ManifestParserTest, IconPurposeParseRules) { ...@@ -1068,9 +1063,9 @@ TEST_F(ManifestParserTest, IconPurposeParseRules) {
auto& manifest = ParseManifest( auto& manifest = ParseManifest(
"{ \"icons\": [ {\"src\": \"\", \"purpose\": \"fizzbuzz\" }, " "{ \"icons\": [ {\"src\": \"\", \"purpose\": \"fizzbuzz\" }, "
" {\"src\": \"\" }] }"); " {\"src\": \"\" }] }");
EXPECT_TRUE(manifest->icons.has_value()); EXPECT_FALSE(manifest->icons.IsEmpty());
auto& icons = manifest->icons.value(); auto& icons = manifest->icons;
ASSERT_EQ(1u, icons.size()); ASSERT_EQ(1u, icons.size());
ASSERT_EQ(icons[0]->purpose.size(), 1u); ASSERT_EQ(icons[0]->purpose.size(), 1u);
EXPECT_EQ(icons[0]->purpose[0], EXPECT_EQ(icons[0]->purpose[0],
...@@ -2166,14 +2161,14 @@ TEST_F(ManifestParserTest, RelatedApplicationsParseRules) { ...@@ -2166,14 +2161,14 @@ TEST_F(ManifestParserTest, RelatedApplicationsParseRules) {
// If no application, empty list. // If no application, empty list.
{ {
auto& manifest = ParseManifest("{ \"related_applications\": []}"); auto& manifest = ParseManifest("{ \"related_applications\": []}");
EXPECT_TRUE(manifest->related_applications->IsEmpty()); EXPECT_TRUE(manifest->related_applications.IsEmpty());
EXPECT_EQ(0u, GetErrorCount()); EXPECT_EQ(0u, GetErrorCount());
} }
// If empty application, empty list. // If empty application, empty list.
{ {
auto& manifest = ParseManifest("{ \"related_applications\": [{}]}"); auto& manifest = ParseManifest("{ \"related_applications\": [{}]}");
EXPECT_TRUE(manifest->related_applications->IsEmpty()); EXPECT_TRUE(manifest->related_applications.IsEmpty());
EXPECT_EQ(1u, GetErrorCount()); EXPECT_EQ(1u, GetErrorCount());
EXPECT_EQ("'platform' is a required field, related application ignored.", EXPECT_EQ("'platform' is a required field, related application ignored.",
errors()[0]); errors()[0]);
...@@ -2183,7 +2178,7 @@ TEST_F(ManifestParserTest, RelatedApplicationsParseRules) { ...@@ -2183,7 +2178,7 @@ TEST_F(ManifestParserTest, RelatedApplicationsParseRules) {
{ {
auto& manifest = auto& manifest =
ParseManifest("{ \"related_applications\": [{\"platform\": 123}]}"); ParseManifest("{ \"related_applications\": [{\"platform\": 123}]}");
EXPECT_TRUE(manifest->related_applications->IsEmpty()); EXPECT_TRUE(manifest->related_applications.IsEmpty());
EXPECT_EQ(2u, GetErrorCount()); EXPECT_EQ(2u, GetErrorCount());
EXPECT_EQ("property 'platform' ignored, type string expected.", EXPECT_EQ("property 'platform' ignored, type string expected.",
errors()[0]); errors()[0]);
...@@ -2197,7 +2192,7 @@ TEST_F(ManifestParserTest, RelatedApplicationsParseRules) { ...@@ -2197,7 +2192,7 @@ TEST_F(ManifestParserTest, RelatedApplicationsParseRules) {
{ {
auto& manifest = auto& manifest =
ParseManifest("{ \"related_applications\": [{\"id\": \"foo\"}]}"); ParseManifest("{ \"related_applications\": [{\"id\": \"foo\"}]}");
EXPECT_TRUE(manifest->related_applications->IsEmpty()); EXPECT_TRUE(manifest->related_applications.IsEmpty());
EXPECT_EQ(1u, GetErrorCount()); EXPECT_EQ(1u, GetErrorCount());
EXPECT_EQ("'platform' is a required field, related application ignored.", EXPECT_EQ("'platform' is a required field, related application ignored.",
errors()[0]); errors()[0]);
...@@ -2207,7 +2202,7 @@ TEST_F(ManifestParserTest, RelatedApplicationsParseRules) { ...@@ -2207,7 +2202,7 @@ TEST_F(ManifestParserTest, RelatedApplicationsParseRules) {
{ {
auto& manifest = ParseManifest( auto& manifest = ParseManifest(
"{ \"related_applications\": [{\"platform\": \"play\"}]}"); "{ \"related_applications\": [{\"platform\": \"play\"}]}");
EXPECT_TRUE(manifest->related_applications->IsEmpty()); EXPECT_TRUE(manifest->related_applications.IsEmpty());
EXPECT_EQ(1u, GetErrorCount()); EXPECT_EQ(1u, GetErrorCount());
EXPECT_EQ("one of 'url' or 'id' is required, related application ignored.", EXPECT_EQ("one of 'url' or 'id' is required, related application ignored.",
errors()[0]); errors()[0]);
...@@ -2218,7 +2213,7 @@ TEST_F(ManifestParserTest, RelatedApplicationsParseRules) { ...@@ -2218,7 +2213,7 @@ TEST_F(ManifestParserTest, RelatedApplicationsParseRules) {
auto& manifest = ParseManifest( auto& manifest = ParseManifest(
"{ \"related_applications\": [" "{ \"related_applications\": ["
"{\"platform\": \"play\", \"url\": \"http://www.foo.com\"}]}"); "{\"platform\": \"play\", \"url\": \"http://www.foo.com\"}]}");
auto& related_applications = *manifest->related_applications; auto& related_applications = manifest->related_applications;
EXPECT_EQ(related_applications.size(), 1u); EXPECT_EQ(related_applications.size(), 1u);
EXPECT_EQ(related_applications[0]->platform, "play"); EXPECT_EQ(related_applications[0]->platform, "play");
EXPECT_TRUE(related_applications[0]->url.has_value()); EXPECT_TRUE(related_applications[0]->url.has_value());
...@@ -2232,7 +2227,7 @@ TEST_F(ManifestParserTest, RelatedApplicationsParseRules) { ...@@ -2232,7 +2227,7 @@ TEST_F(ManifestParserTest, RelatedApplicationsParseRules) {
auto& manifest = ParseManifest( auto& manifest = ParseManifest(
"{ \"related_applications\": [" "{ \"related_applications\": ["
"{\"platform\": \"play\", \"url\": \"http://www.foo.com:co&uk\"}]}"); "{\"platform\": \"play\", \"url\": \"http://www.foo.com:co&uk\"}]}");
EXPECT_TRUE(manifest->related_applications->IsEmpty()); EXPECT_TRUE(manifest->related_applications.IsEmpty());
EXPECT_EQ(2u, GetErrorCount()); EXPECT_EQ(2u, GetErrorCount());
EXPECT_EQ("property 'url' ignored, URL is invalid.", errors()[0]); EXPECT_EQ("property 'url' ignored, URL is invalid.", errors()[0]);
EXPECT_EQ("one of 'url' or 'id' is required, related application ignored.", EXPECT_EQ("one of 'url' or 'id' is required, related application ignored.",
...@@ -2244,7 +2239,7 @@ TEST_F(ManifestParserTest, RelatedApplicationsParseRules) { ...@@ -2244,7 +2239,7 @@ TEST_F(ManifestParserTest, RelatedApplicationsParseRules) {
auto& manifest = ParseManifest( auto& manifest = ParseManifest(
"{ \"related_applications\": [" "{ \"related_applications\": ["
"{\"platform\": \"itunes\", \"id\": \"foo\"}]}"); "{\"platform\": \"itunes\", \"id\": \"foo\"}]}");
auto& related_applications = *manifest->related_applications; auto& related_applications = manifest->related_applications;
EXPECT_EQ(related_applications.size(), 1u); EXPECT_EQ(related_applications.size(), 1u);
EXPECT_EQ(related_applications[0]->platform, "itunes"); EXPECT_EQ(related_applications[0]->platform, "itunes");
EXPECT_EQ(related_applications[0]->id, "foo"); EXPECT_EQ(related_applications[0]->id, "foo");
...@@ -2258,7 +2253,7 @@ TEST_F(ManifestParserTest, RelatedApplicationsParseRules) { ...@@ -2258,7 +2253,7 @@ TEST_F(ManifestParserTest, RelatedApplicationsParseRules) {
"{ \"related_applications\": [" "{ \"related_applications\": ["
"{\"platform\": \"play\", \"id\": \"foo\"}," "{\"platform\": \"play\", \"id\": \"foo\"},"
"{\"platform\": \"itunes\", \"id\": \"bar\"}]}"); "{\"platform\": \"itunes\", \"id\": \"bar\"}]}");
auto& related_applications = *manifest->related_applications; auto& related_applications = manifest->related_applications;
EXPECT_EQ(related_applications.size(), 2u); EXPECT_EQ(related_applications.size(), 2u);
EXPECT_EQ(related_applications[0]->platform, "play"); EXPECT_EQ(related_applications[0]->platform, "play");
EXPECT_EQ(related_applications[0]->id, "foo"); EXPECT_EQ(related_applications[0]->id, "foo");
...@@ -2276,7 +2271,7 @@ TEST_F(ManifestParserTest, RelatedApplicationsParseRules) { ...@@ -2276,7 +2271,7 @@ TEST_F(ManifestParserTest, RelatedApplicationsParseRules) {
"{\"platform\": \"itunes\"}," "{\"platform\": \"itunes\"},"
"{\"platform\": \"play\", \"id\": \"foo\"}," "{\"platform\": \"play\", \"id\": \"foo\"},"
"{}]}"); "{}]}");
auto& related_applications = *manifest->related_applications; auto& related_applications = manifest->related_applications;
EXPECT_EQ(related_applications.size(), 1u); EXPECT_EQ(related_applications.size(), 1u);
EXPECT_EQ(related_applications[0]->platform, "play"); EXPECT_EQ(related_applications[0]->platform, "play");
EXPECT_EQ(related_applications[0]->id, "foo"); EXPECT_EQ(related_applications[0]->id, "foo");
...@@ -2698,7 +2693,7 @@ TEST_F(ManifestParserTest, SplashScreenUrlParseRules) { ...@@ -2698,7 +2693,7 @@ TEST_F(ManifestParserTest, SplashScreenUrlParseRules) {
// Don't parse if property isn't a string. // Don't parse if property isn't a string.
{ {
auto& manifest = ParseManifest("{ \"splash_screen_url\": {} }"); auto& manifest = ParseManifest("{ \"splash_screen_url\": {} }");
ASSERT_TRUE(manifest->splash_screen_url->IsEmpty()); ASSERT_TRUE(manifest->splash_screen_url.IsEmpty());
EXPECT_EQ(1u, GetErrorCount()); EXPECT_EQ(1u, GetErrorCount());
EXPECT_EQ("property 'splash_screen_url' ignored, type string expected.", EXPECT_EQ("property 'splash_screen_url' ignored, type string expected.",
errors()[0]); errors()[0]);
...@@ -2707,7 +2702,7 @@ TEST_F(ManifestParserTest, SplashScreenUrlParseRules) { ...@@ -2707,7 +2702,7 @@ TEST_F(ManifestParserTest, SplashScreenUrlParseRules) {
// Don't parse if property isn't a string. // Don't parse if property isn't a string.
{ {
auto& manifest = ParseManifest("{ \"splash_screen_url\": 42 }"); auto& manifest = ParseManifest("{ \"splash_screen_url\": 42 }");
ASSERT_TRUE(manifest->splash_screen_url->IsEmpty()); ASSERT_TRUE(manifest->splash_screen_url.IsEmpty());
EXPECT_EQ(1u, GetErrorCount()); EXPECT_EQ(1u, GetErrorCount());
EXPECT_EQ("property 'splash_screen_url' ignored, type string expected.", EXPECT_EQ("property 'splash_screen_url' ignored, type string expected.",
errors()[0]); errors()[0]);
...@@ -2717,7 +2712,7 @@ TEST_F(ManifestParserTest, SplashScreenUrlParseRules) { ...@@ -2717,7 +2712,7 @@ TEST_F(ManifestParserTest, SplashScreenUrlParseRules) {
{ {
auto& manifest = auto& manifest =
ParseManifest("{ \"splash_screen_url\": \"http://www.google.ca:a\" }"); ParseManifest("{ \"splash_screen_url\": \"http://www.google.ca:a\" }");
ASSERT_TRUE(manifest->splash_screen_url->IsEmpty()); ASSERT_TRUE(manifest->splash_screen_url.IsEmpty());
EXPECT_EQ(1u, GetErrorCount()); EXPECT_EQ(1u, GetErrorCount());
EXPECT_EQ("property 'splash_screen_url' ignored, URL is invalid.", EXPECT_EQ("property 'splash_screen_url' ignored, URL is invalid.",
errors()[0]); errors()[0]);
...@@ -2729,7 +2724,7 @@ TEST_F(ManifestParserTest, SplashScreenUrlParseRules) { ...@@ -2729,7 +2724,7 @@ TEST_F(ManifestParserTest, SplashScreenUrlParseRules) {
"{ \"splash_screen_url\": \"http://foo.com/splash.html\" }", "{ \"splash_screen_url\": \"http://foo.com/splash.html\" }",
KURL("http://foo.com/manifest.json"), KURL("http://foo.com/manifest.json"),
KURL("http://foo.com/index.html")); KURL("http://foo.com/index.html"));
ASSERT_EQ(manifest->splash_screen_url->GetString(), ASSERT_EQ(manifest->splash_screen_url.GetString(),
"http://foo.com/splash.html"); "http://foo.com/splash.html");
EXPECT_EQ(0u, GetErrorCount()); EXPECT_EQ(0u, GetErrorCount());
} }
...@@ -2740,7 +2735,7 @@ TEST_F(ManifestParserTest, SplashScreenUrlParseRules) { ...@@ -2740,7 +2735,7 @@ TEST_F(ManifestParserTest, SplashScreenUrlParseRules) {
"{ \"splash_screen_url\": \"http://bar.com/splash.html\" }", "{ \"splash_screen_url\": \"http://bar.com/splash.html\" }",
KURL("http://foo.com/manifest.json"), KURL("http://foo.com/manifest.json"),
KURL("http://foo.com/index.html")); KURL("http://foo.com/index.html"));
ASSERT_TRUE(manifest->splash_screen_url->IsEmpty()); ASSERT_TRUE(manifest->splash_screen_url.IsEmpty());
EXPECT_EQ(1u, GetErrorCount()); EXPECT_EQ(1u, GetErrorCount());
EXPECT_EQ( EXPECT_EQ(
"property 'splash_screen_url' ignored, should " "property 'splash_screen_url' ignored, should "
...@@ -2754,7 +2749,7 @@ TEST_F(ManifestParserTest, SplashScreenUrlParseRules) { ...@@ -2754,7 +2749,7 @@ TEST_F(ManifestParserTest, SplashScreenUrlParseRules) {
ParseManifestWithURLs("{ \"splash_screen_url\": \"splash.html\" }", ParseManifestWithURLs("{ \"splash_screen_url\": \"splash.html\" }",
KURL("http://foo.com/splashy/manifest.json"), KURL("http://foo.com/splashy/manifest.json"),
KURL("http://foo.com/index.html")); KURL("http://foo.com/index.html"));
ASSERT_EQ(manifest->splash_screen_url->GetString(), ASSERT_EQ(manifest->splash_screen_url.GetString(),
"http://foo.com/splashy/splash.html"); "http://foo.com/splashy/splash.html");
EXPECT_EQ(0u, GetErrorCount()); EXPECT_EQ(0u, GetErrorCount());
} }
......
...@@ -31,16 +31,14 @@ TypeConverter<blink::Manifest, blink::mojom::blink::ManifestPtr>::Convert( ...@@ -31,16 +31,14 @@ TypeConverter<blink::Manifest, blink::mojom::blink::ManifestPtr>::Convert(
base::NullableString16(blink::WebString(input->short_name).Utf16()); base::NullableString16(blink::WebString(input->short_name).Utf16());
} }
if (input->start_url.has_value()) if (!input->start_url.IsEmpty())
output.start_url = *input->start_url; output.start_url = input->start_url;
output.display = input->display; output.display = input->display;
output.orientation = input->orientation; output.orientation = input->orientation;
if (input->icons.has_value()) { for (auto& icon : input->icons)
for (auto& icon : *input->icons)
output.icons.push_back(icon.To<blink::Manifest::ImageResource>()); output.icons.push_back(icon.To<blink::Manifest::ImageResource>());
}
if (!input->share_target.is_null()) { if (!input->share_target.is_null()) {
output.share_target = output.share_target =
...@@ -55,12 +53,10 @@ TypeConverter<blink::Manifest, blink::mojom::blink::ManifestPtr>::Convert( ...@@ -55,12 +53,10 @@ TypeConverter<blink::Manifest, blink::mojom::blink::ManifestPtr>::Convert(
output.file_handler = std::move(file_handler); output.file_handler = std::move(file_handler);
} }
if (input->related_applications.has_value()) { for (auto& related_application : input->related_applications) {
for (auto& related_application : *input->related_applications) {
output.related_applications.push_back( output.related_applications.push_back(
related_application.To<blink::Manifest::RelatedApplication>()); related_application.To<blink::Manifest::RelatedApplication>());
} }
}
output.prefer_related_applications = input->prefer_related_applications; output.prefer_related_applications = input->prefer_related_applications;
...@@ -70,16 +66,16 @@ TypeConverter<blink::Manifest, blink::mojom::blink::ManifestPtr>::Convert( ...@@ -70,16 +66,16 @@ TypeConverter<blink::Manifest, blink::mojom::blink::ManifestPtr>::Convert(
if (input->has_background_color) if (input->has_background_color)
output.background_color = input->background_color; output.background_color = input->background_color;
if (input->splash_screen_url.has_value()) if (!input->splash_screen_url.IsEmpty())
output.splash_screen_url = *input->splash_screen_url; output.splash_screen_url = input->splash_screen_url;
if (!input->gcm_sender_id.IsEmpty()) { if (!input->gcm_sender_id.IsEmpty()) {
output.gcm_sender_id = output.gcm_sender_id =
base::NullableString16(blink::WebString(input->gcm_sender_id).Utf16()); base::NullableString16(blink::WebString(input->gcm_sender_id).Utf16());
} }
if (input->scope.has_value()) if (!input->scope.IsEmpty())
output.scope = *input->scope; output.scope = input->scope;
return output; return output;
} }
......
...@@ -41,14 +41,14 @@ void ManifestUmaUtil::ParseSucceeded( ...@@ -41,14 +41,14 @@ void ManifestUmaUtil::ParseSucceeded(
UMA_HISTOGRAM_BOOLEAN("Manifest.HasProperty.short_name", UMA_HISTOGRAM_BOOLEAN("Manifest.HasProperty.short_name",
!manifest->short_name.IsEmpty()); !manifest->short_name.IsEmpty());
UMA_HISTOGRAM_BOOLEAN("Manifest.HasProperty.start_url", UMA_HISTOGRAM_BOOLEAN("Manifest.HasProperty.start_url",
!manifest->start_url->IsEmpty()); !manifest->start_url.IsEmpty());
UMA_HISTOGRAM_BOOLEAN("Manifest.HasProperty.display", UMA_HISTOGRAM_BOOLEAN("Manifest.HasProperty.display",
manifest->display != kWebDisplayModeUndefined); manifest->display != kWebDisplayModeUndefined);
UMA_HISTOGRAM_BOOLEAN( UMA_HISTOGRAM_BOOLEAN(
"Manifest.HasProperty.orientation", "Manifest.HasProperty.orientation",
manifest->orientation != kWebScreenOrientationLockDefault); manifest->orientation != kWebScreenOrientationLockDefault);
UMA_HISTOGRAM_BOOLEAN("Manifest.HasProperty.icons", UMA_HISTOGRAM_BOOLEAN("Manifest.HasProperty.icons",
manifest->icons.has_value()); !manifest->icons.IsEmpty());
UMA_HISTOGRAM_BOOLEAN("Manifest.HasProperty.share_target", UMA_HISTOGRAM_BOOLEAN("Manifest.HasProperty.share_target",
manifest->share_target.get()); manifest->share_target.get());
UMA_HISTOGRAM_BOOLEAN("Manifest.HasProperty.gcm_sender_id", UMA_HISTOGRAM_BOOLEAN("Manifest.HasProperty.gcm_sender_id",
......
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