OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "chrome/browser/browser_process.h" | 10 #include "chrome/browser/browser_process.h" |
11 #include "chrome/browser/infobars/infobar_tab_helper.h" | 11 #include "chrome/browser/infobars/infobar_tab_helper.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
13 #include "chrome/browser/translate/translate_infobar_view.h" | 13 #include "chrome/browser/translate/translate_infobar_view.h" |
14 #include "chrome/browser/translate/translate_manager.h" | 14 #include "chrome/browser/translate/translate_manager.h" |
15 #include "chrome/browser/translate/translate_tab_helper.h" | 15 #include "chrome/browser/translate/translate_tab_helper.h" |
16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 16 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" |
17 #include "chrome/common/chrome_constants.h" | 17 #include "chrome/common/chrome_constants.h" |
18 #include "content/browser/tab_contents/tab_contents.h" | 18 #include "content/browser/tab_contents/tab_contents.h" |
19 #include "content/public/browser/navigation_details.h" | 19 #include "content/public/browser/navigation_details.h" |
20 #include "content/public/browser/navigation_entry.h" | 20 #include "content/public/browser/navigation_entry.h" |
21 #include "grit/generated_resources.h" | 21 #include "grit/generated_resources.h" |
22 #include "grit/theme_resources_standard.h" | 22 #include "grit/theme_resources_standard.h" |
23 #include "ui/base/l10n/l10n_util.h" | 23 #include "ui/base/l10n/l10n_util.h" |
24 #include "ui/base/resource/resource_bundle.h" | 24 #include "ui/base/resource/resource_bundle.h" |
25 | 25 |
| 26 using content::NavigationEntry; |
| 27 |
26 // static | 28 // static |
27 const size_t TranslateInfoBarDelegate::kNoIndex = static_cast<size_t>(-1); | 29 const size_t TranslateInfoBarDelegate::kNoIndex = static_cast<size_t>(-1); |
28 | 30 |
29 // static | 31 // static |
30 TranslateInfoBarDelegate* TranslateInfoBarDelegate::CreateDelegate( | 32 TranslateInfoBarDelegate* TranslateInfoBarDelegate::CreateDelegate( |
31 Type type, | 33 Type type, |
32 InfoBarTabHelper* infobar_helper, | 34 InfoBarTabHelper* infobar_helper, |
33 PrefService* prefs, | 35 PrefService* prefs, |
34 const std::string& original_language, | 36 const std::string& original_language, |
35 const std::string& target_language) { | 37 const std::string& target_language) { |
(...skipping 356 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 InfoBarDelegate::Type TranslateInfoBarDelegate::GetInfoBarType() const { | 394 InfoBarDelegate::Type TranslateInfoBarDelegate::GetInfoBarType() const { |
393 return PAGE_ACTION_TYPE; | 395 return PAGE_ACTION_TYPE; |
394 } | 396 } |
395 | 397 |
396 TranslateInfoBarDelegate* | 398 TranslateInfoBarDelegate* |
397 TranslateInfoBarDelegate::AsTranslateInfoBarDelegate() { | 399 TranslateInfoBarDelegate::AsTranslateInfoBarDelegate() { |
398 return this; | 400 return this; |
399 } | 401 } |
400 | 402 |
401 std::string TranslateInfoBarDelegate::GetPageHost() { | 403 std::string TranslateInfoBarDelegate::GetPageHost() { |
402 content::NavigationEntry* entry = | 404 NavigationEntry* entry = |
403 owner()->web_contents()->GetController().GetActiveEntry(); | 405 owner()->web_contents()->GetController().GetActiveEntry(); |
404 return entry ? entry->GetURL().HostNoBrackets() : std::string(); | 406 return entry ? entry->GetURL().HostNoBrackets() : std::string(); |
405 } | 407 } |
OLD | NEW |