Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(26)

Side by Side Diff: content/public/browser/web_intents_dispatcher.h

Issue 9692017: An internal intents dispatcher useful for initiating an intent from the browser process. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Add typedef Created 8 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_PUBLIC_BROWSER_WEB_INTENTS_DISPATCHER_H_ 5 #ifndef CONTENT_PUBLIC_BROWSER_WEB_INTENTS_DISPATCHER_H_
6 #define CONTENT_PUBLIC_BROWSER_WEB_INTENTS_DISPATCHER_H_ 6 #define CONTENT_PUBLIC_BROWSER_WEB_INTENTS_DISPATCHER_H_
7 7
8 #include "base/callback.h" 8 #include "base/callback.h"
9 #include "content/common/content_export.h"
9 #include "webkit/glue/web_intent_reply_data.h" 10 #include "webkit/glue/web_intent_reply_data.h"
10 11
11 namespace webkit_glue { 12 namespace webkit_glue {
12 enum WebIntentReplyType; 13 enum WebIntentReplyType;
13 struct WebIntentData; 14 struct WebIntentData;
14 } 15 }
15 16
16 namespace content { 17 namespace content {
17 18
18 class WebContents; 19 class WebContents;
19 20
20 // This class is the coordinator for dispatching web intents and seeing that 21 // This class is the coordinator for dispatching web intents and seeing that
21 // return messages are sent to the correct invoking context. The WebContents 22 // return messages are sent to the correct invoking context. The WebContents
22 // for the invoking context will create one of these for each intent and hand 23 // for the invoking context will create one of these for each intent and hand
23 // a pointer to the client WebContentsDelegate code. The WebContentsDelegate 24 // a pointer to the client WebContentsDelegate code. The WebContentsDelegate
24 // code can then read the intent data, create UI to pick the service, and 25 // code can then read the intent data, create UI to pick the service, and
25 // create a new context for that service. 26 // create a new context for that service.
26 // 27 //
27 // At that point, it should call DispatchIntent, which will connect the object 28 // At that point, it should call DispatchIntent, which will deliver the intent
28 // to the new context. If anything goes wrong, the client should call 29 // to the new context. If anything goes wrong during setup, the client
29 // SendReplyMessage with an error. That will self-delete the object. 30 // should call SendReplyMessage with an error. The dispatcher lives until the
31 // SendReplyMessage method is called, which will self-delete the object.
30 // 32 //
31 // At that point, before the client may use the object again, it must register a 33 // The client should also register a reply notification, so it can avoid
32 // reply notification, so it can avoid referencing the dispatcher after other 34 // referencing the dispatcher after other code calls SendReplyMessage, which can
33 // code calls SendReplyMessage. 35 // happen if, for example, the user closes the delivery context.
34 class CONTENT_EXPORT WebIntentsDispatcher { 36 class CONTENT_EXPORT WebIntentsDispatcher {
35 public: 37 public:
38 typedef base::Callback<void(webkit_glue::WebIntentReplyType)>
James Hawkins 2012/03/13 20:15:44 Document the callback and the parameter.
Greg Billock 2012/03/13 20:34:42 Done.
39 ReplyNotification;
40
36 virtual ~WebIntentsDispatcher() {} 41 virtual ~WebIntentsDispatcher() {}
37 42
38 // Get the intent data being dispatched. 43 // Get the intent data being dispatched.
39 virtual const webkit_glue::WebIntentData& GetIntent() = 0; 44 virtual const webkit_glue::WebIntentData& GetIntent() = 0;
40 45
41 // Attach the intent to a new context in which the service page is loaded. 46 // Attach the intent to a new context in which the service page is loaded.
47 // |web_contents| should not be NULL.
James Hawkins 2012/03/13 20:15:44 s/should/must/ right?
Greg Billock 2012/03/13 20:34:42 Done.
42 virtual void DispatchIntent(WebContents* web_contents) = 0; 48 virtual void DispatchIntent(WebContents* web_contents) = 0;
43 49
44 // Return a success or failure message to the source context which invoked 50 // Return a success or failure message to the source context which invoked
45 // the intent. Deletes the object; it should not be used after this call 51 // the intent. Deletes the object; it should not be used after this call
46 // returns. Calls the reply notification, if registered. 52 // returns. Calls the reply notifications, if any are registered.
47 virtual void SendReplyMessage(webkit_glue::WebIntentReplyType reply_type, 53 virtual void SendReplyMessage(webkit_glue::WebIntentReplyType reply_type,
48 const string16& data) = 0; 54 const string16& data) = 0;
49 55
50 // Register a callback to be notified when SendReplyMessage is called. 56 // Register a callback to be notified when SendReplyMessage is called.
51 virtual void RegisterReplyNotification( 57 // Multiple callbacks may be registered.
52 const base::Callback<void(webkit_glue::WebIntentReplyType)>& closure) = 0; 58 virtual void RegisterReplyNotification(const ReplyNotification& closure) = 0;
53 }; 59 };
54 60
55 } // namespace content 61 } // namespace content
56 62
57 #endif // CONTENT_PUBLIC_BROWSER_WEB_INTENTS_DISPATCHER_H_ 63 #endif // CONTENT_PUBLIC_BROWSER_WEB_INTENTS_DISPATCHER_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698