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" |
(...skipping 22 matching lines...) Expand all Loading... |
33 const content::LoadCommittedDetails& details, | 33 const content::LoadCommittedDetails& details, |
34 const content::FrameNavigateParams& params) OVERRIDE; | 34 const content::FrameNavigateParams& params) OVERRIDE; |
35 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 35 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
36 virtual void TabContentsDestroyed(TabContents* tab) OVERRIDE; | 36 virtual void TabContentsDestroyed(TabContents* tab) OVERRIDE; |
37 | 37 |
38 // Used to notify the object that the source tab has been destroyed. | 38 // Used to notify the object that the source tab has been destroyed. |
39 virtual void SourceTabContentsDestroyed(TabContents* tab); | 39 virtual void SourceTabContentsDestroyed(TabContents* tab); |
40 | 40 |
41 // Sets the intent data to be injected. Call after the user has selected a | 41 // Sets the intent data to be injected. Call after the user has selected a |
42 // service to pass the intent data to that service. | 42 // service to pass the intent data to that service. |
43 // |source_tab| is a sender to use to communicate to the source tab. Takes | 43 // |source_tab| is a sender to use to communicate to the source tab. The |
44 // ownership of |source_tab|. | 44 // caller must ensure that SourceTabContentsDestroyed is called when this |
| 45 // object becomes unusable. |
45 // |intent| is the intent data from the source | 46 // |intent| is the intent data from the source |
46 // |intent_id| is the ID assigned to the intent invocation from the source | 47 // |intent_id| is the ID assigned to the intent invocation from the source |
47 // context. | 48 // context. |
48 void SetIntent(IPC::Message::Sender* source_tab, | 49 void SetIntent(IPC::Message::Sender* source_tab, |
49 const webkit_glue::WebIntentData& intent, | 50 const webkit_glue::WebIntentData& intent, |
50 int intent_id); | 51 int intent_id); |
51 | 52 |
52 private: | 53 private: |
53 // Delivers the intent data to the renderer. | 54 // Delivers the intent data to the renderer. |
54 void SendIntent(); | 55 void SendIntent(); |
55 | 56 |
56 // Handles receiving a reply from the intent delivery page. | 57 // Handles receiving a reply from the intent delivery page. |
57 void OnReply(const IPC::Message& message, | 58 void OnReply(const IPC::Message& message, |
58 webkit_glue::WebIntentReplyType reply_type, | 59 webkit_glue::WebIntentReplyType reply_type, |
59 const string16& data, | 60 const string16& data, |
60 int intent_id); | 61 int intent_id); |
61 | 62 |
62 // Source intent data provided by caller. | 63 // Source intent data provided by caller. |
63 scoped_ptr<webkit_glue::WebIntentData> source_intent_; | 64 scoped_ptr<webkit_glue::WebIntentData> source_intent_; |
64 | 65 |
65 // Message forwarder to the tab invoking the intent. | 66 // Weak pointer to the message forwarder to the tab invoking the intent. |
66 scoped_ptr<IPC::Message::Sender> source_tab_; | 67 IPC::Message::Sender* source_tab_; |
67 | 68 |
68 // Unique ID assigned to the intent by the source tab. | 69 // Unique ID assigned to the intent by the source tab. |
69 int intent_id_; | 70 int intent_id_; |
70 | 71 |
71 DISALLOW_COPY_AND_ASSIGN(IntentInjector); | 72 DISALLOW_COPY_AND_ASSIGN(IntentInjector); |
72 }; | 73 }; |
73 | 74 |
74 #endif // CONTENT_BROWSER_INTENTS_INTENT_INJECTOR_H_ | 75 #endif // CONTENT_BROWSER_INTENTS_INTENT_INJECTOR_H_ |
OLD | NEW |