Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(616)

Side by Side Diff: chrome/browser/translate/translate_infobar_delegate.cc

Issue 10537090: TabContentsWrapper -> TabContents, part 32. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/translate/translate_manager.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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.h"
17 #include "chrome/common/chrome_constants.h" 17 #include "chrome/common/chrome_constants.h"
18 #include "content/public/browser/navigation_details.h" 18 #include "content/public/browser/navigation_details.h"
19 #include "content/public/browser/navigation_entry.h" 19 #include "content/public/browser/navigation_entry.h"
20 #include "content/public/browser/web_contents.h" 20 #include "content/public/browser/web_contents.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; 26 using content::NavigationEntry;
(...skipping 112 matching lines...) Expand 10 before | Expand all | Expand 10 after
139 if (!owner()->web_contents()->GetBrowserContext()->IsOffTheRecord()) { 139 if (!owner()->web_contents()->GetBrowserContext()->IsOffTheRecord()) {
140 prefs_.ResetTranslationAcceptedCount(original_language_code); 140 prefs_.ResetTranslationAcceptedCount(original_language_code);
141 prefs_.IncrementTranslationDeniedCount(original_language_code); 141 prefs_.IncrementTranslationDeniedCount(original_language_code);
142 } 142 }
143 143
144 // Remember that the user declined the translation so as to prevent showing a 144 // Remember that the user declined the translation so as to prevent showing a
145 // translate infobar for that page again. (TranslateManager initiates 145 // translate infobar for that page again. (TranslateManager initiates
146 // translations when getting a LANGUAGE_DETERMINED from the page, which 146 // translations when getting a LANGUAGE_DETERMINED from the page, which
147 // happens when a load stops. That could happen multiple times, including 147 // happens when a load stops. That could happen multiple times, including
148 // after the user already declined the translation.) 148 // after the user already declined the translation.)
149 TranslateTabHelper* helper = TabContentsWrapper::GetCurrentWrapperForContents( 149 TranslateTabHelper* helper = TabContents::FromWebContents(
150 owner()->web_contents())->translate_tab_helper(); 150 owner()->web_contents())->translate_tab_helper();
151 helper->language_state().set_translation_declined(true); 151 helper->language_state().set_translation_declined(true);
152 } 152 }
153 153
154 bool TranslateInfoBarDelegate::IsLanguageBlacklisted() { 154 bool TranslateInfoBarDelegate::IsLanguageBlacklisted() {
155 return prefs_.IsLanguageBlacklisted(GetOriginalLanguageCode()); 155 return prefs_.IsLanguageBlacklisted(GetOriginalLanguageCode());
156 } 156 }
157 157
158 void TranslateInfoBarDelegate::ToggleLanguageBlacklist() { 158 void TranslateInfoBarDelegate::ToggleLanguageBlacklist() {
159 const std::string& original_lang = GetOriginalLanguageCode(); 159 const std::string& original_lang = GetOriginalLanguageCode();
(...skipping 238 matching lines...) Expand 10 before | Expand all | Expand 10 after
398 TranslateInfoBarDelegate* 398 TranslateInfoBarDelegate*
399 TranslateInfoBarDelegate::AsTranslateInfoBarDelegate() { 399 TranslateInfoBarDelegate::AsTranslateInfoBarDelegate() {
400 return this; 400 return this;
401 } 401 }
402 402
403 std::string TranslateInfoBarDelegate::GetPageHost() { 403 std::string TranslateInfoBarDelegate::GetPageHost() {
404 NavigationEntry* entry = 404 NavigationEntry* entry =
405 owner()->web_contents()->GetController().GetActiveEntry(); 405 owner()->web_contents()->GetController().GetActiveEntry();
406 return entry ? entry->GetURL().HostNoBrackets() : std::string(); 406 return entry ? entry->GetURL().HostNoBrackets() : std::string();
407 } 407 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/translate/translate_manager.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698