Chromium Code Reviews| 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 "chrome/browser/translate/chrome_translate_client.h" | 5 #include "chrome/browser/translate/chrome_translate_client.h" |
| 6 | 6 |
| 7 #include <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/logging.h" | 9 #include "base/logging.h" |
| 10 #include "base/path_service.h" | 10 #include "base/path_service.h" |
| (...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 218 return; | 218 return; |
| 219 } | 219 } |
| 220 #endif | 220 #endif |
| 221 | 221 |
| 222 // Bubble UI. | 222 // Bubble UI. |
| 223 if (step == translate::TRANSLATE_STEP_BEFORE_TRANSLATE) { | 223 if (step == translate::TRANSLATE_STEP_BEFORE_TRANSLATE) { |
| 224 // TODO(droger): Move this logic out of UI code. | 224 // TODO(droger): Move this logic out of UI code. |
| 225 GetLanguageState().SetTranslateEnabled(true); | 225 GetLanguageState().SetTranslateEnabled(true); |
| 226 // In the new UI, continue offering translation after the user navigates to | 226 // In the new UI, continue offering translation after the user navigates to |
| 227 // another page. | 227 // another page. |
| 228 if (!base::FeatureList::IsEnabled(translate::kTranslateUI2016Q2) && | 228 if (!base::FeatureList::IsEnabled(translate::kTranslateUI2016Q2) && |
|
groby-ooo-7-16
2017/04/10 20:52:47
I _really_ would prefer if this logic could be mov
hamelphi
2017/04/11 22:46:07
I moved the logic to TranslateManager. Let me know
hamelphi
2017/04/12 21:10:53
Unittests done.
| |
| 229 !GetLanguageState().HasLanguageChanged()) { | 229 !GetLanguageState().HasLanguageChanged() && |
| 230 translate_manager_->RecordTranslateEvent( | 230 !translate_manager_->ShouldOverrideDecision( |
| 231 metrics::TranslateEventProto::MATCHES_PREVIOUS_LANGUAGE); | 231 metrics::TranslateEventProto::MATCHES_PREVIOUS_LANGUAGE)) { |
| 232 return; | 232 return; |
| 233 } | 233 } |
| 234 if (!triggered_from_menu && | |
| 235 GetTranslatePrefs()->IsTooOftenDenied(source_language) && | |
| 236 !translate_manager_->ShouldOverrideDecision( | |
| 237 metrics::TranslateEventProto::LANGUAGE_DISABLED_BY_AUTO_BLACKLIST)) | |
| 238 return; | |
| 239 } | |
| 234 | 240 |
| 235 if (!triggered_from_menu && | |
| 236 GetTranslatePrefs()->IsTooOftenDenied(source_language)) { | |
| 237 translate_manager_->RecordTranslateEvent( | |
| 238 metrics::TranslateEventProto::LANGUAGE_DISABLED_BY_AUTO_BLACKLIST); | |
| 239 return; | |
| 240 } | |
| 241 } | |
| 242 ShowTranslateBubbleResult result = ShowBubble(step, error_type); | 241 ShowTranslateBubbleResult result = ShowBubble(step, error_type); |
| 243 if (result != ShowTranslateBubbleResult::SUCCESS && | 242 if (result != ShowTranslateBubbleResult::SUCCESS && |
| 244 step == translate::TRANSLATE_STEP_BEFORE_TRANSLATE) { | 243 step == translate::TRANSLATE_STEP_BEFORE_TRANSLATE) { |
| 245 translate_manager_->RecordTranslateEvent( | 244 translate_manager_->RecordTranslateEvent( |
| 246 BubbleResultToTranslateEvent(result)); | 245 BubbleResultToTranslateEvent(result)); |
| 247 } | 246 } |
| 248 } | 247 } |
| 249 | 248 |
| 250 translate::TranslateDriver* ChromeTranslateClient::GetTranslateDriver() { | 249 translate::TranslateDriver* ChromeTranslateClient::GetTranslateDriver() { |
| 251 return &translate_driver_; | 250 return &translate_driver_; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 376 return ShowTranslateBubbleResult::SUCCESS; | 375 return ShowTranslateBubbleResult::SUCCESS; |
| 377 } | 376 } |
| 378 | 377 |
| 379 return TranslateBubbleFactory::Show(browser->window(), web_contents(), step, | 378 return TranslateBubbleFactory::Show(browser->window(), web_contents(), step, |
| 380 error_type); | 379 error_type); |
| 381 #else | 380 #else |
| 382 NOTREACHED(); | 381 NOTREACHED(); |
| 383 return ShowTranslateBubbleResult::SUCCESS; | 382 return ShowTranslateBubbleResult::SUCCESS; |
| 384 #endif | 383 #endif |
| 385 } | 384 } |
| OLD | NEW |