Commit 988c98a5 authored by David Black's avatar David Black Committed by Commit Bot

Adds ConversationStarter class and stubs in Fetch API.

Follow up CLs will wire the fetch API up to a loader as well as invoke
the fetch API from AssistantSuggestionsController at the appropriate
points in the Assistant lifecycle.

Bug: b:148239201
Change-Id: I8eb816aab3eff180b90d4eb21371d81b6219ce0c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2018443
Commit-Queue: David Black <dmblack@google.com>
Reviewed-by: default avatarXiyuan Xia <xiyuan@chromium.org>
Reviewed-by: default avatarXiaohui Chen <xiaohuic@chromium.org>
Cr-Commit-Position: refs/heads/master@{#735157}
parent 370cd65c
...@@ -71,6 +71,8 @@ component("cpp") { ...@@ -71,6 +71,8 @@ component("cpp") {
"assistant/assistant_web_view_2.h", "assistant/assistant_web_view_2.h",
"assistant/assistant_web_view_factory.cc", "assistant/assistant_web_view_factory.cc",
"assistant/assistant_web_view_factory.h", "assistant/assistant_web_view_factory.h",
"assistant/conversation_starter.cc",
"assistant/conversation_starter.h",
"assistant/conversation_starters_client.cc", "assistant/conversation_starters_client.cc",
"assistant/conversation_starters_client.h", "assistant/conversation_starters_client.h",
"assistant/proactive_suggestions.cc", "assistant/proactive_suggestions.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 "ash/public/cpp/assistant/conversation_starter.h"
namespace ash {
ConversationStarter::ConversationStarter(const std::string& label,
const base::Optional<GURL>& action_url,
const base::Optional<GURL>& icon_url,
uint32_t required_permissions)
: label_(label),
action_url_(action_url),
icon_url_(icon_url),
required_permissions_(required_permissions) {}
ConversationStarter::~ConversationStarter() = default;
} // namespace ash
// 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 ASH_PUBLIC_CPP_ASSISTANT_CONVERSATION_STARTER_H_
#define ASH_PUBLIC_CPP_ASSISTANT_CONVERSATION_STARTER_H_
#include <string>
#include "ash/public/cpp/ash_public_export.h"
#include "base/optional.h"
#include "url/gurl.h"
namespace ash {
// Models an immutable conversation starter.
class ASH_PUBLIC_EXPORT ConversationStarter {
public:
// Enumeration of possible permissions which a conversation starter may
// require in order to be presented to the user.
enum class Permission : uint32_t { kRelatedInfo = 1u };
ConversationStarter(const std::string& label,
const base::Optional<GURL>& action_url,
const base::Optional<GURL>& icon_url,
uint32_t required_permissions);
ConversationStarter(const ConversationStarter& copy) = delete;
ConversationStarter& operator=(ConversationStarter& assign) = delete;
~ConversationStarter();
const std::string& label() const { return label_; }
const base::Optional<GURL>& action_url() const { return action_url_; }
const base::Optional<GURL>& icon_url() const { return icon_url_; }
const uint32_t& required_permissions() const { return required_permissions_; }
private:
const std::string label_;
const base::Optional<GURL> action_url_;
const base::Optional<GURL> icon_url_;
const uint32_t required_permissions_;
};
} // namespace ash
#endif // ASH_PUBLIC_CPP_ASSISTANT_CONVERSATION_STARTER_H_
...@@ -5,16 +5,26 @@ ...@@ -5,16 +5,26 @@
#ifndef ASH_PUBLIC_CPP_ASSISTANT_CONVERSATION_STARTERS_CLIENT_H_ #ifndef ASH_PUBLIC_CPP_ASSISTANT_CONVERSATION_STARTERS_CLIENT_H_
#define ASH_PUBLIC_CPP_ASSISTANT_CONVERSATION_STARTERS_CLIENT_H_ #define ASH_PUBLIC_CPP_ASSISTANT_CONVERSATION_STARTERS_CLIENT_H_
#include <vector>
#include "ash/public/cpp/ash_public_export.h" #include "ash/public/cpp/ash_public_export.h"
#include "base/callback_forward.h"
namespace ash { namespace ash {
class ConversationStarter;
// The interface for the conversation starters feature browser client. // The interface for the conversation starters feature browser client.
class ASH_PUBLIC_EXPORT ConversationStartersClient { class ASH_PUBLIC_EXPORT ConversationStartersClient {
public: public:
// Returns the singleton instance. // Returns the singleton instance.
static ConversationStartersClient* Get(); static ConversationStartersClient* Get();
// Fetches conversation starters from the server, running |callback| with the
// returned list upon completion. Note that the returned list may be empty.
using Callback = base::OnceCallback<void(std::vector<ConversationStarter>&&)>;
virtual void FetchConversationStarters(Callback callback) = 0;
protected: protected:
ConversationStartersClient(); ConversationStartersClient();
virtual ~ConversationStartersClient(); virtual ~ConversationStartersClient();
......
...@@ -4,6 +4,9 @@ ...@@ -4,6 +4,9 @@
#include "chrome/browser/ui/ash/assistant/conversation_starters_client_impl.h" #include "chrome/browser/ui/ash/assistant/conversation_starters_client_impl.h"
#include <vector>
#include "ash/public/cpp/assistant/conversation_starter.h"
#include "chrome/browser/profiles/profile.h" #include "chrome/browser/profiles/profile.h"
ConversationStartersClientImpl::ConversationStartersClientImpl(Profile* profile) ConversationStartersClientImpl::ConversationStartersClientImpl(Profile* profile)
...@@ -12,3 +15,9 @@ ConversationStartersClientImpl::ConversationStartersClientImpl(Profile* profile) ...@@ -12,3 +15,9 @@ ConversationStartersClientImpl::ConversationStartersClientImpl(Profile* profile)
} }
ConversationStartersClientImpl::~ConversationStartersClientImpl() = default; ConversationStartersClientImpl::~ConversationStartersClientImpl() = default;
// TODO(dmblack): Fetch conversation starters from the server.
void ConversationStartersClientImpl::FetchConversationStarters(
Callback callback) {
std::move(callback).Run(std::vector<ash::ConversationStarter>());
}
...@@ -18,6 +18,9 @@ class ConversationStartersClientImpl : public ash::ConversationStartersClient { ...@@ -18,6 +18,9 @@ class ConversationStartersClientImpl : public ash::ConversationStartersClient {
ConversationStartersClientImpl& assign) = delete; ConversationStartersClientImpl& assign) = delete;
~ConversationStartersClientImpl() override; ~ConversationStartersClientImpl() override;
// ash::ConversationStartersClient:
void FetchConversationStarters(Callback callback) override;
private: private:
Profile* const profile_; Profile* const profile_;
}; };
......
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