Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: components/translate/content/browser/content_translate_driver.h

Issue 290573013: LanguageState should be owned by TranslateManager (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Adding TBR for CL Created 6 years, 6 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef COMPONENTS_TRANSLATE_CONTENT_BROWSER_CONTENT_TRANSLATE_DRIVER_H_ 5 #ifndef COMPONENTS_TRANSLATE_CONTENT_BROWSER_CONTENT_TRANSLATE_DRIVER_H_
6 #define COMPONENTS_TRANSLATE_CONTENT_BROWSER_CONTENT_TRANSLATE_DRIVER_H_ 6 #define COMPONENTS_TRANSLATE_CONTENT_BROWSER_CONTENT_TRANSLATE_DRIVER_H_
7 7
8 #include "base/basictypes.h"
8 #include "components/translate/core/browser/translate_driver.h" 9 #include "components/translate/core/browser/translate_driver.h"
9 10
10 #include "components/translate/core/browser/language_state.h"
11
12 namespace content { 11 namespace content {
13 struct LoadCommittedDetails;
14 class NavigationController; 12 class NavigationController;
15 class WebContents; 13 class WebContents;
16 } 14 }
17 15
18 // Content implementation of TranslateDriver. 16 // Content implementation of TranslateDriver.
19 class ContentTranslateDriver : public TranslateDriver { 17 class ContentTranslateDriver : public TranslateDriver {
20 public: 18 public:
21 19
22 // The observer for the ContentTranslateDriver. 20 // The observer for the ContentTranslateDriver.
23 class Observer { 21 class Observer {
24 public: 22 public:
25 // Handles when the value of IsPageTranslated is changed. 23 // Handles when the value of IsPageTranslated is changed.
26 virtual void OnIsPageTranslatedChanged(content::WebContents* source) = 0; 24 virtual void OnIsPageTranslatedChanged(content::WebContents* source) = 0;
27 25
28 // Handles when the value of translate_enabled is changed. 26 // Handles when the value of translate_enabled is changed.
29 virtual void OnTranslateEnabledChanged(content::WebContents* source) = 0; 27 virtual void OnTranslateEnabledChanged(content::WebContents* source) = 0;
30 28
31 protected: 29 protected:
32 virtual ~Observer() {} 30 virtual ~Observer() {}
33 }; 31 };
34 32
35 ContentTranslateDriver(content::NavigationController* nav_controller); 33 ContentTranslateDriver(content::NavigationController* nav_controller);
36 virtual ~ContentTranslateDriver(); 34 virtual ~ContentTranslateDriver();
37 35
38 // Sets the Observer. Calling this method is optional. 36 // Sets the Observer. Calling this method is optional.
39 void set_observer(Observer* observer) { observer_ = observer; } 37 void set_observer(Observer* observer) { observer_ = observer; }
40 38
41 // Must be called on navigations.
42 void DidNavigate(const content::LoadCommittedDetails& details);
43
44 // TranslateDriver methods. 39 // TranslateDriver methods.
45 virtual void OnIsPageTranslatedChanged() OVERRIDE; 40 virtual void OnIsPageTranslatedChanged() OVERRIDE;
46 virtual void OnTranslateEnabledChanged() OVERRIDE; 41 virtual void OnTranslateEnabledChanged() OVERRIDE;
47 virtual bool IsLinkNavigation() OVERRIDE; 42 virtual bool IsLinkNavigation() OVERRIDE;
48 virtual LanguageState& GetLanguageState() OVERRIDE;
49 virtual void TranslatePage(const std::string& translate_script, 43 virtual void TranslatePage(const std::string& translate_script,
50 const std::string& source_lang, 44 const std::string& source_lang,
51 const std::string& target_lang) OVERRIDE; 45 const std::string& target_lang) OVERRIDE;
52 virtual void RevertTranslation() OVERRIDE; 46 virtual void RevertTranslation() OVERRIDE;
53 virtual bool IsOffTheRecord() OVERRIDE; 47 virtual bool IsOffTheRecord() OVERRIDE;
54 virtual const std::string& GetContentsMimeType() OVERRIDE; 48 virtual const std::string& GetContentsMimeType() OVERRIDE;
55 virtual const GURL& GetLastCommittedURL() OVERRIDE; 49 virtual const GURL& GetLastCommittedURL() OVERRIDE;
56 virtual const GURL& GetActiveURL() OVERRIDE; 50 virtual const GURL& GetActiveURL() OVERRIDE;
57 virtual const GURL& GetVisibleURL() OVERRIDE; 51 virtual const GURL& GetVisibleURL() OVERRIDE;
58 virtual bool HasCurrentPage() OVERRIDE; 52 virtual bool HasCurrentPage() OVERRIDE;
59 virtual int GetCurrentPageID() OVERRIDE; 53 virtual int GetCurrentPageID() OVERRIDE;
60 virtual void OpenUrlInNewTab(const GURL& url) OVERRIDE; 54 virtual void OpenUrlInNewTab(const GURL& url) OVERRIDE;
61 55
62 private: 56 private:
63 // The navigation controller of the tab we are associated with. 57 // The navigation controller of the tab we are associated with.
64 content::NavigationController* navigation_controller_; 58 content::NavigationController* navigation_controller_;
65 59
66 LanguageState language_state_;
67 Observer* observer_; 60 Observer* observer_;
68 61
69 DISALLOW_COPY_AND_ASSIGN(ContentTranslateDriver); 62 DISALLOW_COPY_AND_ASSIGN(ContentTranslateDriver);
70 }; 63 };
71 64
72 #endif // COMPONENTS_TRANSLATE_CONTENT_BROWSER_CONTENT_TRANSLATE_DRIVER_H_ 65 #endif // COMPONENTS_TRANSLATE_CONTENT_BROWSER_CONTENT_TRANSLATE_DRIVER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698