OLD | NEW |
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 #include "chrome/browser/translate/translate_tab_helper.h" | 5 #include "chrome/browser/translate/translate_tab_helper.h" |
6 | 6 |
7 #include "chrome/browser/translate/page_translated_details.h" | 7 #include "chrome/browser/translate/page_translated_details.h" |
| 8 #include "chrome/common/chrome_notification_types.h" |
8 #include "chrome/common/render_messages.h" | 9 #include "chrome/common/render_messages.h" |
9 #include "content/browser/tab_contents/tab_contents.h" | 10 #include "content/browser/tab_contents/tab_contents.h" |
10 #include "content/common/notification_service.h" | 11 #include "content/common/notification_service.h" |
11 | 12 |
12 TranslateTabHelper::TranslateTabHelper(TabContents* tab_contents) | 13 TranslateTabHelper::TranslateTabHelper(TabContents* tab_contents) |
13 : TabContentsObserver(tab_contents), | 14 : TabContentsObserver(tab_contents), |
14 language_state_(&tab_contents->controller()) { | 15 language_state_(&tab_contents->controller()) { |
15 } | 16 } |
16 | 17 |
17 TranslateTabHelper::~TranslateTabHelper() { | 18 TranslateTabHelper::~TranslateTabHelper() { |
(...skipping 17 matching lines...) Expand all Loading... |
35 // Let the LanguageState clear its state. | 36 // Let the LanguageState clear its state. |
36 language_state_.DidNavigate(details); | 37 language_state_.DidNavigate(details); |
37 } | 38 } |
38 | 39 |
39 void TranslateTabHelper::OnLanguageDetermined(const std::string& language, | 40 void TranslateTabHelper::OnLanguageDetermined(const std::string& language, |
40 bool page_translatable) { | 41 bool page_translatable) { |
41 language_state_.LanguageDetermined(language, page_translatable); | 42 language_state_.LanguageDetermined(language, page_translatable); |
42 | 43 |
43 std::string lang = language; | 44 std::string lang = language; |
44 NotificationService::current()->Notify( | 45 NotificationService::current()->Notify( |
45 NotificationType::TAB_LANGUAGE_DETERMINED, | 46 chrome::NOTIFICATION_TAB_LANGUAGE_DETERMINED, |
46 Source<TabContents>(tab_contents()), | 47 Source<TabContents>(tab_contents()), |
47 Details<std::string>(&lang)); | 48 Details<std::string>(&lang)); |
48 } | 49 } |
49 | 50 |
50 void TranslateTabHelper::OnPageTranslated(int32 page_id, | 51 void TranslateTabHelper::OnPageTranslated(int32 page_id, |
51 const std::string& original_lang, | 52 const std::string& original_lang, |
52 const std::string& translated_lang, | 53 const std::string& translated_lang, |
53 TranslateErrors::Type error_type) { | 54 TranslateErrors::Type error_type) { |
54 language_state_.set_current_language(translated_lang); | 55 language_state_.set_current_language(translated_lang); |
55 language_state_.set_translation_pending(false); | 56 language_state_.set_translation_pending(false); |
56 PageTranslatedDetails details(original_lang, translated_lang, error_type); | 57 PageTranslatedDetails details(original_lang, translated_lang, error_type); |
57 NotificationService::current()->Notify( | 58 NotificationService::current()->Notify( |
58 NotificationType::PAGE_TRANSLATED, | 59 chrome::NOTIFICATION_PAGE_TRANSLATED, |
59 Source<TabContents>(tab_contents()), | 60 Source<TabContents>(tab_contents()), |
60 Details<PageTranslatedDetails>(&details)); | 61 Details<PageTranslatedDetails>(&details)); |
61 } | 62 } |
OLD | NEW |