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

Side by Side Diff: chrome/browser/translate/chrome_translate_client.h

Issue 378253002: Fix translate namespace (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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 CHROME_BROWSER_TRANSLATE_CHROME_TRANSLATE_CLIENT_H_ 5 #ifndef CHROME_BROWSER_TRANSLATE_CHROME_TRANSLATE_CLIENT_H_
6 #define CHROME_BROWSER_TRANSLATE_CHROME_TRANSLATE_CLIENT_H_ 6 #define CHROME_BROWSER_TRANSLATE_CHROME_TRANSLATE_CLIENT_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 13 matching lines...) Expand all
24 24
25 namespace content { 25 namespace content {
26 class BrowserContext; 26 class BrowserContext;
27 class WebContents; 27 class WebContents;
28 } // namespace content 28 } // namespace content
29 29
30 namespace test { 30 namespace test {
31 class ScopedCLDDynamicDataHarness; 31 class ScopedCLDDynamicDataHarness;
32 } // namespace test 32 } // namespace test
33 33
34 class PrefService;
35
36 namespace translate {
34 struct LanguageDetectionDetails; 37 struct LanguageDetectionDetails;
35 class LanguageState; 38 class LanguageState;
36 class PrefService;
37 class TranslateAcceptLanguages; 39 class TranslateAcceptLanguages;
38 class TranslatePrefs; 40 class TranslatePrefs;
39 class TranslateManager; 41 class TranslateManager;
42 } // namespace translate
40 43
41 class ChromeTranslateClient 44 class ChromeTranslateClient
42 : public TranslateClient, 45 : public translate::TranslateClient,
43 public content::WebContentsObserver, 46 public content::WebContentsObserver,
44 public content::WebContentsUserData<ChromeTranslateClient> { 47 public content::WebContentsUserData<ChromeTranslateClient> {
45 public: 48 public:
46 virtual ~ChromeTranslateClient(); 49 virtual ~ChromeTranslateClient();
47 50
48 // Gets the LanguageState associated with the page. 51 // Gets the LanguageState associated with the page.
49 LanguageState& GetLanguageState(); 52 translate::LanguageState& GetLanguageState();
50 53
51 // Returns the ContentTranslateDriver instance associated with this 54 // Returns the ContentTranslateDriver instance associated with this
52 // WebContents. 55 // WebContents.
53 ContentTranslateDriver& translate_driver() { return translate_driver_; } 56 translate::ContentTranslateDriver& translate_driver() {
57 return translate_driver_;
58 }
54 59
55 // Helper method to return a new TranslatePrefs instance. 60 // Helper method to return a new TranslatePrefs instance.
56 static scoped_ptr<TranslatePrefs> CreateTranslatePrefs(PrefService* prefs); 61 static scoped_ptr<translate::TranslatePrefs> CreateTranslatePrefs(
62 PrefService* prefs);
57 63
58 // Helper method to return the TranslateAcceptLanguages instance associated 64 // Helper method to return the TranslateAcceptLanguages instance associated
59 // with |browser_context|. 65 // with |browser_context|.
60 static TranslateAcceptLanguages* GetTranslateAcceptLanguages( 66 static translate::TranslateAcceptLanguages* GetTranslateAcceptLanguages(
61 content::BrowserContext* browser_context); 67 content::BrowserContext* browser_context);
62 68
63 // Helper method to return the TranslateManager instance associated with 69 // Helper method to return the TranslateManager instance associated with
64 // |web_contents|, or NULL if there is no such associated instance. 70 // |web_contents|, or NULL if there is no such associated instance.
65 static TranslateManager* GetManagerFromWebContents( 71 static translate::TranslateManager* GetManagerFromWebContents(
66 content::WebContents* web_contents); 72 content::WebContents* web_contents);
67 73
68 // Gets |source| and |target| language for translation. 74 // Gets |source| and |target| language for translation.
69 static void GetTranslateLanguages(content::WebContents* web_contents, 75 static void GetTranslateLanguages(content::WebContents* web_contents,
70 std::string* source, 76 std::string* source,
71 std::string* target); 77 std::string* target);
72 78
73 // Gets the associated TranslateManager. 79 // Gets the associated TranslateManager.
74 TranslateManager* GetTranslateManager(); 80 translate::TranslateManager* GetTranslateManager();
75 81
76 // Gets the associated WebContents. Returns NULL if the WebContents is being 82 // Gets the associated WebContents. Returns NULL if the WebContents is being
77 // destroyed. 83 // destroyed.
78 content::WebContents* GetWebContents(); 84 content::WebContents* GetWebContents();
79 85
80 // Number of attempts before waiting for a page to be fully reloaded. 86 // Number of attempts before waiting for a page to be fully reloaded.
81 void set_translate_max_reload_attempts(int attempts) { 87 void set_translate_max_reload_attempts(int attempts) {
82 max_reload_check_attempts_ = attempts; 88 max_reload_check_attempts_ = attempts;
83 } 89 }
84 90
85 // TranslateClient implementation. 91 // TranslateClient implementation.
86 virtual TranslateDriver* GetTranslateDriver() OVERRIDE; 92 virtual translate::TranslateDriver* GetTranslateDriver() OVERRIDE;
87 virtual PrefService* GetPrefs() OVERRIDE; 93 virtual PrefService* GetPrefs() OVERRIDE;
88 virtual scoped_ptr<TranslatePrefs> GetTranslatePrefs() OVERRIDE; 94 virtual scoped_ptr<translate::TranslatePrefs> GetTranslatePrefs() OVERRIDE;
89 virtual TranslateAcceptLanguages* GetTranslateAcceptLanguages() OVERRIDE; 95 virtual translate::TranslateAcceptLanguages* GetTranslateAcceptLanguages()
96 OVERRIDE;
90 virtual int GetInfobarIconID() const OVERRIDE; 97 virtual int GetInfobarIconID() const OVERRIDE;
91 virtual scoped_ptr<infobars::InfoBar> CreateInfoBar( 98 virtual scoped_ptr<infobars::InfoBar> CreateInfoBar(
92 scoped_ptr<TranslateInfoBarDelegate> delegate) const OVERRIDE; 99 scoped_ptr<translate::TranslateInfoBarDelegate> delegate) const OVERRIDE;
93 virtual void ShowTranslateUI(translate::TranslateStep step, 100 virtual void ShowTranslateUI(translate::TranslateStep step,
94 const std::string source_language, 101 const std::string source_language,
95 const std::string target_language, 102 const std::string target_language,
96 TranslateErrors::Type error_type, 103 translate::TranslateErrors::Type error_type,
97 bool triggered_from_menu) OVERRIDE; 104 bool triggered_from_menu) OVERRIDE;
98 virtual bool IsTranslatableURL(const GURL& url) OVERRIDE; 105 virtual bool IsTranslatableURL(const GURL& url) OVERRIDE;
99 virtual void ShowReportLanguageDetectionErrorUI( 106 virtual void ShowReportLanguageDetectionErrorUI(
100 const GURL& report_url) OVERRIDE; 107 const GURL& report_url) OVERRIDE;
101 108
102 private: 109 private:
103 explicit ChromeTranslateClient(content::WebContents* web_contents); 110 explicit ChromeTranslateClient(content::WebContents* web_contents);
104 friend class content::WebContentsUserData<ChromeTranslateClient>; 111 friend class content::WebContentsUserData<ChromeTranslateClient>;
105 112
106 // content::WebContentsObserver implementation. 113 // content::WebContentsObserver implementation.
107 virtual void NavigationEntryCommitted( 114 virtual void NavigationEntryCommitted(
108 const content::LoadCommittedDetails& load_details) OVERRIDE; 115 const content::LoadCommittedDetails& load_details) OVERRIDE;
109 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 116 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
110 virtual void DidNavigateAnyFrame( 117 virtual void DidNavigateAnyFrame(
111 const content::LoadCommittedDetails& details, 118 const content::LoadCommittedDetails& details,
112 const content::FrameNavigateParams& params) OVERRIDE; 119 const content::FrameNavigateParams& params) OVERRIDE;
113 virtual void WebContentsDestroyed() OVERRIDE; 120 virtual void WebContentsDestroyed() OVERRIDE;
114 121
115 // Initiates translation once the page is finished loading. 122 // Initiates translation once the page is finished loading.
116 void InitiateTranslation(const std::string& page_lang, int attempt); 123 void InitiateTranslation(const std::string& page_lang, int attempt);
117 124
118 // IPC handlers. 125 // IPC handlers.
119 void OnTranslateAssignedSequenceNumber(int page_seq_no); 126 void OnTranslateAssignedSequenceNumber(int page_seq_no);
120 void OnLanguageDetermined(const LanguageDetectionDetails& details, 127 void OnLanguageDetermined(const translate::LanguageDetectionDetails& details,
121 bool page_needs_translation); 128 bool page_needs_translation);
122 void OnPageTranslated(const std::string& original_lang, 129 void OnPageTranslated(const std::string& original_lang,
123 const std::string& translated_lang, 130 const std::string& translated_lang,
124 TranslateErrors::Type error_type); 131 translate::TranslateErrors::Type error_type);
125 132
126 // Shows the translate bubble. 133 // Shows the translate bubble.
127 void ShowBubble(translate::TranslateStep step, 134 void ShowBubble(translate::TranslateStep step,
128 TranslateErrors::Type error_type); 135 translate::TranslateErrors::Type error_type);
129 136
130 // Max number of attempts before checking if a page has been reloaded. 137 // Max number of attempts before checking if a page has been reloaded.
131 int max_reload_check_attempts_; 138 int max_reload_check_attempts_;
132 139
133 ContentTranslateDriver translate_driver_; 140 translate::ContentTranslateDriver translate_driver_;
134 scoped_ptr<TranslateManager> translate_manager_; 141 scoped_ptr<translate::TranslateManager> translate_manager_;
135 142
136 // Provides CLD data for this process. 143 // Provides CLD data for this process.
137 scoped_ptr<translate::BrowserCldDataProvider> cld_data_provider_; 144 scoped_ptr<translate::BrowserCldDataProvider> cld_data_provider_;
138 145
139 base::WeakPtrFactory<ChromeTranslateClient> weak_pointer_factory_; 146 base::WeakPtrFactory<ChromeTranslateClient> weak_pointer_factory_;
140 147
141 DISALLOW_COPY_AND_ASSIGN(ChromeTranslateClient); 148 DISALLOW_COPY_AND_ASSIGN(ChromeTranslateClient);
142 }; 149 };
143 150
144 #endif // CHROME_BROWSER_TRANSLATE_CHROME_TRANSLATE_CLIENT_H_ 151 #endif // CHROME_BROWSER_TRANSLATE_CHROME_TRANSLATE_CLIENT_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698