Broke ContentSettingBubbleModelTest.Plugins on Android.
[chromium-blink-merge.git] / content / browser / intents / web_intents_dispatcher_impl.h
blobdf8ddc1322ce7d58bfe6c9c3e58b28d763c9e6f0
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
3 // found in the LICENSE file.
5 #ifndef CONTENT_BROWSER_INTENTS_WEB_INTENTS_DISPATCHER_IMPL_H_
6 #define CONTENT_BROWSER_INTENTS_WEB_INTENTS_DISPATCHER_IMPL_H_
8 #include <vector>
9 #include "base/callback.h"
10 #include "base/compiler_specific.h"
11 #include "content/public/browser/web_contents_observer.h"
12 #include "content/public/browser/web_intents_dispatcher.h"
13 #include "webkit/glue/web_intent_data.h"
14 #include "webkit/glue/web_intent_reply_data.h"
16 namespace content {
17 class IntentInjector;
19 // Implements the coordinator object interface for Web Intents.
20 // Observes the source (client) contents to make sure messages sent back by the
21 // service can be delivered. Keeps a copy of triggering intent data to
22 // be delivered to the service and serves as a forwarder for sending reply
23 // messages back to the client page.
24 class WebIntentsDispatcherImpl : public WebIntentsDispatcher,
25 public WebContentsObserver {
26 public:
27 // |source_contents| is the page which triggered the web intent.
28 // |intent| is the intent payload created by that page.
29 // |intent_id| is the identifier assigned by WebKit to direct replies back to
30 // the correct Javascript callback.
31 WebIntentsDispatcherImpl(WebContents* source_contents,
32 const webkit_glue::WebIntentData& intent,
33 int intent_id);
34 virtual ~WebIntentsDispatcherImpl();
36 // WebIntentsDispatcher implementation.
37 virtual const webkit_glue::WebIntentData& GetIntent() OVERRIDE;
38 virtual void DispatchIntent(WebContents* destination_contents) OVERRIDE;
39 virtual void ResetDispatch() OVERRIDE;
40 virtual void SendReply(const webkit_glue::WebIntentReply& reply) OVERRIDE;
41 virtual void RegisterReplyNotification(
42 const WebIntentsDispatcher::ReplyNotification& closure) OVERRIDE;
44 // WebContentsObserver implementation.
45 virtual void WebContentsDestroyed(WebContents* contents) OVERRIDE;
47 private:
48 webkit_glue::WebIntentData intent_;
50 int intent_id_;
52 // Weak pointer to the internal object which provides the intent to the
53 // newly-created service WebContents. This object is self-deleting
54 // (connected to the service WebContents).
55 IntentInjector* intent_injector_;
57 // Callbacks to be notified when SendReplyMessage is called.
58 std::vector<WebIntentsDispatcher::ReplyNotification> reply_notifiers_;
60 DISALLOW_COPY_AND_ASSIGN(WebIntentsDispatcherImpl);
63 } // namespace content
65 #endif // CONTENT_BROWSER_INTENTS_WEB_INTENTS_DISPATCHER_IMPL_H_