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

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

Issue 2889133002: Remove unused BackgroundAnimationType to simplify translate delegate. (Closed)
Patch Set: fix Created 3 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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_INFOBAR_DELEGATE_H_ 5 #ifndef COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_INFOBAR_DELEGATE_H_
6 #define COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_INFOBAR_DELEGATE_H_ 6 #define COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_INFOBAR_DELEGATE_H_
7 7
8 #include <stddef.h> 8 #include <stddef.h>
9 9
10 #include <memory> 10 #include <memory>
(...skipping 19 matching lines...) Expand all
30 namespace translate { 30 namespace translate {
31 31
32 // Feature flag for "Translate Compact Infobar UI" project. 32 // Feature flag for "Translate Compact Infobar UI" project.
33 extern const base::Feature kTranslateCompactUI; 33 extern const base::Feature kTranslateCompactUI;
34 34
35 class TranslateDriver; 35 class TranslateDriver;
36 class TranslateManager; 36 class TranslateManager;
37 37
38 class TranslateInfoBarDelegate : public infobars::InfoBarDelegate { 38 class TranslateInfoBarDelegate : public infobars::InfoBarDelegate {
39 public: 39 public:
40 // The types of background color animations.
41 enum BackgroundAnimationType {
42 NONE,
43 NORMAL_TO_ERROR,
44 ERROR_TO_NORMAL
45 };
46
47 static const size_t kNoIndex; 40 static const size_t kNoIndex;
48 41
49 ~TranslateInfoBarDelegate() override; 42 ~TranslateInfoBarDelegate() override;
50 43
51 // Factory method to create a translate infobar. |error_type| must be 44 // Factory method to create a translate infobar. |error_type| must be
52 // specified iff |step| == TRANSLATION_ERROR. For other translate steps, 45 // specified iff |step| == TRANSLATION_ERROR. For other translate steps,
53 // |original_language| and |target_language| must be ASCII language codes 46 // |original_language| and |target_language| must be ASCII language codes
54 // (e.g. "en", "fr", etc.) for languages the TranslateManager supports 47 // (e.g. "en", "fr", etc.) for languages the TranslateManager supports
55 // translating. The lone exception is when the user initiates translation 48 // translating. The lone exception is when the user initiates translation
56 // from the context menu, in which case it's legal to call this with 49 // from the context menu, in which case it's legal to call this with
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
117 bool is_error() const { 110 bool is_error() const {
118 return step_ == translate::TRANSLATE_STEP_TRANSLATE_ERROR; 111 return step_ == translate::TRANSLATE_STEP_TRANSLATE_ERROR;
119 } 112 }
120 113
121 // Return true if the translation was triggered by a menu entry instead of 114 // Return true if the translation was triggered by a menu entry instead of
122 // via an infobar/bubble or preference. 115 // via an infobar/bubble or preference.
123 bool triggered_from_menu() const { 116 bool triggered_from_menu() const {
124 return triggered_from_menu_; 117 return triggered_from_menu_;
125 } 118 }
126 119
127 // Returns what kind of background fading effect the infobar should use when
128 // its is shown.
129 BackgroundAnimationType background_animation_type() const {
130 return background_animation_;
131 }
132
133 virtual void Translate(); 120 virtual void Translate();
134 virtual void RevertTranslation(); 121 virtual void RevertTranslation();
135 void ReportLanguageDetectionError(); 122 void ReportLanguageDetectionError();
136 123
137 // Called when the user declines to translate a page, by either closing the 124 // Called when the user declines to translate a page, by either closing the
138 // infobar or pressing the "Don't translate" button. 125 // infobar or pressing the "Don't translate" button.
139 virtual void TranslationDeclined(); 126 virtual void TranslationDeclined();
140 127
141 // Methods called by the Options menu delegate. 128 // Methods called by the Options menu delegate.
142 virtual bool IsTranslatableLanguageByPrefs(); 129 virtual bool IsTranslatableLanguageByPrefs();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
193 180
194 // Gets the TranslateDriver associated with this object. 181 // Gets the TranslateDriver associated with this object.
195 // May return NULL if the driver has been destroyed. 182 // May return NULL if the driver has been destroyed.
196 TranslateDriver* GetTranslateDriver(); 183 TranslateDriver* GetTranslateDriver();
197 184
198 protected: 185 protected:
199 TranslateInfoBarDelegate( 186 TranslateInfoBarDelegate(
200 const base::WeakPtr<TranslateManager>& translate_manager, 187 const base::WeakPtr<TranslateManager>& translate_manager,
201 bool is_off_the_record, 188 bool is_off_the_record,
202 translate::TranslateStep step, 189 translate::TranslateStep step,
203 TranslateInfoBarDelegate* old_delegate,
204 const std::string& original_language, 190 const std::string& original_language,
205 const std::string& target_language, 191 const std::string& target_language,
206 TranslateErrors::Type error_type, 192 TranslateErrors::Type error_type,
207 bool triggered_from_menu); 193 bool triggered_from_menu);
208 194
209 private: 195 private:
210 friend class TranslationInfoBarTest; 196 friend class TranslationInfoBarTest;
211 typedef std::pair<std::string, base::string16> LanguageNamePair; 197 typedef std::pair<std::string, base::string16> LanguageNamePair;
212 198
213 // InfoBarDelegate: 199 // InfoBarDelegate:
214 Type GetInfoBarType() const override; 200 Type GetInfoBarType() const override;
215 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override; 201 infobars::InfoBarDelegate::InfoBarIdentifier GetIdentifier() const override;
216 int GetIconId() const override; 202 int GetIconId() const override;
217 void InfoBarDismissed() override; 203 void InfoBarDismissed() override;
218 TranslateInfoBarDelegate* AsTranslateInfoBarDelegate() override; 204 TranslateInfoBarDelegate* AsTranslateInfoBarDelegate() override;
219 205
220 bool is_off_the_record_; 206 bool is_off_the_record_;
221 translate::TranslateStep step_; 207 translate::TranslateStep step_;
222 208
223 // The type of fading animation if any that should be used when showing this
224 // infobar.
225 BackgroundAnimationType background_animation_;
226
227 TranslateUIDelegate ui_delegate_; 209 TranslateUIDelegate ui_delegate_;
228 base::WeakPtr<TranslateManager> translate_manager_; 210 base::WeakPtr<TranslateManager> translate_manager_;
229 211
230 // The error that occurred when trying to translate (NONE if no error). 212 // The error that occurred when trying to translate (NONE if no error).
231 TranslateErrors::Type error_type_; 213 TranslateErrors::Type error_type_;
232 214
233 // The translation related preferences. 215 // The translation related preferences.
234 std::unique_ptr<TranslatePrefs> prefs_; 216 std::unique_ptr<TranslatePrefs> prefs_;
235 217
236 // Whether the translation was triggered via a menu click vs automatically 218 // Whether the translation was triggered via a menu click vs automatically
237 // (due to language detection, preferences...) 219 // (due to language detection, preferences...)
238 bool triggered_from_menu_; 220 bool triggered_from_menu_;
239 221
240 DISALLOW_COPY_AND_ASSIGN(TranslateInfoBarDelegate); 222 DISALLOW_COPY_AND_ASSIGN(TranslateInfoBarDelegate);
241 }; 223 };
242 224
243 } // namespace translate 225 } // namespace translate
244 226
245 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_INFOBAR_DELEGATE_H_ 227 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_INFOBAR_DELEGATE_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698