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

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

Issue 2697703004: Allow TranslateRanker to override decisions taken by heuristics. (Closed)
Patch Set: Make TranslateAcceptLanguages default constructor protected. 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 2017 The Chromium Authors. All rights reserved. 1 // Copyright 2017 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_MOCK_TRANSLATE_RANKER_H_ 5 #ifndef COMPONENTS_TRANSLATE_CORE_BROWSER_MOCK_TRANSLATE_RANKER_H_
6 #define COMPONENTS_TRANSLATE_CORE_BROWSER_MOCK_TRANSLATE_RANKER_H_ 6 #define COMPONENTS_TRANSLATE_CORE_BROWSER_MOCK_TRANSLATE_RANKER_H_
7 7
8 #include <memory> 8 #include <memory>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 11 matching lines...) Expand all
22 namespace testing { 22 namespace testing {
23 23
24 class MockTranslateRanker : public TranslateRanker { 24 class MockTranslateRanker : public TranslateRanker {
25 public: 25 public:
26 MockTranslateRanker(); 26 MockTranslateRanker();
27 ~MockTranslateRanker() override; 27 ~MockTranslateRanker() override;
28 28
29 void set_is_logging_enabled(bool val) { is_logging_enabled_ = val; } 29 void set_is_logging_enabled(bool val) { is_logging_enabled_ = val; }
30 void set_is_query_enabled(bool val) { is_query_enabled_ = val; } 30 void set_is_query_enabled(bool val) { is_query_enabled_ = val; }
31 void set_is_enforcement_enabled(bool val) { is_enforcement_enabled_ = val; } 31 void set_is_enforcement_enabled(bool val) { is_enforcement_enabled_ = val; }
32 void set_is_decision_override_enabled(bool val) {
33 is_decision_override_enabled_ = val;
34 }
32 void set_model_version(int val) { model_version_ = val; } 35 void set_model_version(int val) { model_version_ = val; }
33 void set_should_offer_translation(bool val) { 36 void set_should_offer_translation(bool val) {
34 should_offer_translation_ = val; 37 should_offer_translation_ = val;
35 } 38 }
36 39
37 // TranslateRanker Implementation: 40 // TranslateRanker Implementation:
38 bool IsLoggingEnabled() override; 41 bool IsLoggingEnabled() override;
39 bool IsQueryEnabled() override; 42 bool IsQueryEnabled() override;
40 bool IsEnforcementEnabled() override; 43 bool IsEnforcementEnabled() override;
44 bool IsDecisionOverrideEnabled() override;
41 int GetModelVersion() const override; 45 int GetModelVersion() const override;
42 bool ShouldOfferTranslation(const TranslatePrefs& translate_prefs, 46 bool ShouldOfferTranslation(const TranslatePrefs& translate_prefs,
43 const std::string& src_lang, 47 const std::string& src_lang,
44 const std::string& dst_lang) override; 48 const std::string& dst_lang) override;
45 void AddTranslateEvent( 49 void AddTranslateEvent(
46 const metrics::TranslateEventProto& translate_event) override; 50 const metrics::TranslateEventProto& translate_event) override;
47 void FlushTranslateEvents( 51 void FlushTranslateEvents(
48 std::vector<metrics::TranslateEventProto>* events) override; 52 std::vector<metrics::TranslateEventProto>* events) override;
49 53
50 private: 54 private:
51 std::vector<metrics::TranslateEventProto> event_cache_; 55 std::vector<metrics::TranslateEventProto> event_cache_;
52 56
53 bool is_logging_enabled_ = false; 57 bool is_logging_enabled_ = false;
54 bool is_query_enabled_ = false; 58 bool is_query_enabled_ = false;
55 bool is_enforcement_enabled_ = false; 59 bool is_enforcement_enabled_ = false;
60 bool is_decision_override_enabled_ = false;
56 bool model_version_ = 0; 61 bool model_version_ = 0;
57 bool should_offer_translation_ = true; 62 bool should_offer_translation_ = true;
58 63
59 DISALLOW_COPY_AND_ASSIGN(MockTranslateRanker); 64 DISALLOW_COPY_AND_ASSIGN(MockTranslateRanker);
60 }; 65 };
61 66
62 } // namespace testing 67 } // namespace testing
63 68
64 } // namespace translate 69 } // namespace translate
65 70
66 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_MOCK_TRANSLATE_RANKER_H_ 71 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_MOCK_TRANSLATE_RANKER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698