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

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

Issue 9651020: Pass content-type resources to web intents. Goes through download, then invokes the p… (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Remove includes Created 8 years, 8 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
« no previous file with comments | « content/common/intents_messages.h ('k') | content/renderer/web_intents_host.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "content/common/content_export.h"
10 #include "webkit/glue/web_intent_reply_data.h" 10 #include "webkit/glue/web_intent_reply_data.h"
11 11
12 namespace webkit_glue { 12 namespace webkit_glue {
13 enum WebIntentReplyType; 13 enum WebIntentReplyType;
14 struct WebIntentData; 14 struct WebIntentData;
15 } 15 }
16 16
17 namespace content { 17 namespace content {
18 18
19 class WebContents; 19 class WebContents;
20 class WebContentsDelegate;
20 21
21 // This class is the coordinator for dispatching web intents and seeing that 22 // This class is the coordinator for dispatching web intents and seeing that
22 // return messages are sent to the correct invoking context. The WebContents 23 // return messages are sent to the correct invoking context. The WebContents
23 // for the invoking context will create one of these for each intent and hand 24 // for the invoking context will create one of these for each intent and hand
24 // a pointer to the client WebContentsDelegate code. The WebContentsDelegate 25 // a pointer to the client WebContentsDelegate code. The WebContentsDelegate
25 // code can then read the intent data, create UI to pick the service, and 26 // code can then read the intent data, create UI to pick the service, and
26 // create a new context for that service. 27 // create a new context for that service.
27 // 28 //
28 // At that point, it should call DispatchIntent, which will deliver the intent 29 // At that point, it should call DispatchIntent, which will deliver the intent
29 // to the new context. If anything goes wrong during setup, the client 30 // to the new context. If anything goes wrong during setup, the client
30 // should call SendReplyMessage with an error. The dispatcher lives until the 31 // should call SendReplyMessage with an error. The dispatcher lives until the
31 // SendReplyMessage method is called, which will self-delete the object. 32 // SendReplyMessage method is called, which will self-delete the object.
32 // 33 //
33 // The client should also register a reply notification, so it can avoid 34 // The client should also register a reply notification, so it can avoid
34 // referencing the dispatcher after other code calls SendReplyMessage, which can 35 // referencing the dispatcher after other code calls SendReplyMessage, which can
35 // happen if, for example, the user closes the delivery context. 36 // happen if, for example, the user closes the delivery context.
36 class CONTENT_EXPORT WebIntentsDispatcher { 37 class CONTENT_EXPORT WebIntentsDispatcher {
37 public: 38 public:
38 // This callback type is registered for notification of |SendReplyMessage|. 39 // This callback type is registered for notification of |SendReplyMessage|.
39 typedef base::Callback<void(webkit_glue::WebIntentReplyType)> 40 typedef base::Callback<void(webkit_glue::WebIntentReplyType)>
40 ReplyNotification; 41 ReplyNotification;
41 42
43 // Create internal (browser-triggered) intent. This will create
44 // a new dispatcher with the passed intent payload |data|. The caller should
45 // manage dispatching it correctly.
46 static WebIntentsDispatcher* Create(const webkit_glue::WebIntentData& data);
47
42 virtual ~WebIntentsDispatcher() {} 48 virtual ~WebIntentsDispatcher() {}
43 49
44 // Get the intent data being dispatched. 50 // Get the intent data being dispatched.
45 virtual const webkit_glue::WebIntentData& GetIntent() = 0; 51 virtual const webkit_glue::WebIntentData& GetIntent() = 0;
46 52
47 // Attach the intent to a new context in which the service page is loaded. 53 // Attach the intent to a new context in which the service page is loaded.
48 // |web_contents| must not be NULL. 54 // |web_contents| must not be NULL.
49 virtual void DispatchIntent(WebContents* web_contents) = 0; 55 virtual void DispatchIntent(WebContents* web_contents) = 0;
50 56
51 // Return a success or failure message to the source context which invoked 57 // Return a success or failure message to the source context which invoked
52 // the intent. Deletes the object; it should not be used after this call 58 // the intent. Deletes the object; it should not be used after this call
53 // returns. Calls the reply notifications, if any are registered. 59 // returns. Calls the reply notifications, if any are registered.
54 virtual void SendReplyMessage(webkit_glue::WebIntentReplyType reply_type, 60 virtual void SendReplyMessage(webkit_glue::WebIntentReplyType reply_type,
55 const string16& data) = 0; 61 const string16& data) = 0;
56 62
57 // Register a callback to be notified when SendReplyMessage is called. 63 // Register a callback to be notified when SendReplyMessage is called.
58 // Multiple callbacks may be registered. 64 // Multiple callbacks may be registered.
59 virtual void RegisterReplyNotification(const ReplyNotification& closure) = 0; 65 virtual void RegisterReplyNotification(const ReplyNotification& closure) = 0;
60 }; 66 };
61 67
62 } // namespace content 68 } // namespace content
63 69
64 #endif // CONTENT_PUBLIC_BROWSER_WEB_INTENTS_DISPATCHER_H_ 70 #endif // CONTENT_PUBLIC_BROWSER_WEB_INTENTS_DISPATCHER_H_
OLDNEW
« no previous file with comments | « content/common/intents_messages.h ('k') | content/renderer/web_intents_host.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698