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_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" |
| 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/drag_messages.h" | 13 #include "content/common/drag_messages.h" |
| 14 #include "content/common/gpu/gpu_messages.h" | 14 #include "content/common/gpu/gpu_messages.h" |
| 15 #include "content/public/browser/browser_context.h" | 15 #include "content/public/browser/browser_context.h" |
| 16 #include "content/public/browser/browser_plugin_guest_manager.h" | 16 #include "content/public/browser/browser_plugin_guest_manager.h" |
| 17 #include "content/public/browser/content_browser_client.h" | 17 #include "content/public/browser/content_browser_client.h" |
| 18 #include "content/public/browser/native_web_keyboard_event.h" | 18 #include "content/public/browser/native_web_keyboard_event.h" |
| 19 #include "content/public/browser/render_view_host.h" | 19 #include "content/public/browser/render_view_host.h" |
| 20 #include "content/public/browser/user_metrics.h" | 20 #include "content/public/browser/user_metrics.h" |
| 21 #include "content/public/common/content_switches.h" | 21 #include "content/public/common/content_switches.h" |
| 22 #include "content/public/common/result_codes.h" | 22 #include "content/public/common/result_codes.h" |
| 23 #include "content/public/common/url_constants.h" | 23 #include "content/public/common/url_constants.h" |
| 24 #include "net/base/escape.h" | 24 #include "net/base/escape.h" |
| 25 #include "third_party/WebKit/public/web/WebFindOptions.h" | |
| 25 #include "ui/events/keycodes/keyboard_codes.h" | 26 #include "ui/events/keycodes/keyboard_codes.h" |
| 26 | 27 |
| 27 namespace content { | 28 namespace content { |
| 28 | 29 |
| 29 BrowserPluginEmbedder::BrowserPluginEmbedder(WebContentsImpl* web_contents) | 30 BrowserPluginEmbedder::BrowserPluginEmbedder(WebContentsImpl* web_contents) |
| 30 : WebContentsObserver(web_contents), | 31 : WebContentsObserver(web_contents), |
| 31 guest_drag_ending_(false), | 32 guest_drag_ending_(false), |
| 32 weak_ptr_factory_(this) { | 33 weak_ptr_factory_(this) { |
| 33 } | 34 } |
| 34 | 35 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 155 bool event_consumed = false; | 156 bool event_consumed = false; |
| 156 GetBrowserPluginGuestManager()->ForEachGuest( | 157 GetBrowserPluginGuestManager()->ForEachGuest( |
| 157 GetWebContents(), | 158 GetWebContents(), |
| 158 base::Bind(&BrowserPluginEmbedder::UnlockMouseIfNecessaryCallback, | 159 base::Bind(&BrowserPluginEmbedder::UnlockMouseIfNecessaryCallback, |
| 159 base::Unretained(this), | 160 base::Unretained(this), |
| 160 &event_consumed)); | 161 &event_consumed)); |
| 161 | 162 |
| 162 return event_consumed; | 163 return event_consumed; |
| 163 } | 164 } |
| 164 | 165 |
| 166 bool BrowserPluginEmbedder::Find(int request_id, | |
| 167 const base::string16& search_text, | |
| 168 const blink::WebFindOptions& options) { | |
| 169 return GetBrowserPluginGuestManager()->ForEachGuest( | |
| 170 GetWebContents(), base::Bind( | |
| 171 &BrowserPluginEmbedder::FindInGuest, | |
| 172 base::Unretained(this), request_id, search_text, options)); | |
| 173 } | |
| 174 | |
| 165 bool BrowserPluginEmbedder::UnlockMouseIfNecessaryCallback(bool* mouse_unlocked, | 175 bool BrowserPluginEmbedder::UnlockMouseIfNecessaryCallback(bool* mouse_unlocked, |
| 166 WebContents* guest) { | 176 WebContents* guest) { |
| 167 *mouse_unlocked |= static_cast<WebContentsImpl*>(guest) | 177 *mouse_unlocked |= static_cast<WebContentsImpl*>(guest) |
| 168 ->GetBrowserPluginGuest() | 178 ->GetBrowserPluginGuest() |
| 169 ->mouse_locked(); | 179 ->mouse_locked(); |
| 170 guest->GotResponseToLockMouseRequest(false); | 180 guest->GotResponseToLockMouseRequest(false); |
| 171 | 181 |
| 172 // Returns false to iterate over all guests. | 182 // Returns false to iterate over all guests. |
| 173 return false; | 183 return false; |
| 174 } | 184 } |
| 175 | 185 |
| 186 bool BrowserPluginEmbedder::FindInGuest(int request_id, | |
| 187 const base::string16& search_text, | |
| 188 const blink::WebFindOptions& options, | |
| 189 WebContents* guest) { | |
| 190 // XXX: Check if |guest| is a top level frame in the browser. How can I find | |
| 191 // this out?? We can check if the embedder WebContents is a top level frame | |
| 192 // but afaik it may have several guests. Is there a away to see if the guest | |
| 193 // is the only guest and it is top level in the sense that it is not embedded | |
| 194 // within a page? | |
|
raymes
2014/09/25 06:59:06
fsamuel@: Do you have any idea whether this is pos
Fady Samuel
2014/09/25 10:41:29
We can probably detect if the BrowserPlugin is in
raymes
2014/09/29 05:01:34
Hmm I'm not exactly sure which part you would like
Fady Samuel
2014/09/29 12:01:34
Yes. The reason I'd do that is so that other Brows
| |
| 195 static_cast<WebContentsImpl*>(guest)->Find(request_id, search_text, options); | |
| 196 return true; | |
| 197 } | |
| 198 | |
| 176 } // namespace content | 199 } // namespace content |
| OLD | NEW |