Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(280)

Side by Side Diff: components/translate/core/browser/translate_ranker.h

Issue 2697703004: Allow TranslateRanker to override decisions taken by heuristics. (Closed)
Patch Set: Make ShouldSuppressBubbleUI easier to read. Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_RANKER_H_ 5 #ifndef COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_RANKER_H_
6 #define COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_RANKER_H_ 6 #define COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_RANKER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 10 matching lines...) Expand all
21 namespace translate { 21 namespace translate {
22 22
23 class TranslatePrefs; 23 class TranslatePrefs;
24 24
25 // If enabled, downloads a translate ranker model and uses it to determine 25 // If enabled, downloads a translate ranker model and uses it to determine
26 // whether the user should be given a translation prompt or not. 26 // whether the user should be given a translation prompt or not.
27 class TranslateRanker : public KeyedService { 27 class TranslateRanker : public KeyedService {
28 public: 28 public:
29 TranslateRanker() = default; 29 TranslateRanker() = default;
30 30
31 // Returns true if translate events logging is enabled.
32 virtual bool IsLoggingEnabled() = 0;
33
34 // Returns true if enforcement is enabled.
35 virtual bool IsEnforcementEnabled() = 0;
36
37 // Returns true if querying is enabled. Enabling enforcement will
38 // automatically enable Query.
39 virtual bool IsQueryEnabled() = 0;
40
41 // Returns the version id for the ranker model. 31 // Returns the version id for the ranker model.
42 virtual int GetModelVersion() const = 0; 32 virtual uint32_t GetModelVersion() const = 0;
43 33
44 // Returns true if executing the ranker model in the translation prompt 34 // Returns true if executing the ranker model in the translation prompt
45 // context described by |translate_prefs|, |src_lang|, |dst_lang| and possibly 35 // context described by |translate_prefs|, |src_lang|, |dst_lang| and possibly
46 // other global browser context attributes suggests that the user should be 36 // other global browser context attributes suggests that the user should be
47 // prompted as to whether translation should be performed. 37 // prompted as to whether translation should be performed.
48 virtual bool ShouldOfferTranslation(const TranslatePrefs& translate_prefs, 38 // TODO(hamelphi): Take only the proto as input and extract features from it.
49 const std::string& src_lang, 39 virtual bool ShouldOfferTranslation(
50 const std::string& dst_lang) = 0; 40 const TranslatePrefs& translate_prefs,
51 41 const std::string& src_lang,
52 // Caches the translate event. 42 const std::string& dst_lang,
53 virtual void AddTranslateEvent( 43 metrics::TranslateEventProto* translate_event) = 0;
54 const metrics::TranslateEventProto& translate_event,
55 const GURL& url) = 0;
56 44
57 // Transfers cached translate events to the given vector pointer and clears 45 // Transfers cached translate events to the given vector pointer and clears
58 // the cache. 46 // the cache.
59 virtual void FlushTranslateEvents( 47 virtual void FlushTranslateEvents(
60 std::vector<metrics::TranslateEventProto>* events) = 0; 48 std::vector<metrics::TranslateEventProto>* events) = 0;
61 49
50 // Record |translate_event| with the given |event_type| and |url|.
51 // |event_type| must be one of the values defined by
52 // metrics::TranslateEventProto::EventType.
53 virtual void RecordTranslateEvent(
54 int event_type,
55 const GURL& url,
56 metrics::TranslateEventProto* translate_event) = 0;
57
58 // If override is enabled, will return true and add |event_type| to
59 // |translate_event.decision_overrides()|. If override is disabled,
60 // returns false and finalize and record |translate_event| with
61 // |event_type| as |translate_event.event_type()|. |event_type|
62 // must be one of the values defined by
63 // metrics::TranslateEventProto::EventType.
64 virtual bool ShouldOverrideDecision(
65 int event_type,
66 const GURL& url,
67 metrics::TranslateEventProto* translate_event) = 0;
68
62 private: 69 private:
63 DISALLOW_COPY_AND_ASSIGN(TranslateRanker); 70 DISALLOW_COPY_AND_ASSIGN(TranslateRanker);
64 }; 71 };
65 72
66 } // namespace translate 73 } // namespace translate
67 74
68 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_RANKER_H_ 75 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_RANKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698