OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_infobar_delegate.h" | 5 #include "chrome/browser/translate/translate_infobar_delegate.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/i18n/string_compare.h" | 9 #include "base/i18n/string_compare.h" |
10 #include "base/metrics/histogram.h" | 10 #include "base/metrics/histogram.h" |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
55 PrefService* prefs, | 55 PrefService* prefs, |
56 const ShortcutConfiguration& shortcut_config) { | 56 const ShortcutConfiguration& shortcut_config) { |
57 // Check preconditions. | 57 // Check preconditions. |
58 if (infobar_type != TRANSLATION_ERROR) { | 58 if (infobar_type != TRANSLATION_ERROR) { |
59 DCHECK(TranslateManager::IsSupportedLanguage(target_language)); | 59 DCHECK(TranslateManager::IsSupportedLanguage(target_language)); |
60 if (!TranslateManager::IsSupportedLanguage(original_language)) { | 60 if (!TranslateManager::IsSupportedLanguage(original_language)) { |
61 // The original language can only be "unknown" for the "translating" | 61 // The original language can only be "unknown" for the "translating" |
62 // infobar, which is the case when the user started a translation from the | 62 // infobar, which is the case when the user started a translation from the |
63 // context menu. | 63 // context menu. |
64 DCHECK(infobar_type == TRANSLATING || infobar_type == AFTER_TRANSLATE); | 64 DCHECK(infobar_type == TRANSLATING || infobar_type == AFTER_TRANSLATE); |
65 DCHECK_EQ(chrome::kUnknownLanguageCode, original_language); | 65 DCHECK_EQ(translate::kUnknownLanguageCode, original_language); |
66 } | 66 } |
67 } | 67 } |
68 | 68 |
69 // Find any existing translate infobar delegate. | 69 // Find any existing translate infobar delegate. |
70 TranslateInfoBarDelegate* old_delegate = NULL; | 70 TranslateInfoBarDelegate* old_delegate = NULL; |
71 for (size_t i = 0; i < infobar_service->infobar_count(); ++i) { | 71 for (size_t i = 0; i < infobar_service->infobar_count(); ++i) { |
72 old_delegate = infobar_service->infobar_at(i)->AsTranslateInfoBarDelegate(); | 72 old_delegate = infobar_service->infobar_at(i)->AsTranslateInfoBarDelegate(); |
73 if (old_delegate) { | 73 if (old_delegate) { |
74 if (!replace_existing_infobar) | 74 if (!replace_existing_infobar) |
75 return; | 75 return; |
(...skipping 348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
424 | 424 |
425 TranslateInfoBarDelegate* | 425 TranslateInfoBarDelegate* |
426 TranslateInfoBarDelegate::AsTranslateInfoBarDelegate() { | 426 TranslateInfoBarDelegate::AsTranslateInfoBarDelegate() { |
427 return this; | 427 return this; |
428 } | 428 } |
429 | 429 |
430 std::string TranslateInfoBarDelegate::GetPageHost() { | 430 std::string TranslateInfoBarDelegate::GetPageHost() { |
431 NavigationEntry* entry = web_contents()->GetController().GetActiveEntry(); | 431 NavigationEntry* entry = web_contents()->GetController().GetActiveEntry(); |
432 return entry ? entry->GetURL().HostNoBrackets() : std::string(); | 432 return entry ? entry->GetURL().HostNoBrackets() : std::string(); |
433 } | 433 } |
OLD | NEW |