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

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

Issue 10537090: TabContentsWrapper -> TabContents, part 32. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 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) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_MANAGER_H_ 5 #ifndef CHROME_BROWSER_TRANSLATE_TRANSLATE_MANAGER_H_
6 #define CHROME_BROWSER_TRANSLATE_TRANSLATE_MANAGER_H_ 6 #define CHROME_BROWSER_TRANSLATE_TRANSLATE_MANAGER_H_
7 #pragma once 7 #pragma once
8 8
9 #include <map> 9 #include <map>
10 #include <set> 10 #include <set>
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after
87 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE; 87 virtual void OnURLFetchComplete(const net::URLFetcher* source) OVERRIDE;
88 88
89 // Used by unit-tests to override the default delay after which the translate 89 // Used by unit-tests to override the default delay after which the translate
90 // script is fetched again from the translation server. 90 // script is fetched again from the translation server.
91 void set_translate_script_expiration_delay(int delay_ms) { 91 void set_translate_script_expiration_delay(int delay_ms) {
92 translate_script_expiration_delay_ = 92 translate_script_expiration_delay_ =
93 base::TimeDelta::FromMilliseconds(delay_ms); 93 base::TimeDelta::FromMilliseconds(delay_ms);
94 } 94 }
95 95
96 // Convenience method to know if a tab is showing a translate infobar. 96 // Convenience method to know if a tab is showing a translate infobar.
97 static bool IsShowingTranslateInfobar(content::WebContents* tab); 97 static bool IsShowingTranslateInfobar(content::WebContents* web_contents);
98 98
99 // Returns true if the URL can be translated. 99 // Returns true if the URL can be translated.
100 static bool IsTranslatableURL(const GURL& url); 100 static bool IsTranslatableURL(const GURL& url);
101 101
102 // Fills |languages| with the list of languages that the translate server can 102 // Fills |languages| with the list of languages that the translate server can
103 // translate to and from. 103 // translate to and from.
104 static void GetSupportedLanguages(std::vector<std::string>* languages); 104 static void GetSupportedLanguages(std::vector<std::string>* languages);
105 105
106 // Returns the language code that can be used with the Translate method for a 106 // Returns the language code that can be used with the Translate method for a
107 // specified |chrome_locale|. 107 // specified |chrome_locale|.
(...skipping 27 matching lines...) Expand all
135 // Fills supported_languages_ with the list of languages that the translate 135 // Fills supported_languages_ with the list of languages that the translate
136 // server can translate to and from. 136 // server can translate to and from.
137 static void SetSupportedLanguages(const std::string& language_list); 137 static void SetSupportedLanguages(const std::string& language_list);
138 138
139 // Initializes the list of supported languages if it wasn't initialized before 139 // Initializes the list of supported languages if it wasn't initialized before
140 // in case we failed to get them from the server, or didn't get them just yet. 140 // in case we failed to get them from the server, or didn't get them just yet.
141 static void InitSupportedLanguages(); 141 static void InitSupportedLanguages();
142 142
143 // Starts the translation process on |tab| containing the page in the 143 // Starts the translation process on |tab| containing the page in the
144 // |page_lang| language. 144 // |page_lang| language.
145 void InitiateTranslation(content::WebContents* tab, 145 void InitiateTranslation(content::WebContents* web_contents,
146 const std::string& page_lang); 146 const std::string& page_lang);
147 147
148 // If the tab identified by |process_id| and |render_id| has been closed, this 148 // If the tab identified by |process_id| and |render_id| has been closed, this
149 // does nothing, otherwise it calls InitiateTranslation. 149 // does nothing, otherwise it calls InitiateTranslation.
150 void InitiateTranslationPosted(int process_id, 150 void InitiateTranslationPosted(int process_id,
151 int render_id, 151 int render_id,
152 const std::string& page_lang); 152 const std::string& page_lang);
153 153
154 // Sends a translation request to the RenderView of |tab_contents|. 154 // Sends a translation request to the RenderView of |tab_contents|.
155 void DoTranslatePage(content::WebContents* web_contents, 155 void DoTranslatePage(content::WebContents* web_contents,
156 const std::string& translate_script, 156 const std::string& translate_script,
157 const std::string& source_lang, 157 const std::string& source_lang,
158 const std::string& target_lang); 158 const std::string& target_lang);
159 159
160 // Shows the after translate or error infobar depending on the details. 160 // Shows the after translate or error infobar depending on the details.
161 void PageTranslated(content::WebContents* tab, 161 void PageTranslated(content::WebContents* web_contents,
162 PageTranslatedDetails* details); 162 PageTranslatedDetails* details);
163 163
164 // Returns true if the passed language has been configured by the user as an 164 // Returns true if the passed language has been configured by the user as an
165 // accept language. 165 // accept language.
166 bool IsAcceptLanguage(content::WebContents* tab, const std::string& language); 166 bool IsAcceptLanguage(content::WebContents* web_contents,
167 const std::string& language);
167 168
168 // Initializes the |accept_languages_| language table based on the associated 169 // Initializes the |accept_languages_| language table based on the associated
169 // preference in |prefs|. 170 // preference in |prefs|.
170 void InitAcceptLanguages(PrefService* prefs); 171 void InitAcceptLanguages(PrefService* prefs);
171 172
172 // Fetches the JS translate script (the script that is injected in the page 173 // Fetches the JS translate script (the script that is injected in the page
173 // to translate it). 174 // to translate it).
174 void RequestTranslateScript(); 175 void RequestTranslateScript();
175 176
176 // Shows the specified translate |infobar| in the given |tab|. If a current 177 // Shows the specified translate |infobar| in the given |tab|. If a current
177 // translate infobar is showing, it just replaces it with the new one. 178 // translate infobar is showing, it just replaces it with the new one.
178 void ShowInfoBar(content::WebContents* tab, 179 void ShowInfoBar(content::WebContents* web_contents,
179 TranslateInfoBarDelegate* infobar); 180 TranslateInfoBarDelegate* infobar);
180 181
181 // Returns the language to translate to. The language returned is the 182 // Returns the language to translate to. The language returned is the
182 // first language found in the following list that is supported by the 183 // first language found in the following list that is supported by the
183 // translation service: 184 // translation service:
184 // the UI language 185 // the UI language
185 // the accept-language list 186 // the accept-language list
186 // If no language is found then an empty string is returned. 187 // If no language is found then an empty string is returned.
187 static std::string GetTargetLanguage(PrefService* prefs); 188 static std::string GetTargetLanguage(PrefService* prefs);
188 189
189 // Returns the translate info bar showing in |tab| or NULL if none is showing. 190 // Returns the translate info bar showing in |tab| or NULL if none is showing.
190 static TranslateInfoBarDelegate* GetTranslateInfoBarDelegate( 191 static TranslateInfoBarDelegate* GetTranslateInfoBarDelegate(
191 content::WebContents* tab); 192 content::WebContents* web_contents);
192 193
193 content::NotificationRegistrar notification_registrar_; 194 content::NotificationRegistrar notification_registrar_;
194 195
195 // Each PrefChangeRegistrar only tracks a single PrefService, so a map from 196 // Each PrefChangeRegistrar only tracks a single PrefService, so a map from
196 // each PrefService used to its registrar is needed. 197 // each PrefService used to its registrar is needed.
197 typedef std::map<PrefService*, PrefChangeRegistrar*> PrefServiceRegistrarMap; 198 typedef std::map<PrefService*, PrefChangeRegistrar*> PrefServiceRegistrarMap;
198 PrefServiceRegistrarMap pref_change_registrars_; 199 PrefServiceRegistrarMap pref_change_registrars_;
199 200
200 // A map that associates a profile with its parsed "accept languages". 201 // A map that associates a profile with its parsed "accept languages".
201 typedef std::set<std::string> LanguageSet; 202 typedef std::set<std::string> LanguageSet;
(...skipping 21 matching lines...) Expand all
223 // server. 224 // server.
224 std::vector<PendingRequest> pending_requests_; 225 std::vector<PendingRequest> pending_requests_;
225 226
226 // The languages supported by the translation server. 227 // The languages supported by the translation server.
227 static base::LazyInstance<std::set<std::string> > supported_languages_; 228 static base::LazyInstance<std::set<std::string> > supported_languages_;
228 229
229 DISALLOW_COPY_AND_ASSIGN(TranslateManager); 230 DISALLOW_COPY_AND_ASSIGN(TranslateManager);
230 }; 231 };
231 232
232 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_MANAGER_H_ 233 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_MANAGER_H_
OLDNEW
« no previous file with comments | « chrome/browser/translate/translate_infobar_delegate.cc ('k') | chrome/browser/translate/translate_manager.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698