Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4062)

Unified Diff: chrome/renderer/browser_plugin/chrome_browser_plugin_delegate.cc

Issue 376033002: Adding MimeHandlerView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@pending-zork-patch2
Patch Set: With the new attach approach Created 6 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..98da85fe788a03ea0448488c6ddbcf32574706fb
--- /dev/null
+++ b/chrome/renderer/browser_plugin/chrome_browser_plugin_delegate.cc
@@ -0,0 +1,62 @@
+// 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, int element_id, const std::string& mime_type)
+ : content::BrowserPluginDelegate(routing_id, element_id, mime_type),
+ content::RenderViewObserver(RenderView::FromRoutingID(routing_id)),
+ routing_id_(routing_id),
+ element_id_(element_id),
+ mime_type_(mime_type) {
+}
+
+ChromeBrowserPluginDelegate::~ChromeBrowserPluginDelegate() {
+}
+
+void ChromeBrowserPluginDelegate::DidFinishLoading(
+ const std::string& html_string) {
+ DCHECK(content::RenderThread::Get());
+ render_view()->Send(
+ new ExtensionHostMsg_CreateMimeHandlerViewGuest(
+ routing_id_, html_string, mime_type_, element_id_));
+}
+
+bool ChromeBrowserPluginDelegate::OnMessageReceived(
+ const IPC::Message& message) {
+ if (message.type() != ExtensionMsg_CreateMimeHandlerViewGuestACK::ID)
+ return false;
+
+ int browser_plugin_instance_id = 0;
+ PickleIterator iter(message);
+ bool success = iter.ReadInt(&browser_plugin_instance_id);
+ DCHECK(success);
+ if (browser_plugin_instance_id != element_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 browser_plugin_instance_id,
+ int guest_instance_id) {
+ printf("Got back in delegate, guest_instance_id: %d\n", guest_instance_id);
+ // TODO(lazyboy): Using GetMainRenderFrame() is OK?
+ render_view()->GetMainRenderFrame()->AttachGuest(browser_plugin_instance_id);
+}

Powered by Google App Engine
This is Rietveld 408576698