OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2012 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. |
| 4 |
| 5 #ifndef CONTENT_BROWSER_INTENTS_INTERNAL_WEB_INTENTS_DISPATCHER_H_ |
| 6 #define CONTENT_BROWSER_INTENTS_INTERNAL_WEB_INTENTS_DISPATCHER_H_ |
| 7 |
| 8 #include <vector> |
| 9 |
| 10 #include "base/callback.h" |
| 11 #include "base/compiler_specific.h" |
| 12 #include "content/public/browser/web_intents_dispatcher.h" |
| 13 #include "webkit/glue/web_intent_data.h" |
| 14 |
| 15 class IntentInjector; |
| 16 |
| 17 // This class implements a web intents dispatcher which originates |
| 18 // within the browser process rather than with a particular renderer. |
| 19 // The implementation handles replies to the web intents invocation by |
| 20 // notifying a registered callback rather than returning |
| 21 // those messages to any renderer. |
| 22 class CONTENT_EXPORT InternalWebIntentsDispatcher |
| 23 : public content::WebIntentsDispatcher { |
| 24 public: |
| 25 // This callback will be called during, and receives the same args as, |
| 26 // |SendReplyMessage|. |
| 27 typedef base::Callback<void(webkit_glue::WebIntentReplyType, |
| 28 const string16&)> ReplyCallback; |
| 29 |
| 30 // |intent| is the intent payload to be dispatched. |
| 31 explicit InternalWebIntentsDispatcher( |
| 32 const webkit_glue::WebIntentData& intent); |
| 33 |
| 34 // |intent| is the intent payload to be dispatched. |
| 35 // |reply_callback| is the callback to notify when the intent is replied to. |
| 36 InternalWebIntentsDispatcher( |
| 37 const webkit_glue::WebIntentData& intent, |
| 38 const ReplyCallback& reply_callback); |
| 39 |
| 40 virtual ~InternalWebIntentsDispatcher(); |
| 41 |
| 42 // WebIntentsDispatcher implementation. |
| 43 virtual const webkit_glue::WebIntentData& GetIntent() OVERRIDE; |
| 44 virtual void DispatchIntent(content::WebContents* destination_tab) OVERRIDE; |
| 45 virtual void SendReplyMessage(webkit_glue::WebIntentReplyType reply_type, |
| 46 const string16& data) OVERRIDE; |
| 47 virtual void RegisterReplyNotification( |
| 48 const content::WebIntentsDispatcher::ReplyNotification& closure) OVERRIDE; |
| 49 |
| 50 private: |
| 51 // The intent data to be delivered. |
| 52 webkit_glue::WebIntentData intent_; |
| 53 |
| 54 // Weak pointer to the internal object which delivers the intent to the |
| 55 // newly-created service tab contents. This object is self-deleting |
| 56 // (connected to the service TabContents). |
| 57 IntentInjector* intent_injector_; |
| 58 |
| 59 // Callbacks to be notified when SendReplyMessage is called. |
| 60 std::vector<content::WebIntentsDispatcher::ReplyNotification> |
| 61 reply_notifiers_; |
| 62 |
| 63 // Callback to be invoked when the intent is replied to. |
| 64 ReplyCallback reply_callback_; |
| 65 |
| 66 DISALLOW_COPY_AND_ASSIGN(InternalWebIntentsDispatcher); |
| 67 }; |
| 68 |
| 69 #endif // CONTENT_BROWSER_INTENTS_INTERNAL_WEB_INTENTS_DISPATCHER_H_ |
OLD | NEW |