summaryrefslogtreecommitdiffstats
path: root/content/browser/intents
diff options
context:
space:
mode:
authorgbillock@chromium.org <gbillock@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-09 04:01:21 +0000
committergbillock@chromium.org <gbillock@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-12-09 04:01:21 +0000
commit678105016404f743786e5da50be61d2e8a8be019 (patch)
treee630876bc868cef05983596a133d01c45e79b644 /content/browser/intents
parentbd990e1bc939e7fc1ba02f339af73cc1838091e9 (diff)
downloadchromium_src-678105016404f743786e5da50be61d2e8a8be019.zip
chromium_src-678105016404f743786e5da50be61d2e8a8be019.tar.gz
chromium_src-678105016404f743786e5da50be61d2e8a8be019.tar.bz2
[Web Intents] Make IntentInjector adapt to the new content API
and reap other simplifying rewards. Update messages to remove intent_id where not needed. Tighten up intents message definitions. R=jhawkins@chromium.org,jam@chromium.org BUG=104980 TEST=*Intent*.* Review URL: http://codereview.chromium.org/8795004 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@113751 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'content/browser/intents')
-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
4 files changed, 26 insertions, 35 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;