| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 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 | 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 CONTENT_BROWSER_INTENTS_INTENT_INJECTOR_H_ | 5 #ifndef CONTENT_BROWSER_INTENTS_INTENT_INJECTOR_H_ |
| 6 #define CONTENT_BROWSER_INTENTS_INTENT_INJECTOR_H_ | 6 #define CONTENT_BROWSER_INTENTS_INTENT_INJECTOR_H_ |
| 7 #pragma once | 7 #pragma once |
| 8 | 8 |
| 9 #include "base/basictypes.h" | 9 #include "base/basictypes.h" |
| 10 #include "base/string16.h" | 10 #include "base/string16.h" |
| 11 #include "content/browser/tab_contents/tab_contents_observer.h" | 11 #include "content/browser/tab_contents/tab_contents_observer.h" |
| 12 #include "content/common/content_export.h" | 12 #include "content/common/content_export.h" |
| 13 #include "webkit/glue/web_intent_reply_data.h" | 13 #include "webkit/glue/web_intent_reply_data.h" |
| 14 | 14 |
| 15 namespace content { | 15 namespace content { |
| 16 class IntentsHost; | 16 class WebIntentsDispatcher; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace webkit_glue { | 19 namespace webkit_glue { |
| 20 struct WebIntentData; | 20 struct WebIntentData; |
| 21 } | 21 } |
| 22 | 22 |
| 23 // Injects an intent into the renderer of a TabContents. The intent dispatch | 23 // Injects an intent into the renderer of a TabContents. The intent dispatch |
| 24 // logic will create one of these to take care of passing intent data down into | 24 // logic will create one of these to take care of passing intent data down into |
| 25 // the context of the service, which will be running in the TabContents on which | 25 // the context of the service, which will be running in the TabContents on which |
| 26 // this class is an observer. Attaches to the service tab and deletes itself | 26 // this class is an observer. Attaches to the service tab and deletes itself |
| (...skipping 10 matching lines...) Expand all Loading... |
| 37 const content::LoadCommittedDetails& details, | 37 const content::LoadCommittedDetails& details, |
| 38 const content::FrameNavigateParams& params) OVERRIDE; | 38 const content::FrameNavigateParams& params) OVERRIDE; |
| 39 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 39 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 40 virtual void TabContentsDestroyed(TabContents* tab) OVERRIDE; | 40 virtual void TabContentsDestroyed(TabContents* tab) OVERRIDE; |
| 41 | 41 |
| 42 // Used to notify the object that the source tab has been destroyed. | 42 // Used to notify the object that the source tab has been destroyed. |
| 43 virtual void SourceTabContentsDestroyed(TabContents* tab); | 43 virtual void SourceTabContentsDestroyed(TabContents* tab); |
| 44 | 44 |
| 45 // Sets the intent data to be injected. Call after the user has selected a | 45 // Sets the intent data to be injected. Call after the user has selected a |
| 46 // service to pass the intent data to that service. | 46 // service to pass the intent data to that service. |
| 47 // |source_tab| is a sender to use to communicate to the source tab. The | 47 // |intents_dispatcher| is a sender to use to communicate to the source tab. |
| 48 // caller must ensure that SourceTabContentsDestroyed is called when this | 48 // The caller must ensure that SourceTabContentsDestroyed is called when this |
| 49 // object becomes unusable. | 49 // object becomes unusable. |
| 50 // |intent| is the intent data from the source | 50 // |intent| is the intent data from the source |
| 51 void SetIntent(content::IntentsHost* source_tab, | 51 void SetIntent(content::WebIntentsDispatcher* intents_dispatcher, |
| 52 const webkit_glue::WebIntentData& intent); | 52 const webkit_glue::WebIntentData& intent); |
| 53 | 53 |
| 54 private: | 54 private: |
| 55 // Delivers the intent data to the renderer. | 55 // Delivers the intent data to the renderer. |
| 56 void SendIntent(); | 56 void SendIntent(); |
| 57 | 57 |
| 58 // Handles receiving a reply from the intent delivery page. | 58 // Handles receiving a reply from the intent delivery page. |
| 59 void OnReply(webkit_glue::WebIntentReplyType reply_type, | 59 void OnReply(webkit_glue::WebIntentReplyType reply_type, |
| 60 const string16& data); | 60 const string16& data); |
| 61 | 61 |
| 62 // Source intent data provided by caller. | 62 // Source intent data provided by caller. |
| 63 scoped_ptr<webkit_glue::WebIntentData> source_intent_; | 63 scoped_ptr<webkit_glue::WebIntentData> source_intent_; |
| 64 | 64 |
| 65 // Weak pointer to the message forwarder to the tab invoking the intent. | 65 // Weak pointer to the message forwarder to the tab invoking the intent. |
| 66 content::IntentsHost* source_tab_; | 66 content::WebIntentsDispatcher* intents_dispatcher_; |
| 67 | 67 |
| 68 DISALLOW_COPY_AND_ASSIGN(IntentInjector); | 68 DISALLOW_COPY_AND_ASSIGN(IntentInjector); |
| 69 }; | 69 }; |
| 70 | 70 |
| 71 #endif // CONTENT_BROWSER_INTENTS_INTENT_INJECTOR_H_ | 71 #endif // CONTENT_BROWSER_INTENTS_INTENT_INJECTOR_H_ |
| OLD | NEW |