Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[game search] Add SourceExtras subclass for games
Bug: 1305880 Change-Id: Ie5b5b8a06e5ad72d4757c6f49b38247477e82bdd Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3546138 Reviewed-by: Melissa Zhang <melzhang@chromium.org> Commit-Queue: Tony Yeoman <tby@chromium.org> Cr-Commit-Position: refs/heads/main@{#985192}
- Loading branch information
tby
authored and
Chromium LUCI CQ
committed
Mar 25, 2022
1 parent
a5cc3f3
commit 79c1639
Showing
6 changed files
with
125 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
// Copyright 2022 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/apps/app_discovery_service/game_extras.h" | ||
|
||
namespace apps { | ||
namespace { | ||
|
||
using Source = GameExtras::Source; | ||
|
||
} // namespace | ||
|
||
GameExtras::GameExtras( | ||
const std::string& id, | ||
const std::u16string& title, | ||
Source source, | ||
const absl::optional<std::vector<std::u16string>>& platforms, | ||
const GURL& icon_url) | ||
: id_(id), | ||
title_(title), | ||
source_(source), | ||
platforms_(platforms), | ||
icon_url_(icon_url) {} | ||
|
||
GameExtras::~GameExtras() = default; | ||
|
||
const std::string& GameExtras::GetId() const { | ||
return id_; | ||
} | ||
|
||
const std::u16string& GameExtras::GetTitle() const { | ||
return title_; | ||
} | ||
|
||
Source GameExtras::GetSource() const { | ||
return source_; | ||
} | ||
|
||
const absl::optional<std::vector<std::u16string>>& GameExtras::GetPlatforms() | ||
const { | ||
return platforms_; | ||
} | ||
|
||
const GURL& GameExtras::GetIconUrl() const { | ||
return icon_url_; | ||
} | ||
|
||
GameExtras* GameExtras::AsGameExtras() { | ||
return this; | ||
} | ||
|
||
} // namespace apps |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
// Copyright 2022 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_APPS_APP_DISCOVERY_SERVICE_GAME_EXTRAS_H_ | ||
#define CHROME_BROWSER_APPS_APP_DISCOVERY_SERVICE_GAME_EXTRAS_H_ | ||
|
||
#include <string> | ||
#include <vector> | ||
|
||
#include "chrome/browser/apps/app_discovery_service/result.h" | ||
#include "third_party/abseil-cpp/absl/types/optional.h" | ||
#include "url/gurl.h" | ||
|
||
namespace apps { | ||
|
||
class GameExtras : public SourceExtras { | ||
public: | ||
// Which cloud gaming source a result comes from. These values are persisted | ||
// to logs. Entries should not be renumbered or reused. | ||
enum class Source { | ||
// TODO(crbug.com/1305880): Replace with real source. | ||
kTemporarySource = 1, | ||
}; | ||
|
||
GameExtras(const std::string& id, | ||
const std::u16string& title, | ||
Source source, | ||
const absl::optional<std::vector<std::u16string>>& platforms, | ||
const GURL& icon_url); | ||
GameExtras(const GameExtras&) = delete; | ||
GameExtras& operator=(const GameExtras&) = delete; | ||
~GameExtras() override; | ||
|
||
const std::string& GetId() const; | ||
const std::u16string& GetTitle() const; | ||
Source GetSource() const; | ||
const absl::optional<std::vector<std::u16string>>& GetPlatforms() const; | ||
const GURL& GetIconUrl() const; | ||
|
||
// Result::SourceExtras: | ||
GameExtras* AsGameExtras() override; | ||
|
||
private: | ||
std::string id_; | ||
std::u16string title_; | ||
Source source_; | ||
absl::optional<std::vector<std::u16string>> platforms_; | ||
GURL icon_url_; | ||
}; | ||
|
||
} // namespace apps | ||
|
||
#endif // CHROME_BROWSER_APPS_APP_DISCOVERY_SERVICE_GAME_EXTRAS_H_ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters