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 "content/browser/browser_plugin/browser_plugin_guest.h" | 7 #include "content/browser/browser_plugin/browser_plugin_guest.h" |
8 #include "content/browser/renderer_host/render_view_host_impl.h" | 8 #include "content/browser/renderer_host/render_view_host_impl.h" |
9 #include "content/browser/web_contents/web_contents_impl.h" | 9 #include "content/browser/web_contents/web_contents_impl.h" |
10 #include "content/common/browser_plugin/browser_plugin_messages.h" | 10 #include "content/common/browser_plugin/browser_plugin_messages.h" |
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
173 | 173 |
174 bool event_consumed = false; | 174 bool event_consumed = false; |
175 GetBrowserPluginGuestManager()->ForEachGuest( | 175 GetBrowserPluginGuestManager()->ForEachGuest( |
176 web_contents(), | 176 web_contents(), |
177 base::Bind(&BrowserPluginEmbedder::UnlockMouseIfNecessaryCallback, | 177 base::Bind(&BrowserPluginEmbedder::UnlockMouseIfNecessaryCallback, |
178 &event_consumed)); | 178 &event_consumed)); |
179 | 179 |
180 return event_consumed; | 180 return event_consumed; |
181 } | 181 } |
182 | 182 |
183 bool BrowserPluginEmbedder::Find(int request_id, | 183 BrowserPluginGuest* BrowserPluginEmbedder::GetFullPageGuest() { |
184 const base::string16& search_text, | 184 BrowserPluginGuest* result = nullptr; |
185 const blink::WebFindOptions& options) { | 185 GetBrowserPluginGuestManager()->ForEachGuest( |
186 return GetBrowserPluginGuestManager()->ForEachGuest( | |
187 web_contents(), | 186 web_contents(), |
188 base::Bind(&BrowserPluginEmbedder::FindInGuest, | 187 base::Bind(&BrowserPluginEmbedder::GetFullPageGuestHelper, &result)); |
189 request_id, | 188 return result; |
190 search_text, | |
191 options)); | |
192 } | |
193 | |
194 bool BrowserPluginEmbedder::StopFinding(StopFindAction action) { | |
195 return GetBrowserPluginGuestManager()->ForEachGuest( | |
196 web_contents(), | |
197 base::Bind(&BrowserPluginEmbedder::StopFindingInGuest, action)); | |
198 } | 189 } |
199 | 190 |
200 // static | 191 // static |
201 bool BrowserPluginEmbedder::UnlockMouseIfNecessaryCallback(bool* mouse_unlocked, | 192 bool BrowserPluginEmbedder::UnlockMouseIfNecessaryCallback(bool* mouse_unlocked, |
202 WebContents* guest) { | 193 WebContents* guest) { |
203 *mouse_unlocked |= static_cast<WebContentsImpl*>(guest) | 194 *mouse_unlocked |= static_cast<WebContentsImpl*>(guest) |
204 ->GetBrowserPluginGuest() | 195 ->GetBrowserPluginGuest() |
205 ->mouse_locked(); | 196 ->mouse_locked(); |
206 guest->GotResponseToLockMouseRequest(false); | 197 guest->GotResponseToLockMouseRequest(false); |
207 | 198 |
208 // Returns false to iterate over all guests. | 199 // Returns false to iterate over all guests. |
209 return false; | 200 return false; |
210 } | 201 } |
211 | 202 |
212 // static | 203 // static |
213 bool BrowserPluginEmbedder::FindInGuest(int request_id, | 204 bool BrowserPluginEmbedder::GetFullPageGuestHelper( |
214 const base::string16& search_text, | 205 BrowserPluginGuest** result, |
215 const blink::WebFindOptions& options, | 206 WebContents* guest_web_contents) { |
216 WebContents* guest) { | 207 BrowserPluginGuest* guest = static_cast<WebContentsImpl*>( |
217 if (static_cast<WebContentsImpl*>(guest)->GetBrowserPluginGuest()->Find( | 208 guest_web_contents)->GetBrowserPluginGuest(); |
218 request_id, search_text, options)) { | 209 if (guest->is_full_page_plugin()) { |
219 // There can only ever currently be one browser plugin that handles find so | 210 *result = guest; |
220 // we can break the iteration at this point. | |
221 return true; | 211 return true; |
222 } | 212 } |
223 return false; | 213 return false; |
224 } | |
225 | |
226 bool BrowserPluginEmbedder::StopFindingInGuest(StopFindAction action, | |
227 WebContents* guest) { | |
228 if (static_cast<WebContentsImpl*>(guest)->GetBrowserPluginGuest() | |
229 ->StopFinding(action)) { | |
230 // There can only ever currently be one browser plugin that handles find so | |
231 // we can break the iteration at this point. | |
232 return true; | |
233 } | |
234 return false; | |
235 } | 214 } |
236 | 215 |
237 } // namespace content | 216 } // namespace content |
OLD | NEW |