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