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/browser/browser_plugin/browser_plugin_embedder.h" | 5 #include "content/browser/browser_plugin/browser_plugin_embedder.h" |
6 | 6 |
7 #include "base/values.h" | 7 #include "base/values.h" |
8 #include "content/browser/browser_plugin/browser_plugin_guest.h" | 8 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
9 #include "content/browser/renderer_host/render_view_host_impl.h" | 9 #include "content/browser/renderer_host/render_view_host_impl.h" |
10 #include "content/browser/web_contents/web_contents_impl.h" | 10 #include "content/browser/web_contents/web_contents_impl.h" |
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
109 guest_started_drag_->EndSystemDrag(); | 109 guest_started_drag_->EndSystemDrag(); |
110 guest_started_drag_.reset(); | 110 guest_started_drag_.reset(); |
111 guest_dragging_over_.reset(); | 111 guest_dragging_over_.reset(); |
112 } | 112 } |
113 | 113 |
114 void BrowserPluginEmbedder::OnUpdateDragCursor(bool* handled) { | 114 void BrowserPluginEmbedder::OnUpdateDragCursor(bool* handled) { |
115 *handled = (guest_dragging_over_.get() != NULL); | 115 *handled = (guest_dragging_over_.get() != NULL); |
116 } | 116 } |
117 | 117 |
118 void BrowserPluginEmbedder::OnGuestCallback( | 118 void BrowserPluginEmbedder::OnGuestCallback( |
119 int instance_id, | 119 int browser_plugin_instance_id, |
120 const BrowserPluginHostMsg_Attach_Params& params, | 120 const BrowserPluginHostMsg_Attach_Params& params, |
121 const base::DictionaryValue* extra_params, | |
122 WebContents* guest_web_contents) { | 121 WebContents* guest_web_contents) { |
123 BrowserPluginGuest* guest = guest_web_contents ? | 122 BrowserPluginGuest* guest = guest_web_contents ? |
124 static_cast<WebContentsImpl*>(guest_web_contents)-> | 123 static_cast<WebContentsImpl*>(guest_web_contents)-> |
125 GetBrowserPluginGuest() : NULL; | 124 GetBrowserPluginGuest() : NULL; |
126 if (guest) | 125 if (guest) |
127 guest->Attach(GetWebContents(), params, *extra_params); | 126 guest->Attach(browser_plugin_instance_id, GetWebContents(), params); |
128 } | 127 } |
129 | 128 |
130 void BrowserPluginEmbedder::OnAttach( | 129 void BrowserPluginEmbedder::OnAttach( |
131 int instance_id, | 130 int browser_plugin_instance_id, |
132 const BrowserPluginHostMsg_Attach_Params& params, | 131 const BrowserPluginHostMsg_Attach_Params& params) { |
133 const base::DictionaryValue& extra_params) { | |
134 GetBrowserPluginGuestManager()->MaybeGetGuestByInstanceIDOrKill( | 132 GetBrowserPluginGuestManager()->MaybeGetGuestByInstanceIDOrKill( |
135 instance_id, GetWebContents()->GetRenderProcessHost()->GetID(), | 133 web_contents(), |
| 134 browser_plugin_instance_id, |
136 base::Bind(&BrowserPluginEmbedder::OnGuestCallback, | 135 base::Bind(&BrowserPluginEmbedder::OnGuestCallback, |
137 base::Unretained(this), | 136 base::Unretained(this), |
138 instance_id, | 137 browser_plugin_instance_id, |
139 params, | 138 params)); |
140 &extra_params)); | |
141 } | 139 } |
142 | 140 |
143 bool BrowserPluginEmbedder::HandleKeyboardEvent( | 141 bool BrowserPluginEmbedder::HandleKeyboardEvent( |
144 const NativeWebKeyboardEvent& event) { | 142 const NativeWebKeyboardEvent& event) { |
145 if (event.windowsKeyCode != ui::VKEY_ESCAPE) | 143 if (event.windowsKeyCode != ui::VKEY_ESCAPE) |
146 return false; | 144 return false; |
147 | 145 |
148 bool event_consumed = false; | 146 bool event_consumed = false; |
149 GetBrowserPluginGuestManager()->ForEachGuest( | 147 GetBrowserPluginGuestManager()->ForEachGuest( |
150 GetWebContents(), | 148 GetWebContents(), |
151 base::Bind(&BrowserPluginEmbedder::UnlockMouseIfNecessaryCallback, | 149 base::Bind(&BrowserPluginEmbedder::UnlockMouseIfNecessaryCallback, |
152 base::Unretained(this), | 150 base::Unretained(this), |
153 &event_consumed)); | 151 &event_consumed)); |
154 | 152 |
155 return event_consumed; | 153 return event_consumed; |
156 } | 154 } |
157 | 155 |
158 bool BrowserPluginEmbedder::UnlockMouseIfNecessaryCallback(bool* mouse_unlocked, | 156 bool BrowserPluginEmbedder::UnlockMouseIfNecessaryCallback(bool* mouse_unlocked, |
159 WebContents* guest) { | 157 WebContents* guest) { |
160 *mouse_unlocked |= static_cast<WebContentsImpl*>(guest) | 158 *mouse_unlocked |= static_cast<WebContentsImpl*>(guest) |
161 ->GetBrowserPluginGuest() | 159 ->GetBrowserPluginGuest() |
162 ->mouse_locked(); | 160 ->mouse_locked(); |
163 guest->GotResponseToLockMouseRequest(false); | 161 guest->GotResponseToLockMouseRequest(false); |
164 | 162 |
165 // Returns false to iterate over all guests. | 163 // Returns false to iterate over all guests. |
166 return false; | 164 return false; |
167 } | 165 } |
168 | 166 |
169 } // namespace content | 167 } // namespace content |
OLD | NEW |