summaryrefslogtreecommitdiffstats
path: root/components/translate
diff options
context:
space:
mode:
authordroger@chromium.org <droger@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-17 15:34:23 +0000
committerdroger@chromium.org <droger@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2014-05-17 15:34:23 +0000
commit151eaa001ed7b11b190c1dd0c6d3dfc9f35125d9 (patch)
tree8ee7e35f9ec2b0aa87138346db514f9cee9e0212 /components/translate
parent3795c04de64dca097465b8c4a3c4f2c0f6382975 (diff)
downloadchromium_src-151eaa001ed7b11b190c1dd0c6d3dfc9f35125d9.zip
chromium_src-151eaa001ed7b11b190c1dd0c6d3dfc9f35125d9.tar.gz
chromium_src-151eaa001ed7b11b190c1dd0c6d3dfc9f35125d9.tar.bz2
Remove most of chrome/ and content/ usage from TranslateInfoBarDelegate
The only problematic dependencies left are WebContents (only needed for the GetWebContents() method, which is only used by OptionsMenuModel), and InfoBarService, which is only used to implement GetWebContents(). BUG=371845 TBR=rohitrao Review URL: https://codereview.chromium.org/291503008 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@271205 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'components/translate')
-rw-r--r--components/translate/core/browser/translate_manager.cc13
-rw-r--r--components/translate/core/browser/translate_manager.h6
2 files changed, 13 insertions, 6 deletions
diff --git a/components/translate/core/browser/translate_manager.cc b/components/translate/core/browser/translate_manager.cc
index 95bc6af..dcc8c30 100644
--- a/components/translate/core/browser/translate_manager.cc
+++ b/components/translate/core/browser/translate_manager.cc
@@ -75,6 +75,10 @@ TranslateManager::TranslateManager(
translate_driver_(translate_client_->GetTranslateDriver()),
weak_method_factory_(this) {}
+base::WeakPtr<TranslateManager> TranslateManager::GetWeakPtr() {
+ return weak_method_factory_.GetWeakPtr();
+}
+
void TranslateManager::InitiateTranslation(const std::string& page_lang) {
// Short-circuit out if not in a state where initiating translation makes
// sense (this method may be called muhtiple times for a given page).
@@ -239,12 +243,9 @@ void TranslateManager::TranslatePage(const std::string& original_source_lang,
// The script is not available yet. Queue that request and query for the
// script. Once it is downloaded we'll do the translate.
- TranslateScript::RequestCallback callback =
- base::Bind(&TranslateManager::OnTranslateScriptFetchComplete,
- weak_method_factory_.GetWeakPtr(),
- translate_driver_->GetCurrentPageID(),
- source_lang,
- target_lang);
+ TranslateScript::RequestCallback callback = base::Bind(
+ &TranslateManager::OnTranslateScriptFetchComplete, GetWeakPtr(),
+ translate_driver_->GetCurrentPageID(), source_lang, target_lang);
script->Request(callback);
}
diff --git a/components/translate/core/browser/translate_manager.h b/components/translate/core/browser/translate_manager.h
index d1f09fc..c29b167 100644
--- a/components/translate/core/browser/translate_manager.h
+++ b/components/translate/core/browser/translate_manager.h
@@ -35,6 +35,12 @@ class TranslateManager {
const std::string& accept_language_pref_name);
virtual ~TranslateManager();
+ // Returns a weak pointer to this instance.
+ base::WeakPtr<TranslateManager> GetWeakPtr();
+
+ // Cannot return NULL.
+ TranslateClient* translate_client() { return translate_client_; }
+
// Returns the language to translate to. The language returned is the
// first language found in the following list that is supported by the
// translation service: