summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--content/browser/intents/intent_injector.cc28
-rw-r--r--content/browser/intents/intent_injector.h22
-rw-r--r--content/browser/intents/intents_host_impl.cc9
-rw-r--r--content/browser/intents/intents_host_impl.h2
-rw-r--r--content/browser/tab_contents/tab_contents.cc3
-rw-r--r--content/browser/tab_contents/tab_contents.h3
-rw-r--r--content/common/intents_messages.h12
-rw-r--r--content/renderer/intents_dispatcher.cc22
-rw-r--r--content/renderer/intents_dispatcher.h4
-rw-r--r--content/renderer/render_view_impl.cc5
-rw-r--r--webkit/glue/web_intent_data.cc10
-rw-r--r--webkit/glue/web_intent_data.h6
12 files changed, 56 insertions, 70 deletions
diff --git a/content/browser/intents/intent_injector.cc b/content/browser/intents/intent_injector.cc
index dd8f5fb..1e40a02 100644
--- a/content/browser/intents/intent_injector.cc
+++ b/content/browser/intents/intent_injector.cc
@@ -10,14 +10,14 @@
#include "content/browser/renderer_host/render_view_host.h"
#include "content/browser/tab_contents/tab_contents.h"
#include "content/common/intents_messages.h"
+#include "content/public/browser/intents_host.h"
#include "content/public/common/content_switches.h"
#include "webkit/glue/web_intent_data.h"
#include "webkit/glue/web_intent_reply_data.h"
IntentInjector::IntentInjector(TabContents* tab_contents)
: TabContentsObserver(tab_contents),
- source_tab_(NULL),
- intent_id_(0) {
+ source_tab_(NULL) {
DCHECK(tab_contents);
}
@@ -26,8 +26,8 @@ IntentInjector::~IntentInjector() {
void IntentInjector::TabContentsDestroyed(TabContents* tab) {
if (source_tab_) {
- source_tab_->Send(new IntentsMsg_WebIntentReply(
- 0, webkit_glue::WEB_INTENT_SERVICE_TAB_CLOSED, string16(), intent_id_));
+ source_tab_->SendReplyMessage(webkit_glue::WEB_INTENT_SERVICE_TAB_CLOSED,
+ string16());
}
delete this;
@@ -37,12 +37,10 @@ void IntentInjector::SourceTabContentsDestroyed(TabContents* tab) {
source_tab_ = NULL;
}
-void IntentInjector::SetIntent(IPC::Message::Sender* source_tab,
- const webkit_glue::WebIntentData& intent,
- int intent_id) {
+void IntentInjector::SetIntent(content::IntentsHost* source_tab,
+ const webkit_glue::WebIntentData& intent) {
source_tab_ = source_tab;
source_intent_.reset(new webkit_glue::WebIntentData(intent));
- intent_id_ = intent_id;
SendIntent();
}
@@ -74,29 +72,25 @@ void IntentInjector::SendIntent() {
// Send intent data through to renderer.
tab_contents()->render_view_host()->Send(new IntentsMsg_SetWebIntentData(
tab_contents()->render_view_host()->routing_id(),
- *(source_intent_.get()),
- intent_id_));
+ *(source_intent_.get())));
source_intent_.reset(NULL);
}
bool IntentInjector::OnMessageReceived(const IPC::Message& message) {
bool handled = true;
IPC_BEGIN_MESSAGE_MAP(IntentInjector, message)
- IPC_MESSAGE_HANDLER(IntentsMsg_WebIntentReply, OnReply);
+ IPC_MESSAGE_HANDLER(IntentsHostMsg_WebIntentReply, OnReply);
IPC_MESSAGE_UNHANDLED(handled = false)
IPC_END_MESSAGE_MAP()
return handled;
}
-void IntentInjector::OnReply(const IPC::Message& message,
- webkit_glue::WebIntentReplyType reply_type,
- const string16& data,
- int intent_id) {
+void IntentInjector::OnReply(webkit_glue::WebIntentReplyType reply_type,
+ const string16& data) {
if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableWebIntents))
NOTREACHED();
if (source_tab_) {
- source_tab_->Send(new IntentsMsg_WebIntentReply(
- 0, reply_type, data, intent_id));
+ source_tab_->SendReplyMessage(reply_type, data);
}
}
diff --git a/content/browser/intents/intent_injector.h b/content/browser/intents/intent_injector.h
index 919b80a..87c743b 100644
--- a/content/browser/intents/intent_injector.h
+++ b/content/browser/intents/intent_injector.h
@@ -12,6 +12,10 @@
#include "content/common/content_export.h"
#include "webkit/glue/web_intent_reply_data.h"
+namespace content {
+class IntentsHost;
+}
+
namespace webkit_glue {
struct WebIntentData;
}
@@ -44,30 +48,22 @@ class CONTENT_EXPORT IntentInjector : public TabContentsObserver {
// caller must ensure that SourceTabContentsDestroyed is called when this
// object becomes unusable.
// |intent| is the intent data from the source
- // |intent_id| is the ID assigned to the intent invocation from the source
- // context.
- void SetIntent(IPC::Message::Sender* source_tab,
- const webkit_glue::WebIntentData& intent,
- int intent_id);
+ void SetIntent(content::IntentsHost* source_tab,
+ const webkit_glue::WebIntentData& intent);
private:
// Delivers the intent data to the renderer.
void SendIntent();
// Handles receiving a reply from the intent delivery page.
- void OnReply(const IPC::Message& message,
- webkit_glue::WebIntentReplyType reply_type,
- const string16& data,
- int intent_id);
+ void OnReply(webkit_glue::WebIntentReplyType reply_type,
+ const string16& data);
// Source intent data provided by caller.
scoped_ptr<webkit_glue::WebIntentData> source_intent_;
// Weak pointer to the message forwarder to the tab invoking the intent.
- IPC::Message::Sender* source_tab_;
-
- // Unique ID assigned to the intent by the source tab.
- int intent_id_;
+ content::IntentsHost* source_tab_;
DISALLOW_COPY_AND_ASSIGN(IntentInjector);
};
diff --git a/content/browser/intents/intents_host_impl.cc b/content/browser/intents/intents_host_impl.cc
index 9454087..e3708db 100644
--- a/content/browser/intents/intents_host_impl.cc
+++ b/content/browser/intents/intents_host_impl.cc
@@ -23,10 +23,10 @@ const webkit_glue::WebIntentData& IntentsHostImpl::GetIntent() {
return intent_;
}
-void IntentsHostImpl::DispatchIntent(TabContents* tab_contents) {
+void IntentsHostImpl::DispatchIntent(TabContents* destination_tab) {
DCHECK(!intent_injector_);
- intent_injector_ = new IntentInjector(tab_contents);
- intent_injector_->SetIntent(this, intent_, intent_id_);
+ intent_injector_ = new IntentInjector(destination_tab);
+ intent_injector_->SetIntent(this, intent_);
}
void IntentsHostImpl::SendReplyMessage(
@@ -37,7 +37,8 @@ void IntentsHostImpl::SendReplyMessage(
if (!tab_contents())
return;
- Send(new IntentsMsg_WebIntentReply(0, reply_type, data, intent_id_));
+ Send(new IntentsMsg_WebIntentReply(
+ routing_id(), reply_type, data, intent_id_));
if (!reply_notifier_.is_null())
reply_notifier_.Run();
}
diff --git a/content/browser/intents/intents_host_impl.h b/content/browser/intents/intents_host_impl.h
index 2969bad..6aea4b8 100644
--- a/content/browser/intents/intents_host_impl.h
+++ b/content/browser/intents/intents_host_impl.h
@@ -32,7 +32,7 @@ class IntentsHostImpl : public content::IntentsHost,
// IntentsHost implementation
virtual const webkit_glue::WebIntentData& GetIntent() OVERRIDE;
- virtual void DispatchIntent(TabContents* tab_contents) OVERRIDE;
+ virtual void DispatchIntent(TabContents* destination_tab) OVERRIDE;
virtual void SendReplyMessage(webkit_glue::WebIntentReplyType reply_type,
const string16& data) OVERRIDE;
virtual void RegisterReplyNotification(const base::Closure& closure) OVERRIDE;
diff --git a/content/browser/tab_contents/tab_contents.cc b/content/browser/tab_contents/tab_contents.cc
index a9d8aa7..4324339 100644
--- a/content/browser/tab_contents/tab_contents.cc
+++ b/content/browser/tab_contents/tab_contents.cc
@@ -918,8 +918,7 @@ void TabContents::OnRegisterIntentService(const string16& action,
this, action, type, href, title, disposition);
}
-void TabContents::OnWebIntentDispatch(const IPC::Message& message,
- const webkit_glue::WebIntentData& intent,
+void TabContents::OnWebIntentDispatch(const webkit_glue::WebIntentData& intent,
int intent_id) {
IntentsHostImpl* intents_host = new IntentsHostImpl(this, intent, intent_id);
delegate()->WebIntentDispatch(this, intents_host);
diff --git a/content/browser/tab_contents/tab_contents.h b/content/browser/tab_contents/tab_contents.h
index 6a271ad..3f70a58 100644
--- a/content/browser/tab_contents/tab_contents.h
+++ b/content/browser/tab_contents/tab_contents.h
@@ -608,8 +608,7 @@ class CONTENT_EXPORT TabContents : public PageNavigator,
const string16& href,
const string16& title,
const string16& disposition);
- void OnWebIntentDispatch(const IPC::Message& message,
- const webkit_glue::WebIntentData& intent,
+ void OnWebIntentDispatch(const webkit_glue::WebIntentData& intent,
int intent_id);
void OnDidStartProvisionalLoadForFrame(int64 frame_id,
bool main_frame,
diff --git a/content/common/intents_messages.h b/content/common/intents_messages.h
index a6a96d0..160a502 100644
--- a/content/common/intents_messages.h
+++ b/content/common/intents_messages.h
@@ -20,15 +20,21 @@ IPC_STRUCT_TRAITS_BEGIN(webkit_glue::WebIntentData)
IPC_STRUCT_TRAITS_MEMBER(data)
IPC_STRUCT_TRAITS_END()
-IPC_MESSAGE_ROUTED2(IntentsMsg_SetWebIntentData,
- webkit_glue::WebIntentData,
- int /* intent ID */)
+// Set the intent data to be set on the service page.
+IPC_MESSAGE_ROUTED1(IntentsMsg_SetWebIntentData,
+ webkit_glue::WebIntentData)
+// Send the service's reply to the client page.
IPC_MESSAGE_ROUTED3(IntentsMsg_WebIntentReply,
webkit_glue::WebIntentReplyType /* reply type */,
string16 /* payload data */,
int /* intent ID */)
+// Notify the container that the service has replied to the client page.
+IPC_MESSAGE_ROUTED2(IntentsHostMsg_WebIntentReply,
+ webkit_glue::WebIntentReplyType /* reply type */,
+ string16 /* payload data */)
+
// Route the startActivity Intents call from a page to the service picker.
IPC_MESSAGE_ROUTED2(IntentsHostMsg_WebIntentDispatch,
webkit_glue::WebIntentData,
diff --git a/content/renderer/intents_dispatcher.cc b/content/renderer/intents_dispatcher.cc
index c63dbb7..aeda9c7 100644
--- a/content/renderer/intents_dispatcher.cc
+++ b/content/renderer/intents_dispatcher.cc
@@ -128,8 +128,7 @@ class IntentsDispatcher::BoundDeliveredIntent : public CppBoundClass {
};
IntentsDispatcher::IntentsDispatcher(RenderViewImpl* render_view)
- : content::RenderViewObserver(render_view),
- intent_id_(0) {
+ : content::RenderViewObserver(render_view) {
}
IntentsDispatcher::~IntentsDispatcher() {}
@@ -144,17 +143,14 @@ bool IntentsDispatcher::OnMessageReceived(const IPC::Message& message) {
return handled;
}
-void IntentsDispatcher::OnSetIntent(const webkit_glue::WebIntentData& intent,
- int intent_id) {
+void IntentsDispatcher::OnSetIntent(const webkit_glue::WebIntentData& intent) {
intent_.reset(new webkit_glue::WebIntentData(intent));
- intent_id_ = intent_id;
}
void IntentsDispatcher::OnWebIntentReply(
webkit_glue::WebIntentReplyType reply_type,
const WebKit::WebString& data,
int intent_id) {
- LOG(INFO) << "RenderView got reply to intent type " << reply_type;
if (reply_type == webkit_glue::WEB_INTENT_REPLY_SUCCESS) {
render_view()->GetWebView()->mainFrame()->handleIntentResult(
@@ -166,19 +162,13 @@ void IntentsDispatcher::OnWebIntentReply(
}
void IntentsDispatcher::OnResult(const WebKit::WebString& data) {
- Send(new IntentsMsg_WebIntentReply(
- routing_id(),
- webkit_glue::WEB_INTENT_REPLY_SUCCESS,
- data,
- intent_id_));
+ Send(new IntentsHostMsg_WebIntentReply(
+ routing_id(), webkit_glue::WEB_INTENT_REPLY_SUCCESS, data));
}
void IntentsDispatcher::OnFailure(const WebKit::WebString& data) {
- Send(new IntentsMsg_WebIntentReply(
- routing_id(),
- webkit_glue::WEB_INTENT_REPLY_FAILURE,
- data,
- intent_id_));
+ Send(new IntentsHostMsg_WebIntentReply(
+ routing_id(), webkit_glue::WEB_INTENT_REPLY_FAILURE, data));
}
// We set the intent payload into all top-level frame window objects. This
diff --git a/content/renderer/intents_dispatcher.h b/content/renderer/intents_dispatcher.h
index 0d4a2ad..2ebc324 100644
--- a/content/renderer/intents_dispatcher.h
+++ b/content/renderer/intents_dispatcher.h
@@ -48,7 +48,7 @@ class IntentsDispatcher : public content::RenderViewObserver {
// On the service page, handler method for the IntentsMsg_SetWebIntent
// message.
- void OnSetIntent(const webkit_glue::WebIntentData& intent, int intent_id);
+ void OnSetIntent(const webkit_glue::WebIntentData& intent);
// On the client page, handler method for the IntentsMsg_WebIntentReply
// message.
@@ -58,8 +58,6 @@ class IntentsDispatcher : public content::RenderViewObserver {
// Delivered intent data from the caller.
scoped_ptr<webkit_glue::WebIntentData> intent_;
- // Delivered intent id from the caller.
- int intent_id_;
// Representation of the intent data as a C++ bound NPAPI object to be
// injected into the Javascript context.
diff --git a/content/renderer/render_view_impl.cc b/content/renderer/render_view_impl.cc
index cce08a2..cb1a684 100644
--- a/content/renderer/render_view_impl.cc
+++ b/content/renderer/render_view_impl.cc
@@ -3104,10 +3104,7 @@ void RenderViewImpl::registerIntentService(
void RenderViewImpl::dispatchIntent(WebKit::WebFrame* frame,
const WebKit::WebIntent& intent) {
- webkit_glue::WebIntentData intent_data;
- intent_data.action = intent.action();
- intent_data.type = intent.type();
- intent_data.data = intent.data();
+ webkit_glue::WebIntentData intent_data(intent);
Send(new IntentsHostMsg_WebIntentDispatch(
routing_id_, intent_data, intent.identifier()));
}
diff --git a/webkit/glue/web_intent_data.cc b/webkit/glue/web_intent_data.cc
index 13e85e6..7b3406a 100644
--- a/webkit/glue/web_intent_data.cc
+++ b/webkit/glue/web_intent_data.cc
@@ -4,6 +4,8 @@
#include "webkit/glue/web_intent_data.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebIntent.h"
+
namespace webkit_glue {
WebIntentData::WebIntentData() {
@@ -12,10 +14,10 @@ WebIntentData::WebIntentData() {
WebIntentData::~WebIntentData() {
}
-WebIntentData::WebIntentData(const WebIntentData& other)
- : action(other.action),
- type(other.type),
- data(other.data) {
+WebIntentData::WebIntentData(const WebKit::WebIntent& intent)
+ : action(intent.action()),
+ type(intent.type()),
+ data(intent.data()) {
}
} // namespace webkit_glue
diff --git a/webkit/glue/web_intent_data.h b/webkit/glue/web_intent_data.h
index 8c4e184..540cd15 100644
--- a/webkit/glue/web_intent_data.h
+++ b/webkit/glue/web_intent_data.h
@@ -8,6 +8,10 @@
#include "base/string16.h"
#include "webkit/glue/webkit_glue_export.h"
+namespace WebKit {
+class WebIntent;
+}
+
namespace webkit_glue {
// Representation of the Web Intent data being initiated or delivered.
@@ -21,7 +25,7 @@ struct WEBKIT_GLUE_EXPORT WebIntentData {
string16 data;
WebIntentData();
- WebIntentData(const WebIntentData& other);
+ WebIntentData(const WebKit::WebIntent& intent);
~WebIntentData();
};