Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(75)

Side by Side Diff: content/browser/browser_plugin/browser_plugin_guest_manager.cc

Issue 128563002: BrowserPlugin: Implemented BrowserPluginGuestManager::ForEachGuest (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 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_manager.h" 5 #include "content/browser/browser_plugin/browser_plugin_guest_manager.h"
6 6
7 #include "content/browser/browser_plugin/browser_plugin_guest.h" 7 #include "content/browser/browser_plugin/browser_plugin_guest.h"
8 #include "content/browser/browser_plugin/browser_plugin_host_factory.h" 8 #include "content/browser/browser_plugin/browser_plugin_host_factory.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"
11 #include "content/common/browser_plugin/browser_plugin_constants.h" 11 #include "content/common/browser_plugin/browser_plugin_constants.h"
12 #include "content/common/browser_plugin/browser_plugin_messages.h" 12 #include "content/common/browser_plugin/browser_plugin_messages.h"
13 #include "content/common/content_export.h" 13 #include "content/common/content_export.h"
14 #include "content/public/browser/render_process_host.h" 14 #include "content/public/browser/render_process_host.h"
15 #include "content/public/browser/user_metrics.h" 15 #include "content/public/browser/user_metrics.h"
16 #include "content/public/common/result_codes.h" 16 #include "content/public/common/result_codes.h"
17 #include "content/public/common/url_constants.h" 17 #include "content/public/common/url_constants.h"
18 #include "content/public/common/url_utils.h" 18 #include "content/public/common/url_utils.h"
19 #include "net/base/escape.h" 19 #include "net/base/escape.h"
20 #include "ui/events/keycodes/keyboard_codes.h"
21 20
22 namespace content { 21 namespace content {
23 22
24 // static 23 // static
25 BrowserPluginHostFactory* BrowserPluginGuestManager::factory_ = NULL; 24 BrowserPluginHostFactory* BrowserPluginGuestManager::factory_ = NULL;
26 25
27 BrowserPluginGuestManager::BrowserPluginGuestManager() 26 BrowserPluginGuestManager::BrowserPluginGuestManager()
28 : next_instance_id_(browser_plugin::kInstanceIDNone) { 27 : next_instance_id_(browser_plugin::kInstanceIDNone) {
29 } 28 }
30 29
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
217 // otherwise the ACK is handled by the guest. 216 // otherwise the ACK is handled by the guest.
218 void BrowserPluginGuestManager::OnUnhandledSwapBuffersACK( 217 void BrowserPluginGuestManager::OnUnhandledSwapBuffersACK(
219 int instance_id, 218 int instance_id,
220 const FrameHostMsg_BuffersSwappedACK_Params& params) { 219 const FrameHostMsg_BuffersSwappedACK_Params& params) {
221 BrowserPluginGuest::AcknowledgeBufferPresent(params.gpu_route_id, 220 BrowserPluginGuest::AcknowledgeBufferPresent(params.gpu_route_id,
222 params.gpu_host_id, 221 params.gpu_host_id,
223 params.mailbox_name, 222 params.mailbox_name,
224 params.sync_point); 223 params.sync_point);
225 } 224 }
226 225
227 void BrowserPluginGuestManager::DidSendScreenRects( 226 bool BrowserPluginGuestManager::ForEachGuest(
228 WebContentsImpl* embedder_web_contents) { 227 WebContentsImpl* embedder_web_contents,
229 // TODO(lazyboy): Generalize iterating over guest instances and performing 228 base::Callback<bool(BrowserPluginGuest*)> callback) {
230 // actions on the guests.
231 for (GuestInstanceMap::iterator it = 229 for (GuestInstanceMap::iterator it =
232 guest_web_contents_by_instance_id_.begin(); 230 guest_web_contents_by_instance_id_.begin();
233 it != guest_web_contents_by_instance_id_.end(); ++it) { 231 it != guest_web_contents_by_instance_id_.end(); ++it) {
234 BrowserPluginGuest* guest = it->second->GetBrowserPluginGuest(); 232 BrowserPluginGuest* guest = it->second->GetBrowserPluginGuest();
235 if (embedder_web_contents == guest->embedder_web_contents()) { 233 if (embedder_web_contents != guest->embedder_web_contents())
236 static_cast<RenderViewHostImpl*>( 234 continue;
237 guest->GetWebContents()->GetRenderViewHost())->SendScreenRects();
238 }
239 }
240 }
241 235
242 bool BrowserPluginGuestManager::UnlockMouseIfNecessary( 236 if (callback.Run(guest))
nasko 2014/01/08 17:58:42 nit: I see that this fits in how HandleInputEvent
Fady Samuel 2014/01/08 18:22:40 Agreed, but I can't think of a better way to do th
243 WebContentsImpl* embedder_web_contents, 237 return true;
244 const NativeWebKeyboardEvent& event) {
245 if ((event.type != blink::WebInputEvent::RawKeyDown) ||
246 (event.windowsKeyCode != ui::VKEY_ESCAPE) ||
247 (event.modifiers & blink::WebInputEvent::InputModifiers)) {
248 return false;
249 }
250
251 // TODO(lazyboy): Generalize iterating over guest instances and performing
252 // actions on the guests.
253 for (GuestInstanceMap::iterator it =
254 guest_web_contents_by_instance_id_.begin();
255 it != guest_web_contents_by_instance_id_.end(); ++it) {
256 BrowserPluginGuest* guest = it->second->GetBrowserPluginGuest();
257 if (embedder_web_contents == guest->embedder_web_contents()) {
258 if (guest->UnlockMouseIfNecessary(event))
259 return true;
260 }
261 } 238 }
262 return false; 239 return false;
263 } 240 }
264 241
265 } // namespace content 242 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698