Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 | 7 |
| 8 #include <map> | 8 #include <map> |
| 9 | 9 |
| 10 #include "base/memory/scoped_ptr.h" | 10 #include "base/memory/scoped_ptr.h" |
| 11 #include "content/public/renderer/render_view_observer.h" | 11 #include "content/public/renderer/render_view_observer.h" |
| 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBlob.h" | 12 #include "third_party/WebKit/Source/WebKit/chromium/public/WebBlob.h" |
| 13 #include "third_party/WebKit/Source/WebKit/chromium/public/WebIntent.h" | |
| 13 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" | 14 #include "third_party/WebKit/Source/WebKit/chromium/public/platform/WebString.h" |
| 15 #include "v8/include/v8.h" | |
| 14 #include "webkit/glue/web_intent_data.h" | 16 #include "webkit/glue/web_intent_data.h" |
| 15 #include "webkit/glue/web_intent_reply_data.h" | 17 #include "webkit/glue/web_intent_reply_data.h" |
| 16 | 18 |
| 17 class RenderViewImpl; | 19 class RenderViewImpl; |
| 18 | 20 |
| 19 namespace WebKit { | 21 namespace WebKit { |
| 20 class WebDeliveredIntentClient; | 22 class WebDeliveredIntentClient; |
| 21 class WebIntentRequest; | 23 class WebIntentRequest; |
| 22 class WebFrame; | 24 class WebFrame; |
| 23 } | 25 } |
| (...skipping 12 matching lines...) Expand all Loading... | |
| 36 virtual ~WebIntentsHost(); | 38 virtual ~WebIntentsHost(); |
| 37 | 39 |
| 38 // Called by the RenderView to register a new Web Intent invocation. | 40 // Called by the RenderView to register a new Web Intent invocation. |
| 39 int RegisterWebIntent(const WebKit::WebIntentRequest& request); | 41 int RegisterWebIntent(const WebKit::WebIntentRequest& request); |
| 40 | 42 |
| 41 // Called into when the delivered intent object gets a postResult call. | 43 // Called into when the delivered intent object gets a postResult call. |
| 42 void OnResult(const WebKit::WebString& data); | 44 void OnResult(const WebKit::WebString& data); |
| 43 // Called into when the delivered intent object gets a postFailure call. | 45 // Called into when the delivered intent object gets a postFailure call. |
| 44 void OnFailure(const WebKit::WebString& data); | 46 void OnFailure(const WebKit::WebString& data); |
| 45 | 47 |
| 48 // Forwarded from RenderViewImpl. Notification that a new script context was | |
| 49 // created within webkit. | |
| 50 virtual void DidCreateScriptContext(WebKit::WebFrame* frame, | |
|
Steve McKay
2012/10/15 19:31:10
Odd phrasing. Maybe:
OnScriptContextCreated?
Greg Billock
2012/10/15 21:01:43
This echoes the existing API method in RenderViewI
| |
| 51 v8::Handle<v8::Context> ctx, | |
| 52 int extension_group, | |
| 53 int world_id); | |
| 54 | |
| 46 private: | 55 private: |
| 47 // A counter used to assign unique IDs to web intents invocations in this | |
| 48 // renderer. | |
| 49 int id_counter_; | |
| 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 | |
| 55 // RenderView::Observer implementation. | 56 // RenderView::Observer implementation. |
| 56 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | 57 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; |
| 57 virtual void DidClearWindowObject(WebKit::WebFrame* frame) OVERRIDE; | 58 |
| 59 // Converts incoming intent data to a WebIntent object. | |
| 60 WebKit::WebIntent CreateWebIntent( | |
| 61 WebKit::WebFrame* frame, const webkit_glue::WebIntentData& intent_data); | |
| 58 | 62 |
| 59 // TODO(gbillock): Do we need various ***ClientRedirect methods to implement | 63 // TODO(gbillock): Do we need various ***ClientRedirect methods to implement |
| 60 // intent cancelling policy? Figure this out. | 64 // intent cancelling policy? Figure this out. |
| 61 | 65 |
| 62 // On the service page, handler method for the IntentsMsg_SetWebIntent | 66 // On the service page, handler method for the IntentsMsg_SetWebIntent |
| 63 // message. | 67 // message. |
| 64 void OnSetIntent(const webkit_glue::WebIntentData& intent); | 68 CONTENT_EXPORT void OnSetIntent(const webkit_glue::WebIntentData& intent); |
| 65 | 69 |
| 66 // On the client page, handler method for the IntentsMsg_WebIntentReply | 70 // On the client page, handler method for the IntentsMsg_WebIntentReply |
| 67 // message. Forwards the reply |data| to the registered WebIntentRequest | 71 // message. Forwards the reply |data| to the registered WebIntentRequest |
| 68 // (found by |intent_id|), where it is dispatched to the client JS callback. | 72 // (found by |intent_id|), where it is dispatched to the client JS callback. |
| 69 void OnWebIntentReply(webkit_glue::WebIntentReplyType reply_type, | 73 void OnWebIntentReply(webkit_glue::WebIntentReplyType reply_type, |
| 70 const WebKit::WebString& data, | 74 const WebKit::WebString& data, |
| 71 int intent_id); | 75 int intent_id); |
| 72 | 76 |
| 77 friend class WebIntentsHostTest; | |
| 78 | |
| 79 // A counter used to assign unique IDs to web intents invocations in this | |
| 80 // renderer. | |
| 81 int id_counter_; | |
| 82 | |
| 83 // Map tracking registered Web Intent requests by assigned ID numbers to | |
| 84 // correctly route any return data. | |
| 85 std::map<int, WebKit::WebIntentRequest> intent_requests_; | |
| 86 | |
| 73 // Delivered intent data from the caller. | 87 // Delivered intent data from the caller. |
| 74 scoped_ptr<webkit_glue::WebIntentData> intent_; | 88 scoped_ptr<webkit_glue::WebIntentData> intent_; |
| 75 | 89 |
| 76 // The client object which will receive callback notifications from the | 90 // The client object which will receive callback notifications from the |
| 77 // delivered intent. | 91 // delivered intent. |
| 78 scoped_ptr<WebKit::WebDeliveredIntentClient> delivered_intent_client_; | 92 scoped_ptr<WebKit::WebDeliveredIntentClient> delivered_intent_client_; |
| 79 | 93 |
| 80 // If we deliver a browser-originated blob intent to the client, | 94 // If we deliver a browser-originated blob intent to the client, |
| 81 // this is that Blob. | 95 // this is that Blob. |
| 82 WebKit::WebBlob web_blob_; | 96 WebKit::WebBlob web_blob_; |
| 83 | 97 |
| 84 DISALLOW_COPY_AND_ASSIGN(WebIntentsHost); | 98 DISALLOW_COPY_AND_ASSIGN(WebIntentsHost); |
| 85 }; | 99 }; |
| 86 | 100 |
| 87 #endif // CONTENT_RENDERER_WEB_INTENTS_HOST_H_ | 101 #endif // CONTENT_RENDERER_WEB_INTENTS_HOST_H_ |
| OLD | NEW |