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 "content/common/intents_messages.h" | 13 #include "webkit/glue/web_intent_reply_data.h" |
14 | |
15 class RenderViewHost; | |
16 class TabContents; | |
17 | 14 |
18 namespace webkit_glue { | 15 namespace webkit_glue { |
19 struct WebIntentData; | 16 struct WebIntentData; |
20 } | 17 } |
21 | 18 |
22 namespace IPC { | |
23 class Message; | |
24 } | |
25 | |
26 // Injects an intent into the renderer of a TabContents. The intent dispatch | 19 // Injects an intent into the renderer of a TabContents. The intent dispatch |
27 // logic will create one of these to take care of passing intent data down into | 20 // logic will create one of these to take care of passing intent data down into |
28 // the context of the service, which will be running in the TabContents on which | 21 // the context of the service, which will be running in the TabContents on which |
29 // this class is an observer. Attaches to the service tab and deletes itself | 22 // this class is an observer. Attaches to the service tab and deletes itself |
30 // when that TabContents is closed. | 23 // when that TabContents is closed. |
31 class CONTENT_EXPORT IntentInjector : public TabContentsObserver { | 24 class CONTENT_EXPORT IntentInjector : public TabContentsObserver { |
32 public: | 25 public: |
33 // |tab_contents| must not be NULL. | 26 // |tab_contents| must not be NULL. |
34 explicit IntentInjector(TabContents* tab_contents); | 27 explicit IntentInjector(TabContents* tab_contents); |
35 virtual ~IntentInjector(); | 28 virtual ~IntentInjector(); |
36 | 29 |
37 // TabContentsObserver implementation. | 30 // TabContentsObserver implementation. |
38 virtual void RenderViewCreated(RenderViewHost* host) OVERRIDE; | 31 virtual void RenderViewCreated(RenderViewHost* host) OVERRIDE; |
39 virtual void DidNavigateMainFrame( | 32 virtual void DidNavigateMainFrame( |
40 const content::LoadCommittedDetails& details, | 33 const content::LoadCommittedDetails& details, |
41 const ViewHostMsg_FrameNavigate_Params& params) OVERRIDE; | 34 const content::FrameNavigateParams& params) OVERRIDE; |
42 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 35 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
43 virtual void TabContentsDestroyed(TabContents* tab) OVERRIDE; | 36 virtual void TabContentsDestroyed(TabContents* tab) OVERRIDE; |
44 | 37 |
45 // 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. |
46 virtual void SourceTabContentsDestroyed(TabContents* tab); | 39 virtual void SourceTabContentsDestroyed(TabContents* tab); |
47 | 40 |
48 // 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 |
49 // service to pass the intent data to that service. | 42 // service to pass the intent data to that service. |
50 // |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. Takes |
51 // ownership of |source_tab|. | 44 // ownership of |source_tab|. |
(...skipping 20 matching lines...) Expand all Loading... |
72 // Message forwarder to the tab invoking the intent. | 65 // Message forwarder to the tab invoking the intent. |
73 scoped_ptr<IPC::Message::Sender> source_tab_; | 66 scoped_ptr<IPC::Message::Sender> source_tab_; |
74 | 67 |
75 // Unique ID assigned to the intent by the source tab. | 68 // Unique ID assigned to the intent by the source tab. |
76 int intent_id_; | 69 int intent_id_; |
77 | 70 |
78 DISALLOW_COPY_AND_ASSIGN(IntentInjector); | 71 DISALLOW_COPY_AND_ASSIGN(IntentInjector); |
79 }; | 72 }; |
80 | 73 |
81 #endif // CONTENT_BROWSER_INTENTS_INTENT_INJECTOR_H_ | 74 #endif // CONTENT_BROWSER_INTENTS_INTENT_INJECTOR_H_ |
OLD | NEW |