OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 "components/translate/core/browser/language_state.h" | 5 #include "components/translate/core/browser/language_state.h" |
6 | 6 |
7 #include "base/logging.h" | 7 #include "base/logging.h" |
8 #include "components/translate/core/browser/translate_driver.h" | 8 #include "components/translate/core/browser/translate_driver.h" |
9 | 9 |
10 namespace translate { | 10 namespace translate { |
11 | 11 |
12 LanguageState::LanguageState(TranslateDriver* driver) | 12 LanguageState::LanguageState(TranslateDriver* driver) |
13 : is_page_translated_(false), | 13 : is_page_translated_(false), |
14 translate_driver_(driver), | 14 translate_driver_(driver), |
15 page_needs_translation_(false), | 15 page_needs_translation_(false), |
16 translation_pending_(false), | 16 translation_pending_(false), |
| 17 translation_error_(false), |
17 translation_declined_(false), | 18 translation_declined_(false), |
18 in_page_navigation_(false), | 19 in_page_navigation_(false), |
19 translate_enabled_(false) { | 20 translate_enabled_(false) { |
20 DCHECK(translate_driver_); | 21 DCHECK(translate_driver_); |
21 } | 22 } |
22 | 23 |
23 LanguageState::~LanguageState() { | 24 LanguageState::~LanguageState() { |
24 } | 25 } |
25 | 26 |
26 void LanguageState::DidNavigate(bool in_page_navigation, | 27 void LanguageState::DidNavigate(bool in_page_navigation, |
(...skipping 11 matching lines...) Expand all Loading... |
38 } else { | 39 } else { |
39 prev_original_lang_ = original_lang_; | 40 prev_original_lang_ = original_lang_; |
40 prev_current_lang_ = current_lang_; | 41 prev_current_lang_ = current_lang_; |
41 original_lang_.clear(); | 42 original_lang_.clear(); |
42 current_lang_.clear(); | 43 current_lang_.clear(); |
43 } | 44 } |
44 | 45 |
45 SetIsPageTranslated(false); | 46 SetIsPageTranslated(false); |
46 | 47 |
47 translation_pending_ = false; | 48 translation_pending_ = false; |
| 49 translation_error_ = false; |
48 translation_declined_ = false; | 50 translation_declined_ = false; |
49 | 51 |
50 SetTranslateEnabled(false); | 52 SetTranslateEnabled(false); |
51 } | 53 } |
52 | 54 |
53 void LanguageState::LanguageDetermined(const std::string& page_language, | 55 void LanguageState::LanguageDetermined(const std::string& page_language, |
54 bool page_needs_translation) { | 56 bool page_needs_translation) { |
55 if (in_page_navigation_ && !original_lang_.empty()) { | 57 if (in_page_navigation_ && !original_lang_.empty()) { |
56 // In-page navigation, we don't expect our states to change. | 58 // In-page navigation, we don't expect our states to change. |
57 // Note that we'll set the languages if original_lang_ is empty. This might | 59 // Note that we'll set the languages if original_lang_ is empty. This might |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
107 | 109 |
108 is_page_translated_ = value; | 110 is_page_translated_ = value; |
109 translate_driver_->OnIsPageTranslatedChanged(); | 111 translate_driver_->OnIsPageTranslatedChanged(); |
110 | 112 |
111 // With the translation done, the translate feature must be enabled. | 113 // With the translation done, the translate feature must be enabled. |
112 if (is_page_translated_) | 114 if (is_page_translated_) |
113 SetTranslateEnabled(true); | 115 SetTranslateEnabled(true); |
114 } | 116 } |
115 | 117 |
116 } // namespace translate | 118 } // namespace translate |
OLD | NEW |