Chromium Code Reviews| 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> | |
| 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 intents invocation. | |
|
James Hawkins
2012/01/13 21:30:03
nit: s/web intents/Web Intent/
(no s).
Greg Billock
2012/01/17 23:52:02
Done.
| |
| 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 int id_counter_; | |
|
James Hawkins
2012/01/13 21:30:03
Document vars.
Greg Billock
2012/01/17 23:52:02
Done.
| |
| 48 std::map<int, WebKit::WebIntentRequest> intent_requests_; | |
| 49 | |
| 42 // RenderView::Observer implementation. | 50 // RenderView::Observer implementation. |
| 43 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 51 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 44 virtual void DidClearWindowObject(WebKit::WebFrame* frame) OVERRIDE; | 52 virtual void DidClearWindowObject(WebKit::WebFrame* frame) OVERRIDE; |
| 45 | 53 |
| 46 // TODO(gbillock): Do we need various ***ClientRedirect methods to implement | 54 // TODO(gbillock): Do we need various ***ClientRedirect methods to implement |
| 47 // intent cancelling policy? Figure this out. | 55 // intent cancelling policy? Figure this out. |
| 48 | 56 |
| 49 // On the service page, handler method for the IntentsMsg_SetWebIntent | 57 // On the service page, handler method for the IntentsMsg_SetWebIntent |
| 50 // message. | 58 // message. |
| 51 void OnSetIntent(const webkit_glue::WebIntentData& intent); | 59 void OnSetIntent(const webkit_glue::WebIntentData& intent); |
| 52 | 60 |
| 53 // On the client page, handler method for the IntentsMsg_WebIntentReply | 61 // On the client page, handler method for the IntentsMsg_WebIntentReply |
| 54 // message. | 62 // message. |
| 55 void OnWebIntentReply(webkit_glue::WebIntentReplyType reply_type, | 63 void OnWebIntentReply(webkit_glue::WebIntentReplyType reply_type, |
| 56 const WebKit::WebString& data, | 64 const WebKit::WebString& data, |
| 57 int intent_id); | 65 int intent_id); |
| 58 | 66 |
| 59 // Delivered intent data from the caller. | 67 // Delivered intent data from the caller. |
| 60 scoped_ptr<webkit_glue::WebIntentData> intent_; | 68 scoped_ptr<webkit_glue::WebIntentData> intent_; |
| 61 | 69 |
| 62 // Representation of the intent data as a C++ bound NPAPI object to be | 70 // Representation of the intent data as a C++ bound NPAPI object to be |
| 63 // injected into the Javascript context. | 71 // injected into the Javascript context. |
| 64 scoped_ptr<BoundDeliveredIntent> delivered_intent_; | 72 scoped_ptr<BoundDeliveredIntent> delivered_intent_; |
| 65 | 73 |
| 66 DISALLOW_COPY_AND_ASSIGN(WebIntentsHost); | 74 DISALLOW_COPY_AND_ASSIGN(WebIntentsHost); |
| 67 }; | 75 }; |
| 68 | 76 |
| 69 #endif // CONTENT_RENDERER_WEB_INTENTS_HOST_H_ | 77 #endif // CONTENT_RENDERER_WEB_INTENTS_HOST_H_ |
| OLD | NEW |