| 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 COMPONENTS_DOM_DISTILLER_WEBUI_DOM_DISTILLER_HANDLER_H_ | 5 #ifndef COMPONENTS_DOM_DISTILLER_WEBUI_DOM_DISTILLER_HANDLER_H_ |
| 6 #define COMPONENTS_DOM_DISTILLER_WEBUI_DOM_DISTILLER_HANDLER_H_ | 6 #define COMPONENTS_DOM_DISTILLER_WEBUI_DOM_DISTILLER_HANDLER_H_ |
| 7 | 7 |
| 8 #include <vector> | |
| 9 | |
| 10 #include "base/memory/weak_ptr.h" | 8 #include "base/memory/weak_ptr.h" |
| 11 #include "base/values.h" | 9 #include "base/values.h" |
| 12 #include "content/public/browser/web_ui_message_handler.h" | 10 #include "content/public/browser/web_ui_message_handler.h" |
| 13 | 11 |
| 14 namespace dom_distiller { | 12 namespace dom_distiller { |
| 15 | 13 |
| 16 // Handler class for DOM Distiller page operations. | 14 class DomDistillerService; |
| 15 |
| 16 // Handler class for DOM Distiller list operations. |
| 17 class DomDistillerHandler : public content::WebUIMessageHandler { | 17 class DomDistillerHandler : public content::WebUIMessageHandler { |
| 18 public: | 18 public: |
| 19 DomDistillerHandler(); | 19 // The lifetime of |service| has to outlive this handler. |
| 20 DomDistillerHandler(DomDistillerService* service, |
| 21 const std::string& scheme); |
| 20 virtual ~DomDistillerHandler(); | 22 virtual ~DomDistillerHandler(); |
| 21 | 23 |
| 22 // content::WebUIMessageHandler implementation. | 24 // content::WebUIMessageHandler implementation. |
| 23 virtual void RegisterMessages() OVERRIDE; | 25 virtual void RegisterMessages() OVERRIDE; |
| 24 | 26 |
| 25 // Callback for the "requestEntries" message. This synchronously requests the | 27 // Callback from JavaScript for the "requestEntries" message. This |
| 26 // list of entries and returns it to the front end. | 28 // requests the list of entries and returns it to the front end by calling |
| 27 virtual void HandleRequestEntries(const ListValue* args); | 29 // "onReceivedEntries". There are no JavaScript arguments to this method. |
| 30 void HandleRequestEntries(const ListValue* args); |
| 31 |
| 32 // Callback from JavaScript for when an article should be added. The first |
| 33 // element in |args| should be a string representing the URL to be added. |
| 34 void HandleAddArticle(const ListValue* args); |
| 35 |
| 36 // Callback from JavaScript for when an article is selected. The first element |
| 37 // in |args| should be a string representing the ID of the entry to be |
| 38 // selected. |
| 39 void HandleSelectArticle(const ListValue* args); |
| 28 | 40 |
| 29 private: | 41 private: |
| 30 // Factory for the creating refs in callbacks. | 42 // Factory for the creating refs in callbacks. |
| 31 base::WeakPtrFactory<DomDistillerHandler> weak_ptr_factory_; | 43 base::WeakPtrFactory<DomDistillerHandler> weak_ptr_factory_; |
| 32 | 44 |
| 45 // The DomDistillerService. |
| 46 DomDistillerService* service_; |
| 47 |
| 48 // The scheme for DOM distiller articles. |
| 49 std::string article_scheme_; |
| 50 |
| 33 DISALLOW_COPY_AND_ASSIGN(DomDistillerHandler); | 51 DISALLOW_COPY_AND_ASSIGN(DomDistillerHandler); |
| 34 }; | 52 }; |
| 35 | 53 |
| 36 } // namespace dom_distiller | 54 } // namespace dom_distiller |
| 37 | 55 |
| 38 #endif // COMPONENTS_DOM_DISTILLER_WEBUI_DOM_DISTILLER_HANDLER_H_ | 56 #endif // COMPONENTS_DOM_DISTILLER_WEBUI_DOM_DISTILLER_HANDLER_H_ |
| OLD | NEW |