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
3 // found in the LICENSE file.
5 #ifndef CHROME_BROWSER_UI_WEBUI_TRANSLATE_INTERNALS_TRANSLATE_INTERNALS_HANDLER_H_
6 #define CHROME_BROWSER_UI_WEBUI_TRANSLATE_INTERNALS_TRANSLATE_INTERNALS_HANDLER_H_
10 #include "base/callback_list.h"
11 #include "base/memory/scoped_ptr.h"
12 #include "components/translate/core/browser/translate_language_list.h"
13 #include "components/translate/core/browser/translate_manager.h"
14 #include "content/public/browser/notification_observer.h"
15 #include "content/public/browser/notification_registrar.h"
16 #include "content/public/browser/web_ui_message_handler.h"
17 #include "content/public/common/webplugininfo.h"
20 struct LanguageDetectionDetails;
21 struct TranslateErrorDetails;
22 struct TranslateEventDetails;
26 class DictionaryValue;
32 class NotificationDetails;
33 class NotificationSource;
36 // The handler class for TranslateInternals page operations.
37 class TranslateInternalsHandler : public content::WebUIMessageHandler,
38 public content::NotificationObserver {
40 TranslateInternalsHandler();
41 virtual ~TranslateInternalsHandler();
43 // content::WebUIMessageHandler methods:
44 virtual void RegisterMessages() OVERRIDE;
47 // content::NotificationObserver implementation:
48 virtual void Observe(int type,
49 const content::NotificationSource& source,
50 const content::NotificationDetails& details) OVERRIDE;
52 // Callback for translate errors.
53 void OnTranslateError(const translate::TranslateErrorDetails& details);
55 // Callback for translate events.
56 virtual void OnTranslateEvent(
57 const translate::TranslateEventDetails& details);
59 // Handles the Javascript message 'removePrefItem'. This message is sent
60 // when UI requests to remove an item in the preference.
61 void OnRemovePrefItem(const base::ListValue* args);
63 // Handles the Javascript message 'requestInfo'. This message is sent
64 // when UI needs to show information concerned with the translation.
65 // For now, this returns only prefs to Javascript.
66 // |args| is not used.
67 void OnRequestInfo(const base::ListValue* args);
69 // Sends a messsage to Javascript.
70 void SendMessageToJs(const std::string& message, const base::Value& value);
72 // Sends the current preference to Javascript.
75 // Sends the languages currently supported by the server to JavaScript.
76 void SendSupportedLanguagesToJs();
78 // Subscription for translate events coming from the translate language list.
79 scoped_ptr<translate::TranslateLanguageList::EventCallbackList::Subscription>
82 // Subscription for translate errors coming from the translate manager.
84 translate::TranslateManager::TranslateErrorCallbackList::Subscription>
87 content::NotificationRegistrar notification_registrar_;
89 DISALLOW_COPY_AND_ASSIGN(TranslateInternalsHandler);
92 #endif // CHROME_BROWSER_UI_WEBUI_TRANSLATE_INTERNALS_TRANSLATE_INTERNALS_HANDLER_H_