Commit d050c9ec authored by Hesen Zhang's avatar Hesen Zhang Committed by Commit Bot

[Upboarding]: Default QueryTileConfig.

- Will continue to implement CreateFromFinch once
the flag change is done, include the unittest.

Bug: 1066550
Change-Id: Ie63e4b037eeb8ffc5d100d3fff7cc168f46eb406
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2130182Reviewed-by: default avatarHesen Zhang <hesen@chromium.org>
Reviewed-by: default avatarDavid Trainor <dtrainor@chromium.org>
Commit-Queue: Hesen Zhang <hesen@chromium.org>
Auto-Submit: Hesen Zhang <hesen@chromium.org>
Cr-Commit-Position: refs/heads/master@{#755454}
parent 94486b02
......@@ -11,6 +11,8 @@ source_set("internal") {
sources = [
"cached_image_loader.cc",
"cached_image_loader.h",
"config.cc",
"config.h",
"image_data_store.cc",
"image_data_store.h",
"image_decoder.cc",
......
// Copyright 2020 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/upboarding/query_tiles/internal/config.h"
namespace upboarding {
namespace {
// Default base URL string for the Query Tiles server.
constexpr char kDefaultBaseURL[] =
"https://autopush-gsaprototype-pa.sandbox.googleapis.com";
// Default URL string for GetQueryTiles RPC.
constexpr char kDefaultGetQueryTilePath[] = "/v1/querytiles";
// Default state of QueryTile feature.
constexpr bool kDefaultQueryTileState = false;
const GURL BuildGetQueryTileURL(const GURL& base_url, const char* path) {
GURL::Replacements replacements;
replacements.SetPathStr(path);
return base_url.ReplaceComponents(replacements);
}
} // namespace
std::unique_ptr<QueryTilesConfig> QueryTilesConfig::Create() {
return std::make_unique<QueryTilesConfig>();
}
std::unique_ptr<QueryTilesConfig> QueryTilesConfig::CreateFromFinch() {
// TODO(hesen): Implement reading parameters from Finch.
return std::make_unique<QueryTilesConfig>();
}
QueryTilesConfig::QueryTilesConfig()
: is_enabled(kDefaultQueryTileState),
base_url(GURL(kDefaultBaseURL)),
get_query_tile_url(
BuildGetQueryTileURL(base_url, kDefaultGetQueryTilePath)) {}
QueryTilesConfig::~QueryTilesConfig() = default;
} // namespace upboarding
// Copyright 2020 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_UPBOARDING_QUERY_TILES_INTERNAL_CONFIG_H_
#define CHROME_BROWSER_UPBOARDING_QUERY_TILES_INTERNAL_CONFIG_H_
#include <memory>
#include <string>
#include <utility>
#include "url/gurl.h"
namespace upboarding {
struct QueryTilesConfig {
// Creates a default QueryTilesConfig.
static std::unique_ptr<QueryTilesConfig> Create();
// Creates a QueryTilesConfig that reads parameters from Finch.
static std::unique_ptr<QueryTilesConfig> CreateFromFinch();
QueryTilesConfig();
~QueryTilesConfig();
QueryTilesConfig(const QueryTilesConfig& other) = delete;
QueryTilesConfig& operator=(const QueryTilesConfig& other) = delete;
// Flag to tell whether query tiles is enabled or not.
bool is_enabled;
// The base URL for the Query Tiles server.
GURL base_url;
// The URL for GetQueryTiles RPC.
GURL get_query_tile_url;
};
} // namespace upboarding
#endif // CHROME_BROWSER_UPBOARDING_QUERY_TILES_INTERNAL_CONFIG_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