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

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

Issue 558663003: Move navigation handling code from TranslateClient to TranslateDriver (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: review comments Created 6 years, 3 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
« no previous file with comments | « no previous file | chrome/browser/translate/chrome_translate_client.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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"
11 #include "base/memory/weak_ptr.h"
12 #include "chrome/browser/ui/translate/translate_bubble_model.h" 11 #include "chrome/browser/ui/translate/translate_bubble_model.h"
13 #include "components/translate/content/browser/browser_cld_data_provider.h" 12 #include "components/translate/content/browser/browser_cld_data_provider.h"
14 #include "components/translate/content/browser/content_translate_driver.h" 13 #include "components/translate/content/browser/content_translate_driver.h"
15 #include "components/translate/core/browser/translate_client.h" 14 #include "components/translate/core/browser/translate_client.h"
16 #include "components/translate/core/browser/translate_step.h" 15 #include "components/translate/core/browser/translate_step.h"
17 #include "components/translate/core/common/translate_errors.h" 16 #include "components/translate/core/common/translate_errors.h"
18 #include "content/public/browser/web_contents_observer.h" 17 #include "content/public/browser/web_contents_observer.h"
19 #include "content/public/browser/web_contents_user_data.h" 18 #include "content/public/browser/web_contents_user_data.h"
20 19
21 namespace base { 20 namespace base {
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
76 std::string* source, 75 std::string* source,
77 std::string* target); 76 std::string* target);
78 77
79 // Gets the associated TranslateManager. 78 // Gets the associated TranslateManager.
80 translate::TranslateManager* GetTranslateManager(); 79 translate::TranslateManager* GetTranslateManager();
81 80
82 // Gets the associated WebContents. Returns NULL if the WebContents is being 81 // Gets the associated WebContents. Returns NULL if the WebContents is being
83 // destroyed. 82 // destroyed.
84 content::WebContents* GetWebContents(); 83 content::WebContents* GetWebContents();
85 84
86 // Number of attempts before waiting for a page to be fully reloaded.
87 void set_translate_max_reload_attempts(int attempts) {
88 max_reload_check_attempts_ = attempts;
89 }
90
91 // TranslateClient implementation. 85 // TranslateClient implementation.
92 virtual translate::TranslateDriver* GetTranslateDriver() OVERRIDE; 86 virtual translate::TranslateDriver* GetTranslateDriver() OVERRIDE;
93 virtual PrefService* GetPrefs() OVERRIDE; 87 virtual PrefService* GetPrefs() OVERRIDE;
94 virtual scoped_ptr<translate::TranslatePrefs> GetTranslatePrefs() OVERRIDE; 88 virtual scoped_ptr<translate::TranslatePrefs> GetTranslatePrefs() OVERRIDE;
95 virtual translate::TranslateAcceptLanguages* GetTranslateAcceptLanguages() 89 virtual translate::TranslateAcceptLanguages* GetTranslateAcceptLanguages()
96 OVERRIDE; 90 OVERRIDE;
97 virtual int GetInfobarIconID() const OVERRIDE; 91 virtual int GetInfobarIconID() const OVERRIDE;
98 virtual scoped_ptr<infobars::InfoBar> CreateInfoBar( 92 virtual scoped_ptr<infobars::InfoBar> CreateInfoBar(
99 scoped_ptr<translate::TranslateInfoBarDelegate> delegate) const OVERRIDE; 93 scoped_ptr<translate::TranslateInfoBarDelegate> delegate) const OVERRIDE;
100 virtual void ShowTranslateUI(translate::TranslateStep step, 94 virtual void ShowTranslateUI(translate::TranslateStep step,
101 const std::string source_language, 95 const std::string source_language,
102 const std::string target_language, 96 const std::string target_language,
103 translate::TranslateErrors::Type error_type, 97 translate::TranslateErrors::Type error_type,
104 bool triggered_from_menu) OVERRIDE; 98 bool triggered_from_menu) OVERRIDE;
105 virtual bool IsTranslatableURL(const GURL& url) OVERRIDE; 99 virtual bool IsTranslatableURL(const GURL& url) OVERRIDE;
106 virtual void ShowReportLanguageDetectionErrorUI( 100 virtual void ShowReportLanguageDetectionErrorUI(
107 const GURL& report_url) OVERRIDE; 101 const GURL& report_url) OVERRIDE;
108 102
109 private: 103 private:
110 explicit ChromeTranslateClient(content::WebContents* web_contents); 104 explicit ChromeTranslateClient(content::WebContents* web_contents);
111 friend class content::WebContentsUserData<ChromeTranslateClient>; 105 friend class content::WebContentsUserData<ChromeTranslateClient>;
112 106
113 // content::WebContentsObserver implementation. 107 // content::WebContentsObserver implementation.
114 virtual void NavigationEntryCommitted(
115 const content::LoadCommittedDetails& load_details) OVERRIDE;
116 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; 108 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
117 virtual void DidNavigateAnyFrame(
118 const content::LoadCommittedDetails& details,
119 const content::FrameNavigateParams& params) OVERRIDE;
120 virtual void WebContentsDestroyed() OVERRIDE; 109 virtual void WebContentsDestroyed() OVERRIDE;
121 110
122 // Initiates translation once the page is finished loading.
123 void InitiateTranslation(const std::string& page_lang, int attempt);
124
125 // IPC handlers. 111 // IPC handlers.
126 void OnTranslateAssignedSequenceNumber(int page_seq_no); 112 void OnTranslateAssignedSequenceNumber(int page_seq_no);
127 void OnLanguageDetermined(const translate::LanguageDetectionDetails& details, 113 void OnLanguageDetermined(const translate::LanguageDetectionDetails& details,
128 bool page_needs_translation); 114 bool page_needs_translation);
129 void OnPageTranslated(const std::string& original_lang, 115 void OnPageTranslated(const std::string& original_lang,
130 const std::string& translated_lang, 116 const std::string& translated_lang,
131 translate::TranslateErrors::Type error_type); 117 translate::TranslateErrors::Type error_type);
132 118
133 // Shows the translate bubble. 119 // Shows the translate bubble.
134 void ShowBubble(translate::TranslateStep step, 120 void ShowBubble(translate::TranslateStep step,
135 translate::TranslateErrors::Type error_type); 121 translate::TranslateErrors::Type error_type);
136 122
137 // Max number of attempts before checking if a page has been reloaded.
138 int max_reload_check_attempts_;
139
140 translate::ContentTranslateDriver translate_driver_; 123 translate::ContentTranslateDriver translate_driver_;
141 scoped_ptr<translate::TranslateManager> translate_manager_; 124 scoped_ptr<translate::TranslateManager> translate_manager_;
142 125
143 // Provides CLD data for this process. 126 // Provides CLD data for this process.
144 scoped_ptr<translate::BrowserCldDataProvider> cld_data_provider_; 127 scoped_ptr<translate::BrowserCldDataProvider> cld_data_provider_;
145 128
146 base::WeakPtrFactory<ChromeTranslateClient> weak_pointer_factory_;
147
148 DISALLOW_COPY_AND_ASSIGN(ChromeTranslateClient); 129 DISALLOW_COPY_AND_ASSIGN(ChromeTranslateClient);
149 }; 130 };
150 131
151 #endif // CHROME_BROWSER_TRANSLATE_CHROME_TRANSLATE_CLIENT_H_ 132 #endif // CHROME_BROWSER_TRANSLATE_CHROME_TRANSLATE_CLIENT_H_
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/translate/chrome_translate_client.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698