| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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 CHROME_BROWSER_TRANSLATE_TRANSLATE_INFOBAR_DELEGATE_H_ | 5 #ifndef CHROME_BROWSER_TRANSLATE_TRANSLATE_INFOBAR_DELEGATE_H_ |
| 6 #define CHROME_BROWSER_TRANSLATE_TRANSLATE_INFOBAR_DELEGATE_H_ | 6 #define CHROME_BROWSER_TRANSLATE_TRANSLATE_INFOBAR_DELEGATE_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 #include <utility> | 9 #include <utility> |
| 10 #include <vector> | 10 #include <vector> |
| 11 | 11 |
| 12 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/memory/scoped_ptr.h" | 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "chrome/browser/infobars/infobar_delegate.h" | |
| 15 #include "chrome/browser/translate/translate_tab_helper.h" | 14 #include "chrome/browser/translate/translate_tab_helper.h" |
| 15 #include "components/infobars/core/infobar_delegate.h" |
| 16 #include "components/translate/core/browser/translate_prefs.h" | 16 #include "components/translate/core/browser/translate_prefs.h" |
| 17 #include "components/translate/core/browser/translate_ui_delegate.h" | 17 #include "components/translate/core/browser/translate_ui_delegate.h" |
| 18 #include "components/translate/core/common/translate_constants.h" | 18 #include "components/translate/core/common/translate_constants.h" |
| 19 #include "components/translate/core/common/translate_errors.h" | 19 #include "components/translate/core/common/translate_errors.h" |
| 20 | 20 |
| 21 class PrefService; | 21 class PrefService; |
| 22 | 22 |
| 23 class TranslateInfoBarDelegate : public InfoBarDelegate { | 23 class TranslateInfoBarDelegate : public infobars::InfoBarDelegate { |
| 24 public: | 24 public: |
| 25 // The types of background color animations. | 25 // The types of background color animations. |
| 26 enum BackgroundAnimationType { | 26 enum BackgroundAnimationType { |
| 27 NONE, | 27 NONE, |
| 28 NORMAL_TO_ERROR, | 28 NORMAL_TO_ERROR, |
| 29 ERROR_TO_NORMAL | 29 ERROR_TO_NORMAL |
| 30 }; | 30 }; |
| 31 | 31 |
| 32 static const size_t kNoIndex; | 32 static const size_t kNoIndex; |
| 33 | 33 |
| (...skipping 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 const std::string& target_language, | 176 const std::string& target_language, |
| 177 TranslateErrors::Type error_type, | 177 TranslateErrors::Type error_type, |
| 178 PrefService* prefs, | 178 PrefService* prefs, |
| 179 bool triggered_from_menu); | 179 bool triggered_from_menu); |
| 180 | 180 |
| 181 private: | 181 private: |
| 182 friend class TranslationInfoBarTest; | 182 friend class TranslationInfoBarTest; |
| 183 typedef std::pair<std::string, base::string16> LanguageNamePair; | 183 typedef std::pair<std::string, base::string16> LanguageNamePair; |
| 184 | 184 |
| 185 // Returns a translate infobar that owns |delegate|. | 185 // Returns a translate infobar that owns |delegate|. |
| 186 static scoped_ptr<InfoBar> CreateInfoBar( | 186 static scoped_ptr<infobars::InfoBar> CreateInfoBar( |
| 187 scoped_ptr<TranslateInfoBarDelegate> delegate); | 187 scoped_ptr<TranslateInfoBarDelegate> delegate); |
| 188 | 188 |
| 189 // InfoBarDelegate: | 189 // InfoBarDelegate: |
| 190 virtual void InfoBarDismissed() OVERRIDE; | 190 virtual void InfoBarDismissed() OVERRIDE; |
| 191 virtual int GetIconID() const OVERRIDE; | 191 virtual int GetIconID() const OVERRIDE; |
| 192 virtual InfoBarDelegate::Type GetInfoBarType() const OVERRIDE; | 192 virtual infobars::InfoBarDelegate::Type GetInfoBarType() const OVERRIDE; |
| 193 virtual bool ShouldExpire(const NavigationDetails& details) const OVERRIDE; | 193 virtual bool ShouldExpire(const NavigationDetails& details) const OVERRIDE; |
| 194 virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate() OVERRIDE; | 194 virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate() OVERRIDE; |
| 195 | 195 |
| 196 translate::TranslateStep step_; | 196 translate::TranslateStep step_; |
| 197 | 197 |
| 198 // The type of fading animation if any that should be used when showing this | 198 // The type of fading animation if any that should be used when showing this |
| 199 // infobar. | 199 // infobar. |
| 200 BackgroundAnimationType background_animation_; | 200 BackgroundAnimationType background_animation_; |
| 201 | 201 |
| 202 TranslateUIDelegate ui_delegate_; | 202 TranslateUIDelegate ui_delegate_; |
| 203 | 203 |
| 204 // The error that occurred when trying to translate (NONE if no error). | 204 // The error that occurred when trying to translate (NONE if no error). |
| 205 TranslateErrors::Type error_type_; | 205 TranslateErrors::Type error_type_; |
| 206 | 206 |
| 207 // The translation related preferences. | 207 // The translation related preferences. |
| 208 scoped_ptr<TranslatePrefs> prefs_; | 208 scoped_ptr<TranslatePrefs> prefs_; |
| 209 | 209 |
| 210 // Whether the translation was triggered via a menu click vs automatically | 210 // Whether the translation was triggered via a menu click vs automatically |
| 211 // (due to language detection, preferences...) | 211 // (due to language detection, preferences...) |
| 212 bool triggered_from_menu_; | 212 bool triggered_from_menu_; |
| 213 DISALLOW_COPY_AND_ASSIGN(TranslateInfoBarDelegate); | 213 DISALLOW_COPY_AND_ASSIGN(TranslateInfoBarDelegate); |
| 214 }; | 214 }; |
| 215 | 215 |
| 216 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_INFOBAR_DELEGATE_H_ | 216 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_INFOBAR_DELEGATE_H_ |
| OLD | NEW |