| 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/compiler_specific.h" | |
| 13 #include "base/logging.h" | 12 #include "base/logging.h" |
| 13 #include "base/memory/scoped_ptr.h" |
| 14 #include "chrome/browser/infobars/infobar_delegate.h" | 14 #include "chrome/browser/infobars/infobar_delegate.h" |
| 15 #include "chrome/browser/translate/translate_prefs.h" | 15 #include "chrome/browser/translate/translate_prefs.h" |
| 16 #include "chrome/common/chrome_constants.h" | 16 #include "chrome/common/chrome_constants.h" |
| 17 #include "chrome/common/translate/translate_errors.h" | 17 #include "chrome/common/translate/translate_errors.h" |
| 18 | 18 |
| 19 class PrefService; | 19 class PrefService; |
| 20 | 20 |
| 21 // The defaults after which extra shortcuts for options | 21 // The defaults after which extra shortcuts for options |
| 22 // can be shown. | 22 // can be shown. |
| 23 struct ShortcutConfiguration { | 23 struct ShortcutConfiguration { |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 171 // text is split in 2 or 3 chunks. |swap_languages| is set to true if | 171 // text is split in 2 or 3 chunks. |swap_languages| is set to true if |
| 172 // |autodetermined_source_language| is false, and <lang1> and <lang2> | 172 // |autodetermined_source_language| is false, and <lang1> and <lang2> |
| 173 // should be inverted (some languages express the sentense as "The page has | 173 // should be inverted (some languages express the sentense as "The page has |
| 174 // been translate to <lang2> from <lang1>."). It is ignored if | 174 // been translate to <lang2> from <lang1>."). It is ignored if |
| 175 // |autodetermined_source_language| is true. | 175 // |autodetermined_source_language| is true. |
| 176 static void GetAfterTranslateStrings(std::vector<string16>* strings, | 176 static void GetAfterTranslateStrings(std::vector<string16>* strings, |
| 177 bool* swap_languages, | 177 bool* swap_languages, |
| 178 bool autodetermined_source_language); | 178 bool autodetermined_source_language); |
| 179 | 179 |
| 180 protected: | 180 protected: |
| 181 TranslateInfoBarDelegate(InfoBarService* infobar_service, | 181 TranslateInfoBarDelegate(Type infobar_type, |
| 182 Type infobar_type, | |
| 183 TranslateInfoBarDelegate* old_delegate, | 182 TranslateInfoBarDelegate* old_delegate, |
| 184 const std::string& original_language, | 183 const std::string& original_language, |
| 185 const std::string& target_language, | 184 const std::string& target_language, |
| 186 TranslateErrors::Type error_type, | 185 TranslateErrors::Type error_type, |
| 187 PrefService* prefs, | 186 PrefService* prefs, |
| 188 ShortcutConfiguration shortcut_config); | 187 ShortcutConfiguration shortcut_config); |
| 189 | 188 |
| 190 private: | 189 private: |
| 190 friend class TranslationInfoBarTest; |
| 191 typedef std::pair<std::string, string16> LanguageNamePair; | 191 typedef std::pair<std::string, string16> LanguageNamePair; |
| 192 | 192 |
| 193 // Returns a translate infobar that owns |delegate|. |
| 194 static scoped_ptr<InfoBar> CreateInfoBar( |
| 195 scoped_ptr<TranslateInfoBarDelegate> delegate); |
| 196 |
| 193 // InfoBarDelegate: | 197 // InfoBarDelegate: |
| 194 virtual InfoBar* CreateInfoBar(InfoBarService* infobar_service) OVERRIDE; | |
| 195 virtual void InfoBarDismissed() OVERRIDE; | 198 virtual void InfoBarDismissed() OVERRIDE; |
| 196 virtual int GetIconID() const OVERRIDE; | 199 virtual int GetIconID() const OVERRIDE; |
| 197 virtual InfoBarDelegate::Type GetInfoBarType() const OVERRIDE; | 200 virtual InfoBarDelegate::Type GetInfoBarType() const OVERRIDE; |
| 198 virtual bool ShouldExpire( | 201 virtual bool ShouldExpire( |
| 199 const content::LoadCommittedDetails& details) const OVERRIDE; | 202 const content::LoadCommittedDetails& details) const OVERRIDE; |
| 200 virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate() OVERRIDE; | 203 virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate() OVERRIDE; |
| 201 | 204 |
| 202 // Gets the host of the page being translated, or an empty string if no URL is | 205 // Gets the host of the page being translated, or an empty string if no URL is |
| 203 // associated with the current page. | 206 // associated with the current page. |
| 204 std::string GetPageHost(); | 207 std::string GetPageHost(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 233 | 236 |
| 234 // The translation related preferences. | 237 // The translation related preferences. |
| 235 TranslatePrefs prefs_; | 238 TranslatePrefs prefs_; |
| 236 | 239 |
| 237 // Translation shortcut configuration | 240 // Translation shortcut configuration |
| 238 ShortcutConfiguration shortcut_config_; | 241 ShortcutConfiguration shortcut_config_; |
| 239 DISALLOW_COPY_AND_ASSIGN(TranslateInfoBarDelegate); | 242 DISALLOW_COPY_AND_ASSIGN(TranslateInfoBarDelegate); |
| 240 }; | 243 }; |
| 241 | 244 |
| 242 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_INFOBAR_DELEGATE_H_ | 245 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_INFOBAR_DELEGATE_H_ |
| OLD | NEW |