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_DRIVER_H_ 6 #define COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_DRIVER_H_ 7 8 #include <string> 9 10 class GURL; 11 12 // Interface that allows Translate core code to interact with its driver (i.e., 13 // obtain information from it and give information to it). A concrete 14 // implementation must be provided by the driver. 15 class TranslateDriver { 16 public: 17 // Returns true if the current page was navigated through a link. 18 virtual bool IsLinkNavigation() = 0; 19 20 // Called when Translate is enabled or disabled. 21 virtual void OnTranslateEnabledChanged() = 0; 22 23 // Called when the page is "translated" state of the page changed. 24 virtual void OnIsPageTranslatedChanged() = 0; 25 26 // Translates the page contents from |source_lang| to |target_lang|. 27 virtual void TranslatePage(const std::string& translate_script, 28 const std::string& source_lang, 29 const std::string& target_lang) = 0; 30 31 // Reverts the contents of the page to its original language. 32 virtual void RevertTranslation() = 0; 33 34 // Returns whether the user is currently operating in off-the-record mode. 35 virtual bool IsOffTheRecord() = 0; 36 37 // Returns the mime type of the current page. 38 virtual const std::string& GetContentsMimeType() = 0; 39 40 // Returns the last committed URL, or an empty GURL if there is no committed 41 // URL. 42 virtual const GURL& GetLastCommittedURL() = 0; 43 44 // Returns the active URL, or an empty GURL if there is no active URL. 45 virtual const GURL& GetActiveURL() = 0; 46 47 // Returns the visible URL, or an empty GURL if there is no visible URL. 48 virtual const GURL& GetVisibleURL() = 0; 49 50 // Returns whether the driver has access to the current page. 51 virtual bool HasCurrentPage() = 0; 52 53 // Returns an int identifying the current page. Should only be called if 54 // |HasCurrentPage()| is true. 55 virtual int GetCurrentPageID() = 0; 56 57 // Opens |url| in a new tab. 58 virtual void OpenUrlInNewTab(const GURL& url) = 0; 59 }; 60 61 #endif // COMPONENTS_TRANSLATE_CORE_BROWSER_TRANSLATE_DRIVER_H_ 62