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 "chrome/browser/translate/translate_manager.h"
12 #include "content/public/browser/web_ui_message_handler.h"
13 #include "content/public/common/webplugininfo.h"
15 struct LanguageDetectionDetails
;
16 struct TranslateErrorDetails
;
17 struct TranslateEventDetails
;
20 class DictionaryValue
;
25 // The handler class for TranslateInternals page operations.
26 class TranslateInternalsHandler
: public content::WebUIMessageHandler
,
27 public TranslateManager::Observer
{
29 TranslateInternalsHandler();
30 virtual ~TranslateInternalsHandler();
32 // content::WebUIMessageHandler methods:
33 virtual void RegisterMessages() OVERRIDE
;
35 // TranslateManager::Observer methods:
36 virtual void OnLanguageDetection(
37 const LanguageDetectionDetails
& details
) OVERRIDE
;
38 virtual void OnTranslateError(
39 const TranslateErrorDetails
& details
) OVERRIDE
;
41 // Callback for translate events.
42 virtual void OnTranslateEvent(const TranslateEventDetails
& details
);
45 // Handles the Javascript message 'removePrefItem'. This message is sent
46 // when UI requests to remove an item in the preference.
47 void OnRemovePrefItem(const base::ListValue
* args
);
49 // Handles the Javascript message 'requestInfo'. This message is sent
50 // when UI needs to show information concerned with the translation.
51 // For now, this returns only prefs to Javascript.
52 // |args| is not used.
53 void OnRequestInfo(const base::ListValue
* args
);
55 // Sends a messsage to Javascript.
56 void SendMessageToJs(const std::string
& message
, const base::Value
& value
);
58 // Sends the current preference to Javascript.
61 // Sends the languages currently supported by the server to JavaScript.
62 void SendSupportedLanguagesToJs();
64 // Subscription for translate events comming from the translate language list.
65 scoped_ptr
<base::CallbackList
<
66 void(const TranslateEventDetails
&)>::Subscription
> event_subscription_
;
68 DISALLOW_COPY_AND_ASSIGN(TranslateInternalsHandler
);
71 #endif // CHROME_BROWSER_UI_WEBUI_TRANSLATE_INTERNALS_TRANSLATE_INTERNALS_HANDLER_H_