1 // Copyright 2014 The Chromium Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style license that can be 3 // found in the LICENSE file. 4 5 #ifndef COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_CLIENT_H_ 6 #define COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_CLIENT_H_ 7 8 #include <string> 9 10 #include "base/memory/ref_counted.h" 11 #include "base/memory/scoped_ptr.h" 12 #include "components/translate/core/browser/translate_prefs.h" 13 #include "components/translate/core/browser/translate_step.h" 14 #include "components/translate/core/common/translate_errors.h" 15 16 class GURL; 17 class PrefService; 18 class TranslateAcceptLanguages; 19 class TranslateDriver; 20 class TranslateInfoBarDelegate; 21 22 namespace infobars { 23 class InfoBar; 24 } 25 26 // A client interface that needs to be supplied to TranslateManager by the 27 // embedder. 28 // 29 // Each client instance is associated with a given context within which a 30 // TranslateManager is used (e.g. a single tab). 31 class TranslateClient { 32 public: 33 // Gets the TranslateDriver associated with the client. 34 virtual TranslateDriver* GetTranslateDriver() = 0; 35 36 // Returns the associated PrefService. 37 virtual PrefService* GetPrefs() = 0; 38 39 // Returns the associated TranslatePrefs. 40 virtual scoped_ptr<TranslatePrefs> GetTranslatePrefs() = 0; 41 42 // Returns the associated TranslateAcceptLanguages. 43 virtual TranslateAcceptLanguages* GetTranslateAcceptLanguages() = 0; 44 45 // Returns the resource ID of the icon to be shown for the Translate infobars. 46 virtual int GetInfobarIconID() const = 0; 47 48 // Returns a translate infobar that owns |delegate|. 49 virtual scoped_ptr<infobars::InfoBar> CreateInfoBar( 50 scoped_ptr<TranslateInfoBarDelegate> delegate) const = 0; 51 52 // Called when the embedder should present UI to the user corresponding to the 53 // user's current |step|. 54 virtual void ShowTranslateUI(translate::TranslateStep step, 55 const std::string source_language, 56 const std::string target_language, 57 TranslateErrors::Type error_type, 58 bool triggered_from_menu) = 0; 59 60 // Returns true if the URL can be translated. 61 virtual bool IsTranslatableURL(const GURL& url) = 0; 62 63 // Presents |report_url|, a URL containing information relating to reporting 64 // a language detection error, to the user to allow them to report language 65 // detection errors as desired. 66 virtual void ShowReportLanguageDetectionErrorUI(const GURL& report_url) = 0; 67 }; 68 69 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_CLIENT_H_ 70