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

Side by Side 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, 3 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 unified diff | Download patch
OLDNEW
(Empty)
1 // Copyright 2014 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 #include "chrome/renderer/browser_plugin/chrome_browser_plugin_delegate.h"
6
7 #include "content/public/renderer/browser_plugin_delegate.h"
8 #include "content/public/renderer/render_thread.h"
9 #include "content/public/renderer/render_frame.h"
10 #include "content/public/renderer/render_view.h"
11 #include "extensions/common/extension_messages.h"
12
13 using content::RenderView;
14
15 ChromeBrowserPluginDelegate::ChromeBrowserPluginDelegate(
16 int routing_id, int element_id, const std::string& mime_type)
17 : content::BrowserPluginDelegate(routing_id, element_id, mime_type),
18 content::RenderViewObserver(RenderView::FromRoutingID(routing_id)),
19 routing_id_(routing_id),
20 element_id_(element_id),
21 mime_type_(mime_type) {
22 }
23
24 ChromeBrowserPluginDelegate::~ChromeBrowserPluginDelegate() {
25 }
26
27 void ChromeBrowserPluginDelegate::DidFinishLoading(
28 const std::string& html_string) {
29 DCHECK(content::RenderThread::Get());
30 render_view()->Send(
31 new ExtensionHostMsg_CreateMimeHandlerViewGuest(
32 routing_id_, html_string, mime_type_, element_id_));
33 }
34
35 bool ChromeBrowserPluginDelegate::OnMessageReceived(
36 const IPC::Message& message) {
37 if (message.type() != ExtensionMsg_CreateMimeHandlerViewGuestACK::ID)
38 return false;
39
40 int browser_plugin_instance_id = 0;
41 PickleIterator iter(message);
42 bool success = iter.ReadInt(&browser_plugin_instance_id);
43 DCHECK(success);
44 if (browser_plugin_instance_id != element_id_)
45 return false;
46
47 bool handled = true;
48 IPC_BEGIN_MESSAGE_MAP(ChromeBrowserPluginDelegate, message)
49 IPC_MESSAGE_HANDLER(ExtensionMsg_CreateMimeHandlerViewGuestACK,
50 OnCreateMimeHandlerViewGuestACK)
51 IPC_MESSAGE_UNHANDLED(handled = false)
52 IPC_END_MESSAGE_MAP()
53 return handled;
54 }
55
56 void ChromeBrowserPluginDelegate::OnCreateMimeHandlerViewGuestACK(
57 int browser_plugin_instance_id,
58 int guest_instance_id) {
59 printf("Got back in delegate, guest_instance_id: %d\n", guest_instance_id);
60 // TODO(lazyboy): Using GetMainRenderFrame() is OK?
61 render_view()->GetMainRenderFrame()->AttachGuest(browser_plugin_instance_id);
62 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698