File: voice_suggest_provider.h

package info (click to toggle)
chromium 138.0.7204.183-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm-proposed-updates
  • size: 6,080,960 kB
  • sloc: cpp: 34,937,079; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,954; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,811; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (56 lines) | stat: -rw-r--r-- 2,322 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
// Copyright 2020 The Chromium Authors
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#ifndef COMPONENTS_OMNIBOX_BROWSER_VOICE_SUGGEST_PROVIDER_H_
#define COMPONENTS_OMNIBOX_BROWSER_VOICE_SUGGEST_PROVIDER_H_

#include <memory>
#include <string>
#include <vector>

#include "base/compiler_specific.h"
#include "base/memory/raw_ptr.h"
#include "components/omnibox/browser/autocomplete_enums.h"
#include "components/omnibox/browser/autocomplete_input.h"
#include "components/omnibox/browser/autocomplete_provider_client.h"
#include "components/omnibox/browser/base_search_provider.h"
#include "third_party/metrics_proto/omnibox_event.pb.h"

// Autocomplete provider serving Voice suggestions on Android.
class VoiceSuggestProvider : public BaseSearchProvider {
 public:
  explicit VoiceSuggestProvider(AutocompleteProviderClient* client);

  void Start(const AutocompleteInput& input, bool minimal_changes) override;
  void Stop(AutocompleteStopReason stop_reason) override;

  // Adds voice suggestion to the list of reported AutocompleteMatches.
  // The voice suggestion is next converted to a proper Search suggestion
  // associated with user-selected search engine, with a relevance score
  // computed from the match_score.
  void AddVoiceSuggestion(std::u16string match_text, float match_score);

  // Clear all cached voice matches.
  void ClearCache();

 private:
  // BaseSearchProvider:
  ~VoiceSuggestProvider() override;
  bool ShouldAppendExtraParams(
      const SearchSuggestionParser::SuggestResult& result) const override;
  void RecordDeletionResult(bool success) override;

  // A list of voice matches and their confidence scores. The first element
  // indicates how confident the voice recognition system is about the accuracy
  // of the match, whereas the second element of the pair holds the match text
  // itself.
  // Multiple matches may hold the same confidence score and/or match text -
  // the score will next be used to filter out low-quality matches, and compute
  // the relevance score for matches.
  // Duplicate voice matches will be deduplicated automatically to the higher
  // ranked match.
  std::vector<std::pair<float, std::u16string>> voice_matches_;
};

#endif  // COMPONENTS_OMNIBOX_BROWSER_VOICE_SUGGEST_PROVIDER_H_