| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #ifndef CONTENT_RENDERER_INTENTS_DISPATCHER_H_ | |
| 6 #define CONTENT_RENDERER_INTENTS_DISPATCHER_H_ | |
| 7 #pragma once | |
| 8 | |
| 9 #include "base/memory/scoped_ptr.h" | |
| 10 #include "content/public/renderer/render_view_observer.h" | |
| 11 #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_reply_data.h" | |
| 14 | |
| 15 class RenderViewImpl; | |
| 16 | |
| 17 namespace WebKit { | |
| 18 class WebFrame; | |
| 19 } | |
| 20 | |
| 21 namespace webkit_glue { | |
| 22 struct WebIntentData; | |
| 23 } | |
| 24 | |
| 25 // IntentsDispatcher is a delegate for Web Intents messages. It is the | |
| 26 // renderer-side handler for IPC messages delivering the intent payload data | |
| 27 // and preparing it for access by the service page. | |
| 28 class IntentsDispatcher : public content::RenderViewObserver { | |
| 29 public: | |
| 30 // |render_view| must not be NULL. | |
| 31 explicit IntentsDispatcher(RenderViewImpl* render_view); | |
| 32 virtual ~IntentsDispatcher(); | |
| 33 | |
| 34 // Called by the bound intent object to register the result from the service | |
| 35 // page. | |
| 36 void OnResult(const WebKit::WebString& data); | |
| 37 void OnFailure(const WebKit::WebString& data); | |
| 38 | |
| 39 private: | |
| 40 class BoundDeliveredIntent; | |
| 41 | |
| 42 // RenderView::Observer implementation. | |
| 43 virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE; | |
| 44 virtual void DidClearWindowObject(WebKit::WebFrame* frame) OVERRIDE; | |
| 45 | |
| 46 // TODO(gbillock): Do we need various ***ClientRedirect methods to implement | |
| 47 // intent cancelling policy? Figure this out. | |
| 48 | |
| 49 // On the service page, handler method for the IntentsMsg_SetWebIntent | |
| 50 // message. | |
| 51 void OnSetIntent(const webkit_glue::WebIntentData& intent); | |
| 52 | |
| 53 // On the client page, handler method for the IntentsMsg_WebIntentReply | |
| 54 // message. | |
| 55 void OnWebIntentReply(webkit_glue::WebIntentReplyType reply_type, | |
| 56 const WebKit::WebString& data, | |
| 57 int intent_id); | |
| 58 | |
| 59 // Delivered intent data from the caller. | |
| 60 scoped_ptr<webkit_glue::WebIntentData> intent_; | |
| 61 | |
| 62 // Representation of the intent data as a C++ bound NPAPI object to be | |
| 63 // injected into the Javascript context. | |
| 64 scoped_ptr<BoundDeliveredIntent> delivered_intent_; | |
| 65 | |
| 66 DISALLOW_COPY_AND_ASSIGN(IntentsDispatcher); | |
| 67 }; | |
| 68 | |
| 69 #endif // CONTENT_RENDERER_INTENTS_DISPATCHER_H_ | |
| OLD | NEW |