Commit 603af455 authored by droger@chromium.org's avatar droger@chromium.org

Remove dependency of TranslateInfobarDelegate on profile

This CL uses TranslateTabHelper instead of Profile and also cleans up
some unused code and irrelevant dependencies.

BUG=371845

Review URL: https://codereview.chromium.org/286973003

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@270758 0039d316-1c4b-4281-b951-d872f2087c98
parent 230db69d
// Copyright (c) 2012 The Chromium Authors. All rights reserved.
// Copyright 2012 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
......@@ -9,16 +9,14 @@
#include "base/i18n/string_compare.h"
#include "base/metrics/histogram.h"
#include "base/prefs/pref_service.h"
#include "chrome/browser/browser_process.h"
#include "chrome/browser/infobars/infobar_service.h"
#include "chrome/browser/profiles/profile.h"
#include "chrome/browser/translate/translate_tab_helper.h"
#include "components/infobars/core/infobar.h"
#include "components/translate/core/browser/translate_accept_languages.h"
#include "components/translate/core/browser/translate_download_manager.h"
#include "components/translate/core/browser/translate_manager.h"
#include "components/translate/core/common/translate_constants.h"
#include "content/public/browser/navigation_entry.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/web_contents.h"
#include "grit/generated_resources.h"
#include "grit/theme_resources.h"
......@@ -144,13 +142,13 @@ void TranslateInfoBarDelegate::TranslationDeclined() {
}
bool TranslateInfoBarDelegate::IsTranslatableLanguageByPrefs() {
Profile* profile =
Profile::FromBrowserContext(GetWebContents()->GetBrowserContext());
Profile* original_profile = profile->GetOriginalProfile();
TranslateTabHelper* translate_tab_helper =
TranslateTabHelper::FromWebContents(GetWebContents());
scoped_ptr<TranslatePrefs> translate_prefs(
TranslateTabHelper::CreateTranslatePrefs(original_profile->GetPrefs()));
TranslateTabHelper::CreateTranslatePrefs(
translate_tab_helper->GetPrefs()));
TranslateAcceptLanguages* accept_languages =
TranslateTabHelper::GetTranslateAcceptLanguages(original_profile);
translate_tab_helper->GetTranslateAcceptLanguages();
return translate_prefs->CanTranslateLanguage(accept_languages,
original_language_code());
}
......@@ -283,13 +281,6 @@ content::WebContents* TranslateInfoBarDelegate::GetWebContents() {
return InfoBarService::WebContentsFromInfoBar(infobar());
}
// static
base::string16 TranslateInfoBarDelegate::GetLanguageDisplayableName(
const std::string& language_code) {
return l10n_util::GetDisplayNameForLocale(
language_code, g_browser_process->GetApplicationLocale(), true);
}
// static
void TranslateInfoBarDelegate::GetAfterTranslateStrings(
std::vector<base::string16>* strings,
......
// Copyright (c) 2011 The Chromium Authors. All rights reserved.
// Copyright 2011 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
......@@ -11,15 +11,19 @@
#include "base/logging.h"
#include "base/memory/scoped_ptr.h"
#include "chrome/browser/translate/translate_tab_helper.h"
#include "components/infobars/core/infobar_delegate.h"
#include "components/translate/core/browser/translate_prefs.h"
#include "components/translate/core/browser/translate_step.h"
#include "components/translate/core/browser/translate_ui_delegate.h"
#include "components/translate/core/common/translate_constants.h"
#include "components/translate/core/common/translate_errors.h"
class PrefService;
namespace content {
class WebContents;
}
class TranslateInfoBarDelegate : public infobars::InfoBarDelegate {
public:
// The types of background color animations.
......@@ -147,11 +151,6 @@ class TranslateInfoBarDelegate : public infobars::InfoBarDelegate {
// Returns the WebContents associated with the TranslateInfoBarDelegate.
content::WebContents* GetWebContents();
// Convenience method that returns the displayable language name for
// |language_code| in the current application locale.
static base::string16 GetLanguageDisplayableName(
const std::string& language_code);
// Adds the strings that should be displayed in the after translate infobar to
// |strings|. If |autodetermined_source_language| is false, the text in that
// infobar is:
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment