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 <vector> | 7 #include <vector> |
8 | 8 |
9 #include "base/logging.h" | 9 #include "base/logging.h" |
10 #include "base/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
11 #include "base/strings/string_split.h" | 11 #include "base/strings/string_split.h" |
12 #include "chrome/browser/chrome_notification_types.h" | 12 #include "chrome/browser/chrome_notification_types.h" |
13 #include "chrome/browser/infobars/infobar_service.h" | 13 #include "chrome/browser/infobars/infobar_service.h" |
14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
15 #include "chrome/browser/translate/translate_accept_languages_factory.h" | 15 #include "chrome/browser/translate/translate_accept_languages_factory.h" |
16 #include "chrome/browser/translate/translate_infobar_delegate.h" | |
17 #include "chrome/browser/translate/translate_service.h" | 16 #include "chrome/browser/translate/translate_service.h" |
18 #include "chrome/browser/ui/browser.h" | 17 #include "chrome/browser/ui/browser.h" |
19 #include "chrome/browser/ui/browser_finder.h" | 18 #include "chrome/browser/ui/browser_finder.h" |
20 #include "chrome/browser/ui/browser_tabstrip.h" | 19 #include "chrome/browser/ui/browser_tabstrip.h" |
21 #include "chrome/browser/ui/browser_window.h" | 20 #include "chrome/browser/ui/browser_window.h" |
22 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
23 #include "chrome/browser/ui/translate/translate_bubble_factory.h" | 22 #include "chrome/browser/ui/translate/translate_bubble_factory.h" |
24 #include "chrome/common/pref_names.h" | 23 #include "chrome/common/pref_names.h" |
25 #include "components/translate/content/common/translate_messages.h" | 24 #include "components/translate/content/common/translate_messages.h" |
26 #include "components/translate/core/browser/page_translated_details.h" | 25 #include "components/translate/core/browser/page_translated_details.h" |
27 #include "components/translate/core/browser/translate_accept_languages.h" | 26 #include "components/translate/core/browser/translate_accept_languages.h" |
28 #include "components/translate/core/browser/translate_download_manager.h" | 27 #include "components/translate/core/browser/translate_download_manager.h" |
| 28 #include "components/translate/core/browser/translate_infobar_delegate.h" |
29 #include "components/translate/core/browser/translate_manager.h" | 29 #include "components/translate/core/browser/translate_manager.h" |
30 #include "components/translate/core/browser/translate_prefs.h" | 30 #include "components/translate/core/browser/translate_prefs.h" |
31 #include "components/translate/core/common/language_detection_details.h" | 31 #include "components/translate/core/common/language_detection_details.h" |
32 #include "content/public/browser/navigation_details.h" | 32 #include "content/public/browser/navigation_details.h" |
33 #include "content/public/browser/navigation_entry.h" | 33 #include "content/public/browser/navigation_entry.h" |
34 #include "content/public/browser/notification_service.h" | 34 #include "content/public/browser/notification_service.h" |
35 #include "content/public/browser/render_view_host.h" | 35 #include "content/public/browser/render_view_host.h" |
36 #include "content/public/browser/web_contents.h" | 36 #include "content/public/browser/web_contents.h" |
| 37 #include "grit/theme_resources.h" |
37 #include "net/http/http_status_code.h" | 38 #include "net/http/http_status_code.h" |
38 #include "url/gurl.h" | 39 #include "url/gurl.h" |
39 | 40 |
40 #if defined(CLD2_DYNAMIC_MODE) | 41 #if defined(CLD2_DYNAMIC_MODE) |
41 #include "base/files/file.h" | 42 #include "base/files/file.h" |
42 #include "base/path_service.h" | 43 #include "base/path_service.h" |
43 #include "chrome/common/chrome_constants.h" | 44 #include "chrome/common/chrome_constants.h" |
44 #include "chrome/common/chrome_paths.h" | 45 #include "chrome/common/chrome_paths.h" |
45 #include "content/public/browser/browser_thread.h" | 46 #include "content/public/browser/browser_thread.h" |
46 #include "content/public/browser/render_process_host.h" | 47 #include "content/public/browser/render_process_host.h" |
(...skipping 177 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
224 if (!browser) { | 225 if (!browser) { |
225 NOTREACHED(); | 226 NOTREACHED(); |
226 return; | 227 return; |
227 } | 228 } |
228 | 229 |
229 chrome::AddSelectedTabWithURL( | 230 chrome::AddSelectedTabWithURL( |
230 browser, report_url, content::PAGE_TRANSITION_AUTO_BOOKMARK); | 231 browser, report_url, content::PAGE_TRANSITION_AUTO_BOOKMARK); |
231 #endif // defined(OS_ANDROID) | 232 #endif // defined(OS_ANDROID) |
232 } | 233 } |
233 | 234 |
| 235 int TranslateTabHelper::GetInfobarIconID() const { |
| 236 return IDR_INFOBAR_TRANSLATE; |
| 237 } |
| 238 |
234 bool TranslateTabHelper::OnMessageReceived(const IPC::Message& message) { | 239 bool TranslateTabHelper::OnMessageReceived(const IPC::Message& message) { |
235 bool handled = true; | 240 bool handled = true; |
236 IPC_BEGIN_MESSAGE_MAP(TranslateTabHelper, message) | 241 IPC_BEGIN_MESSAGE_MAP(TranslateTabHelper, message) |
237 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_TranslateLanguageDetermined, | 242 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_TranslateLanguageDetermined, |
238 OnLanguageDetermined) | 243 OnLanguageDetermined) |
239 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_PageTranslated, OnPageTranslated) | 244 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_PageTranslated, OnPageTranslated) |
240 #if defined(CLD2_DYNAMIC_MODE) | 245 #if defined(CLD2_DYNAMIC_MODE) |
241 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_NeedCLDData, OnCLDDataRequested) | 246 IPC_MESSAGE_HANDLER(ChromeViewHostMsg_NeedCLDData, OnCLDDataRequested) |
242 #endif | 247 #endif |
243 IPC_MESSAGE_UNHANDLED(handled = false) | 248 IPC_MESSAGE_UNHANDLED(handled = false) |
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
537 if (GetLanguageState().InTranslateNavigation()) | 542 if (GetLanguageState().InTranslateNavigation()) |
538 return; | 543 return; |
539 } | 544 } |
540 | 545 |
541 TranslateBubbleFactory::Show( | 546 TranslateBubbleFactory::Show( |
542 browser->window(), web_contents(), step, error_type); | 547 browser->window(), web_contents(), step, error_type); |
543 #else | 548 #else |
544 NOTREACHED(); | 549 NOTREACHED(); |
545 #endif | 550 #endif |
546 } | 551 } |
OLD | NEW |