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

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

Powered by Google App Engine
This is Rietveld 408576698