OLD | NEW |
---|---|
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "content/renderer/browser_plugin/browser_plugin_placeholder.h" | 5 #include "content/renderer/browser_plugin/browser_plugin_placeholder.h" |
6 | 6 |
7 #include "base/atomic_sequence_num.h" | 7 #include "base/atomic_sequence_num.h" |
8 #include "base/id_map.h" | 8 #include "base/id_map.h" |
9 #include "base/lazy_instance.h" | 9 #include "base/lazy_instance.h" |
10 #include "base/process.h" | 10 #include "base/process.h" |
11 #include "base/string_number_conversions.h" | 11 #include "base/string_number_conversions.h" |
12 #include "base/string_piece.h" | 12 #include "base/string_piece.h" |
13 #include "base/string_util.h" | 13 #include "base/string_util.h" |
14 #include "base/values.h" | 14 #include "base/values.h" |
15 #include "content/common/view_messages.h" | 15 #include "content/common/browser_plugin_messages.h" |
16 #include "content/public/renderer/render_view.h" | 16 #include "content/public/renderer/render_view.h" |
17 #include "content/renderer/render_view_impl.h" | |
17 #include "ipc/ipc_channel_handle.h" | 18 #include "ipc/ipc_channel_handle.h" |
18 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" | 19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebFrame.h" |
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPlugin.h" |
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebPluginContainer.h" |
21 #include "webkit/plugins/webview_plugin.h" | 22 #include "webkit/plugins/webview_plugin.h" |
22 | 23 |
23 static base::StaticAtomicSequenceNumber g_next_id; | 24 static base::StaticAtomicSequenceNumber g_next_id; |
24 | 25 |
25 // The global list of all Browser Plugin Placeholders within a process. | 26 // The global list of all Browser Plugin Placeholders within a process. |
26 base::LazyInstance<IDMap<BrowserPluginPlaceholder> >::Leaky | 27 base::LazyInstance<IDMap<BrowserPluginPlaceholder> >::Leaky |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
60 plugin_params_(params), | 61 plugin_params_(params), |
61 plugin_(webkit::WebViewPlugin::Create( | 62 plugin_(webkit::WebViewPlugin::Create( |
62 this, render_view->GetWebkitPreferences(), html_data, | 63 this, render_view->GetWebkitPreferences(), html_data, |
63 GURL(kPluginPlaceholderDataURL))) { | 64 GURL(kPluginPlaceholderDataURL))) { |
64 id_ = g_next_id.GetNext(); | 65 id_ = g_next_id.GetNext(); |
65 RegisterPlaceholder(GetID(), this); | 66 RegisterPlaceholder(GetID(), this); |
66 | 67 |
67 // By default we navigate to google.com | 68 // By default we navigate to google.com |
68 GetPluginParameters(0, 0, "http://www.google.com/"); | 69 GetPluginParameters(0, 0, "http://www.google.com/"); |
69 | 70 |
70 // TODO(fsamuel): Request a browser plugin instance from the | 71 render_view->Send(new BrowserPluginHostMsg_OpenChannel( |
71 // browser process. | 72 render_view->GetRoutingID(), GetID(), frame->identifier(), src_, size_)); |
72 } | 73 } |
73 | 74 |
74 BrowserPluginPlaceholder::~BrowserPluginPlaceholder() { | 75 BrowserPluginPlaceholder::~BrowserPluginPlaceholder() { |
75 UnregisterPlaceholder(GetID()); | 76 UnregisterPlaceholder(GetID()); |
76 } | 77 } |
77 | 78 |
78 void BrowserPluginPlaceholder::RegisterPlaceholder( | 79 void BrowserPluginPlaceholder::RegisterPlaceholder( |
79 int id, | 80 int id, |
80 BrowserPluginPlaceholder* placeholder) { | 81 BrowserPluginPlaceholder* placeholder) { |
81 g_all_placeholders.Get().AddWithID(placeholder, id); | 82 g_all_placeholders.Get().AddWithID(placeholder, id); |
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
113 // we reset our attributes to the default. | 114 // we reset our attributes to the default. |
114 if (src_.empty()) | 115 if (src_.empty()) |
115 src_ = default_src; | 116 src_ = default_src; |
116 | 117 |
117 size_.SetSize(width, height); | 118 size_.SetSize(width, height); |
118 } | 119 } |
119 | 120 |
120 void BrowserPluginPlaceholder::GuestReady( | 121 void BrowserPluginPlaceholder::GuestReady( |
121 base::ProcessHandle process_handle, | 122 base::ProcessHandle process_handle, |
122 const IPC::ChannelHandle& channel_handle) { | 123 const IPC::ChannelHandle& channel_handle) { |
123 // TODO(fsamuel): Once the guest renderer is ready, | 124 WebKit::WebPlugin* new_plugin = |
124 // it will inform the host renderer and the BrowserPluginPlaceholder | 125 static_cast<RenderViewImpl*>( |
piman
2012/04/06 23:19:26
This cast makes me nervous.
Either expose CreateBr
Fady Samuel
2012/04/11 22:06:34
Done. BrowserPluginPlaceholder now takes in a Rend
| |
125 // can swap itself out with the guest. | 126 render_view())->CreateBrowserPlugin(process_handle, |
126 NOTIMPLEMENTED(); | 127 channel_handle, |
128 plugin_params()); | |
129 LoadGuest(new_plugin); | |
127 } | 130 } |
128 | 131 |
129 void BrowserPluginPlaceholder::LoadGuest(WebKit::WebPlugin* new_plugin) { | 132 void BrowserPluginPlaceholder::LoadGuest(WebKit::WebPlugin* new_plugin) { |
130 WebKit::WebPluginContainer* container = plugin_->container(); | 133 WebKit::WebPluginContainer* container = plugin_->container(); |
131 if (!new_plugin || !new_plugin->initialize(container)) | 134 if (!new_plugin || !new_plugin->initialize(container)) |
132 return; | 135 return; |
133 plugin_->RestoreTitleText(); | 136 plugin_->RestoreTitleText(); |
134 container->setPlugin(new_plugin); | 137 container->setPlugin(new_plugin); |
135 container->invalidate(); | 138 container->invalidate(); |
136 container->reportGeometry(); | 139 container->reportGeometry(); |
137 plugin_->ReplayReceivedData(new_plugin); | 140 plugin_->ReplayReceivedData(new_plugin); |
138 plugin_->destroy(); | 141 plugin_->destroy(); |
139 } | 142 } |
140 | 143 |
141 void BrowserPluginPlaceholder::WillDestroyPlugin() { | 144 void BrowserPluginPlaceholder::WillDestroyPlugin() { |
142 delete this; | 145 delete this; |
143 } | 146 } |
OLD | NEW |