File: voice_suggest_provider.h

package info (click to toggle)
chromium 139.0.7258.127-1
  • links: PTS, VCS
  • area: main
  • in suites:
  • size: 6,122,068 kB
  • sloc: cpp: 35,100,771; ansic: 7,163,530; javascript: 4,103,002; python: 1,436,920; asm: 946,517; xml: 746,709; pascal: 187,653; perl: 88,691; sh: 88,436; objc: 79,953; sql: 51,488; cs: 44,583; fortran: 24,137; makefile: 22,147; tcl: 15,277; php: 13,980; yacc: 8,984; 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 (5)
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_