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. | |
| 37 // Takes ownership of |request|. | |
| 38 int RegisterWebIntent(WebKit::WebIntentRequest* request); | |
| 39 | |
| 34 // Called by the bound intent object to register the result from the service | 40 // Called by the bound intent object to register the result from the service |
| 35 // page. | 41 // page. |
| 36 void OnResult(const WebKit::WebString& data); | 42 void OnResult(const WebKit::WebString& data); |
| 37 void OnFailure(const WebKit::WebString& data); | 43 void OnFailure(const WebKit::WebString& data); |
| 38 | 44 |
| 39 private: | 45 private: |
| 40 class BoundDeliveredIntent; | 46 class BoundDeliveredIntent; |
| 41 | 47 |
| 48 int id_counter_; | |
|
James Hawkins
2012/01/12 00:11:58
Document these vars.
| |
| 49 std::map<int, WebKit::WebIntentRequest*> intent_requests_; | |
| 50 | |
| 42 // RenderView::Observer implementation. | 51 // RenderView::Observer implementation. |
| 43 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 52 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 44 virtual void DidClearWindowObject(WebKit::WebFrame* frame) OVERRIDE; | 53 virtual void DidClearWindowObject(WebKit::WebFrame* frame) OVERRIDE; |
| 45 | 54 |
| 46 // TODO(gbillock): Do we need various ***ClientRedirect methods to implement | 55 // TODO(gbillock): Do we need various ***ClientRedirect methods to implement |
| 47 // intent cancelling policy? Figure this out. | 56 // intent cancelling policy? Figure this out. |
| 48 | 57 |
| 49 // On the service page, handler method for the IntentsMsg_SetWebIntent | 58 // On the service page, handler method for the IntentsMsg_SetWebIntent |
| 50 // message. | 59 // message. |
| 51 void OnSetIntent(const webkit_glue::WebIntentData& intent); | 60 void OnSetIntent(const webkit_glue::WebIntentData& intent); |
| 52 | 61 |
| 53 // On the client page, handler method for the IntentsMsg_WebIntentReply | 62 // On the client page, handler method for the IntentsMsg_WebIntentReply |
| 54 // message. | 63 // message. |
| 55 void OnWebIntentReply(webkit_glue::WebIntentReplyType reply_type, | 64 void OnWebIntentReply(webkit_glue::WebIntentReplyType reply_type, |
| 56 const WebKit::WebString& data, | 65 const WebKit::WebString& data, |
| 57 int intent_id); | 66 int intent_id); |
| 58 | 67 |
| 59 // Delivered intent data from the caller. | 68 // Delivered intent data from the caller. |
| 60 scoped_ptr<webkit_glue::WebIntentData> intent_; | 69 scoped_ptr<webkit_glue::WebIntentData> intent_; |
| 61 | 70 |
| 62 // Representation of the intent data as a C++ bound NPAPI object to be | 71 // Representation of the intent data as a C++ bound NPAPI object to be |
| 63 // injected into the Javascript context. | 72 // injected into the Javascript context. |
| 64 scoped_ptr<BoundDeliveredIntent> delivered_intent_; | 73 scoped_ptr<BoundDeliveredIntent> delivered_intent_; |
| 65 | 74 |
| 66 DISALLOW_COPY_AND_ASSIGN(WebIntentsHost); | 75 DISALLOW_COPY_AND_ASSIGN(WebIntentsHost); |
| 67 }; | 76 }; |
| 68 | 77 |
| 69 #endif // CONTENT_RENDERER_WEB_INTENTS_HOST_H_ | 78 #endif // CONTENT_RENDERER_WEB_INTENTS_HOST_H_ |
| OLD | NEW |