Commit c1928d6b authored by Wenzhao Zang's avatar Wenzhao Zang Committed by Commit Bot

cros: Create flag to allow QA to get access to the Backdrop test server

Bug: 914144
Change-Id: Iaa3ef0883ed373d30ddfb2d65e5822a3b1bfcab5
Reviewed-on: https://chromium-review.googlesource.com/c/1372361
Commit-Queue: Wenzhao (Colin) Zang <wzang@chromium.org>
Reviewed-by: default avatarAlexander Alekseev <alemate@chromium.org>
Cr-Commit-Position: refs/heads/master@{#615776}
parent 168680a0
......@@ -4,10 +4,13 @@
#include "chrome/browser/chromeos/extensions/backdrop_wallpaper_handlers/backdrop_wallpaper_handlers.h"
#include "base/command_line.h"
#include "base/strings/string_util.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/chromeos/extensions/backdrop_wallpaper_handlers/backdrop_wallpaper.pb.h"
#include "chrome/browser/net/system_network_context_manager.h"
#include "chrome/common/extensions/api/wallpaper_private.h"
#include "chromeos/chromeos_switches.h"
#include "content/public/browser/browser_thread.h"
#include "net/base/load_flags.h"
#include "url/gurl.h"
......@@ -35,6 +38,17 @@ constexpr char kBackdropSurpriseMeImageUrl[] =
// The label used to return exclusive content or filter unwanted images.
constexpr char kFilteringLabel[] = "chromebook";
// Returns the corresponding test url if |kTestWallpaperServer| is present,
// otherwise returns |url| as is. See https://crbug.com/914144.
std::string MaybeConvertToTestUrl(std::string url) {
if (base::CommandLine::ForCurrentProcess()->HasSwitch(
chromeos::switches::kTestWallpaperServer)) {
base::ReplaceFirstSubstringAfterOffset(&url, 0, "clients3",
"chromecast-dev.sandbox");
}
return url;
}
// Helper function to parse the data from a |backdrop::Image| object and save it
// to |image_info_out|.
void ParseImageInfo(
......@@ -177,7 +191,8 @@ void CollectionInfoFetcher::Start(OnCollectionsInfoFetched callback) {
// |base::Unretained| is safe because this instance outlives
// |backdrop_fetcher_|.
backdrop_fetcher_->Start(
GURL(kBackdropCollectionsUrl), serialized_proto, traffic_annotation,
GURL(MaybeConvertToTestUrl(kBackdropCollectionsUrl)), serialized_proto,
traffic_annotation,
base::BindOnce(&CollectionInfoFetcher::OnResponseFetched,
base::Unretained(this)));
}
......@@ -254,8 +269,8 @@ void ImageInfoFetcher::Start(OnImagesInfoFetched callback) {
// |base::Unretained| is safe because this instance outlives
// |backdrop_fetcher_|.
backdrop_fetcher_->Start(GURL(kBackdropImagesUrl), serialized_proto,
traffic_annotation,
backdrop_fetcher_->Start(GURL(MaybeConvertToTestUrl(kBackdropImagesUrl)),
serialized_proto, traffic_annotation,
base::BindOnce(&ImageInfoFetcher::OnResponseFetched,
base::Unretained(this)));
}
......@@ -335,7 +350,8 @@ void SurpriseMeImageFetcher::Start(OnSurpriseMeImageFetched callback) {
// |base::Unretained| is safe because this instance outlives
// |backdrop_fetcher_|.
backdrop_fetcher_->Start(
GURL(kBackdropSurpriseMeImageUrl), serialized_proto, traffic_annotation,
GURL(MaybeConvertToTestUrl(kBackdropSurpriseMeImageUrl)),
serialized_proto, traffic_annotation,
base::BindOnce(&SurpriseMeImageFetcher::OnResponseFetched,
base::Unretained(this)));
}
......
......@@ -553,6 +553,9 @@ const char kStubCrosSettings[] = "stub-cros-settings";
// Enables testing for encryption migration UI.
const char kTestEncryptionMigrationUI[] = "test-encryption-migration-ui";
// Enables the wallpaper picker to fetch images from the test server.
const char kTestWallpaperServer[] = "test-wallpaper-server";
// Overrides Tether with stub service. Provide integer arguments for the number
// of fake networks desired, e.g. 'tether-stub=2'.
const char kTetherStub[] = "tether-stub";
......
......@@ -152,6 +152,7 @@ CHROMEOS_EXPORT extern const char kShowAndroidFilesInFilesApp[];
CHROMEOS_EXPORT extern const char kShowLoginDevOverlay[];
CHROMEOS_EXPORT extern const char kStubCrosSettings[];
CHROMEOS_EXPORT extern const char kTestEncryptionMigrationUI[];
CHROMEOS_EXPORT extern const char kTestWallpaperServer[];
CHROMEOS_EXPORT extern const char kTetherStub[];
CHROMEOS_EXPORT extern const char kTetherHostScansIgnoreWiredConnections[];
CHROMEOS_EXPORT extern const char kVoiceInteractionLocales[];
......
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