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_CONTENT_BROWSER_CONTENT_TRANSLATE_DRIVER_H_ 6 #define COMPONENTS_TRANSLATE_CONTENT_BROWSER_CONTENT_TRANSLATE_DRIVER_H_ 7 8 #include "base/basictypes.h" 9 #include "components/translate/core/browser/translate_driver.h" 10 11 namespace content { 12 class NavigationController; 13 class WebContents; 14 } 15 16 // Content implementation of TranslateDriver. 17 class ContentTranslateDriver : public TranslateDriver { 18 public: 19 20 // The observer for the ContentTranslateDriver. 21 class Observer { 22 public: 23 // Handles when the value of IsPageTranslated is changed. 24 virtual void OnIsPageTranslatedChanged(content::WebContents* source) = 0; 25 26 // Handles when the value of translate_enabled is changed. 27 virtual void OnTranslateEnabledChanged(content::WebContents* source) = 0; 28 29 protected: 30 virtual ~Observer() {} 31 }; 32 33 ContentTranslateDriver(content::NavigationController* nav_controller); 34 virtual ~ContentTranslateDriver(); 35 36 // Sets the Observer. Calling this method is optional. 37 void set_observer(Observer* observer) { observer_ = observer; } 38 39 // TranslateDriver methods. 40 virtual void OnIsPageTranslatedChanged() OVERRIDE; 41 virtual void OnTranslateEnabledChanged() OVERRIDE; 42 virtual bool IsLinkNavigation() OVERRIDE; 43 virtual void TranslatePage(const std::string& translate_script, 44 const std::string& source_lang, 45 const std::string& target_lang) OVERRIDE; 46 virtual void RevertTranslation() OVERRIDE; 47 virtual bool IsOffTheRecord() OVERRIDE; 48 virtual const std::string& GetContentsMimeType() OVERRIDE; 49 virtual const GURL& GetLastCommittedURL() OVERRIDE; 50 virtual const GURL& GetActiveURL() OVERRIDE; 51 virtual const GURL& GetVisibleURL() OVERRIDE; 52 virtual bool HasCurrentPage() OVERRIDE; 53 virtual int GetCurrentPageID() OVERRIDE; 54 virtual void OpenUrlInNewTab(const GURL& url) OVERRIDE; 55 56 private: 57 // The navigation controller of the tab we are associated with. 58 content::NavigationController* navigation_controller_; 59 60 Observer* observer_; 61 62 DISALLOW_COPY_AND_ASSIGN(ContentTranslateDriver); 63 }; 64 65 #endif // COMPONENTS_TRANSLATE_CONTENT_BROWSER_CONTENT_TRANSLATE_DRIVER_H_ 66