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

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

Issue 25373009: Translate: New Bubble UX (for the view toolkit) (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Sky's review (2) Created 7 years, 2 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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_TRANSLATE_MANAGER_H_ 5 #ifndef CHROME_BROWSER_TRANSLATE_TRANSLATE_MANAGER_H_
6 #define CHROME_BROWSER_TRANSLATE_TRANSLATE_MANAGER_H_ 6 #define CHROME_BROWSER_TRANSLATE_TRANSLATE_MANAGER_H_
7 7
8 #include <map> 8 #include <map>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
11 11
12 #include "base/gtest_prod_util.h" 12 #include "base/gtest_prod_util.h"
13 #include "base/memory/scoped_ptr.h" 13 #include "base/memory/scoped_ptr.h"
14 #include "base/memory/weak_ptr.h" 14 #include "base/memory/weak_ptr.h"
15 #include "base/observer_list.h" 15 #include "base/observer_list.h"
16 #include "base/time/time.h" 16 #include "base/time/time.h"
17 #include "chrome/browser/ui/translate/translate_bubble_model.h"
17 #include "chrome/common/translate/translate_errors.h" 18 #include "chrome/common/translate/translate_errors.h"
18 #include "content/public/browser/notification_observer.h" 19 #include "content/public/browser/notification_observer.h"
19 #include "content/public/browser/notification_registrar.h" 20 #include "content/public/browser/notification_registrar.h"
20 21
21 template <typename T> struct DefaultSingletonTraits; 22 template <typename T> struct DefaultSingletonTraits;
22 class GURL; 23 class GURL;
23 struct LanguageDetectionDetails; 24 struct LanguageDetectionDetails;
24 struct PageTranslatedDetails; 25 struct PageTranslatedDetails;
25 class PrefService; 26 class PrefService;
26 class Profile; 27 class Profile;
27 struct ShortcutConfiguration; 28 struct ShortcutConfiguration;
28 class TranslateAcceptLanguages; 29 class TranslateAcceptLanguages;
30 class TranslateBubbleShowable;
29 struct TranslateErrorDetails; 31 struct TranslateErrorDetails;
30 struct TranslateEventDetails; 32 struct TranslateEventDetails;
31 class TranslateInfoBarDelegate; 33 class TranslateInfoBarDelegate;
32 class TranslateLanguageList; 34 class TranslateLanguageList;
33 class TranslateScript; 35 class TranslateScript;
34 36
35 namespace content { 37 namespace content {
36 class WebContents; 38 class WebContents;
37 } 39 }
38 40
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
121 // Used by unit-tests to override some defaults: 123 // Used by unit-tests to override some defaults:
122 // Delay after which the translate script is fetched again from the 124 // Delay after which the translate script is fetched again from the
123 // translation server. 125 // translation server.
124 void SetTranslateScriptExpirationDelay(int delay_ms); 126 void SetTranslateScriptExpirationDelay(int delay_ms);
125 127
126 // Number of attempts before waiting for a page to be fully reloaded. 128 // Number of attempts before waiting for a page to be fully reloaded.
127 void set_translate_max_reload_attemps(int attempts) { 129 void set_translate_max_reload_attemps(int attempts) {
128 max_reload_check_attempts_ = attempts; 130 max_reload_check_attempts_ = attempts;
129 } 131 }
130 132
133 // Sets the object which controls how to show the bubble. This is intended to
134 // be used at tests.
135 void SetTranslateBubbleShowable(
136 scoped_ptr<TranslateBubbleShowable> translate_bubble_showable);
137
131 // The observer class for TranslateManager. 138 // The observer class for TranslateManager.
132 class Observer { 139 class Observer {
133 public: 140 public:
134 virtual void OnLanguageDetection( 141 virtual void OnLanguageDetection(
135 const LanguageDetectionDetails& details) = 0; 142 const LanguageDetectionDetails& details) = 0;
136 virtual void OnTranslateError( 143 virtual void OnTranslateError(
137 const TranslateErrorDetails& details) = 0; 144 const TranslateErrorDetails& details) = 0;
138 virtual void OnTranslateEvent( 145 virtual void OnTranslateEvent(
139 const TranslateEventDetails& details) = 0; 146 const TranslateEventDetails& details) = 0;
140 }; 147 };
(...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 PageTranslatedDetails* details); 191 PageTranslatedDetails* details);
185 192
186 void OnTranslateScriptFetchComplete(bool success, const std::string& data); 193 void OnTranslateScriptFetchComplete(bool success, const std::string& data);
187 194
188 // Notifies to the observers when a language is detected. 195 // Notifies to the observers when a language is detected.
189 void NotifyLanguageDetection(const LanguageDetectionDetails& details); 196 void NotifyLanguageDetection(const LanguageDetectionDetails& details);
190 197
191 // Notifies to the observers when translate failed. 198 // Notifies to the observers when translate failed.
192 void NotifyTranslateError(const TranslateErrorDetails& details); 199 void NotifyTranslateError(const TranslateErrorDetails& details);
193 200
201 // Shows the translate bubble.
202 void ShowBubble(content::WebContents* web_contents,
203 TranslateBubbleModel::ViewState view_state);
204
194 // Returns the different parameters used to decide whether extra shortcuts 205 // Returns the different parameters used to decide whether extra shortcuts
195 // are needed. 206 // are needed.
196 static ShortcutConfiguration ShortcutConfig(); 207 static ShortcutConfiguration ShortcutConfig();
197 208
198 content::NotificationRegistrar notification_registrar_; 209 content::NotificationRegistrar notification_registrar_;
199 210
200 // Max number of attempts before checking if a page has been reloaded. 211 // Max number of attempts before checking if a page has been reloaded.
201 int max_reload_check_attempts_; 212 int max_reload_check_attempts_;
202 213
203 // The list of pending translate requests. Translate requests are queued when 214 // The list of pending translate requests. Translate requests are queued when
204 // the translate script is not ready and has to be fetched from the translate 215 // the translate script is not ready and has to be fetched from the translate
205 // server. 216 // server.
206 std::vector<PendingRequest> pending_requests_; 217 std::vector<PendingRequest> pending_requests_;
207 218
208 // List of registered observers. 219 // List of registered observers.
209 ObserverList<Observer> observer_list_; 220 ObserverList<Observer> observer_list_;
210 221
211 // An instance of TranslateLanguageList which manages supported language list. 222 // An instance of TranslateLanguageList which manages supported language list.
212 scoped_ptr<TranslateLanguageList> language_list_; 223 scoped_ptr<TranslateLanguageList> language_list_;
213 224
214 // An instance of TranslateScript which manages JavaScript source for 225 // An instance of TranslateScript which manages JavaScript source for
215 // Translate. 226 // Translate.
216 scoped_ptr<TranslateScript> script_; 227 scoped_ptr<TranslateScript> script_;
217 228
218 // An instance of TranslateAcceptLanguages which manages Accept languages of 229 // An instance of TranslateAcceptLanguages which manages Accept languages of
219 // each profiles. 230 // each profiles.
220 scoped_ptr<TranslateAcceptLanguages> accept_languages_; 231 scoped_ptr<TranslateAcceptLanguages> accept_languages_;
221 232
233 // An instance of TranslateBubbleShowable which show the Translate bubble.
234 scoped_ptr<TranslateBubbleShowable> bubble_showable_;
235
222 base::WeakPtrFactory<TranslateManager> weak_method_factory_; 236 base::WeakPtrFactory<TranslateManager> weak_method_factory_;
223 237
224 DISALLOW_COPY_AND_ASSIGN(TranslateManager); 238 DISALLOW_COPY_AND_ASSIGN(TranslateManager);
225 }; 239 };
226 240
227 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_MANAGER_H_ 241 #endif // CHROME_BROWSER_TRANSLATE_TRANSLATE_MANAGER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698