OLD | NEW |
(Empty) | |
| 1 // Copyright (c) 2011 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_INTENTS_HOST_IMPL_H_ |
| 6 #define CONTENT_BROWSER_INTENTS_INTENTS_HOST_IMPL_H_ |
| 7 |
| 8 #include "base/callback.h" |
| 9 #include "base/compiler_specific.h" |
| 10 #include "content/browser/tab_contents/tab_contents_observer.h" |
| 11 #include "content/public/browser/intents_host.h" |
| 12 #include "webkit/glue/web_intent_data.h" |
| 13 |
| 14 class IntentInjector; |
| 15 |
| 16 // Implements the coordinator object interface for Web Intents. |
| 17 // Observes the source (client) tab to make sure messages sent back by the |
| 18 // service can be delivered. Keeps a copy of triggering intent data to |
| 19 // be delivered to the service and serves as a forwarder for sending reply |
| 20 // messages back to the client page. |
| 21 class IntentsHostImpl : public content::IntentsHost, |
| 22 public TabContentsObserver { |
| 23 public: |
| 24 // |source_tab| is the page which triggered the web intent. |
| 25 // |intent| is the intent payload created by that page. |
| 26 // |intent_id| is the identifier assigned by WebKit to direct replies back to |
| 27 // the correct Javascript callback. |
| 28 IntentsHostImpl(TabContents* source_tab, |
| 29 const webkit_glue::WebIntentData& intent, |
| 30 int intent_id); |
| 31 virtual ~IntentsHostImpl(); |
| 32 |
| 33 // IntentsHost implementation |
| 34 virtual const webkit_glue::WebIntentData& GetIntent() OVERRIDE; |
| 35 virtual void DispatchIntent(TabContents* tab_contents) OVERRIDE; |
| 36 virtual void SendReplyMessage(webkit_glue::WebIntentReplyType reply_type, |
| 37 const string16& data) OVERRIDE; |
| 38 virtual void RegisterReplyNotification(const base::Closure& closure) OVERRIDE; |
| 39 |
| 40 // TabContentsObserver implementation |
| 41 virtual void TabContentsDestroyed(TabContents* tab) OVERRIDE; |
| 42 |
| 43 private: |
| 44 webkit_glue::WebIntentData intent_; |
| 45 |
| 46 int intent_id_; |
| 47 |
| 48 // Weak pointer to the internal object which provides the intent to the |
| 49 // newly-created service tab contents. This object is self-deleting |
| 50 // (connected to the service TabContents). |
| 51 IntentInjector* intent_injector_; |
| 52 |
| 53 // A callback to be notified when SendReplyMessage is called. |
| 54 base::Closure reply_notifier_; |
| 55 |
| 56 DISALLOW_COPY_AND_ASSIGN(IntentsHostImpl); |
| 57 }; |
| 58 |
| 59 #endif // CONTENT_BROWSER_INTENTS_INTENTS_HOST_IMPL_H_ |
OLD | NEW |