Upload upstream chromium 114.0.5735.31
[platform/framework/web/chromium-efl.git] / components / search_engines / search_terms_data.h
1 // Copyright 2014 The Chromium Authors
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #ifndef COMPONENTS_SEARCH_ENGINES_SEARCH_TERMS_DATA_H_
6 #define COMPONENTS_SEARCH_ENGINES_SEARCH_TERMS_DATA_H_
7
8 #include <memory>
9 #include <string>
10
11 #include "base/compiler_specific.h"
12
13 // All data needed by TemplateURLRef::ReplaceSearchTerms which typically may
14 // only be accessed on the UI thread.
15 class SearchTermsData {
16  public:
17   // Enumeration of the known search or suggest request sources. These values
18   // are not persisted or used in histograms; thus can be freely changed.
19   enum class RequestSource {
20     SEARCHBOX,      // Omnibox or the NTP realbox. The default.
21     CROS_APP_LIST,  // Chrome OS app list searchbox.
22     NTP_MODULE,     // Suggestions for the NTP modules.
23     JOURNEYS,       // Suggestions for the Journeys.
24   };
25
26   // Utility function that takes a snapshot of a different SearchTermsData
27   // instance. This is used to access SearchTermsData off the UI thread, or to
28   // copy the SearchTermsData for lifetime reasons.
29   static std::unique_ptr<SearchTermsData> MakeSnapshot(
30       const SearchTermsData* original_data);
31
32   SearchTermsData();
33
34   SearchTermsData(const SearchTermsData&) = delete;
35   SearchTermsData& operator=(const SearchTermsData&) = delete;
36
37   virtual ~SearchTermsData();
38
39   // Returns the value to use for replacements of type GOOGLE_BASE_URL.  This
40   // implementation simply returns the default value.
41   virtual std::string GoogleBaseURLValue() const;
42
43   // Returns the value to use for the GOOGLE_BASE_SEARCH_BY_IMAGE_URL. Points
44   // at Lens if the user is enrolled in the Lens experiment, and defaults to
45   // Image Search otherwise.
46   virtual std::string GoogleBaseSearchByImageURLValue() const;
47
48   // Returns the value for the GOOGLE_BASE_SUGGEST_URL term.  This
49   // implementation simply returns the default value.
50   std::string GoogleBaseSuggestURLValue() const;
51
52   // Returns the locale used by the application.  This implementation returns
53   // "en" and thus should be overridden where the result is actually meaningful.
54   virtual std::string GetApplicationLocale() const;
55
56   // Returns the value for the Chrome Omnibox rlz.  This implementation returns
57   // the empty string.
58   virtual std::u16string GetRlzParameterValue(bool from_app_list) const;
59
60   // The optional client parameter passed with Google search requests.  This
61   // implementation returns the empty string.
62   virtual std::string GetSearchClient() const;
63
64   // The suggest client parameter ("client") passed with Google suggest
65   // requests.  See GetSuggestRequestIdentifier() for more details.
66   // This implementation returns the empty string.
67   virtual std::string GetSuggestClient(RequestSource request_source) const;
68
69   // The suggest request identifier parameter ("gs_ri") passed with Google
70   // suggest requests.   Along with suggestclient (See GetSuggestClient()),
71   // this parameter controls what suggestion results are returned.
72   // This implementation returns the empty string.
73   virtual std::string GetSuggestRequestIdentifier(
74       RequestSource request_source) const;
75
76   // Returns the value to use for replacements of type
77   // GOOGLE_IMAGE_SEARCH_SOURCE.
78   virtual std::string GoogleImageSearchSource() const;
79
80   // Returns the optional referral ID to be passed to Yandex when searching from
81   // the omnibox (returns the empty string if not supported/applicable).
82   virtual std::string GetYandexReferralID() const;
83
84   // Returns the optional referral ID to be passed to @MAIL.RU when searching
85   // from the omnibox (returns the empty string if not supported/applicable).
86   virtual std::string GetMailRUReferralID() const;
87
88   // Estimates dynamic memory usage.
89   // See base/trace_event/memory_usage_estimator.h for more info.
90   virtual size_t EstimateMemoryUsage() const;
91 };
92
93 #endif  // COMPONENTS_SEARCH_ENGINES_SEARCH_TERMS_DATA_H_