Chromium Code Reviews| 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 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 108 | 108 |
| 109 return embedder_web_contents()->GotResponseToLockMouseRequest(allowed); | 109 return embedder_web_contents()->GotResponseToLockMouseRequest(allowed); |
| 110 } | 110 } |
| 111 | 111 |
| 112 void BrowserPluginGuest::Destroy() { | 112 void BrowserPluginGuest::Destroy() { |
| 113 if (!delegate_) | 113 if (!delegate_) |
| 114 return; | 114 return; |
| 115 delegate_->Destroy(); | 115 delegate_->Destroy(); |
| 116 } | 116 } |
| 117 | 117 |
| 118 WebContentsImpl* BrowserPluginGuest::CreateNewGuestWindow( | |
| 119 WebContents::CreateParams* params) { | |
| 120 if (!delegate_) | |
|
lazyboy
2014/06/17 23:46:46
This would pretty much result in null pointer exce
Fady Samuel
2014/06/18 21:08:34
I've made delegate a part of the constructor. Now
lazyboy
2014/06/19 16:17:31
That's great.
Can you also update your CL descript
Fady Samuel
2014/06/20 15:16:35
Done.
| |
| 121 return NULL; | |
| 122 return static_cast<WebContentsImpl*>(delegate_->CreateNewGuestWindow(params)); | |
| 123 } | |
| 124 | |
| 118 bool BrowserPluginGuest::OnMessageReceivedFromEmbedder( | 125 bool BrowserPluginGuest::OnMessageReceivedFromEmbedder( |
| 119 const IPC::Message& message) { | 126 const IPC::Message& message) { |
| 120 bool handled = true; | 127 bool handled = true; |
| 121 IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message) | 128 IPC_BEGIN_MESSAGE_MAP(BrowserPluginGuest, message) |
| 122 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CompositorFrameSwappedACK, | 129 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CompositorFrameSwappedACK, |
| 123 OnCompositorFrameSwappedACK) | 130 OnCompositorFrameSwappedACK) |
| 124 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CopyFromCompositingSurfaceAck, | 131 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_CopyFromCompositingSurfaceAck, |
| 125 OnCopyFromCompositingSurfaceAck) | 132 OnCopyFromCompositingSurfaceAck) |
| 126 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_DragStatusUpdate, | 133 IPC_MESSAGE_HANDLER(BrowserPluginHostMsg_DragStatusUpdate, |
| 127 OnDragStatusUpdate) | 134 OnDragStatusUpdate) |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 232 has_render_view_ = true; | 239 has_render_view_ = true; |
| 233 } | 240 } |
| 234 } | 241 } |
| 235 | 242 |
| 236 BrowserPluginGuest::~BrowserPluginGuest() { | 243 BrowserPluginGuest::~BrowserPluginGuest() { |
| 237 } | 244 } |
| 238 | 245 |
| 239 // static | 246 // static |
| 240 BrowserPluginGuest* BrowserPluginGuest::Create( | 247 BrowserPluginGuest* BrowserPluginGuest::Create( |
| 241 int instance_id, | 248 int instance_id, |
| 242 SiteInstance* guest_site_instance, | |
| 243 WebContentsImpl* web_contents, | 249 WebContentsImpl* web_contents, |
| 244 scoped_ptr<base::DictionaryValue> extra_params, | 250 BrowserPluginGuestDelegate* delegate) { |
| 245 BrowserPluginGuest* opener) { | |
| 246 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Create")); | 251 RecordAction(base::UserMetricsAction("BrowserPlugin.Guest.Create")); |
| 247 BrowserPluginGuest* guest = new BrowserPluginGuest( | 252 BrowserPluginGuest* guest = new BrowserPluginGuest( |
| 248 instance_id, web_contents->opener() != NULL, web_contents); | 253 instance_id, web_contents->opener() != NULL, web_contents); |
| 249 web_contents->SetBrowserPluginGuest(guest); | 254 web_contents->SetBrowserPluginGuest(guest); |
| 250 WebContents* opener_web_contents = NULL; | |
| 251 if (opener) { | |
| 252 opener_web_contents = opener->GetWebContents(); | |
| 253 guest_site_instance = opener_web_contents->GetSiteInstance(); | |
| 254 } | |
| 255 BrowserPluginGuestDelegate* delegate = NULL; | |
| 256 GetContentClient()->browser()->GuestWebContentsCreated( | |
| 257 instance_id, | |
| 258 guest_site_instance, | |
| 259 web_contents, | |
| 260 opener_web_contents, | |
| 261 &delegate, | |
| 262 extra_params.Pass()); | |
| 263 if (delegate) { | 255 if (delegate) { |
| 264 delegate->RegisterDestructionCallback( | 256 delegate->RegisterDestructionCallback( |
| 265 base::Bind(&BrowserPluginGuest::WillDestroy, | 257 base::Bind(&BrowserPluginGuest::WillDestroy, |
| 266 base::Unretained(guest))); | 258 base::Unretained(guest))); |
| 267 guest->set_delegate(delegate); | 259 guest->set_delegate(delegate); |
| 268 } | 260 } |
| 269 return guest; | 261 return guest; |
| 270 } | 262 } |
| 271 | 263 |
| 272 // static | 264 // static |
| (...skipping 621 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 894 void BrowserPluginGuest::OnImeCompositionRangeChanged( | 886 void BrowserPluginGuest::OnImeCompositionRangeChanged( |
| 895 const gfx::Range& range, | 887 const gfx::Range& range, |
| 896 const std::vector<gfx::Rect>& character_bounds) { | 888 const std::vector<gfx::Rect>& character_bounds) { |
| 897 static_cast<RenderWidgetHostViewBase*>( | 889 static_cast<RenderWidgetHostViewBase*>( |
| 898 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged( | 890 web_contents()->GetRenderWidgetHostView())->ImeCompositionRangeChanged( |
| 899 range, character_bounds); | 891 range, character_bounds); |
| 900 } | 892 } |
| 901 #endif | 893 #endif |
| 902 | 894 |
| 903 } // namespace content | 895 } // namespace content |
| OLD | NEW |