| 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/browser_plugin/browser_plugin_host_factory.h" | 9 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" |
| 10 #include "content/browser/renderer_host/render_view_host_impl.h" | 10 #include "content/browser/renderer_host/render_view_host_impl.h" |
| 11 #include "content/browser/web_contents/web_contents_impl.h" | 11 #include "content/browser/web_contents/web_contents_impl.h" |
| 12 #include "content/common/browser_plugin/browser_plugin_constants.h" | 12 #include "content/common/browser_plugin/browser_plugin_constants.h" |
| 13 #include "content/common/browser_plugin/browser_plugin_messages.h" | 13 #include "content/common/browser_plugin/browser_plugin_messages.h" |
| 14 #include "content/common/drag_messages.h" | 14 #include "content/common/drag_messages.h" |
| 15 #include "content/common/gpu/gpu_messages.h" | 15 #include "content/common/gpu/gpu_messages.h" |
| 16 #include "content/public/browser/browser_context.h" | 16 #include "content/public/browser/browser_context.h" |
| 17 #include "content/public/browser/browser_plugin_guest_manager_delegate.h" | 17 #include "content/public/browser/browser_plugin_guest_manager.h" |
| 18 #include "content/public/browser/content_browser_client.h" | 18 #include "content/public/browser/content_browser_client.h" |
| 19 #include "content/public/browser/native_web_keyboard_event.h" | 19 #include "content/public/browser/native_web_keyboard_event.h" |
| 20 #include "content/public/browser/render_view_host.h" | 20 #include "content/public/browser/render_view_host.h" |
| 21 #include "content/public/browser/user_metrics.h" | 21 #include "content/public/browser/user_metrics.h" |
| 22 #include "content/public/common/content_switches.h" | 22 #include "content/public/common/content_switches.h" |
| 23 #include "content/public/common/result_codes.h" | 23 #include "content/public/common/result_codes.h" |
| 24 #include "content/public/common/url_constants.h" | 24 #include "content/public/common/url_constants.h" |
| 25 #include "net/base/escape.h" | 25 #include "net/base/escape.h" |
| 26 #include "ui/events/keycodes/keyboard_codes.h" | 26 #include "ui/events/keycodes/keyboard_codes.h" |
| 27 | 27 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 } | 59 } |
| 60 | 60 |
| 61 void BrowserPluginEmbedder::StartDrag(BrowserPluginGuest* guest) { | 61 void BrowserPluginEmbedder::StartDrag(BrowserPluginGuest* guest) { |
| 62 guest_started_drag_ = guest->AsWeakPtr(); | 62 guest_started_drag_ = guest->AsWeakPtr(); |
| 63 } | 63 } |
| 64 | 64 |
| 65 WebContentsImpl* BrowserPluginEmbedder::GetWebContents() const { | 65 WebContentsImpl* BrowserPluginEmbedder::GetWebContents() const { |
| 66 return static_cast<WebContentsImpl*>(web_contents()); | 66 return static_cast<WebContentsImpl*>(web_contents()); |
| 67 } | 67 } |
| 68 | 68 |
| 69 BrowserPluginGuestManagerDelegate* | 69 BrowserPluginGuestManager* |
| 70 BrowserPluginEmbedder::GetBrowserPluginGuestManager() const { | 70 BrowserPluginEmbedder::GetBrowserPluginGuestManager() const { |
| 71 return GetWebContents()->GetBrowserContext()->GetGuestManagerDelegate(); | 71 return GetWebContents()->GetBrowserContext()->GetGuestManager(); |
| 72 } | 72 } |
| 73 | 73 |
| 74 bool BrowserPluginEmbedder::DidSendScreenRectsCallback( | 74 bool BrowserPluginEmbedder::DidSendScreenRectsCallback( |
| 75 WebContents* guest_web_contents) { | 75 WebContents* guest_web_contents) { |
| 76 static_cast<RenderViewHostImpl*>( | 76 static_cast<RenderViewHostImpl*>( |
| 77 guest_web_contents->GetRenderViewHost())->SendScreenRects(); | 77 guest_web_contents->GetRenderViewHost())->SendScreenRects(); |
| 78 // Not handled => Iterate over all guests. | 78 // Not handled => Iterate over all guests. |
| 79 return false; | 79 return false; |
| 80 } | 80 } |
| 81 | 81 |
| (...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 } | 169 } |
| 170 | 170 |
| 171 void BrowserPluginEmbedder::GuestCallback( | 171 void BrowserPluginEmbedder::GuestCallback( |
| 172 int instance_id, | 172 int instance_id, |
| 173 const BrowserPluginHostMsg_Attach_Params& params, | 173 const BrowserPluginHostMsg_Attach_Params& params, |
| 174 const base::DictionaryValue* extra_params, | 174 const base::DictionaryValue* extra_params, |
| 175 WebContents* guest_web_contents) { | 175 WebContents* guest_web_contents) { |
| 176 BrowserPluginGuest* guest = guest_web_contents ? | 176 BrowserPluginGuest* guest = guest_web_contents ? |
| 177 static_cast<WebContentsImpl*>(guest_web_contents)-> | 177 static_cast<WebContentsImpl*>(guest_web_contents)-> |
| 178 GetBrowserPluginGuest() : NULL; | 178 GetBrowserPluginGuest() : NULL; |
| 179 BrowserPluginGuestManagerDelegate* guest_manager = | 179 BrowserPluginGuestManager* guest_manager = GetBrowserPluginGuestManager(); |
| 180 GetBrowserPluginGuestManager(); | |
| 181 if (guest) { | 180 if (guest) { |
| 182 // There is an implicit order expectation here: | 181 // There is an implicit order expectation here: |
| 183 // 1. The content embedder is made aware of the attachment. | 182 // 1. The content embedder is made aware of the attachment. |
| 184 // 2. BrowserPluginGuest::Attach is called. | 183 // 2. BrowserPluginGuest::Attach is called. |
| 185 // 3. The content embedder issues queued events if any that happened | 184 // 3. The content embedder issues queued events if any that happened |
| 186 // prior to attachment. | 185 // prior to attachment. |
| 187 GetContentClient()->browser()->GuestWebContentsAttached( | 186 GetContentClient()->browser()->GuestWebContentsAttached( |
| 188 guest->GetWebContents(), | 187 guest->GetWebContents(), |
| 189 GetWebContents(), | 188 GetWebContents(), |
| 190 *extra_params); | 189 *extra_params); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 219 GetBrowserPluginGuestManager()->MaybeGetGuestByInstanceIDOrKill( | 218 GetBrowserPluginGuestManager()->MaybeGetGuestByInstanceIDOrKill( |
| 220 instance_id, GetWebContents()->GetRenderProcessHost()->GetID(), | 219 instance_id, GetWebContents()->GetRenderProcessHost()->GetID(), |
| 221 base::Bind(&BrowserPluginEmbedder::GuestCallback, | 220 base::Bind(&BrowserPluginEmbedder::GuestCallback, |
| 222 base::Unretained(this), | 221 base::Unretained(this), |
| 223 instance_id, | 222 instance_id, |
| 224 params, | 223 params, |
| 225 &extra_params)); | 224 &extra_params)); |
| 226 } | 225 } |
| 227 | 226 |
| 228 } // namespace content | 227 } // namespace content |
| OLD | NEW |