| 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 202 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 213 step != translate::TRANSLATE_STEP_BEFORE_TRANSLATE, | 213 step != translate::TRANSLATE_STEP_BEFORE_TRANSLATE, |
| 214 translate_manager_->GetWeakPtr(), | 214 translate_manager_->GetWeakPtr(), |
| 215 InfoBarService::FromWebContents(web_contents()), | 215 InfoBarService::FromWebContents(web_contents()), |
| 216 web_contents()->GetBrowserContext()->IsOffTheRecord(), step, | 216 web_contents()->GetBrowserContext()->IsOffTheRecord(), step, |
| 217 source_language, target_language, error_type, triggered_from_menu); | 217 source_language, target_language, error_type, triggered_from_menu); |
| 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 translate_manager_->ShouldSuppressBubbleUI(triggered_from_menu, |
| 225 GetLanguageState().SetTranslateEnabled(true); | 225 source_language)) { |
| 226 // In the new UI, continue offering translation after the user navigates to | 226 return; |
| 227 // another page. | 227 } |
| 228 if (!base::FeatureList::IsEnabled(translate::kTranslateUI2016Q2) && | |
| 229 !GetLanguageState().HasLanguageChanged()) { | |
| 230 translate_manager_->RecordTranslateEvent( | |
| 231 metrics::TranslateEventProto::MATCHES_PREVIOUS_LANGUAGE); | |
| 232 return; | |
| 233 } | |
| 234 | 228 |
| 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); | 229 ShowTranslateBubbleResult result = ShowBubble(step, error_type); |
| 243 if (result != ShowTranslateBubbleResult::SUCCESS && | 230 if (result != ShowTranslateBubbleResult::SUCCESS && |
| 244 step == translate::TRANSLATE_STEP_BEFORE_TRANSLATE) { | 231 step == translate::TRANSLATE_STEP_BEFORE_TRANSLATE) { |
| 245 translate_manager_->RecordTranslateEvent( | 232 translate_manager_->RecordTranslateEvent( |
| 246 BubbleResultToTranslateEvent(result)); | 233 BubbleResultToTranslateEvent(result)); |
| 247 } | 234 } |
| 248 } | 235 } |
| 249 | 236 |
| 250 translate::TranslateDriver* ChromeTranslateClient::GetTranslateDriver() { | 237 translate::TranslateDriver* ChromeTranslateClient::GetTranslateDriver() { |
| 251 return &translate_driver_; | 238 return &translate_driver_; |
| (...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 return ShowTranslateBubbleResult::SUCCESS; | 363 return ShowTranslateBubbleResult::SUCCESS; |
| 377 } | 364 } |
| 378 | 365 |
| 379 return TranslateBubbleFactory::Show(browser->window(), web_contents(), step, | 366 return TranslateBubbleFactory::Show(browser->window(), web_contents(), step, |
| 380 error_type); | 367 error_type); |
| 381 #else | 368 #else |
| 382 NOTREACHED(); | 369 NOTREACHED(); |
| 383 return ShowTranslateBubbleResult::SUCCESS; | 370 return ShowTranslateBubbleResult::SUCCESS; |
| 384 #endif | 371 #endif |
| 385 } | 372 } |
| OLD | NEW |