OLD | NEW |
1 // Copyright 2011 The Chromium Authors. All rights reserved. | 1 // Copyright 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 #include "chrome/browser/translate/translate_tab_helper.h" | 5 #include "chrome/browser/translate/translate_tab_helper.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
9 #include "base/strings/string_split.h" | 9 #include "base/strings/string_split.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 12 matching lines...) Expand all Loading... |
23 #include "components/translate/core/browser/page_translated_details.h" | 23 #include "components/translate/core/browser/page_translated_details.h" |
24 #include "components/translate/core/browser/translate_accept_languages.h" | 24 #include "components/translate/core/browser/translate_accept_languages.h" |
25 #include "components/translate/core/browser/translate_download_manager.h" | 25 #include "components/translate/core/browser/translate_download_manager.h" |
26 #include "components/translate/core/browser/translate_prefs.h" | 26 #include "components/translate/core/browser/translate_prefs.h" |
27 #include "components/translate/core/common/language_detection_details.h" | 27 #include "components/translate/core/common/language_detection_details.h" |
28 #include "content/public/browser/navigation_details.h" | 28 #include "content/public/browser/navigation_details.h" |
29 #include "content/public/browser/navigation_entry.h" | 29 #include "content/public/browser/navigation_entry.h" |
30 #include "content/public/browser/notification_service.h" | 30 #include "content/public/browser/notification_service.h" |
31 #include "content/public/browser/web_contents.h" | 31 #include "content/public/browser/web_contents.h" |
32 #include "net/http/http_status_code.h" | 32 #include "net/http/http_status_code.h" |
| 33 #include "url/gurl.h" |
33 | 34 |
34 #if defined(CLD2_DYNAMIC_MODE) | 35 #if defined(CLD2_DYNAMIC_MODE) |
35 #include "base/files/file.h" | 36 #include "base/files/file.h" |
36 #include "base/path_service.h" | 37 #include "base/path_service.h" |
37 #include "chrome/common/chrome_paths.h" | 38 #include "chrome/common/chrome_paths.h" |
38 #include "content/public/browser/browser_thread.h" | 39 #include "content/public/browser/browser_thread.h" |
39 #include "content/public/browser/render_process_host.h" | 40 #include "content/public/browser/render_process_host.h" |
40 #include "content/public/browser/render_view_host.h" | 41 #include "content/public/browser/render_view_host.h" |
41 #endif | 42 #endif |
42 | 43 |
(...skipping 150 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
193 Profile* profile = | 194 Profile* profile = |
194 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 195 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
195 return CreateTranslatePrefs(profile->GetPrefs()); | 196 return CreateTranslatePrefs(profile->GetPrefs()); |
196 } | 197 } |
197 | 198 |
198 TranslateAcceptLanguages* TranslateTabHelper::GetTranslateAcceptLanguages() { | 199 TranslateAcceptLanguages* TranslateTabHelper::GetTranslateAcceptLanguages() { |
199 DCHECK(web_contents()); | 200 DCHECK(web_contents()); |
200 return GetTranslateAcceptLanguages(web_contents()->GetBrowserContext()); | 201 return GetTranslateAcceptLanguages(web_contents()->GetBrowserContext()); |
201 } | 202 } |
202 | 203 |
| 204 bool TranslateTabHelper::IsTranslatableURL(const GURL& url) { |
| 205 return TranslateService::IsTranslatableURL(url); |
| 206 } |
| 207 |
203 bool TranslateTabHelper::OnMessageReceived(const IPC::Message& message) { | 208 bool TranslateTabHelper::OnMessageReceived(const IPC::Message& message) { |
204 bool handled = true; | 209 bool handled = true; |
205 IPC_BEGIN_MESSAGE_MAP(TranslateTabHelper, message) | 210 IPC_BEGIN_MESSAGE_MAP(TranslateTabHelper, message) |
206 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_TranslateLanguageDetermined, | 211 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_TranslateLanguageDetermined, |
207 OnLanguageDetermined) | 212 OnLanguageDetermined) |
208 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_PageTranslated, OnPageTranslated) | 213 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_PageTranslated, OnPageTranslated) |
209 #if defined(CLD2_DYNAMIC_MODE) | 214 #if defined(CLD2_DYNAMIC_MODE) |
210 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_NeedCLDData, OnCLDDataRequested) | 215 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_NeedCLDData, OnCLDDataRequested) |
211 #endif | 216 #endif |
212 IPC_MESSAGE_UNHANDLED(handled = false) | 217 IPC_MESSAGE_UNHANDLED(handled = false) |
(...skipping 283 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
496 if (GetLanguageState().InTranslateNavigation()) | 501 if (GetLanguageState().InTranslateNavigation()) |
497 return; | 502 return; |
498 } | 503 } |
499 | 504 |
500 TranslateBubbleFactory::Show( | 505 TranslateBubbleFactory::Show( |
501 browser->window(), web_contents(), step, error_type); | 506 browser->window(), web_contents(), step, error_type); |
502 #else | 507 #else |
503 NOTREACHED(); | 508 NOTREACHED(); |
504 #endif | 509 #endif |
505 } | 510 } |
OLD | NEW |