| Index: chrome/browser/translate/translate_manager.h
|
| diff --git a/chrome/browser/translate/translate_manager.h b/chrome/browser/translate/translate_manager.h
|
| index b3e779a5962ea703409f214d1246092f0311ebba..f5a4bd59d4491bb4fc4d9650c02960fa25239df3 100644
|
| --- a/chrome/browser/translate/translate_manager.h
|
| +++ b/chrome/browser/translate/translate_manager.h
|
| @@ -16,11 +16,11 @@
|
| #include "content/public/browser/notification_observer.h"
|
| #include "content/public/browser/notification_registrar.h"
|
|
|
| -template <typename T> struct DefaultSingletonTraits;
|
| class GURL;
|
| struct PageTranslatedDetails;
|
| class PrefService;
|
| struct TranslateErrorDetails;
|
| +class TranslateTabHelper;
|
|
|
| namespace content {
|
| class WebContents;
|
| @@ -33,9 +33,7 @@ class WebContents;
|
|
|
| class TranslateManager : public content::NotificationObserver {
|
| public:
|
| - // Returns the singleton instance.
|
| - static TranslateManager* GetInstance();
|
| -
|
| + explicit TranslateManager(TranslateTabHelper* helper);
|
| virtual ~TranslateManager();
|
|
|
| // Returns true if the URL can be translated.
|
| @@ -57,18 +55,17 @@ class TranslateManager : public content::NotificationObserver {
|
| // Translates the page contents from |source_lang| to |target_lang|.
|
| // The actual translation might be performed asynchronously if the translate
|
| // script is not yet available.
|
| - void TranslatePage(content::WebContents* web_contents,
|
| - const std::string& source_lang,
|
| + void TranslatePage(const std::string& source_lang,
|
| const std::string& target_lang);
|
|
|
| - // Reverts the contents of the page in |web_contents| to its original
|
| + // Reverts the contents of the page to its original
|
| // language.
|
| - void RevertTranslation(content::WebContents* web_contents);
|
| + void RevertTranslation();
|
|
|
| // Reports to the Google translate server that a page language was incorrectly
|
| // detected. This call is initiated by the user selecting the "report" menu
|
| // under options in the translate infobar.
|
| - void ReportLanguageDetectionError(content::WebContents* web_contents);
|
| + void ReportLanguageDetectionError();
|
|
|
| // content::NotificationObserver implementation:
|
| virtual void Observe(int type,
|
| @@ -90,44 +87,25 @@ class TranslateManager : public content::NotificationObserver {
|
| static scoped_ptr<TranslateErrorCallbackList::Subscription>
|
| RegisterTranslateErrorCallback(const TranslateErrorCallback& callback);
|
|
|
| - protected:
|
| - TranslateManager();
|
| -
|
| private:
|
| - friend struct DefaultSingletonTraits<TranslateManager>;
|
| -
|
| - // Structure that describes a translate request.
|
| - // Translation may be deferred while the translate script is being retrieved
|
| - // from the translate server.
|
| - struct PendingRequest {
|
| - int render_process_id;
|
| - int render_view_id;
|
| - int page_id;
|
| - std::string source_lang;
|
| - std::string target_lang;
|
| - };
|
| -
|
| - // Starts the translation process on |tab| containing the page in the
|
| - // |page_lang| language.
|
| - void InitiateTranslation(content::WebContents* web_contents,
|
| - const std::string& page_lang);
|
| -
|
| - // If the tab identified by |process_id| and |render_id| has been closed, this
|
| - // does nothing, otherwise it calls InitiateTranslation.
|
| - void InitiateTranslationPosted(int process_id, int render_id,
|
| - const std::string& page_lang, int attempt);
|
| -
|
| - // Sends a translation request to the RenderView of |web_contents|.
|
| - void DoTranslatePage(content::WebContents* web_contents,
|
| - const std::string& translate_script,
|
| + // Starts the translation process for a page in the |page_lang| language.
|
| + void InitiateTranslation(const std::string& page_lang);
|
| +
|
| + // If the tab is loading, this does nothing, otherwise it calls
|
| + // InitiateTranslation.
|
| + void InitiateTranslationPosted(const std::string& page_lang, int attempt);
|
| +
|
| + // Sends a translation request.
|
| + void DoTranslatePage(const std::string& translate_script,
|
| const std::string& source_lang,
|
| const std::string& target_lang);
|
|
|
| // Shows the after translate or error infobar depending on the details.
|
| - void PageTranslated(content::WebContents* web_contents,
|
| - PageTranslatedDetails* details);
|
| + void PageTranslated(PageTranslatedDetails* details);
|
|
|
| - void OnTranslateScriptFetchComplete(PendingRequest request,
|
| + void OnTranslateScriptFetchComplete(int page_id,
|
| + const std::string& source_lang,
|
| + const std::string& target_lang,
|
| bool success,
|
| const std::string& data);
|
|
|
| @@ -136,6 +114,8 @@ class TranslateManager : public content::NotificationObserver {
|
| // Max number of attempts before checking if a page has been reloaded.
|
| int max_reload_check_attempts_;
|
|
|
| + TranslateTabHelper* translate_tab_helper_; // Weak
|
| +
|
| base::WeakPtrFactory<TranslateManager> weak_method_factory_;
|
|
|
| DISALLOW_COPY_AND_ASSIGN(TranslateManager);
|
|
|