summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorgbillock@chromium.org <gbillock@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-16 18:33:47 +0000
committergbillock@chromium.org <gbillock@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2011-09-16 18:33:47 +0000
commit1ef931342c36238ca8de166bcfbcfd694cdf4bdb (patch)
tree8091902aa1f88da6035b98ced904ca68d33276e3
parent1078339c6d930e52d6aeca220ab36e990bdb3c35 (diff)
downloadchromium_src-1ef931342c36238ca8de166bcfbcfd694cdf4bdb.zip
chromium_src-1ef931342c36238ca8de166bcfbcfd694cdf4bdb.tar.gz
chromium_src-1ef931342c36238ca8de166bcfbcfd694cdf4bdb.tar.bz2
Add messages/handlers for the invocation sequence. Copy from geolocation_dispatcher.
Get return path serialization working. R=groby@chromium.org BUG=None TEST=None Review URL: http://codereview.chromium.org/7823002 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@101536 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--content/browser/intents/intent_injector.cc96
-rw-r--r--content/browser/intents/intent_injector.h69
-rw-r--r--content/common/content_message_generator.h1
-rw-r--r--content/common/intents_messages.h48
-rw-r--r--content/content_browser.gypi2
-rw-r--r--content/content_common.gypi1
-rw-r--r--content/content_renderer.gypi2
-rw-r--r--content/renderer/intents_dispatcher.cc170
-rw-r--r--content/renderer/intents_dispatcher.h60
-rw-r--r--content/renderer/render_view.cc11
-rw-r--r--content/renderer/render_view.h9
-rw-r--r--ipc/ipc_message_utils.h1
-rw-r--r--webkit/glue/web_intent_data.cc21
-rw-r--r--webkit/glue/web_intent_data.h31
-rw-r--r--webkit/glue/webkit_glue.gypi2
15 files changed, 524 insertions, 0 deletions
diff --git a/content/browser/intents/intent_injector.cc b/content/browser/intents/intent_injector.cc
new file mode 100644
index 0000000..600baad
--- /dev/null
+++ b/content/browser/intents/intent_injector.cc
@@ -0,0 +1,96 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/browser/intents/intent_injector.h"
+
+#include "base/command_line.h"
+#include "base/logging.h"
+#include "base/string16.h"
+#include "content/common/content_switches.h"
+#include "content/browser/renderer_host/render_view_host.h"
+#include "content/browser/tab_contents/tab_contents.h"
+#include "ipc/ipc_message_macros.h"
+#include "webkit/glue/web_intent_data.h"
+
+IntentInjector::IntentInjector(TabContents* tab_contents)
+ : TabContentsObserver(tab_contents),
+ source_routing_id_(0),
+ intent_id_(0) {
+ DCHECK(tab_contents);
+}
+
+IntentInjector::~IntentInjector() {
+}
+
+void IntentInjector::TabContentsDestroyed(TabContents* tab) {
+ delete this;
+}
+
+void IntentInjector::SetIntent(int routing_id,
+ int intent_id,
+ const string16& action,
+ const string16& type,
+ const string16& data) {
+ webkit_glue::WebIntentData* intent_data = new webkit_glue::WebIntentData;
+ intent_data->action = action;
+ intent_data->type = type;
+ intent_data->data = data;
+ source_intent_.reset(intent_data);
+ intent_id_ = intent_id;
+ source_routing_id_ = routing_id;
+
+ SendIntent();
+}
+
+void IntentInjector::RenderViewCreated(RenderViewHost* host) {
+ SendIntent();
+}
+
+void IntentInjector::DidNavigateMainFramePostCommit(
+ const content::LoadCommittedDetails& details,
+ const ViewHostMsg_FrameNavigate_Params& params) {
+ SendIntent();
+}
+
+// TODO(gbillock): The "correct" thing here is for this to be a
+// RenderViewHostObserver, and do this on RenderViewHostInitialized. There's no
+// good hooks for attaching the intent to such an object, though. All RVHOs get
+// made deep inside tab contents initialization. Idea: propagate out
+// RenderViewHostInitialized to a TabContentsObserver latch? That still looks
+// like it might be racy, though.
+void IntentInjector::SendIntent() {
+ if (source_intent_.get() == NULL ||
+ !CommandLine::ForCurrentProcess()->HasSwitch(
+ switches::kEnableWebIntents) ||
+ tab_contents()->render_view_host() == NULL) {
+ return;
+ }
+
+ // 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_.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_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
+void IntentInjector::OnReply(const IPC::Message& message,
+ IntentsMsg_WebIntentReply_Type::Value reply_type,
+ const string16& data,
+ int intent_id) {
+ if (!CommandLine::ForCurrentProcess()->HasSwitch(switches::kEnableWebIntents))
+ NOTREACHED();
+
+ Send(new IntentsMsg_WebIntentReply(
+ source_routing_id_, reply_type, data, intent_id));
+}
diff --git a/content/browser/intents/intent_injector.h b/content/browser/intents/intent_injector.h
new file mode 100644
index 0000000..0250060
--- /dev/null
+++ b/content/browser/intents/intent_injector.h
@@ -0,0 +1,69 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_BROWSER_INTENTS_INTENT_INJECTOR_H_
+#define CONTENT_BROWSER_INTENTS_INTENT_INJECTOR_H_
+#pragma once
+
+#include "base/basictypes.h"
+#include "base/string16.h"
+#include "content/browser/tab_contents/tab_contents_observer.h"
+#include "content/common/intents_messages.h"
+
+class RenderViewHost;
+class TabContents;
+
+namespace webkit_glue {
+struct WebIntentData;
+}
+
+namespace IPC {
+class Message;
+}
+
+// Injects an intent into the renderer of a TabContents. The intent dispatch
+// logic will create one of these to take care of passing intent data down into
+// the context of the service, which will be running in the TabContents on which
+// this class is an observer. Deletes itself when the tab is closed.
+class IntentInjector : public TabContentsObserver {
+ public:
+ // |tab_contents| must not be NULL.
+ explicit IntentInjector(TabContents* tab_contents);
+ virtual ~IntentInjector();
+
+ // TabContentsObserver implementation.
+ virtual void RenderViewCreated(RenderViewHost* host) OVERRIDE;
+ virtual void DidNavigateMainFramePostCommit(
+ const content::LoadCommittedDetails& details,
+ const ViewHostMsg_FrameNavigate_Params& params) OVERRIDE;
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
+ virtual void TabContentsDestroyed(TabContents* tab) OVERRIDE;
+
+ // Sets the intent data to be injected. Call after the user has selected a
+ // service to pass the intent data to that service.
+ void SetIntent(int routing_id,
+ int intent_id,
+ const string16& action,
+ const string16& type,
+ const string16& data);
+
+ 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,
+ IntentsMsg_WebIntentReply_Type::Value reply_type,
+ const string16& data,
+ int intent_id);
+
+ // Source intent data provided by caller.
+ scoped_ptr<webkit_glue::WebIntentData> source_intent_;
+ int source_routing_id_;
+ int intent_id_;
+
+ DISALLOW_COPY_AND_ASSIGN(IntentInjector);
+};
+
+#endif // CONTENT_BROWSER_INTENTS_INTENT_INJECTOR_H_
diff --git a/content/common/content_message_generator.h b/content/common/content_message_generator.h
index 881eb7b..e486364 100644
--- a/content/common/content_message_generator.h
+++ b/content/common/content_message_generator.h
@@ -19,6 +19,7 @@
#include "content/common/geolocation_messages.h"
#include "content/common/gpu/gpu_messages.h"
#include "content/common/indexed_db_messages.h"
+#include "content/common/intents_messages.h"
#include "content/common/media/audio_messages.h"
#include "content/common/media/media_stream_messages.h"
#include "content/common/media/video_capture_messages.h"
diff --git a/content/common/intents_messages.h b/content/common/intents_messages.h
new file mode 100644
index 0000000..25e7a7a
--- /dev/null
+++ b/content/common/intents_messages.h
@@ -0,0 +1,48 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+// Message definition file, included multiple times, hence no include guard.
+
+#include "ipc/ipc_message_macros.h"
+#include "ipc/ipc_message_utils.h"
+#include "ipc/param_traits_macros.h"
+#include "webkit/glue/web_intent_data.h"
+
+#define IPC_MESSAGE_START IntentsMsgStart
+
+IPC_STRUCT_TRAITS_BEGIN(webkit_glue::WebIntentData)
+ IPC_STRUCT_TRAITS_MEMBER(action)
+ IPC_STRUCT_TRAITS_MEMBER(type)
+ IPC_STRUCT_TRAITS_MEMBER(data)
+IPC_STRUCT_TRAITS_END()
+
+// Define enums used in this file inside an include-guard.
+#ifndef CONTENT_COMMON_INTENTS_MESSAGES_H_
+#define CONTENT_COMMON_INTENTS_MESSAGES_H_
+
+// Constant values use to indicate what type of reply the caller is getting from
+// the web intents service page.
+struct IntentsMsg_WebIntentReply_Type {
+ public:
+ enum Value {
+ // Sent for a reply message (success).
+ Reply,
+
+ // Sent for a failure message.
+ Failure,
+ };
+};
+
+#endif // CONTENT_COMMON_INTENTS_MESSAGES_H_
+
+IPC_ENUM_TRAITS(IntentsMsg_WebIntentReply_Type::Value)
+
+IPC_MESSAGE_ROUTED2(IntentsMsg_SetWebIntentData,
+ webkit_glue::WebIntentData,
+ int /* intent ID */)
+
+IPC_MESSAGE_ROUTED3(IntentsMsg_WebIntentReply,
+ IntentsMsg_WebIntentReply_Type::Value /* reply type */,
+ string16 /* payload data */,
+ int /* intent ID */)
diff --git a/content/content_browser.gypi b/content/content_browser.gypi
index cf0b524..4d97734 100644
--- a/content/content_browser.gypi
+++ b/content/content_browser.gypi
@@ -256,6 +256,8 @@
'browser/in_process_webkit/webkit_context.h',
'browser/in_process_webkit/webkit_thread.cc',
'browser/in_process_webkit/webkit_thread.h',
+ 'browser/intents/intent_injector.cc',
+ 'browser/intents/intent_injector.h',
'browser/javascript_dialogs.h',
'browser/load_from_memory_cache_details.cc',
'browser/load_from_memory_cache_details.h',
diff --git a/content/content_common.gypi b/content/content_common.gypi
index 4080c61..4aa18f7 100644
--- a/content/content_common.gypi
+++ b/content/content_common.gypi
@@ -131,6 +131,7 @@
'common/indexed_db_messages.h',
'common/indexed_db_param_traits.cc',
'common/indexed_db_param_traits.h',
+ 'common/intents_messages.h',
'common/json_value_serializer.cc',
'common/json_value_serializer.h',
'common/mac/attributed_string_coder.h',
diff --git a/content/content_renderer.gypi b/content/content_renderer.gypi
index 94c1617..8eea52d 100644
--- a/content/content_renderer.gypi
+++ b/content/content_renderer.gypi
@@ -57,6 +57,8 @@
'renderer/gpu/webgraphicscontext3d_command_buffer_impl.h',
'renderer/indexed_db_dispatcher.cc',
'renderer/indexed_db_dispatcher.h',
+ 'renderer/intents_dispatcher.cc',
+ 'renderer/intents_dispatcher.h',
'renderer/load_progress_tracker.cc',
'renderer/load_progress_tracker.h',
'renderer/media/audio_device.cc',
diff --git a/content/renderer/intents_dispatcher.cc b/content/renderer/intents_dispatcher.cc
new file mode 100644
index 0000000..aa174cf
--- /dev/null
+++ b/content/renderer/intents_dispatcher.cc
@@ -0,0 +1,170 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "content/renderer/intents_dispatcher.h"
+
+#include "content/common/intents_messages.h"
+#include "content/renderer/v8_value_converter.h"
+#include "ipc/ipc_message.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebBindings.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebCString.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebSerializedScriptValue.h"
+#include "webkit/glue/cpp_bound_class.h"
+
+using WebKit::WebCString;
+using WebKit::WebString;
+
+// This class encapsulates the API the Intent object will expose to Javascript.
+// It is made available to the Javascript runtime in the service page using
+// NPAPI methods as with plugin/Javascript interaction objects and other
+// browser-provided Javascript API objects on |window|.
+class IntentsDispatcher::BoundDeliveredIntent : public CppBoundClass {
+ public:
+ BoundDeliveredIntent(const string16& action,
+ const string16& type,
+ const string16& data,
+ IntentsDispatcher* parent,
+ WebKit::WebFrame* frame) {
+ action_ = WebString(action).utf8();
+ type_ = WebString(type).utf8();
+ parent_ = parent;
+
+ v8::HandleScope scope;
+ v8::Local<v8::Context> ctx = frame->mainWorldScriptContext();
+ v8::Context::Scope cscope(ctx);
+ WebKit::WebSerializedScriptValue ssv =
+ WebKit::WebSerializedScriptValue::fromString(WebString(data));
+ // TODO(gbillock): use an exception handler instead? Need to
+ // pass back error state to caller? This is a pretty unexpected
+ // internal error...
+ CHECK(!ssv.isNull());
+ v8::Local<v8::Value> data_obj =
+ v8::Local<v8::Value>::New(ssv.deserialize());
+
+ data_val_.reset(new CppVariant);
+ WebKit::WebBindings::toNPVariant(data_obj,
+ frame->windowObject(),
+ data_val_.get());
+
+ BindProperty("action", &BoundDeliveredIntent::getAction);
+ BindProperty("type", &BoundDeliveredIntent::getType);
+ BindProperty("data", &BoundDeliveredIntent::getData);
+ BindMethod("postResult", &BoundDeliveredIntent::postResult);
+ BindMethod("postFailure", &BoundDeliveredIntent::postFailure);
+ }
+
+ virtual ~BoundDeliveredIntent() {
+ }
+
+ WebKit::WebString SerializeCppVariant(const CppVariant& val) {
+ v8::HandleScope scope;
+ v8::Handle<v8::Value> v8obj = WebKit::WebBindings::toV8Value(&val);
+
+ WebKit::WebSerializedScriptValue ssv =
+ WebKit::WebSerializedScriptValue::serialize(v8obj);
+ if (ssv.isNull())
+ return WebKit::WebString();
+
+ return ssv.toString();
+ }
+
+ void postResult(const CppArgumentList& args, CppVariant* retval) {
+ if (args.size() != 1) {
+ WebKit::WebBindings::setException(
+ NULL, "Must pass one argument to postResult");
+ return;
+ }
+
+ WebString str = SerializeCppVariant(args[0]);
+ parent_->OnResult(str);
+ }
+
+ void postFailure(const CppArgumentList& args, CppVariant* retval) {
+ if (args.size() != 1) {
+ WebKit::WebBindings::setException(
+ NULL, "Must pass one argument to postFailure");
+ return;
+ }
+
+ WebString str = SerializeCppVariant(args[0]);
+ parent_->OnFailure(str);
+ }
+
+ void getAction(CppVariant* result) {
+ std::string action;
+ action.assign(action_.data(), action_.length());
+ result->Set(action);
+ }
+
+ void getType(CppVariant* result) {
+ std::string type;
+ type.assign(type_.data(), type_.length());
+ result->Set(type);
+ }
+
+ void getData(CppVariant* result) {
+ result->Set(*data_val_.get());
+ }
+
+ private:
+ // Intent data suitable for surfacing to Javascript callers.
+ WebCString action_;
+ WebCString type_;
+ scoped_ptr<CppVariant> data_val_;
+
+ // The dispatcher object, for forwarding postResult/postFailure calls.
+ IntentsDispatcher* parent_;
+};
+
+IntentsDispatcher::IntentsDispatcher(RenderView* render_view)
+ : RenderViewObserver(render_view),
+ intent_id_(0) {
+}
+
+IntentsDispatcher::~IntentsDispatcher() {}
+
+bool IntentsDispatcher::OnMessageReceived(const IPC::Message& message) {
+ bool handled = true;
+ IPC_BEGIN_MESSAGE_MAP(IntentsDispatcher, message)
+ IPC_MESSAGE_HANDLER(IntentsMsg_SetWebIntentData, OnSetIntent)
+ IPC_MESSAGE_UNHANDLED(handled = false)
+ IPC_END_MESSAGE_MAP()
+ return handled;
+}
+
+void IntentsDispatcher::OnSetIntent(const webkit_glue::WebIntentData& intent,
+ int intent_id) {
+ intent_.reset(new webkit_glue::WebIntentData(intent));
+ intent_id_ = intent_id;
+}
+
+void IntentsDispatcher::OnResult(const WebKit::WebString& data) {
+ Send(new IntentsMsg_WebIntentReply(
+ routing_id(),
+ IntentsMsg_WebIntentReply_Type::Reply,
+ data,
+ intent_id_));
+}
+
+void IntentsDispatcher::OnFailure(const WebKit::WebString& data) {
+ Send(new IntentsMsg_WebIntentReply(
+ routing_id(),
+ IntentsMsg_WebIntentReply_Type::Failure,
+ data,
+ intent_id_));
+}
+
+// We set the intent payload into all top-level frame window objects. This
+// should persist the data through redirects, and not deliver it to any
+// sub-frames. TODO(gbillock): This policy needs to be fine-tuned and
+// documented.
+void IntentsDispatcher::DidClearWindowObject(WebKit::WebFrame* frame) {
+ if (intent_.get() == NULL || frame->top() != frame)
+ return;
+
+ delivered_intent_.reset(new BoundDeliveredIntent(
+ intent_->action, intent_->type, intent_->data, this, frame));
+ delivered_intent_->BindToJavascript(frame, "intent");
+}
diff --git a/content/renderer/intents_dispatcher.h b/content/renderer/intents_dispatcher.h
new file mode 100644
index 0000000..8a5eb07
--- /dev/null
+++ b/content/renderer/intents_dispatcher.h
@@ -0,0 +1,60 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef CONTENT_RENDERER_INTENTS_DISPATCHER_H_
+#define CONTENT_RENDERER_INTENTS_DISPATCHER_H_
+#pragma once
+
+#include "base/memory/scoped_ptr.h"
+#include "content/renderer/render_view_observer.h"
+#include "third_party/WebKit/Source/WebKit/chromium/public/WebString.h"
+
+namespace webkit_glue {
+struct WebIntentData;
+}
+
+namespace WebKit {
+class WebFrame;
+}
+
+// IntentsDispatcher is a delegate for Web Intents messages. It is the
+// renderer-side handler for IPC messages delivering the intent payload data
+// and preparing it for access by the service page.
+class IntentsDispatcher : public RenderViewObserver {
+ public:
+ // |render_view| must not be NULL.
+ explicit IntentsDispatcher(RenderView* render_view);
+ virtual ~IntentsDispatcher();
+
+ // Called by the bound intent object to register the result from the service
+ // page.
+ void OnResult(const WebKit::WebString& data);
+ void OnFailure(const WebKit::WebString& data);
+
+ private:
+ class BoundDeliveredIntent;
+
+ // RenderView::Observer implementation.
+ virtual bool OnMessageReceived(const IPC::Message& message) OVERRIDE;
+ virtual void DidClearWindowObject(WebKit::WebFrame* frame) OVERRIDE;
+
+ // TODO(gbillock): Do we need various ***ClientRedirect methods to implement
+ // intent cancelling policy? Figure this out.
+
+ // Handler method for the IntentsMsg_SetWebIntent message.
+ void OnSetIntent(const webkit_glue::WebIntentData& intent, int intent_id);
+
+ // 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.
+ scoped_ptr<BoundDeliveredIntent> delivered_intent_;
+
+ DISALLOW_COPY_AND_ASSIGN(IntentsDispatcher);
+};
+
+#endif // CONTENT_RENDERER_INTENTS_DISPATCHER_H_
diff --git a/content/renderer/render_view.cc b/content/renderer/render_view.cc
index ceeb44f..5ca296b 100644
--- a/content/renderer/render_view.cc
+++ b/content/renderer/render_view.cc
@@ -48,6 +48,7 @@
#include "content/renderer/external_popup_menu.h"
#include "content/renderer/geolocation_dispatcher.h"
#include "content/renderer/gpu/webgraphicscontext3d_command_buffer_impl.h"
+#include "content/renderer/intents_dispatcher.h"
#include "content/renderer/load_progress_tracker.h"
#include "content/renderer/media/audio_message_filter.h"
#include "content/renderer/media/audio_renderer_impl.h"
@@ -406,6 +407,7 @@ RenderView::RenderView(RenderThreadBase* render_thread,
decrement_shared_popup_at_destruction_ = false;
}
+ intents_dispatcher_ = new IntentsDispatcher(this);
notification_provider_ = new NotificationProvider(this);
render_thread_->AddRoute(routing_id_, this);
@@ -740,6 +742,7 @@ bool RenderView::OnMessageReceived(const IPC::Message& message) {
IPC_MESSAGE_HANDLER(ViewMsg_SetHistoryLengthAndPrune,
OnSetHistoryLengthAndPrune)
IPC_MESSAGE_HANDLER(ViewMsg_EnableViewSourceMode, OnEnableViewSourceMode)
+ IPC_MESSAGE_HANDLER(IntentsMsg_WebIntentReply, OnWebIntentReply);
// Have the super handle all other messages.
IPC_MESSAGE_UNHANDLED(handled = RenderWidget::OnMessageReceived(message))
@@ -4507,6 +4510,14 @@ void RenderView::startActivity(const WebKit::WebString& action,
routing_id_, action, type, data, intent_id));
}
+void RenderView::OnWebIntentReply(
+ IntentsMsg_WebIntentReply_Type::Value reply_type,
+ const WebKit::WebString& data,
+ int intent_id) {
+ // TODO(gbillock): Implement once the webkit side lands.
+ LOG(INFO) << "RenderView got reply to intent type " << reply_type;
+}
+
bool RenderView::IsNonLocalTopLevelNavigation(
const GURL& url, WebKit::WebFrame* frame, WebKit::WebNavigationType type) {
// Must be a top level frame.
diff --git a/content/renderer/render_view.h b/content/renderer/render_view.h
index 9c8d31e..65c7fa1 100644
--- a/content/renderer/render_view.h
+++ b/content/renderer/render_view.h
@@ -25,6 +25,7 @@
#include "content/renderer/renderer_webcookiejar_impl.h"
#include "content/common/content_export.h"
#include "content/common/edit_command.h"
+#include "content/common/intents_messages.h"
#include "content/common/navigation_gesture.h"
#include "content/common/page_zoom.h"
#include "content/common/renderer_preferences.h"
@@ -60,6 +61,7 @@ class ExternalPopupMenu;
class FilePath;
class GeolocationDispatcher;
class GURL;
+class IntentsDispatcher;
class LoadProgressTracker;
class MediaStreamImpl;
class NavigationState;
@@ -440,6 +442,10 @@ class RenderView : public RenderWidget,
const WebKit::WebString& type,
const WebKit::WebString& data,
int intent_id);
+ virtual void OnWebIntentReply(
+ IntentsMsg_WebIntentReply_Type::Value reply_type,
+ const WebKit::WebString& data,
+ int intent_id);
// WebKit::WebFrameClient implementation -------------------------------------
@@ -1138,6 +1144,9 @@ class RenderView : public RenderWidget,
// The geolocation dispatcher attached to this view, lazily initialized.
GeolocationDispatcher* geolocation_dispatcher_;
+ // The intents dispatcher attached to this view. Not lazily initialized.
+ IntentsDispatcher* intents_dispatcher_;
+
// The speech dispatcher attached to this view, lazily initialized.
SpeechInputDispatcher* speech_input_dispatcher_;
diff --git a/ipc/ipc_message_utils.h b/ipc/ipc_message_utils.h
index 9c93ce7..8a03069 100644
--- a/ipc/ipc_message_utils.h
+++ b/ipc/ipc_message_utils.h
@@ -95,6 +95,7 @@ enum IPCMessageStart {
MediaStreamMsgStart,
ChromePluginMsgStart,
ChromeBenchmarkingMsgStart,
+ IntentsMsgStart,
LastIPCMsgStart // Must come last.
};
diff --git a/webkit/glue/web_intent_data.cc b/webkit/glue/web_intent_data.cc
new file mode 100644
index 0000000..13e85e6
--- /dev/null
+++ b/webkit/glue/web_intent_data.cc
@@ -0,0 +1,21 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "webkit/glue/web_intent_data.h"
+
+namespace webkit_glue {
+
+WebIntentData::WebIntentData() {
+}
+
+WebIntentData::~WebIntentData() {
+}
+
+WebIntentData::WebIntentData(const WebIntentData& other)
+ : action(other.action),
+ type(other.type),
+ data(other.data) {
+}
+
+} // namespace webkit_glue
diff --git a/webkit/glue/web_intent_data.h b/webkit/glue/web_intent_data.h
new file mode 100644
index 0000000..5c1e84e
--- /dev/null
+++ b/webkit/glue/web_intent_data.h
@@ -0,0 +1,31 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#ifndef WEBKIT_GLUE_WEB_INTENT_DATA_H_
+#define WEBKIT_GLUE_WEB_INTENT_DATA_H_
+
+#include "base/string16.h"
+
+namespace webkit_glue {
+
+// Representation of the Web Intent data being initiated or delivered.
+// TODO(gbillock): There's a duplicate name here in the registration pathway we
+// need to resolve.
+struct WebIntentData {
+ // The action of the intent.
+ string16 action;
+ // The MIME type of data in this intent payload.
+ string16 type;
+ // The representation of the payload data. Wire format is from
+ // SerializedScriptObject.
+ string16 data;
+
+ WebIntentData();
+ WebIntentData(const WebIntentData& other);
+ ~WebIntentData();
+};
+
+} // namespace webkit_glue
+
+#endif // WEBKIT_GLUE_WEB_INTENT_DATA_H_
diff --git a/webkit/glue/webkit_glue.gypi b/webkit/glue/webkit_glue.gypi
index 0938301..3f73cee 100644
--- a/webkit/glue/webkit_glue.gypi
+++ b/webkit/glue/webkit_glue.gypi
@@ -425,6 +425,8 @@
'weburlloader_impl.h',
'webvideoframe_impl.cc',
'webvideoframe_impl.h',
+ 'web_intent_data.cc',
+ 'web_intent_data.h',
'window_open_disposition.h',
'window_open_disposition.cc',