Chromium Code Reviews| Index: chrome/renderer/browser_plugin/chrome_browser_plugin_delegate.cc |
| diff --git a/chrome/renderer/browser_plugin/chrome_browser_plugin_delegate.cc b/chrome/renderer/browser_plugin/chrome_browser_plugin_delegate.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..c1a793a63acc7d1d0b61f45a16af8ab21d229a0c |
| --- /dev/null |
| +++ b/chrome/renderer/browser_plugin/chrome_browser_plugin_delegate.cc |
| @@ -0,0 +1,70 @@ |
| +// Copyright 2014 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 "chrome/renderer/browser_plugin/chrome_browser_plugin_delegate.h" |
| + |
| +#include "content/public/renderer/browser_plugin_delegate.h" |
| +#include "content/public/renderer/render_thread.h" |
| +#include "content/public/renderer/render_frame.h" |
| +#include "content/public/renderer/render_view.h" |
| +#include "extensions/common/extension_messages.h" |
| + |
| +using content::RenderView; |
| + |
| +ChromeBrowserPluginDelegate::ChromeBrowserPluginDelegate( |
| + int routing_id, const std::string& mime_type) |
| + : content::BrowserPluginDelegate(routing_id, mime_type), |
| + content::RenderViewObserver(RenderView::FromRoutingID(routing_id)), |
|
Fady Samuel
2014/09/02 15:08:24
This should probably be RenderFrameObserver.
lazyboy
2014/09/02 20:17:22
Done.
|
| + routing_id_(routing_id), |
|
Fady Samuel
2014/09/02 15:08:24
No need for this. RenderViewObserver (should be Re
lazyboy
2014/09/02 20:17:22
Done.
|
| + mime_type_(mime_type), |
| + element_instance_id_(-1) { |
|
Fady Samuel
2014/09/02 15:08:25
nit: Should be kInstanceIDNone eventually. I think
lazyboy
2014/09/02 20:17:22
Hmmm, there's browser_plugin::kInstanceIDNone as w
|
| +} |
| + |
| +ChromeBrowserPluginDelegate::~ChromeBrowserPluginDelegate() { |
| +} |
| + |
| +void ChromeBrowserPluginDelegate::SetElementInstanceID( |
| + int element_instance_id) { |
| + element_instance_id_ = element_instance_id; |
| +} |
| + |
| +void ChromeBrowserPluginDelegate::DidFinishLoading() { |
| + DCHECK(content::RenderThread::Get()); |
|
Fady Samuel
2014/09/02 15:08:24
Why is this here?
lazyboy
2014/09/02 20:17:21
Removed
(leftover as I was using RenderThread.Send
|
| + render_view()->Send( |
| + new ExtensionHostMsg_CreateMimeHandlerViewGuest( |
| + routing_id_, html_string_, mime_type_, element_instance_id_)); |
| +} |
| + |
| +void ChromeBrowserPluginDelegate::DidReceiveData( |
| + const char* data, int data_length) { |
| + std::string value(data, data_length); |
| + html_string_ += value; |
| +} |
| + |
| +bool ChromeBrowserPluginDelegate::OnMessageReceived( |
| + const IPC::Message& message) { |
| + if (message.type() != ExtensionMsg_CreateMimeHandlerViewGuestACK::ID) |
| + return false; |
| + |
|
Fady Samuel
2014/09/02 15:08:25
DCHECK that element_instance_id_ != kInstanceIDNon
lazyboy
2014/09/02 20:17:21
Done.
|
| + int element_instance_id = 0; |
| + PickleIterator iter(message); |
| + bool success = iter.ReadInt(&element_instance_id); |
| + DCHECK(success); |
| + if (element_instance_id != element_instance_id_) |
| + return false; |
| + |
| + bool handled = true; |
| + IPC_BEGIN_MESSAGE_MAP(ChromeBrowserPluginDelegate, message) |
| + IPC_MESSAGE_HANDLER(ExtensionMsg_CreateMimeHandlerViewGuestACK, |
| + OnCreateMimeHandlerViewGuestACK) |
| + IPC_MESSAGE_UNHANDLED(handled = false) |
| + IPC_END_MESSAGE_MAP() |
| + return handled; |
| +} |
| + |
| +void ChromeBrowserPluginDelegate::OnCreateMimeHandlerViewGuestACK( |
| + int element_instance_id) { |
| + // TODO(lazyboy): Using GetMainRenderFrame() is OK? |
|
Fady Samuel
2014/09/02 15:08:24
Ohh, this should be a RenderFrameObserver, and not
Fady Samuel
2014/09/02 15:08:25
DCHECK that element_instance_id_ != kInstanceIDNon
lazyboy
2014/09/02 20:17:22
Done.
lazyboy
2014/09/02 20:17:22
Done.
|
| + render_view()->GetMainRenderFrame()->AttachGuest(element_instance_id); |
| +} |