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 "chrome/browser/translate/translate_manager.h"
13 #include "components/translate/core/browser/translate_language_list.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"
19 struct LanguageDetectionDetails;
20 struct TranslateErrorDetails;
21 struct TranslateEventDetails;
24 class DictionaryValue;
30 class NotificationDetails;
31 class NotificationSource;
34 // The handler class for TranslateInternals page operations.
35 class TranslateInternalsHandler : public content::WebUIMessageHandler,
36 public content::NotificationObserver {
38 TranslateInternalsHandler();
39 virtual ~TranslateInternalsHandler();
41 // content::WebUIMessageHandler methods:
42 virtual void RegisterMessages() OVERRIDE;
45 // content::NotificationObserver implementation:
46 virtual void Observe(int type,
47 const content::NotificationSource& source,
48 const content::NotificationDetails& details) OVERRIDE;
50 // Callback for translate errors.
51 void OnTranslateError(const TranslateErrorDetails& details);
53 // Callback for translate events.
54 virtual void OnTranslateEvent(const TranslateEventDetails& details);
56 // Handles the Javascript message 'removePrefItem'. This message is sent
57 // when UI requests to remove an item in the preference.
58 void OnRemovePrefItem(const base::ListValue* args);
60 // Handles the Javascript message 'requestInfo'. This message is sent
61 // when UI needs to show information concerned with the translation.
62 // For now, this returns only prefs to Javascript.
63 // |args| is not used.
64 void OnRequestInfo(const base::ListValue* args);
66 // Sends a messsage to Javascript.
67 void SendMessageToJs(const std::string& message, const base::Value& value);
69 // Sends the current preference to Javascript.
72 // Sends the languages currently supported by the server to JavaScript.
73 void SendSupportedLanguagesToJs();
75 // Subscription for translate events coming from the translate language list.
76 scoped_ptr<TranslateLanguageList::EventCallbackList::Subscription>
79 // Subscription for translate errors coming from the translate manager.
80 scoped_ptr<TranslateManager::TranslateErrorCallbackList::Subscription>
83 content::NotificationRegistrar notification_registrar_;
85 DISALLOW_COPY_AND_ASSIGN(TranslateInternalsHandler);
88 #endif // CHROME_BROWSER_UI_WEBUI_TRANSLATE_INTERNALS_TRANSLATE_INTERNALS_HANDLER_H_