Commit 093ae54f authored by John Lee's avatar John Lee Committed by Commit Bot

NTP, Navi: Add whitelist for onboarding NTP backgrounds

This is to support being able to set a NTP background without requiring
a network call to load collections and album photos.

Bug: 924176
Change-Id: Ie19043170e144fbf03e4b7f9dbcffcf106a2107b
Reviewed-on: https://chromium-review.googlesource.com/c/1449103
Commit-Queue: John Lee <johntlee@chromium.org>
Reviewed-by: default avatarKyle Milka <kmilka@chromium.org>
Cr-Commit-Position: refs/heads/master@{#628534}
parent 7ae0a3bc
......@@ -3008,6 +3008,8 @@ jumbo_split_static_library("browser") {
"search/background/ntp_background_service_factory.cc",
"search/background/ntp_background_service_factory.h",
"search/background/ntp_background_service_observer.h",
"search/background/onboarding_ntp_backgrounds.cc",
"search/background/onboarding_ntp_backgrounds.h",
"search/iframe_source.cc",
"search/iframe_source.h",
"search/instant_service.cc",
......
......@@ -9,6 +9,7 @@
#include "chrome/browser/browser_process.h"
#include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/browser/search/background/ntp_background.pb.h"
#include "chrome/browser/search/background/onboarding_ntp_backgrounds.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/browser_thread.h"
#include "net/base/load_flags.h"
......@@ -514,6 +515,12 @@ void NtpBackgroundService::RemoveObserver(
}
bool NtpBackgroundService::IsValidBackdropUrl(const GURL& url) const {
for (auto& onboarding_background : GetOnboardingNtpBackgrounds()) {
if (onboarding_background == url) {
return true;
}
}
for (auto& image : collection_images_) {
if (image.image_url == url)
return true;
......
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#include "chrome/browser/search/background/onboarding_ntp_backgrounds.h"
#include "url/gurl.h"
std::array<GURL, kOnboardingNtpBackgroundsCount> GetOnboardingNtpBackgrounds() {
// A set of whitelisted NTP background image URLs that are always considered
// to be valid URLs that are shown to the user as part of the Onboarding flow.
// These backgrounds were handpicked from the Backdrop API.
const std::array<GURL, kOnboardingNtpBackgroundsCount>
kOnboardingNtpBackgrounds = {
{// Art
GURL(
"https://lh4.googleusercontent.com/proxy/"
"rh9ut9biDoATqaadvgilbUAkIDo50op0G9056C1TnbfK5063_"
"M1OzTyOSfgbHbwcXzWz-UoM19yeObH2gXCX8wB8hVPbc_MXHBMfJWUmpg1Tg0s="
"w3840-h2160-p-k-no-nd-mv"),
// Landscape
GURL("https://lh6.googleusercontent.com/proxy/"
"5YUVHiA1x4KXBMvcnQ_"
"fNcsGFQig9vpKgEbH98vc3mIx6963Jawv4WtVMemvIEdCHGpo60iD8t0OfwnHu"
"5w"
"Y5InXTyqTPZx4a77T7iIFnHti=w3840-h2160-p-k-no-nd-mv"),
// Cityscape
GURL(
"https://lh6.googleusercontent.com/proxy/"
"Ym39mP3aRahUqQD_W1bks3MdDZx-Mea7_ajAs293LciDm70mFzpsswh_"
"QBJVFeUMWYF2jIQFvcBPeEdNAAwBlFNc2PsINAWHXe68Kg=w3840-h2160-p-k-"
"no-nd-mv"),
// Seascape
GURL("https://lh4.googleusercontent.com/proxy/"
"hl6qyPDq9FBOuU8G1A3X2khJJdAzfccHtIoX7hHtlkR4tgj_"
"WJvpj4s8FX8cb8u9R6xhrp96xXJIIFrTK8Rdpqh0tTiSfL5k_OXcWw=w3840-"
"h2160-p-k-no-nd-mv"),
// Geometric forms
GURL("https://lh5.googleusercontent.com/proxy/"
"Dm41Zdz8s5TnQcIRSCnAXUvHItsB67S7U3DytjCwsIpG9SmJKsVkkBRCK0ODme"
"vy"
"_M47-2CSAxGzFaiJM3bHaPfVT90Fm6lBbNd2yueqMg=w3840-h2160-p-k-no-"
"nd-mv")}};
return kOnboardingNtpBackgrounds;
}
// Copyright 2019 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_SEARCH_BACKGROUND_ONBOARDING_NTP_BACKGROUNDS_H_
#define CHROME_BROWSER_SEARCH_BACKGROUND_ONBOARDING_NTP_BACKGROUNDS_H_
#include <array>
#include "url/gurl.h"
const size_t kOnboardingNtpBackgroundsCount = 5;
std::array<GURL, kOnboardingNtpBackgroundsCount> GetOnboardingNtpBackgrounds();
#endif // CHROME_BROWSER_SEARCH_BACKGROUND_ONBOARDING_NTP_BACKGROUNDS_H_
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