Skip to content

Commit

Permalink
Reland chromium#2 "Move manifest.mojom and content::Manifest to blink"
Browse files Browse the repository at this point in the history
This is a reland of c07726e

Original change's description:
> Move manifest.mojom and content::Manifest to blink
>
> ... as a part of Onion Soup project.
>
> This also required moving WebDisplayMode from public/platform
> to public/common since it's referenced both in manifest itself
> and, more generally, browser code.
>
> mojom::blink::Manifest is typemapped to blink::Manifest, which uses
> stl types and should be used by blink's embedder, not blink
> implementation.
>
> Bug: 704441
> Change-Id: I94d07bb028278f17d215f64c14552793d5f916ae
> Reviewed-on: https://chromium-review.googlesource.com/1006188
> Commit-Queue: Dmitry Gozman <dgozman@chromium.org>
> Reviewed-by: Daniel Cheng <dcheng@chromium.org>
> Reviewed-by: Reilly Grant <reillyg@chromium.org>
> Reviewed-by: Kentaro Hara <haraken@chromium.org>
> Reviewed-by: Mathieu Perreault <mathp@chromium.org>
> Reviewed-by: Mounir Lamouri <mlamouri@chromium.org>
> Reviewed-by: Mikel Astiz <mastiz@chromium.org>
> Reviewed-by: Scott Violet <sky@chromium.org>
> Reviewed-by: David Trainor <dtrainor@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#554953}

TBR=dgozman
NOPRESUBMIT=true

