| 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/prefs/pref_service.h" | 10 #include "base/prefs/pref_service.h" |
| (...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 168 if (error_type != TranslateErrors::NONE) | 168 if (error_type != TranslateErrors::NONE) |
| 169 step = translate::TRANSLATE_STEP_TRANSLATE_ERROR; | 169 step = translate::TRANSLATE_STEP_TRANSLATE_ERROR; |
| 170 | 170 |
| 171 if (TranslateService::IsTranslateBubbleEnabled()) { | 171 if (TranslateService::IsTranslateBubbleEnabled()) { |
| 172 // Bubble UI. | 172 // Bubble UI. |
| 173 if (step == translate::TRANSLATE_STEP_BEFORE_TRANSLATE) { | 173 if (step == translate::TRANSLATE_STEP_BEFORE_TRANSLATE) { |
| 174 // TODO(droger): Move this logic out of UI code. | 174 // TODO(droger): Move this logic out of UI code. |
| 175 GetLanguageState().SetTranslateEnabled(true); | 175 GetLanguageState().SetTranslateEnabled(true); |
| 176 if (!GetLanguageState().HasLanguageChanged()) | 176 if (!GetLanguageState().HasLanguageChanged()) |
| 177 return; | 177 return; |
| 178 |
| 179 if (!triggered_from_menu) { |
| 180 if (web_contents()->GetBrowserContext()->IsOffTheRecord()) |
| 181 return; |
| 182 if (GetTranslatePrefs()->IsTooOftenDenied()) |
| 183 return; |
| 184 } |
| 178 } | 185 } |
| 179 ShowBubble(step, error_type); | 186 ShowBubble(step, error_type); |
| 180 return; | 187 return; |
| 181 } | 188 } |
| 182 | 189 |
| 183 // Infobar UI. | 190 // Infobar UI. |
| 184 TranslateInfoBarDelegate::Create( | 191 TranslateInfoBarDelegate::Create( |
| 185 step != translate::TRANSLATE_STEP_BEFORE_TRANSLATE, | 192 step != translate::TRANSLATE_STEP_BEFORE_TRANSLATE, |
| 186 translate_manager_->GetWeakPtr(), | 193 translate_manager_->GetWeakPtr(), |
| 187 InfoBarService::FromWebContents(web_contents()), | 194 InfoBarService::FromWebContents(web_contents()), |
| (...skipping 370 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 if (GetLanguageState().InTranslateNavigation()) | 565 if (GetLanguageState().InTranslateNavigation()) |
| 559 return; | 566 return; |
| 560 } | 567 } |
| 561 | 568 |
| 562 TranslateBubbleFactory::Show( | 569 TranslateBubbleFactory::Show( |
| 563 browser->window(), web_contents(), step, error_type); | 570 browser->window(), web_contents(), step, error_type); |
| 564 #else | 571 #else |
| 565 NOTREACHED(); | 572 NOTREACHED(); |
| 566 #endif | 573 #endif |
| 567 } | 574 } |
| OLD | NEW |