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