Permalink
Browse files

Added WindowDelegate callback for DOMUI messages.

  • Loading branch information...
1 parent 85fda6f commit 8988850bac5b6c1106419012d31b698c425a8d9f @pathorn pathorn committed Nov 1, 2009
Showing with 46 additions and 9 deletions.
  1. +5 −0 include/berkelium/WindowDelegate.hpp
  2. +12 −0 ppmmain.cpp
  3. +0 −7 src/MemoryRenderViewHost.cpp
  4. +0 −2 src/MemoryRenderViewHost.hpp
  5. +25 −0 src/WindowImpl.cpp
  6. +4 −0 src/WindowImpl.hpp
@@ -64,6 +64,11 @@ class BERKELIUM_EXPORT WindowDelegate {
virtual void onUnresponsive(Window *win)=0;
virtual void onResponsive(Window *win)=0;
+ virtual void onChromeSend(
+ Window *win,
+ const std::string &message,
+ const std::vector<std::string> &content)=0;
+
virtual void onCreatedWindow(Window *win, Window *newWindow)=0;
virtual void onPaint(
View
@@ -141,6 +141,18 @@ class TestDelegate : public WindowDelegate {
newWindow->setDelegate(new TestDelegate);
}
+ virtual void onChromeSend(
+ Window *win,
+ const std::string &message,
+ const std::vector<std::string> &contents)
+ {
+ std::cout << "*** onChromeSend ("<<message<<"):"<<std::endl;
+ for (std::vector<std::string>::const_iterator iter = contents.begin();
+ iter != contents.end(); ++iter) {
+ std::cout << "\t\'" << *iter << "\'" << std::endl;
+ }
+ }
+
virtual void onPaintPluginTexture(
Window *win,
void* sourceGLTexture,
@@ -64,7 +64,6 @@ void MemoryRenderViewHost::OnMessageReceived(const IPC::Message& msg) {
IPC_BEGIN_MESSAGE_MAP_EX(MemoryRenderViewHost, msg, msg_is_ok)
IPC_MESSAGE_HANDLER(ViewHostMsg_ScrollRect, Memory_OnMsgScrollRect)
IPC_MESSAGE_HANDLER(ViewHostMsg_PaintRect, Memory_OnMsgPaintRect)
- IPC_MESSAGE_HANDLER(ViewHostMsg_DOMUISend, Memory_OnMsgDOMUISend)
IPC_MESSAGE_UNHANDLED(RenderViewHost::OnMessageReceived(msg))
IPC_END_MESSAGE_MAP_EX()
;
@@ -76,12 +75,6 @@ void MemoryRenderViewHost::OnMessageReceived(const IPC::Message& msg) {
}
}
-void MemoryRenderViewHost::Memory_OnMsgDOMUISend(
- const std::string& message, const std::string& content)
-{
- std::cout << "Got a DOMUI Message named \'"<<message<<
- "\', with these parameters"<<std::endl<<content<<std::endl;
-}
///////// MemoryRenderWidgetHost /////////
@@ -105,8 +105,6 @@ class MemoryRenderViewHost : public MemoryRenderHostImpl <RenderViewHost> {
~MemoryRenderViewHost();
virtual void OnMessageReceived(const IPC::Message& msg);
- void Memory_OnMsgDOMUISend(const std::string& message,
- const std::string& content);
};
class MemoryRenderViewHostFactory : public RenderViewHostFactory {
View
@@ -39,6 +39,7 @@
#include "berkelium/WindowDelegate.hpp"
#include "base/file_util.h"
+#include "base/values.h"
#include "net/base/net_util.h"
#include "chrome/browser/renderer_host/render_view_host.h"
#include "chrome/browser/renderer_host/site_instance.h"
@@ -569,6 +570,30 @@ void WindowImpl::RenderViewGone(RenderViewHost* rvh) {
if (mDelegate) mDelegate->onCrashed(this);
}
+void WindowImpl::ProcessDOMUIMessage(
+ const std::string& message, const Value* content,
+ int request_id, bool has_callback)
+{
+ std::vector<std::string> argsVector;
+
+ /* Callbacks don't work for DOMUI, so we just process message and content.
+ (request_id and has_callback are hardcoded to false.)
+ In addition, content is currently hardcoded as an array of strings.
+ */
+ if (content->GetType() == Value::TYPE_LIST) {
+ const ListValue* argsListValue = static_cast<const ListValue*>(content);
+ for (size_t i = 0; i < argsListValue->GetSize(); ++i) {
+ argsVector.push_back(std::string());
+ argsListValue->GetString(i, &argsVector.back());
+ }
+ }
+
+ if (mDelegate) {
+ mDelegate->onChromeSend(this, message, argsVector);
+ }
+}
+
+
void WindowImpl::DidNavigate(RenderViewHost* rvh,
const ViewHostMsg_FrameNavigate_Params& params) {
int extra_invalidate_flags = 0;
View
@@ -156,6 +156,10 @@ class WindowImpl :
virtual void RenderViewReady(RenderViewHost* render_view_host);
+ void ProcessDOMUIMessage(const std::string& message,
+ const Value* content,
+ int request_id,
+ bool has_callback);
virtual bool IsReservedAccelerator(const NativeWebKeyboardEvent&) {return false;}
virtual void DidDisplayInsecureContent(){}
virtual void DidRunInsecureContent(const std::string&){}

0 comments on commit 8988850

Please sign in to comment.