[go: nahoru, domu]

blob: 871e8ee229c5a0d1bab9d1617a3621a3a5041738 [file] [log] [blame]
// Copyright 2021 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_ASH_INPUT_METHOD_SUGGESTIONS_SOURCE_H_
#define CHROME_BROWSER_ASH_INPUT_METHOD_SUGGESTIONS_SOURCE_H_
#include <vector>
#include "base/functional/callback.h"
#include "chromeos/ash/services/ime/public/cpp/assistive_suggestions.h"
namespace ash {
namespace input_method {
// Represents a source of text based suggestions.
class SuggestionsSource {
public:
virtual ~SuggestionsSource() = default;
// Get any suggestions that have been generated by the class. This may, or
// may not, return suggestions.
virtual std::vector<ime::AssistiveSuggestion> GetSuggestions() = 0;
};
// As the name suggests, this also represents a source of text based
// suggestions, however the interface for fetching suggestions from this object
// is asynchronous.
class AsyncSuggestionsSource {
public:
virtual ~AsyncSuggestionsSource() = default;
using RequestSuggestionsCallback =
base::OnceCallback<void(const std::vector<ime::AssistiveSuggestion>&)>;
// Fetch the suggestions from this object, any suggestions fetched will be
// returned in the callback passed.
virtual void RequestSuggestions(
const std::string& preceding_text,
const ime::AssistiveSuggestionMode& suggestion_mode,
const std::vector<ime::DecoderCompletionCandidate>& completion_candidates,
RequestSuggestionsCallback callback) = 0;
// Is the source ready to produce suggestions?
virtual bool IsAvailable() = 0;
};
} // namespace input_method
} // namespace ash
#endif // CHROME_BROWSER_ASH_INPUT_METHOD_SUGGESTIONS_SOURCE_H_