Bug: 704441
Change-Id: I3f2138335ea98710d2e8f6f06ab9fe9f3d561b96
Reviewed-on: https://chromium-review.googlesource.com/1040686
Commit-Queue: Dmitry Gozman <dgozman@chromium.org>
Reviewed-by: Daniel Cheng <dcheng@chromium.org>
Reviewed-by: Mounir Lamouri <mlamouri@chromium.org>
Reviewed-by: Dmitry Gozman <dgozman@chromium.org>
Reviewed-by: Kentaro Hara <haraken@chromium.org>
Cr-Commit-Position: refs/heads/master@{#556292}
  • Loading branch information
dgozman authored and Commit Bot committed May 5, 2018
1 parent bd3ce41 commit c5f1009
Show file tree
Hide file tree
Showing 122 changed files with 923 additions and 812 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public class ShortcutHelper {
// be correctly populated into the WebappRegistry/WebappDataStorage.
public static final int WEBAPP_SHORTCUT_VERSION = 2;

// This value is equal to kInvalidOrMissingColor in the C++ content::Manifest struct.
// This value is equal to kInvalidOrMissingColor in the C++ blink::Manifest struct.
public static final long MANIFEST_COLOR_INVALID_OR_MISSING = ((long) Integer.MAX_VALUE) + 1;

private static final String TAG = "ShortcutHelper";
Expand Down
1 change: 0 additions & 1 deletion chrome/browser/DEPS
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,6 @@ include_rules = [
"+third_party/blink/public/common",
"+third_party/blink/public/mojom",
"+third_party/blink/public/platform/web_cache.h",
"+third_party/blink/public/platform/web_display_mode.h",
"+third_party/blink/public/platform/web_loading_behavior_flag.h",
"+third_party/blink/public/platform/web_gesture_event.h",
"+third_party/blink/public/platform/web_input_event.h",
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/android/metrics/launch_metrics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include "components/rappor/rappor_service_impl.h"
#include "content/public/browser/web_contents.h"
#include "jni/LaunchMetrics_jni.h"
#include "third_party/blink/public/platform/web_display_mode.h"
#include "third_party/blink/public/common/manifest/web_display_mode.h"
#include "url/gurl.h"

using base::android::JavaParamRef;
Expand Down
6 changes: 3 additions & 3 deletions chrome/browser/android/shortcut_helper.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
#include "content/public/browser/manifest_icon_downloader.h"
#include "content/public/browser/manifest_icon_selector.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/manifest.h"
#include "jni/ShortcutHelper_jni.h"
#include "third_party/blink/public/common/manifest/manifest.h"
#include "ui/gfx/android/java_bitmap.h"
#include "ui/gfx/color_analysis.h"
#include "url/gurl.h"
Expand Down Expand Up @@ -138,7 +138,7 @@ void AddShortcutWithSkBitmap(const ShortcutInfo& info,
// static
std::unique_ptr<ShortcutInfo> ShortcutHelper::CreateShortcutInfo(
const GURL& manifest_url,
const content::Manifest& manifest,
const blink::Manifest& manifest,
const GURL& primary_icon_url,
const GURL& badge_icon_url) {
auto shortcut_info = std::make_unique<ShortcutInfo>(GURL());
Expand All @@ -156,7 +156,7 @@ std::unique_ptr<ShortcutInfo> ShortcutHelper::CreateShortcutInfo(
content::ManifestIconSelector::FindBestMatchingIcon(
manifest.icons, shortcut_info->ideal_splash_image_size_in_px,
shortcut_info->minimum_splash_image_size_in_px,
content::Manifest::Icon::IconPurpose::ANY);
blink::Manifest::Icon::IconPurpose::ANY);

return shortcut_info;
}
Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/android/shortcut_helper.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class ShortcutHelper {
// screen.
static std::unique_ptr<ShortcutInfo> CreateShortcutInfo(
const GURL& manifest_url,
const content::Manifest& manifest,
const blink::Manifest& manifest,
const GURL& primary_icon_url,
const GURL& badge_icon_url);

Expand Down
12 changes: 6 additions & 6 deletions chrome/browser/android/shortcut_info.cc
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ ShortcutInfo::ShortcutInfo(const GURL& shortcut_url)
display(blink::kWebDisplayModeBrowser),
orientation(blink::kWebScreenOrientationLockDefault),
source(SOURCE_ADD_TO_HOMESCREEN_SHORTCUT),
theme_color(content::Manifest::kInvalidOrMissingColor),
background_color(content::Manifest::kInvalidOrMissingColor),
theme_color(blink::Manifest::kInvalidOrMissingColor),
background_color(blink::Manifest::kInvalidOrMissingColor),
ideal_splash_image_size_in_px(0),
minimum_splash_image_size_in_px(0) {}

Expand All @@ -20,7 +20,7 @@ ShortcutInfo::ShortcutInfo(const ShortcutInfo& other) = default;
ShortcutInfo::~ShortcutInfo() {
}

void ShortcutInfo::UpdateFromManifest(const content::Manifest& manifest) {
void ShortcutInfo::UpdateFromManifest(const blink::Manifest& manifest) {
if (!manifest.short_name.string().empty() ||
!manifest.name.string().empty()) {
short_name = manifest.short_name.string();
Expand Down Expand Up @@ -57,11 +57,11 @@ void ShortcutInfo::UpdateFromManifest(const content::Manifest& manifest) {
}

// Set the theme color based on the manifest value, if any.
if (manifest.theme_color != content::Manifest::kInvalidOrMissingColor)
if (manifest.theme_color != blink::Manifest::kInvalidOrMissingColor)
theme_color = manifest.theme_color;

// Set the background color based on the manifest value, if any.
if (manifest.background_color != content::Manifest::kInvalidOrMissingColor)
if (manifest.background_color != blink::Manifest::kInvalidOrMissingColor)
background_color = manifest.background_color;

// Sets the URL of the HTML splash screen, if any.
Expand All @@ -70,7 +70,7 @@ void ShortcutInfo::UpdateFromManifest(const content::Manifest& manifest) {

// Set the icon urls based on the icons in the manifest, if any.
icon_urls.clear();
for (const content::Manifest::Icon& icon : manifest.icons)
for (const blink::Manifest::Icon& icon : manifest.icons)
icon_urls.push_back(icon.src.spec());

if (manifest.share_target)
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/android/shortcut_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#include <vector>

#include "base/strings/string16.h"
#include "content/public/common/manifest.h"
#include "third_party/blink/public/common/manifest/manifest.h"
#include "third_party/blink/public/common/screen_orientation/web_screen_orientation_lock_type.h"
#include "url/gurl.h"

Expand Down Expand Up @@ -71,7 +71,7 @@ struct ShortcutInfo {
~ShortcutInfo();

// Updates the info based on the given |manifest|.
void UpdateFromManifest(const content::Manifest& manifest);
void UpdateFromManifest(const blink::Manifest& manifest);

// Updates the source of the shortcut.
void UpdateSource(const Source source);
Expand Down
6 changes: 3 additions & 3 deletions chrome/browser/android/shortcut_info_unittest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@
#include "base/macros.h"
#include "base/strings/string16.h"
#include "base/strings/utf_string_conversions.h"
#include "content/public/common/manifest.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/common/manifest/manifest.h"
#include "url/gurl.h"

class ShortcutInfoTest : public testing::Test {
Expand All @@ -17,7 +17,7 @@ class ShortcutInfoTest : public testing::Test {

protected:
ShortcutInfo info_;
content::Manifest manifest_;
blink::Manifest manifest_;

DISALLOW_COPY_AND_ASSIGN(ShortcutInfoTest);
};
Expand Down Expand Up @@ -50,7 +50,7 @@ TEST_F(ShortcutInfoTest, AllAttributesUpdate) {
manifest_.splash_screen_url = GURL("https://new.com/splash.html");

info_.icon_urls.push_back("https://old.com/icon.png");
content::Manifest::Icon icon;
blink::Manifest::Icon icon;
icon.src = GURL("https://new.com/icon.png");
manifest_.icons.push_back(icon);

Expand Down
2 changes: 1 addition & 1 deletion chrome/browser/android/webapk/webapk_info.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include "base/macros.h"
#include "base/time/time.h"
#include "content/public/common/manifest.h"
#include "third_party/blink/public/common/manifest/manifest.h"
#include "third_party/blink/public/common/screen_orientation/web_screen_orientation_lock_type.h"

// Structure with information about a WebAPK.
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/android/webapk/webapk_installer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -118,10 +118,10 @@ GURL GetScope(const ShortcutInfo& info) {
: ShortcutHelper::GetScopeFromURL(info.url);
}

// Converts a color from the format specified in content::Manifest to a CSS
// Converts a color from the format specified in blink::Manifest to a CSS
// string.
std::string ColorToString(int64_t color) {
if (color == content::Manifest::kInvalidOrMissingColor)
if (color == blink::Manifest::kInvalidOrMissingColor)
return "";
SkColor sk_color = reinterpret_cast<uint32_t&>(color);
return color_utils::SkColorToRgbaString(sk_color);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@
#include "content/public/browser/browser_context.h"
#include "content/public/browser/storage_partition.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/manifest.h"
#include "jni/WebApkUpdateDataFetcher_jni.h"
#include "third_party/blink/public/common/manifest/manifest.h"
#include "third_party/smhasher/src/MurmurHash2.h"
#include "ui/gfx/android/java_bitmap.h"
#include "ui/gfx/codec/png_codec.h"
Expand Down
1 change: 0 additions & 1 deletion chrome/browser/android/webapk/webapk_update_data_fetcher.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
#include "third_party/skia/include/core/SkBitmap.h"

namespace content {
struct Manifest;
class WebContents;
}

Expand Down
6 changes: 3 additions & 3 deletions chrome/browser/android/webapk/webapk_web_manifest_checker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

#include "chrome/browser/android/webapk/webapk_web_manifest_checker.h"

#include "content/public/common/manifest.h"
#include "third_party/blink/public/common/manifest/manifest.h"
#include "url/gurl.h"

namespace {
Expand All @@ -19,8 +19,8 @@ bool IsUrlWebApkCompatible(const GURL& url) {

} // anonymous namespace

bool AreWebManifestUrlsWebApkCompatible(const content::Manifest& manifest) {
for (const content::Manifest::Icon& icon : manifest.icons) {
bool AreWebManifestUrlsWebApkCompatible(const blink::Manifest& manifest) {
for (const blink::Manifest::Icon& icon : manifest.icons) {
if (!IsUrlWebApkCompatible(icon.src))
return false;
}
Expand Down
4 changes: 2 additions & 2 deletions chrome/browser/android/webapk/webapk_web_manifest_checker.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
#ifndef CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_WEB_MANIFEST_CHECKER_H_
#define CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_WEB_MANIFEST_CHECKER_H_

namespace content {
namespace blink {
struct Manifest;
}

// Returns whether the format of the URLs in the Web Manifest is WebAPK
// compatible.
bool AreWebManifestUrlsWebApkCompatible(const content::Manifest& manifest);
bool AreWebManifestUrlsWebApkCompatible(const blink::Manifest& manifest);

#endif // CHROME_BROWSER_ANDROID_WEBAPK_WEBAPK_WEB_MANIFEST_CHECKER_H_
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@
#include "chrome/browser/android/webapk/webapk_web_manifest_checker.h"

#include "base/strings/utf_string_conversions.h"
#include "content/public/common/manifest.h"
#include "testing/gtest/include/gtest/gtest.h"
#include "third_party/blink/public/platform/web_display_mode.h"
#include "third_party/blink/public/common/manifest/manifest.h"
#include "third_party/blink/public/common/manifest/web_display_mode.h"
#include "url/gurl.h"

namespace {
Expand All @@ -16,14 +16,14 @@ base::NullableString16 ToNullableUTF16(const std::string& str) {
return base::NullableString16(base::UTF8ToUTF16(str), false);
}

content::Manifest GetValidManifest() {
content::Manifest manifest;
blink::Manifest GetValidManifest() {
blink::Manifest manifest;
manifest.name = ToNullableUTF16("foo");
manifest.short_name = ToNullableUTF16("bar");
manifest.start_url = GURL("http://example.com");
manifest.display = blink::kWebDisplayModeStandalone;

content::Manifest::Icon icon;
blink::Manifest::Icon icon;
icon.type = base::ASCIIToUTF16("image/png");
icon.sizes.push_back(gfx::Size(144, 144));
manifest.icons.push_back(icon);
Expand All @@ -34,14 +34,14 @@ content::Manifest GetValidManifest() {
} // anonymous namespace

TEST(WebApkWebManifestCheckerTest, Compatible) {
content::Manifest manifest = GetValidManifest();
blink::Manifest manifest = GetValidManifest();
EXPECT_TRUE(AreWebManifestUrlsWebApkCompatible(manifest));
}

TEST(WebApkWebManifestCheckerTest, CompatibleURLHasNoPassword) {
const GURL kUrlWithPassword("http://answer:42@life/universe/and/everything");

content::Manifest manifest = GetValidManifest();
blink::Manifest manifest = GetValidManifest();
manifest.start_url = kUrlWithPassword;
EXPECT_FALSE(AreWebManifestUrlsWebApkCompatible(manifest));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
#include "content/public/browser/manifest_icon_selector.h"
#include "content/public/browser/render_frame_host.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/manifest.h"
#include "third_party/blink/public/common/associated_interfaces/associated_interface_provider.h"
#include "third_party/blink/public/common/manifest/manifest.h"
#include "third_party/blink/public/common/screen_orientation/web_screen_orientation_lock_type.h"
#include "ui/gfx/codec/png_codec.h"
#include "ui/gfx/favicon_size.h"
Expand Down Expand Up @@ -241,7 +241,7 @@ void AddToHomescreenDataFetcher::OnDidGetManifestAndIcons(
content::ManifestIconSelector::FindBestMatchingIcon(
data.manifest->icons, shortcut_info_.ideal_splash_image_size_in_px,
shortcut_info_.minimum_splash_image_size_in_px,
content::Manifest::Icon::IconPurpose::ANY);
blink::Manifest::Icon::IconPurpose::ANY);
if (data.badge_icon) {
shortcut_info_.best_badge_icon_url = data.badge_icon_url;
badge_icon_ = *data.badge_icon;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
#include "chrome/test/base/chrome_render_view_host_test_harness.h"
#include "chrome/test/base/testing_profile.h"
#include "content/public/browser/web_contents.h"
#include "content/public/common/manifest.h"
#include "third_party/blink/public/platform/web_display_mode.h"
#include "third_party/blink/public/common/manifest/manifest.h"
#include "third_party/blink/public/common/manifest/web_display_mode.h"
#include "ui/gfx/image/image_unittest_util.h"
#include "url/gurl.h"

Expand Down Expand Up @@ -103,18 +103,18 @@ base::NullableString16 NullableStringFromUTF8(const std::string& value) {
return base::NullableString16(base::UTF8ToUTF16(value), false);
}

// Builds WebAPK compatible content::Manifest.
content::Manifest BuildDefaultManifest() {
content::Manifest manifest;
// Builds WebAPK compatible blink::Manifest.
blink::Manifest BuildDefaultManifest() {
blink::Manifest manifest;
manifest.name = NullableStringFromUTF8(kDefaultManifestName);
manifest.short_name = NullableStringFromUTF8(kDefaultManifestShortName);
manifest.start_url = GURL(kDefaultStartUrl);
manifest.display = kDefaultManifestDisplayMode;

content::Manifest::Icon primary_icon;
blink::Manifest::Icon primary_icon;
primary_icon.type = base::ASCIIToUTF16("image/png");
primary_icon.sizes.push_back(gfx::Size(144, 144));
primary_icon.purpose.push_back(content::Manifest::Icon::IconPurpose::ANY);
primary_icon.purpose.push_back(blink::Manifest::Icon::IconPurpose::ANY);
primary_icon.src = GURL(kDefaultIconUrl);
manifest.icons.push_back(primary_icon);

Expand Down Expand Up @@ -177,7 +177,7 @@ class TestInstallableManager : public InstallableManager {

void SetInstallable(bool is_installable) { is_installable_ = is_installable; }

void SetManifest(const content::Manifest& manifest) {
void SetManifest(const blink::Manifest& manifest) {
manifest_ = manifest;

if (!manifest.icons.empty()) {
Expand All @@ -202,7 +202,7 @@ class TestInstallableManager : public InstallableManager {
void ResolveQueuedMetrics() { std::move(queued_metrics_callback_).Run(); }

private:
content::Manifest manifest_;
blink::Manifest manifest_;
GURL primary_icon_url_;
GURL badge_icon_url_;
std::unique_ptr<SkBitmap> primary_icon_;
Expand Down Expand Up @@ -290,7 +290,7 @@ class AddToHomescreenDataFetcherTest : public ChromeRenderViewHostTestHarness {
histograms.ExpectTotalCount("Webapp.AddToHomescreenDialog.Timeout", 1);
}

void SetManifest(const content::Manifest& manifest) {
void SetManifest(const blink::Manifest& manifest) {
installable_manager_->SetManifest(manifest);
}

Expand Down Expand Up @@ -329,7 +329,7 @@ TEST_F(AddToHomescreenDataFetcherTest, EmptyManifest) {
TEST_F(AddToHomescreenDataFetcherTest, NoIconManifest) {
// Test a manifest with no icons. This should use the short name and have
// a generated icon (empty icon url).
content::Manifest manifest = BuildDefaultManifest();
blink::Manifest manifest = BuildDefaultManifest();
manifest.icons.clear();
SetManifest(manifest);

Expand Down Expand Up @@ -486,7 +486,7 @@ TEST_F(AddToHomescreenDataFetcherTest, ServiceWorkerCheckTimesOutUnknown) {

TEST_F(AddToHomescreenDataFetcherTest, InstallableManifest) {
// Test a site that has an offline-capable service worker.
content::Manifest manifest(BuildDefaultManifest());
blink::Manifest manifest(BuildDefaultManifest());
SetManifest(manifest);

base::HistogramTester histograms;
Expand All @@ -513,7 +513,7 @@ TEST_F(AddToHomescreenDataFetcherTest, ManifestNameClobbersWebApplicationName) {
// Manifest::short_name that Manifest::name is used as the title.
{
// Check the case where we have no icons.
content::Manifest manifest = BuildDefaultManifest();
blink::Manifest manifest = BuildDefaultManifest();
manifest.icons.clear();
manifest.short_name = base::NullableString16();
SetManifest(manifest);
Expand All @@ -528,7 +528,7 @@ TEST_F(AddToHomescreenDataFetcherTest, ManifestNameClobbersWebApplicationName) {
kDefaultManifestName));
}

content::Manifest manifest(BuildDefaultManifest());
blink::Manifest manifest(BuildDefaultManifest());
manifest.short_name = base::NullableString16();
SetManifest(manifest);

Expand Down Expand Up @@ -585,7 +585,7 @@ TEST_F(AddToHomescreenDataFetcherTest, ManifestNoNameNoShortName) {
// - The page is not WebAPK compatible.
// - WebApplicationInfo::title is used as the "name".
// - We still use the icons from the manifest.
content::Manifest manifest(BuildDefaultManifest());
blink::Manifest manifest(BuildDefaultManifest());
manifest.name = base::NullableString16();
manifest.short_name = base::NullableString16();

Expand Down
Loading

0 comments on commit c5f1009

Please sign in to comment.