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_RENDERER_WEB_INTENTS_HOST_H_ | 5 #ifndef CONTENT_RENDERER_WEB_INTENTS_HOST_H_ |
6 #define CONTENT_RENDERER_WEB_INTENTS_HOST_H_ | 6 #define CONTENT_RENDERER_WEB_INTENTS_HOST_H_ |
7 #pragma once | 7 #pragma once |
8 | 8 |
9 #include <map> | |
darin (slow to review)
2012/01/19 07:23:57
nit: add a new line after this include
Greg Billock
2012/01/19 18:51:59
Done.
| |
9 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
10 #include "content/public/renderer/render_view_observer.h" | 11 #include "content/public/renderer/render_view_observer.h" |
11 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
12 #include "webkit/glue/web_intent_data.h" | 13 #include "webkit/glue/web_intent_data.h" |
13 #include "webkit/glue/web_intent_reply_data.h" | 14 #include "webkit/glue/web_intent_reply_data.h" |
14 | 15 |
15 class RenderViewImpl; | 16 class RenderViewImpl; |
16 | 17 |
17 namespace WebKit { | 18 namespace WebKit { |
19 class WebIntentRequest; | |
18 class WebFrame; | 20 class WebFrame; |
19 } | 21 } |
20 | 22 |
21 namespace webkit_glue { | 23 namespace webkit_glue { |
22 struct WebIntentData; | 24 struct WebIntentData; |
23 } | 25 } |
24 | 26 |
25 // WebIntentsHost is a delegate for Web Intents messages. It is the | 27 // WebIntentsHost is a delegate for Web Intents messages. It is the |
26 // renderer-side handler for IPC messages delivering the intent payload data | 28 // renderer-side handler for IPC messages delivering the intent payload data |
27 // and preparing it for access by the service page. | 29 // and preparing it for access by the service page. |
28 class WebIntentsHost : public content::RenderViewObserver { | 30 class WebIntentsHost : public content::RenderViewObserver { |
29 public: | 31 public: |
30 // |render_view| must not be NULL. | 32 // |render_view| must not be NULL. |
31 explicit WebIntentsHost(RenderViewImpl* render_view); | 33 explicit WebIntentsHost(RenderViewImpl* render_view); |
32 virtual ~WebIntentsHost(); | 34 virtual ~WebIntentsHost(); |
33 | 35 |
36 // Called by the RenderView to register a new Web Intent invocation. | |
37 int RegisterWebIntent(const WebKit::WebIntentRequest& request); | |
38 | |
34 // Called by the bound intent object to register the result from the service | 39 // Called by the bound intent object to register the result from the service |
35 // page. | 40 // page. |
36 void OnResult(const WebKit::WebString& data); | 41 void OnResult(const WebKit::WebString& data); |
37 void OnFailure(const WebKit::WebString& data); | 42 void OnFailure(const WebKit::WebString& data); |
38 | 43 |
39 private: | 44 private: |
40 class BoundDeliveredIntent; | 45 class BoundDeliveredIntent; |
41 | 46 |
47 // A counter used to assign unique IDs to web intents invocations in this | |
48 // renderer. | |
49 int id_counter_; | |
darin (slow to review)
2012/01/19 07:23:57
perhaps you should be using IDMap<T> here? see ba
Greg Billock
2012/01/19 18:51:59
It looks like that class really wants to store poi
| |
50 | |
51 // Map tracking registered Web Intent requests by assigned ID numbers to | |
52 // correctly route any return data. | |
53 std::map<int, WebKit::WebIntentRequest> intent_requests_; | |
54 | |
42 // RenderView::Observer implementation. | 55 // RenderView::Observer implementation. |
43 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 56 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
44 virtual void DidClearWindowObject(WebKit::WebFrame* frame) OVERRIDE; | 57 virtual void DidClearWindowObject(WebKit::WebFrame* frame) OVERRIDE; |
45 | 58 |
46 // TODO(gbillock): Do we need various ***ClientRedirect methods to implement | 59 // TODO(gbillock): Do we need various ***ClientRedirect methods to implement |
47 // intent cancelling policy? Figure this out. | 60 // intent cancelling policy? Figure this out. |
48 | 61 |
49 // On the service page, handler method for the IntentsMsg_SetWebIntent | 62 // On the service page, handler method for the IntentsMsg_SetWebIntent |
50 // message. | 63 // message. |
51 void OnSetIntent(const webkit_glue::WebIntentData& intent); | 64 void OnSetIntent(const webkit_glue::WebIntentData& intent); |
52 | 65 |
53 // On the client page, handler method for the IntentsMsg_WebIntentReply | 66 // On the client page, handler method for the IntentsMsg_WebIntentReply |
54 // message. | 67 // message. |
55 void OnWebIntentReply(webkit_glue::WebIntentReplyType reply_type, | 68 void OnWebIntentReply(webkit_glue::WebIntentReplyType reply_type, |
56 const WebKit::WebString& data, | 69 const WebKit::WebString& data, |
57 int intent_id); | 70 int intent_id); |
58 | 71 |
59 // Delivered intent data from the caller. | 72 // Delivered intent data from the caller. |
60 scoped_ptr<webkit_glue::WebIntentData> intent_; | 73 scoped_ptr<webkit_glue::WebIntentData> intent_; |
61 | 74 |
62 // Representation of the intent data as a C++ bound NPAPI object to be | 75 // Representation of the intent data as a C++ bound NPAPI object to be |
63 // injected into the Javascript context. | 76 // injected into the Javascript context. |
64 scoped_ptr<BoundDeliveredIntent> delivered_intent_; | 77 scoped_ptr<BoundDeliveredIntent> delivered_intent_; |
65 | 78 |
66 DISALLOW_COPY_AND_ASSIGN(WebIntentsHost); | 79 DISALLOW_COPY_AND_ASSIGN(WebIntentsHost); |
67 }; | 80 }; |
68 | 81 |
69 #endif // CONTENT_RENDERER_WEB_INTENTS_HOST_H_ | 82 #endif // CONTENT_RENDERER_WEB_INTENTS_HOST_H_ |
OLD | NEW |