blob: 311b847055310a0d6c3949c0be31825416a99dfb (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
|
// Copyright (c) 2010 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#ifndef CHROME_BROWSER_TRANSLATE_TRANSLATE_INFOBARS_DELEGATES_H_
#define CHROME_BROWSER_TRANSLATE_TRANSLATE_INFOBARS_DELEGATES_H_
#include "chrome/browser/tab_contents/infobar_delegate.h"
#include "chrome/browser/translate/translate_prefs.h"
class SkBitmap;
// An interface derived from InfoBarDelegate to form the base interface for
// translate infobars.
class TranslateInfoBarDelegate : public InfoBarDelegate {
public:
enum TranslateState {
kBeforeTranslate = 1,
kTranslating,
kAfterTranslate,
kTranslationFailed,
};
TranslateInfoBarDelegate(TabContents* contents, PrefService* user_prefs,
TranslateState state, const GURL& url,
const std::string& original_language, const std::string& target_language);
void UpdateState(TranslateState new_state);
void GetAvailableOriginalLanguages(std::vector<std::string>* languages);
void GetAvailableTargetLanguages(std::vector<std::string>* languages);
void ModifyOriginalLanguage(int lang_index);
void ModifyTargetLanguage(int lang_index);
void Translate();
bool IsLanguageBlacklisted();
void ToggleLanguageBlacklist();
bool IsSiteBlacklisted();
void ToggleSiteBlacklist();
bool ShouldAlwaysTranslate();
void ToggleAlwaysTranslate();
int original_lang_index() const {
return original_lang_index_;
}
int target_lang_index() const {
return target_lang_index_;
}
const std::string& original_lang_code() const {
return supported_languages_[original_lang_index_];
}
const std::string& target_lang_code() const {
return supported_languages_[target_lang_index_];
}
const std::string& GetLocaleFromIndex(int lang_index) const {
return supported_languages_[lang_index];
}
TabContents* tab_contents() const {
return tab_contents_;
}
TranslateState state() const {
return state_;
}
// Overridden from InfoBarDelegate.
virtual Type GetInfoBarType() {
return PAGE_ACTION_TYPE;
}
virtual SkBitmap* GetIcon() const;
virtual TranslateInfoBarDelegate* AsTranslateInfoBarDelegate() {
return this;
}
virtual bool EqualsDelegate(InfoBarDelegate* delegate) const;
virtual void InfoBarClosed();
// Returns the printable version of the language code |language_code|.
static string16 GetDisplayNameForLocale(const std::string& language_code);
// Overridden from InfoBarDelegate:
virtual InfoBar* CreateInfoBar();
private:
TabContents* tab_contents_; // Weak.
TranslatePrefs prefs_;
TranslateState state_;
std::string site_;
int original_lang_index_;
int target_lang_index_;
// The list of languages supported.
std::vector<std::string> supported_languages_;
bool never_translate_language_;
bool never_translate_site_;
bool always_translate_;
DISALLOW_COPY_AND_ASSIGN(TranslateInfoBarDelegate);
};
#endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_INFOBARS_DELEGATES_H_
|