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" |
12 #include "base/logging.h" | 13 #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/translate/translate_errors.h" | 16 #include "chrome/common/translate/translate_errors.h" |
17 #include "components/translate/common/translate_constants.h" | 17 #include "components/translate/common/translate_constants.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 149 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 // text is split in 2 or 3 chunks. |swap_languages| is set to true if | 173 // text is split in 2 or 3 chunks. |swap_languages| is set to true if |
174 // |autodetermined_source_language| is false, and <lang1> and <lang2> | 174 // |autodetermined_source_language| is false, and <lang1> and <lang2> |
175 // should be inverted (some languages express the sentense as "The page has | 175 // should be inverted (some languages express the sentense as "The page has |
176 // been translate to <lang2> from <lang1>."). It is ignored if | 176 // been translate to <lang2> from <lang1>."). It is ignored if |
177 // |autodetermined_source_language| is true. | 177 // |autodetermined_source_language| is true. |
178 static void GetAfterTranslateStrings(std::vector<string16>* strings, | 178 static void GetAfterTranslateStrings(std::vector<string16>* strings, |
179 bool* swap_languages, | 179 bool* swap_languages, |
180 bool autodetermined_source_language); | 180 bool autodetermined_source_language); |
181 | 181 |
182 protected: | 182 protected: |
183 TranslateInfoBarDelegate(Type infobar_type, | 183 TranslateInfoBarDelegate(InfoBarService* infobar_service, |
| 184 Type infobar_type, |
184 TranslateInfoBarDelegate* old_delegate, | 185 TranslateInfoBarDelegate* old_delegate, |
185 const std::string& original_language, | 186 const std::string& original_language, |
186 const std::string& target_language, | 187 const std::string& target_language, |
187 TranslateErrors::Type error_type, | 188 TranslateErrors::Type error_type, |
188 PrefService* prefs, | 189 PrefService* prefs, |
189 ShortcutConfiguration shortcut_config); | 190 ShortcutConfiguration shortcut_config); |
190 | 191 |
191 private: | 192 private: |
192 friend class TranslationInfoBarTest; | |
193 typedef std::pair<std::string, string16> LanguageNamePair; | 193 typedef std::pair<std::string, string16> LanguageNamePair; |
194 | 194 |
195 // Returns a translate infobar that owns |delegate|. | |
196 static scoped_ptr<InfoBar> CreateInfoBar( | |
197 scoped_ptr<TranslateInfoBarDelegate> delegate); | |
198 | |
199 // InfoBarDelegate: | 195 // InfoBarDelegate: |
| 196 virtual InfoBar* CreateInfoBar(InfoBarService* infobar_service) OVERRIDE; |
200 virtual void InfoBarDismissed() OVERRIDE; | 197 virtual void InfoBarDismissed() OVERRIDE; |
201 virtual int GetIconID() const OVERRIDE; | 198 virtual int GetIconID() const OVERRIDE; |
202 virtual InfoBarDelegate::Type GetInfoBarType() const OVERRIDE; | 199 virtual InfoBarDelegate::Type GetInfoBarType() const OVERRIDE; |
203 virtual bool ShouldExpire( | 200 virtual bool ShouldExpire( |
204 const content::LoadCommittedDetails& details) const OVERRIDE; | 201 const content::LoadCommittedDetails& details) const OVERRIDE; |
205 virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate() OVERRIDE; | 202 virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate() OVERRIDE; |
206 | 203 |
207 Type infobar_type_; | 204 Type infobar_type_; |
208 | 205 |
209 // The type of fading animation if any that should be used when showing this | 206 // The type of fading animation if any that should be used when showing this |
(...skipping 14 matching lines...) Expand all Loading... |
224 | 221 |
225 // The translation related preferences. | 222 // The translation related preferences. |
226 TranslatePrefs prefs_; | 223 TranslatePrefs prefs_; |
227 | 224 |
228 // Translation shortcut configuration | 225 // Translation shortcut configuration |
229 ShortcutConfiguration shortcut_config_; | 226 ShortcutConfiguration shortcut_config_; |
230 DISALLOW_COPY_AND_ASSIGN(TranslateInfoBarDelegate); | 227 DISALLOW_COPY_AND_ASSIGN(TranslateInfoBarDelegate); |
231 }; | 228 }; |
232 | 229 |
233 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_INFOBAR_DELEGATE_H_ | 230 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_INFOBAR_DELEGATE_H_ |
OLD | NEW |