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

Side by Side Diff: chrome/browser/ui/webui/translate_internals/translate_internals_handler.h

Issue 143003020: Move TranslateLanguageList to the Translate component (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@removeDelegate
Patch Set: rebase Created 6 years, 10 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 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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_UI_WEBUI_TRANSLATE_INTERNALS_TRANSLATE_INTERNALS_HANDLER_ H_ 5 #ifndef CHROME_BROWSER_UI_WEBUI_TRANSLATE_INTERNALS_TRANSLATE_INTERNALS_HANDLER_ H_
6 #define CHROME_BROWSER_UI_WEBUI_TRANSLATE_INTERNALS_TRANSLATE_INTERNALS_HANDLER_ H_ 6 #define CHROME_BROWSER_UI_WEBUI_TRANSLATE_INTERNALS_TRANSLATE_INTERNALS_HANDLER_ H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/callback_list.h"
10 #include "chrome/browser/translate/translate_manager.h" 11 #include "chrome/browser/translate/translate_manager.h"
11 #include "content/public/browser/web_ui_message_handler.h" 12 #include "content/public/browser/web_ui_message_handler.h"
12 #include "content/public/common/webplugininfo.h" 13 #include "content/public/common/webplugininfo.h"
13 14
14 struct LanguageDetectionDetails; 15 struct LanguageDetectionDetails;
15 struct TranslateErrorDetails; 16 struct TranslateErrorDetails;
16 struct TranslateEventDetails; 17 struct TranslateEventDetails;
17 18
18 namespace base { 19 namespace base {
19 class DictionaryValue; 20 class DictionaryValue;
20 class ListValue; 21 class ListValue;
21 class Value; 22 class Value;
22 } 23 }
23 24
24 // The handler class for TranslateInternals page operations. 25 // The handler class for TranslateInternals page operations.
25 class TranslateInternalsHandler : public content::WebUIMessageHandler, 26 class TranslateInternalsHandler : public content::WebUIMessageHandler,
26 public TranslateManager::Observer { 27 public TranslateManager::Observer {
27 public: 28 public:
28 TranslateInternalsHandler(); 29 TranslateInternalsHandler();
29 virtual ~TranslateInternalsHandler(); 30 virtual ~TranslateInternalsHandler();
30 31
31 // content::WebUIMessageHandler methods: 32 // content::WebUIMessageHandler methods:
32 virtual void RegisterMessages() OVERRIDE; 33 virtual void RegisterMessages() OVERRIDE;
33 34
34 // TranslateManager::Observer methods: 35 // TranslateManager::Observer methods:
35 virtual void OnLanguageDetection( 36 virtual void OnLanguageDetection(
36 const LanguageDetectionDetails& details) OVERRIDE; 37 const LanguageDetectionDetails& details) OVERRIDE;
37 virtual void OnTranslateError( 38 virtual void OnTranslateError(
38 const TranslateErrorDetails& details) OVERRIDE; 39 const TranslateErrorDetails& details) OVERRIDE;
39 virtual void OnTranslateEvent( 40
40 const TranslateEventDetails& details) OVERRIDE; 41 // Callback for translate events.
42 virtual void OnTranslateEvent(const TranslateEventDetails& details);
41 43
42 private: 44 private:
43 // Handles the Javascript message 'removePrefItem'. This message is sent 45 // Handles the Javascript message 'removePrefItem'. This message is sent
44 // when UI requests to remove an item in the preference. 46 // when UI requests to remove an item in the preference.
45 void OnRemovePrefItem(const base::ListValue* args); 47 void OnRemovePrefItem(const base::ListValue* args);
46 48
47 // Handles the Javascript message 'requestInfo'. This message is sent 49 // Handles the Javascript message 'requestInfo'. This message is sent
48 // when UI needs to show information concerned with the translation. 50 // when UI needs to show information concerned with the translation.
49 // For now, this returns only prefs to Javascript. 51 // For now, this returns only prefs to Javascript.
50 // |args| is not used. 52 // |args| is not used.
51 void OnRequestInfo(const base::ListValue* args); 53 void OnRequestInfo(const base::ListValue* args);
52 54
53 // Sends a messsage to Javascript. 55 // Sends a messsage to Javascript.
54 void SendMessageToJs(const std::string& message, const base::Value& value); 56 void SendMessageToJs(const std::string& message, const base::Value& value);
55 57
56 // Sends the current preference to Javascript. 58 // Sends the current preference to Javascript.
57 void SendPrefsToJs(); 59 void SendPrefsToJs();
58 60
59 // Sends the languages currently supported by the server to JavaScript. 61 // Sends the languages currently supported by the server to JavaScript.
60 void SendSupportedLanguagesToJs(); 62 void SendSupportedLanguagesToJs();
61 63
64 // Subscription for translate events comming from the translate language list.
65 scoped_ptr<base::CallbackList<
66 void(const TranslateEventDetails&)>::Subscription> event_subscription_;
67
62 DISALLOW_COPY_AND_ASSIGN(TranslateInternalsHandler); 68 DISALLOW_COPY_AND_ASSIGN(TranslateInternalsHandler);
63 }; 69 };
64 70
65 #endif // CHROME_BROWSER_UI_WEBUI_TRANSLATE_INTERNALS_TRANSLATE_INTERNALS_HANDL ER_H_ 71 #endif // CHROME_BROWSER_UI_WEBUI_TRANSLATE_INTERNALS_TRANSLATE_INTERNALS_HANDL ER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698