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

Side by Side Diff: chrome/browser/translate/translate_infobar_delegate.h

Issue 11644059: Change infobar creation to use a public static Create() method on the infobar delegate classes. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 7 years, 11 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 | Annotate | Revision Log
OLDNEW
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>
(...skipping 19 matching lines...) Expand all
30 30
31 // The types of background color animations. 31 // The types of background color animations.
32 enum BackgroundAnimationType { 32 enum BackgroundAnimationType {
33 NONE, 33 NONE,
34 NORMAL_TO_ERROR, 34 NORMAL_TO_ERROR,
35 ERROR_TO_NORMAL 35 ERROR_TO_NORMAL
36 }; 36 };
37 37
38 static const size_t kNoIndex; 38 static const size_t kNoIndex;
39 39
40 // Factory method to create a non-error translate infobar. |original_language| 40 virtual ~TranslateInfoBarDelegate();
41 // and |target_language| must be ASCII language codes (e.g. "en", "fr", etc.)
42 // for languages the TranslateManager supports translating. The lone exception
43 // is when the user initiates translation from the context menu, in which case
44 // it's legal to call this with |type| == TRANSLATING and
45 // |originalLanguage| == kUnknownLanguageCode.
46 static TranslateInfoBarDelegate* CreateDelegate(
47 Type infobar_type,
48 InfoBarService* infobar_service,
49 PrefService* prefs,
50 const std::string& original_language,
51 const std::string& target_language);
52 41
53 // Factory method to create an error translate infobar. 42 // Factory method to create a translate infobar. |error_type| must be
54 static TranslateInfoBarDelegate* CreateErrorDelegate( 43 // specified iff |infobar_type| == TRANSLATION_ERROR. For other infobar
55 TranslateErrors::Type error_type, 44 // types, |original_language| and |target_language| must be ASCII language
56 InfoBarService* infobar_service, 45 // codes (e.g. "en", "fr", etc.) for languages the TranslateManager supports
57 PrefService* prefs, 46 // translating. The lone exception is when the user initiates translation
58 const std::string& original_language, 47 // from the context menu, in which case it's legal to call this with
59 const std::string& target_language); 48 // |infobar_type| == TRANSLATING and
60 49 // |original_language| == kUnknownLanguageCode.
61 virtual ~TranslateInfoBarDelegate(); 50 //
51 // If |replace_existing_infobar| is true, the infobar is created and added to
52 // |infobar_service|, replacing any other translate infobar already present
53 // there. Otherwise, the infobar will only be added if there is no other
54 // translate infobar already present.
55 static void Create(InfoBarService* infobar_service,
56 bool replace_existing_infobar,
57 Type infobar_type,
58 TranslateErrors::Type error_type,
59 PrefService* prefs,
60 const std::string& original_language,
61 const std::string& target_language);
62 62
63 // Returns the number of languages supported. 63 // Returns the number of languages supported.
64 size_t num_languages() const { return languages_.size(); } 64 size_t num_languages() const { return languages_.size(); }
65 65
66 // Returns the ISO code for the language at |index|. 66 // Returns the ISO code for the language at |index|.
67 std::string language_code_at(size_t index) const { 67 std::string language_code_at(size_t index) const {
68 DCHECK_LT(index, num_languages()); 68 DCHECK_LT(index, num_languages());
69 return languages_[index].first; 69 return languages_[index].first;
70 } 70 }
71 71
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 // The error that occurred when trying to translate (NONE if no error). 216 // The error that occurred when trying to translate (NONE if no error).
217 TranslateErrors::Type error_type_; 217 TranslateErrors::Type error_type_;
218 218
219 // The translation related preferences. 219 // The translation related preferences.
220 TranslatePrefs prefs_; 220 TranslatePrefs prefs_;
221 221
222 DISALLOW_COPY_AND_ASSIGN(TranslateInfoBarDelegate); 222 DISALLOW_COPY_AND_ASSIGN(TranslateInfoBarDelegate);
223 }; 223 };
224 224
225 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_INFOBAR_DELEGATE_H_ 225 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_INFOBAR_DELEGATE_H_
OLDNEW
« no previous file with comments | « chrome/browser/three_d_api_observer.cc ('k') | chrome/browser/translate/translate_infobar_delegate.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698