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_guest.h" | 5 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/message_loop/message_loop.h" | 9 #include "base/message_loop/message_loop.h" |
10 #include "base/strings/utf_string_conversions.h" | 10 #include "base/strings/utf_string_conversions.h" |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
162 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_UpdateGeometry, OnUpdateGeometry) | 162 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_UpdateGeometry, OnUpdateGeometry) |
163 IPC_MESSAGE_UNHANDLED(handled = false) | 163 IPC_MESSAGE_UNHANDLED(handled = false) |
164 IPC_END_MESSAGE_MAP() | 164 IPC_END_MESSAGE_MAP() |
165 return handled; | 165 return handled; |
166 } | 166 } |
167 | 167 |
168 void BrowserPluginGuest::Initialize( | 168 void BrowserPluginGuest::Initialize( |
169 const BrowserPluginHostMsg_Attach_Params& params, | 169 const BrowserPluginHostMsg_Attach_Params& params, |
170 WebContentsImpl* embedder_web_contents, | 170 WebContentsImpl* embedder_web_contents, |
171 const base::DictionaryValue& extra_params) { | 171 const base::DictionaryValue& extra_params) { |
172 // Once a BrowserPluginGuest has an embedder WebContents, it's considered to | |
lazyboy
2014/07/07 21:34:45
Was there any particular reason to move this earli
Fady Samuel
2014/07/08 15:47:09
Done.
| |
173 // be attached. | |
174 embedder_web_contents_ = embedder_web_contents; | |
175 | |
172 focused_ = params.focused; | 176 focused_ = params.focused; |
173 guest_visible_ = params.visible; | 177 guest_visible_ = params.visible; |
174 guest_opaque_ = params.opaque; | 178 guest_opaque_ = params.opaque; |
175 guest_window_rect_ = gfx::Rect(params.origin, | 179 guest_window_rect_ = gfx::Rect(params.origin, |
176 params.resize_guest_params.view_size); | 180 params.resize_guest_params.view_size); |
177 | 181 |
178 auto_size_enabled_ = params.auto_size_params.enable; | 182 auto_size_enabled_ = params.auto_size_params.enable; |
179 max_auto_size_ = params.auto_size_params.max_size; | 183 max_auto_size_ = params.auto_size_params.max_size; |
180 min_auto_size_ = params.auto_size_params.min_size; | 184 min_auto_size_ = params.auto_size_params.min_size; |
181 | 185 |
182 // Once a BrowserPluginGuest has an embedder WebContents, it's considered to | |
183 // be attached. | |
184 embedder_web_contents_ = embedder_web_contents; | |
185 | |
186 WebContentsViewGuest* new_view = | 186 WebContentsViewGuest* new_view = |
187 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView()); | 187 static_cast<WebContentsViewGuest*>(GetWebContents()->GetView()); |
188 new_view->OnGuestInitialized(embedder_web_contents->GetView()); | 188 new_view->OnGuestInitialized(embedder_web_contents->GetView()); |
189 | 189 |
190 RendererPreferences* renderer_prefs = | 190 RendererPreferences* renderer_prefs = |
191 GetWebContents()->GetMutableRendererPrefs(); | 191 GetWebContents()->GetMutableRendererPrefs(); |
192 std::string guest_user_agent_override = renderer_prefs->user_agent_override; | 192 std::string guest_user_agent_override = renderer_prefs->user_agent_override; |
193 // Copy renderer preferences (and nothing else) from the embedder's | 193 // Copy renderer preferences (and nothing else) from the embedder's |
194 // WebContents to the guest. | 194 // WebContents to the guest. |
195 // | 195 // |
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
285 | 285 |
286 BrowserPluginGuestManager* | 286 BrowserPluginGuestManager* |
287 BrowserPluginGuest::GetBrowserPluginGuestManager() const { | 287 BrowserPluginGuest::GetBrowserPluginGuestManager() const { |
288 return GetWebContents()->GetBrowserContext()->GetGuestManager(); | 288 return GetWebContents()->GetBrowserContext()->GetGuestManager(); |
289 } | 289 } |
290 | 290 |
291 // screen. | 291 // screen. |
292 gfx::Rect BrowserPluginGuest::ToGuestRect(const gfx::Rect& bounds) { | 292 gfx::Rect BrowserPluginGuest::ToGuestRect(const gfx::Rect& bounds) { |
293 gfx::Rect guest_rect(bounds); | 293 gfx::Rect guest_rect(bounds); |
294 guest_rect.Offset(guest_window_rect_.OffsetFromOrigin()); | 294 guest_rect.Offset(guest_window_rect_.OffsetFromOrigin()); |
295 if (embedder_web_contents()->GetBrowserPluginGuest()) { | |
296 BrowserPluginGuest* embedder_guest = | |
297 embedder_web_contents()->GetBrowserPluginGuest(); | |
298 guest_rect.Offset(embedder_guest->guest_window_rect_.OffsetFromOrigin()); | |
299 } | |
295 return guest_rect; | 300 return guest_rect; |
296 } | 301 } |
297 | 302 |
298 void BrowserPluginGuest::EmbedderVisibilityChanged(bool visible) { | 303 void BrowserPluginGuest::EmbedderVisibilityChanged(bool visible) { |
299 embedder_visible_ = visible; | 304 embedder_visible_ = visible; |
300 UpdateVisibility(); | 305 UpdateVisibility(); |
301 } | 306 } |
302 | 307 |
303 void BrowserPluginGuest::PointerLockPermissionResponse(bool allow) { | 308 void BrowserPluginGuest::PointerLockPermissionResponse(bool allow) { |
304 SendMessageToEmbedder( | 309 SendMessageToEmbedder( |
305 new BrowserPluginMsg_SetMouseLock(instance_id(), allow)); | 310 new BrowserPluginMsg_SetMouseLock(instance_id(), allow)); |
306 } | 311 } |
307 | 312 |
308 WebContentsImpl* BrowserPluginGuest::GetWebContents() const { | 313 WebContentsImpl* BrowserPluginGuest::GetWebContents() const { |
309 return static_cast<WebContentsImpl*>(web_contents()); | 314 return static_cast<WebContentsImpl*>(web_contents()); |
310 } | 315 } |
311 | 316 |
312 gfx::Point BrowserPluginGuest::GetScreenCoordinates( | 317 gfx::Point BrowserPluginGuest::GetScreenCoordinates( |
313 const gfx::Point& relative_position) const { | 318 const gfx::Point& relative_position) const { |
319 if (!attached()) | |
320 return gfx::Point(); | |
lazyboy
2014/07/07 21:34:45
return relative_position;
Fady Samuel
2014/07/08 15:47:09
Done.
| |
321 | |
314 gfx::Point screen_pos(relative_position); | 322 gfx::Point screen_pos(relative_position); |
315 screen_pos += guest_window_rect_.OffsetFromOrigin(); | 323 screen_pos += guest_window_rect_.OffsetFromOrigin(); |
324 if (embedder_web_contents()->GetBrowserPluginGuest()) { | |
325 BrowserPluginGuest* embedder_guest = | |
326 embedder_web_contents()->GetBrowserPluginGuest(); | |
327 screen_pos += embedder_guest->guest_window_rect_.OffsetFromOrigin(); | |
328 } | |
316 return screen_pos; | 329 return screen_pos; |
317 } | 330 } |
318 | 331 |
319 bool BrowserPluginGuest::InAutoSizeBounds(const gfx::Size& size) const { | 332 bool BrowserPluginGuest::InAutoSizeBounds(const gfx::Size& size) const { |
320 return size.width() <= max_auto_size_.width() && | 333 return size.width() <= max_auto_size_.width() && |
321 size.height() <= max_auto_size_.height(); | 334 size.height() <= max_auto_size_.height(); |
322 } | 335 } |
323 | 336 |
324 void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) { | 337 void BrowserPluginGuest::SendMessageToEmbedder(IPC::Message* msg) { |
325 if (!attached()) { | 338 if (!attached()) { |
(...skipping 551 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
877 void BrowserPluginGuest::OnImeCompositionRangeChanged( | 890 void BrowserPluginGuest::OnImeCompositionRangeChanged( |
878 const gfx::Range& range, | 891 const gfx::Range& range, |
879 const std::vector<gfx::Rect>& character_bounds) { | 892 const std::vector<gfx::Rect>& character_bounds) { |
880 static_cast<RenderWidgetHostViewBase*>( | 893 static_cast<RenderWidgetHostViewBase*>( |
881 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged( | 894 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged( |
882 range, character_bounds); | 895 range, character_bounds); |
883 } | 896 } |
884 #endif | 897 #endif |
885 | 898 |
886 } // namespace content | 899 } // namespace content |
OLD | NEW |