| OLD | NEW |
| 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_HANDLER_H_ | 5 #ifndef CHROME_BROWSER_UI_WEBUI_TRANSLATE_INTERNALS_HANDLER_H_ |
| 6 #define CHROME_BROWSER_UI_WEBUI_TRANSLATE_INTERNALS_HANDLER_H_ | 6 #define CHROME_BROWSER_UI_WEBUI_TRANSLATE_INTERNALS_HANDLER_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "chrome/browser/translate/translate_manager.h" | 10 #include "chrome/browser/translate/translate_manager.h" |
| 11 #include "content/public/browser/web_ui_message_handler.h" | 11 #include "content/public/browser/web_ui_message_handler.h" |
| 12 #include "webkit/plugins/webplugininfo.h" | 12 #include "webkit/plugins/webplugininfo.h" |
| 13 | 13 |
| 14 struct LanguageDetectionDetails; | 14 struct LanguageDetectionDetails; |
| 15 struct TranslateErrorDetails; |
| 15 | 16 |
| 16 namespace base { | 17 namespace base { |
| 17 class DictionaryValue; | 18 class DictionaryValue; |
| 18 class ListValue; | 19 class ListValue; |
| 19 class Value; | 20 class Value; |
| 20 } | 21 } |
| 21 | 22 |
| 22 // The handler class for TranslateInternals page operations. | 23 // The handler class for TranslateInternals page operations. |
| 23 class TranslateInternalsHandler : public content::WebUIMessageHandler, | 24 class TranslateInternalsHandler : public content::WebUIMessageHandler, |
| 24 public TranslateManager::Observer { | 25 public TranslateManager::Observer { |
| 25 public: | 26 public: |
| 26 TranslateInternalsHandler(); | 27 TranslateInternalsHandler(); |
| 27 virtual ~TranslateInternalsHandler(); | 28 virtual ~TranslateInternalsHandler(); |
| 28 | 29 |
| 29 // content::WebUIMessageHandler methods: | 30 // content::WebUIMessageHandler methods: |
| 30 virtual void RegisterMessages() OVERRIDE; | 31 virtual void RegisterMessages() OVERRIDE; |
| 31 | 32 |
| 32 // TranslateManager::Observer methods: | 33 // TranslateManager::Observer methods: |
| 33 virtual void OnLanguageDetection( | 34 virtual void OnLanguageDetection( |
| 34 const LanguageDetectionDetails& details) OVERRIDE; | 35 const LanguageDetectionDetails& details) OVERRIDE; |
| 36 virtual void OnTranslateError( |
| 37 const TranslateErrorDetails& details) OVERRIDE; |
| 35 | 38 |
| 36 private: | 39 private: |
| 37 // Handles the Javascript message 'removePrefItem'. This message is sent | 40 // Handles the Javascript message 'removePrefItem'. This message is sent |
| 38 // when UI requests to remove an item in the preference. | 41 // when UI requests to remove an item in the preference. |
| 39 void OnRemovePrefItem(const base::ListValue* args); | 42 void OnRemovePrefItem(const base::ListValue* args); |
| 40 | 43 |
| 41 // Handles the Javascript message 'requestInfo'. This message is sent | 44 // Handles the Javascript message 'requestInfo'. This message is sent |
| 42 // when UI needs to show information concerned with the translation. | 45 // when UI needs to show information concerned with the translation. |
| 43 // For now, this returns only prefs to Javascript. | 46 // For now, this returns only prefs to Javascript. |
| 44 // |args| is not used. | 47 // |args| is not used. |
| 45 void OnRequestInfo(const base::ListValue* args); | 48 void OnRequestInfo(const base::ListValue* args); |
| 46 | 49 |
| 47 // Sends a messsage to Javascript. | 50 // Sends a messsage to Javascript. |
| 48 void SendMessageToJs(const std::string& message, const base::Value& value); | 51 void SendMessageToJs(const std::string& message, const base::Value& value); |
| 49 | 52 |
| 50 // Sends the current preference to Javascript. | 53 // Sends the current preference to Javascript. |
| 51 void SendPrefsToJs(); | 54 void SendPrefsToJs(); |
| 52 | 55 |
| 53 DISALLOW_COPY_AND_ASSIGN(TranslateInternalsHandler); | 56 DISALLOW_COPY_AND_ASSIGN(TranslateInternalsHandler); |
| 54 }; | 57 }; |
| 55 | 58 |
| 56 #endif // CHROME_BROWSER_UI_WEBUI_TRANSLATE_INTERNALS_HANDLER_H_ | 59 #endif // CHROME_BROWSER_UI_WEBUI_TRANSLATE_INTERNALS_HANDLER_H_ |
| OLD | NEW |