OLD | NEW |
---|---|
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 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/renderer/render_frame_impl.h" | 5 #include "content/renderer/render_frame_impl.h" |
6 | 6 |
7 #include <map> | 7 #include <map> |
8 #include <string> | 8 #include <string> |
9 #include <utility> | 9 #include <utility> |
10 #include <vector> | 10 #include <vector> |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
148 #include "third_party/WebKit/public/platform/WebData.h" | 148 #include "third_party/WebKit/public/platform/WebData.h" |
149 #include "third_party/WebKit/public/platform/WebStorageQuotaCallbacks.h" | 149 #include "third_party/WebKit/public/platform/WebStorageQuotaCallbacks.h" |
150 #include "third_party/WebKit/public/platform/WebString.h" | 150 #include "third_party/WebKit/public/platform/WebString.h" |
151 #include "third_party/WebKit/public/platform/WebURL.h" | 151 #include "third_party/WebKit/public/platform/WebURL.h" |
152 #include "third_party/WebKit/public/platform/WebURLError.h" | 152 #include "third_party/WebKit/public/platform/WebURLError.h" |
153 #include "third_party/WebKit/public/platform/WebURLResponse.h" | 153 #include "third_party/WebKit/public/platform/WebURLResponse.h" |
154 #include "third_party/WebKit/public/platform/WebVector.h" | 154 #include "third_party/WebKit/public/platform/WebVector.h" |
155 #include "third_party/WebKit/public/platform/modules/webusb/WebUSBClient.h" | 155 #include "third_party/WebKit/public/platform/modules/webusb/WebUSBClient.h" |
156 #include "third_party/WebKit/public/web/WebColorSuggestion.h" | 156 #include "third_party/WebKit/public/web/WebColorSuggestion.h" |
157 #include "third_party/WebKit/public/web/WebDocument.h" | 157 #include "third_party/WebKit/public/web/WebDocument.h" |
158 #include "third_party/WebKit/public/web/WebFindOptions.h" | |
158 #include "third_party/WebKit/public/web/WebFrameSerializer.h" | 159 #include "third_party/WebKit/public/web/WebFrameSerializer.h" |
159 #include "third_party/WebKit/public/web/WebFrameWidget.h" | 160 #include "third_party/WebKit/public/web/WebFrameWidget.h" |
160 #include "third_party/WebKit/public/web/WebKit.h" | 161 #include "third_party/WebKit/public/web/WebKit.h" |
161 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 162 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
162 #include "third_party/WebKit/public/web/WebMediaStreamRegistry.h" | 163 #include "third_party/WebKit/public/web/WebMediaStreamRegistry.h" |
163 #include "third_party/WebKit/public/web/WebNavigationPolicy.h" | 164 #include "third_party/WebKit/public/web/WebNavigationPolicy.h" |
164 #include "third_party/WebKit/public/web/WebPlugin.h" | 165 #include "third_party/WebKit/public/web/WebPlugin.h" |
166 #include "third_party/WebKit/public/web/WebPluginContainer.h" | |
167 #include "third_party/WebKit/public/web/WebPluginDocument.h" | |
165 #include "third_party/WebKit/public/web/WebPluginParams.h" | 168 #include "third_party/WebKit/public/web/WebPluginParams.h" |
166 #include "third_party/WebKit/public/web/WebRange.h" | 169 #include "third_party/WebKit/public/web/WebRange.h" |
167 #include "third_party/WebKit/public/web/WebScopedUserGesture.h" | 170 #include "third_party/WebKit/public/web/WebScopedUserGesture.h" |
168 #include "third_party/WebKit/public/web/WebScriptSource.h" | 171 #include "third_party/WebKit/public/web/WebScriptSource.h" |
169 #include "third_party/WebKit/public/web/WebSearchableFormData.h" | 172 #include "third_party/WebKit/public/web/WebSearchableFormData.h" |
170 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" | 173 #include "third_party/WebKit/public/web/WebSecurityOrigin.h" |
171 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" | 174 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
172 #include "third_party/WebKit/public/web/WebSerializedScriptValue.h" | 175 #include "third_party/WebKit/public/web/WebSerializedScriptValue.h" |
173 #include "third_party/WebKit/public/web/WebSettings.h" | 176 #include "third_party/WebKit/public/web/WebSettings.h" |
174 #include "third_party/WebKit/public/web/WebSurroundingText.h" | 177 #include "third_party/WebKit/public/web/WebSurroundingText.h" |
(...skipping 20 matching lines...) Expand all Loading... | |
195 | 198 |
196 #include "content/common/gpu/client/context_provider_command_buffer.h" | 199 #include "content/common/gpu/client/context_provider_command_buffer.h" |
197 #include "content/renderer/android/synchronous_compositor_factory.h" | 200 #include "content/renderer/android/synchronous_compositor_factory.h" |
198 #include "content/renderer/java/gin_java_bridge_dispatcher.h" | 201 #include "content/renderer/java/gin_java_bridge_dispatcher.h" |
199 #include "content/renderer/media/android/renderer_media_player_manager.h" | 202 #include "content/renderer/media/android/renderer_media_player_manager.h" |
200 #include "content/renderer/media/android/renderer_media_session_manager.h" | 203 #include "content/renderer/media/android/renderer_media_session_manager.h" |
201 #include "content/renderer/media/android/stream_texture_factory_impl.h" | 204 #include "content/renderer/media/android/stream_texture_factory_impl.h" |
202 #include "content/renderer/media/android/webmediaplayer_android.h" | 205 #include "content/renderer/media/android/webmediaplayer_android.h" |
203 #include "content/renderer/media/android/webmediasession_android.h" | 206 #include "content/renderer/media/android/webmediasession_android.h" |
204 #include "media/base/android/media_codec_util.h" | 207 #include "media/base/android/media_codec_util.h" |
208 #include "third_party/WebKit/public/platform/WebFloatPoint.h" | |
205 #else | 209 #else |
206 #include "cc/blink/context_provider_web_context.h" | 210 #include "cc/blink/context_provider_web_context.h" |
207 #include "device/devices_app/public/cpp/constants.h" | 211 #include "device/devices_app/public/cpp/constants.h" |
208 #endif | 212 #endif |
209 | 213 |
210 #if defined(ENABLE_PEPPER_CDMS) | 214 #if defined(ENABLE_PEPPER_CDMS) |
211 #include "content/renderer/media/cdm/pepper_cdm_wrapper_impl.h" | 215 #include "content/renderer/media/cdm/pepper_cdm_wrapper_impl.h" |
212 #elif defined(ENABLE_BROWSER_CDMS) | 216 #elif defined(ENABLE_BROWSER_CDMS) |
213 #include "content/renderer/media/cdm/renderer_cdm_manager.h" | 217 #include "content/renderer/media/cdm/renderer_cdm_manager.h" |
214 #endif | 218 #endif |
(...skipping 19 matching lines...) Expand all Loading... | |
234 using blink::WebContextMenuData; | 238 using blink::WebContextMenuData; |
235 using blink::WebCString; | 239 using blink::WebCString; |
236 using blink::WebData; | 240 using blink::WebData; |
237 using blink::WebDataSource; | 241 using blink::WebDataSource; |
238 using blink::WebDocument; | 242 using blink::WebDocument; |
239 using blink::WebDOMEvent; | 243 using blink::WebDOMEvent; |
240 using blink::WebDOMMessageEvent; | 244 using blink::WebDOMMessageEvent; |
241 using blink::WebElement; | 245 using blink::WebElement; |
242 using blink::WebExternalPopupMenu; | 246 using blink::WebExternalPopupMenu; |
243 using blink::WebExternalPopupMenuClient; | 247 using blink::WebExternalPopupMenuClient; |
248 using blink::WebFindOptions; | |
244 using blink::WebFrame; | 249 using blink::WebFrame; |
245 using blink::WebFrameSerializer; | 250 using blink::WebFrameSerializer; |
246 using blink::WebFrameSerializerClient; | 251 using blink::WebFrameSerializerClient; |
247 using blink::WebHistoryItem; | 252 using blink::WebHistoryItem; |
248 using blink::WebHTTPBody; | 253 using blink::WebHTTPBody; |
249 using blink::WebLocalFrame; | 254 using blink::WebLocalFrame; |
250 using blink::WebMediaPlayer; | 255 using blink::WebMediaPlayer; |
251 using blink::WebMediaPlayerClient; | 256 using blink::WebMediaPlayerClient; |
252 using blink::WebMediaPlayerEncryptedMediaClient; | 257 using blink::WebMediaPlayerEncryptedMediaClient; |
253 using blink::WebMediaSession; | 258 using blink::WebMediaSession; |
254 using blink::WebNavigationPolicy; | 259 using blink::WebNavigationPolicy; |
255 using blink::WebNavigationType; | 260 using blink::WebNavigationType; |
256 using blink::WebNode; | 261 using blink::WebNode; |
262 using blink::WebPluginDocument; | |
257 using blink::WebPluginParams; | 263 using blink::WebPluginParams; |
258 using blink::WebPopupMenuInfo; | 264 using blink::WebPopupMenuInfo; |
259 using blink::WebRange; | 265 using blink::WebRange; |
266 using blink::WebRect; | |
260 using blink::WebReferrerPolicy; | 267 using blink::WebReferrerPolicy; |
261 using blink::WebScriptSource; | 268 using blink::WebScriptSource; |
262 using blink::WebSearchableFormData; | 269 using blink::WebSearchableFormData; |
263 using blink::WebSecurityOrigin; | 270 using blink::WebSecurityOrigin; |
264 using blink::WebSecurityPolicy; | 271 using blink::WebSecurityPolicy; |
265 using blink::WebSerializedScriptValue; | 272 using blink::WebSerializedScriptValue; |
266 using blink::WebServiceWorkerProvider; | 273 using blink::WebServiceWorkerProvider; |
267 using blink::WebSettings; | 274 using blink::WebSettings; |
268 using blink::WebStorageQuotaCallbacks; | 275 using blink::WebStorageQuotaCallbacks; |
269 using blink::WebString; | 276 using blink::WebString; |
270 using blink::WebURL; | 277 using blink::WebURL; |
271 using blink::WebURLError; | 278 using blink::WebURLError; |
272 using blink::WebURLRequest; | 279 using blink::WebURLRequest; |
273 using blink::WebURLResponse; | 280 using blink::WebURLResponse; |
274 using blink::WebUserGestureIndicator; | 281 using blink::WebUserGestureIndicator; |
275 using blink::WebVector; | 282 using blink::WebVector; |
276 using blink::WebView; | 283 using blink::WebView; |
277 using base::Time; | 284 using base::Time; |
278 using base::TimeDelta; | 285 using base::TimeDelta; |
279 | 286 |
287 #if defined(OS_ANDROID) | |
288 using blink::WebFloatPoint; | |
289 using blink::WebFloatRect; | |
290 #endif | |
291 | |
280 namespace content { | 292 namespace content { |
281 | 293 |
282 namespace { | 294 namespace { |
283 | 295 |
284 const char kDefaultAcceptHeader[] = | 296 const char kDefaultAcceptHeader[] = |
285 "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/" | 297 "text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/" |
286 "*;q=0.8"; | 298 "*;q=0.8"; |
287 const char kAcceptHeader[] = "Accept"; | 299 const char kAcceptHeader[] = "Accept"; |
288 | 300 |
289 const size_t kExtraCharsBeforeAndAfterSelection = 100; | 301 const size_t kExtraCharsBeforeAndAfterSelection = 100; |
(...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
902 in_browser_initiated_detach_(false), | 914 in_browser_initiated_detach_(false), |
903 in_frame_tree_(false), | 915 in_frame_tree_(false), |
904 render_view_(params.render_view->AsWeakPtr()), | 916 render_view_(params.render_view->AsWeakPtr()), |
905 routing_id_(params.routing_id), | 917 routing_id_(params.routing_id), |
906 is_swapped_out_(false), | 918 is_swapped_out_(false), |
907 render_frame_proxy_(NULL), | 919 render_frame_proxy_(NULL), |
908 is_detaching_(false), | 920 is_detaching_(false), |
909 proxy_routing_id_(MSG_ROUTING_NONE), | 921 proxy_routing_id_(MSG_ROUTING_NONE), |
910 #if defined(ENABLE_PLUGINS) | 922 #if defined(ENABLE_PLUGINS) |
911 plugin_power_saver_helper_(nullptr), | 923 plugin_power_saver_helper_(nullptr), |
924 plugin_find_handler_(nullptr), | |
912 #endif | 925 #endif |
913 cookie_jar_(this), | 926 cookie_jar_(this), |
914 selection_text_offset_(0), | 927 selection_text_offset_(0), |
915 selection_range_(gfx::Range::InvalidRange()), | 928 selection_range_(gfx::Range::InvalidRange()), |
916 handling_select_range_(false), | 929 handling_select_range_(false), |
917 notification_permission_dispatcher_(NULL), | 930 notification_permission_dispatcher_(NULL), |
918 web_user_media_client_(NULL), | 931 web_user_media_client_(NULL), |
919 media_permission_dispatcher_(NULL), | 932 media_permission_dispatcher_(NULL), |
920 midi_dispatcher_(NULL), | 933 midi_dispatcher_(NULL), |
921 #if defined(OS_ANDROID) | 934 #if defined(OS_ANDROID) |
(...skipping 426 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1348 IPC_MESSAGE_HANDLER(FrameMsg_SetFocusedFrame, OnSetFocusedFrame) | 1361 IPC_MESSAGE_HANDLER(FrameMsg_SetFocusedFrame, OnSetFocusedFrame) |
1349 IPC_MESSAGE_HANDLER(FrameMsg_SetTextTrackSettings, | 1362 IPC_MESSAGE_HANDLER(FrameMsg_SetTextTrackSettings, |
1350 OnTextTrackSettingsChanged) | 1363 OnTextTrackSettingsChanged) |
1351 IPC_MESSAGE_HANDLER(FrameMsg_PostMessageEvent, OnPostMessageEvent) | 1364 IPC_MESSAGE_HANDLER(FrameMsg_PostMessageEvent, OnPostMessageEvent) |
1352 IPC_MESSAGE_HANDLER(FrameMsg_FailedNavigation, OnFailedNavigation) | 1365 IPC_MESSAGE_HANDLER(FrameMsg_FailedNavigation, OnFailedNavigation) |
1353 IPC_MESSAGE_HANDLER(FrameMsg_GetSavableResourceLinks, | 1366 IPC_MESSAGE_HANDLER(FrameMsg_GetSavableResourceLinks, |
1354 OnGetSavableResourceLinks) | 1367 OnGetSavableResourceLinks) |
1355 IPC_MESSAGE_HANDLER(FrameMsg_GetSerializedHtmlWithLocalLinks, | 1368 IPC_MESSAGE_HANDLER(FrameMsg_GetSerializedHtmlWithLocalLinks, |
1356 OnGetSerializedHtmlWithLocalLinks) | 1369 OnGetSerializedHtmlWithLocalLinks) |
1357 IPC_MESSAGE_HANDLER(FrameMsg_SerializeAsMHTML, OnSerializeAsMHTML) | 1370 IPC_MESSAGE_HANDLER(FrameMsg_SerializeAsMHTML, OnSerializeAsMHTML) |
1371 IPC_MESSAGE_HANDLER(FrameMsg_Find, OnFind) | |
1372 IPC_MESSAGE_HANDLER(FrameMsg_StopFinding, OnStopFinding) | |
1358 #if defined(OS_ANDROID) | 1373 #if defined(OS_ANDROID) |
1374 IPC_MESSAGE_HANDLER(InputMsg_ActivateNearestFindResult, | |
1375 OnActivateNearestFindResult) | |
1376 IPC_MESSAGE_HANDLER(FrameMsg_FindMatchRects, OnFindMatchRects) | |
1359 IPC_MESSAGE_HANDLER(FrameMsg_SelectPopupMenuItems, OnSelectPopupMenuItems) | 1377 IPC_MESSAGE_HANDLER(FrameMsg_SelectPopupMenuItems, OnSelectPopupMenuItems) |
1360 #elif defined(OS_MACOSX) | 1378 #elif defined(OS_MACOSX) |
1361 IPC_MESSAGE_HANDLER(FrameMsg_SelectPopupMenuItem, OnSelectPopupMenuItem) | 1379 IPC_MESSAGE_HANDLER(FrameMsg_SelectPopupMenuItem, OnSelectPopupMenuItem) |
1362 IPC_MESSAGE_HANDLER(InputMsg_CopyToFindPboard, OnCopyToFindPboard) | 1380 IPC_MESSAGE_HANDLER(InputMsg_CopyToFindPboard, OnCopyToFindPboard) |
1363 #endif | 1381 #endif |
1364 IPC_END_MESSAGE_MAP() | 1382 IPC_END_MESSAGE_MAP() |
1365 | 1383 |
1366 return handled; | 1384 return handled; |
1367 } | 1385 } |
1368 | 1386 |
(...skipping 677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2046 } | 2064 } |
2047 | 2065 |
2048 WebDOMMessageEvent msg_event(serialized_script_value, | 2066 WebDOMMessageEvent msg_event(serialized_script_value, |
2049 params.source_origin, | 2067 params.source_origin, |
2050 source_frame, | 2068 source_frame, |
2051 frame_->document(), | 2069 frame_->document(), |
2052 channels); | 2070 channels); |
2053 frame_->dispatchMessageEventWithOriginCheck(target_origin, msg_event); | 2071 frame_->dispatchMessageEventWithOriginCheck(target_origin, msg_event); |
2054 } | 2072 } |
2055 | 2073 |
2056 #if defined(OS_ANDROID) | |
2057 void RenderFrameImpl::OnSelectPopupMenuItems( | |
2058 bool canceled, | |
2059 const std::vector<int>& selected_indices) { | |
2060 // It is possible to receive more than one of these calls if the user presses | |
2061 // a select faster than it takes for the show-select-popup IPC message to make | |
2062 // it to the browser UI thread. Ignore the extra-messages. | |
2063 // TODO(jcivelli): http:/b/5793321 Implement a better fix, as detailed in bug. | |
2064 if (!external_popup_menu_) | |
2065 return; | |
2066 | |
2067 external_popup_menu_->DidSelectItems(canceled, selected_indices); | |
2068 external_popup_menu_.reset(); | |
2069 } | |
2070 #endif | |
2071 | |
2072 #if defined(OS_MACOSX) | |
2073 void RenderFrameImpl::OnSelectPopupMenuItem(int selected_index) { | |
2074 if (external_popup_menu_ == NULL) | |
2075 return; | |
2076 external_popup_menu_->DidSelectItem(selected_index); | |
2077 external_popup_menu_.reset(); | |
2078 } | |
2079 #endif | |
2080 | |
2081 void RenderFrameImpl::OnReload(bool ignore_cache) { | 2074 void RenderFrameImpl::OnReload(bool ignore_cache) { |
2082 frame_->reload(ignore_cache); | 2075 frame_->reload(ignore_cache); |
2083 } | 2076 } |
2084 | 2077 |
2085 void RenderFrameImpl::OnTextSurroundingSelectionRequest(size_t max_length) { | 2078 void RenderFrameImpl::OnTextSurroundingSelectionRequest(size_t max_length) { |
2086 blink::WebSurroundingText surroundingText; | 2079 blink::WebSurroundingText surroundingText; |
2087 surroundingText.initialize(frame_->selectionRange(), max_length); | 2080 surroundingText.initialize(frame_->selectionRange(), max_length); |
2088 | 2081 |
2089 if (surroundingText.isNull()) { | 2082 if (surroundingText.isNull()) { |
2090 // |surroundingText| might not be correctly initialized, for example if | 2083 // |surroundingText| might not be correctly initialized, for example if |
(...skipping 1872 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
3963 } | 3956 } |
3964 } | 3957 } |
3965 | 3958 |
3966 void RenderFrameImpl::reportFindInPageMatchCount(int request_id, | 3959 void RenderFrameImpl::reportFindInPageMatchCount(int request_id, |
3967 int count, | 3960 int count, |
3968 bool final_update) { | 3961 bool final_update) { |
3969 int active_match_ordinal = -1; // -1 = don't update active match ordinal | 3962 int active_match_ordinal = -1; // -1 = don't update active match ordinal |
3970 if (!count) | 3963 if (!count) |
3971 active_match_ordinal = 0; | 3964 active_match_ordinal = 0; |
3972 | 3965 |
3973 render_view_->Send(new ViewHostMsg_Find_Reply( | 3966 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, count, gfx::Rect(), |
3974 render_view_->GetRoutingID(), request_id, count, | 3967 active_match_ordinal, final_update)); |
3975 gfx::Rect(), active_match_ordinal, final_update)); | |
3976 } | 3968 } |
3977 | 3969 |
3978 void RenderFrameImpl::reportFindInPageSelection( | 3970 void RenderFrameImpl::reportFindInPageSelection( |
3979 int request_id, | 3971 int request_id, |
3980 int active_match_ordinal, | 3972 int active_match_ordinal, |
3981 const blink::WebRect& selection_rect) { | 3973 const blink::WebRect& selection_rect) { |
3982 render_view_->Send(new ViewHostMsg_Find_Reply( | 3974 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, -1, selection_rect, |
3983 render_view_->GetRoutingID(), request_id, -1, selection_rect, | 3975 active_match_ordinal, false)); |
3984 active_match_ordinal, false)); | |
3985 } | 3976 } |
3986 | 3977 |
3987 void RenderFrameImpl::requestStorageQuota( | 3978 void RenderFrameImpl::requestStorageQuota( |
3988 blink::WebLocalFrame* frame, | 3979 blink::WebLocalFrame* frame, |
3989 blink::WebStorageQuotaType type, | 3980 blink::WebStorageQuotaType type, |
3990 unsigned long long requested_size, | 3981 unsigned long long requested_size, |
3991 blink::WebStorageQuotaCallbacks callbacks) { | 3982 blink::WebStorageQuotaCallbacks callbacks) { |
3992 DCHECK(!frame_ || frame_ == frame); | 3983 DCHECK(!frame_ || frame_ == frame); |
3993 WebSecurityOrigin origin = frame->document().securityOrigin(); | 3984 WebSecurityOrigin origin = frame->document().securityOrigin(); |
3994 if (origin.isUnique()) { | 3985 if (origin.isUnique()) { |
(...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
4946 } | 4937 } |
4947 } | 4938 } |
4948 | 4939 |
4949 // Cleanup and notify the browser process about completion. | 4940 // Cleanup and notify the browser process about completion. |
4950 file.Close(); // Need to flush file contents before sending IPC response. | 4941 file.Close(); // Need to flush file contents before sending IPC response. |
4951 Send(new FrameHostMsg_SerializeAsMHTMLResponse( | 4942 Send(new FrameHostMsg_SerializeAsMHTMLResponse( |
4952 routing_id_, params.job_id, success, | 4943 routing_id_, params.job_id, success, |
4953 digests_of_uris_of_serialized_resources)); | 4944 digests_of_uris_of_serialized_resources)); |
4954 } | 4945 } |
4955 | 4946 |
4947 void RenderFrameImpl::OnFind(int request_id, | |
4948 const base::string16& search_text, | |
4949 const WebFindOptions& options) { | |
4950 // This should only be received on the main frame, since find-in-page is | |
4951 // currently orchestrated by the main frame. | |
4952 if (!is_main_frame_) { | |
4953 NOTREACHED(); | |
4954 return; | |
4955 } | |
4956 | |
4957 DCHECK(!search_text.empty()); | |
4958 | |
4959 blink::WebPlugin* plugin = GetWebPluginForFind(); | |
4960 // Check if the plugin still exists in the document. | |
4961 if (plugin) { | |
4962 if (options.findNext) { | |
4963 // Just navigate back/forward. | |
4964 plugin->selectFindResult(options.forward); | |
4965 } else { | |
4966 if (!plugin->startFind(search_text, options.matchCase, request_id)) { | |
4967 // Send "no results". | |
4968 SendFindReply(request_id, 0, 0, gfx::Rect(), true); | |
4969 } | |
4970 } | |
4971 return; | |
4972 } | |
4973 | |
4974 WebFrame* main_frame = GetWebFrame(); | |
4975 WebFrame* frame_after_main = main_frame->traverseNext(true); | |
4976 WebFrame* focused_frame = render_view_->webview()->focusedFrame(); | |
4977 WebFrame* search_frame = focused_frame; // start searching focused frame. | |
4978 | |
4979 bool multi_frame = (frame_after_main != main_frame); | |
4980 | |
4981 // If we have multiple frames, we don't want to wrap the search within the | |
4982 // frame, so we check here if we only have main_frame in the chain. | |
4983 bool wrap_within_frame = !multi_frame; | |
4984 | |
4985 WebRect selection_rect; | |
4986 bool result = false; | |
4987 | |
4988 // If something is selected when we start searching it means we cannot just | |
4989 // increment the current match ordinal; we need to re-generate it. | |
4990 WebRange current_selection = focused_frame->selectionRange(); | |
4991 | |
4992 do { | |
4993 result = search_frame->find(request_id, search_text, options, | |
4994 wrap_within_frame, &selection_rect); | |
4995 | |
4996 if (!result) { | |
4997 // don't leave text selected as you move to the next frame. | |
Charlie Reis
2016/01/21 00:02:28
nit: Don't
paulmeyer
2016/01/21 14:25:46
Done.
| |
4998 search_frame->executeCommand(WebString::fromUTF8("Unselect"), | |
4999 GetFocusedElement()); | |
5000 | |
5001 // Find the next frame, but skip the invisible ones. | |
5002 do { | |
5003 // What is the next frame to search? (we might be going backwards). Note | |
Charlie Reis
2016/01/21 00:02:28
nit: We
paulmeyer
2016/01/21 14:25:46
Done.
| |
5004 // that we specify wrap=true so that search_frame never becomes NULL. | |
5005 search_frame = options.forward ? search_frame->traverseNext(true) | |
5006 : search_frame->traversePrevious(true); | |
5007 } while (!search_frame->hasVisibleContent() && | |
5008 search_frame != focused_frame); | |
5009 | |
5010 // Make sure selection doesn't affect the search operation in new frame. | |
5011 search_frame->executeCommand(WebString::fromUTF8("Unselect"), | |
5012 GetFocusedElement()); | |
5013 | |
5014 // If we have multiple frames and we have wrapped back around to the | |
5015 // focused frame, we need to search it once more allowing wrap within | |
5016 // the frame, otherwise it will report 'no match' if the focused frame has | |
5017 // reported matches, but no frames after the focused_frame contain a | |
5018 // match for the search word(s). | |
5019 if (multi_frame && search_frame == focused_frame) { | |
5020 result = search_frame->find(request_id, search_text, options, | |
5021 true, // Force wrapping. | |
5022 &selection_rect); | |
5023 } | |
5024 } | |
5025 | |
5026 render_view_->webview()->setFocusedFrame(search_frame); | |
5027 } while (!result && search_frame != focused_frame); | |
5028 | |
5029 if (options.findNext && current_selection.isNull()) { | |
5030 // Force the main_frame to report the actual count. | |
5031 main_frame->increaseMatchCount(0, request_id); | |
5032 } else { | |
5033 // If nothing is found, set result to "0 of 0", otherwise, set it to | |
5034 // "-1 of 1" to indicate that we found at least one item, but we don't know | |
5035 // yet what is active. | |
5036 int ordinal = result ? -1 : 0; // -1 here means, we might know more later. | |
Charlie Reis
2016/01/21 00:02:28
nit: Drop comma.
paulmeyer
2016/01/21 14:25:46
Done.
| |
5037 int match_count = result ? 1 : 0; // 1 here means possibly more coming. | |
5038 | |
5039 // If we find no matches then this will be our last status update. | |
5040 // Otherwise the scoping effort will send more results. | |
5041 bool final_status_update = !result; | |
5042 | |
5043 SendFindReply(request_id, match_count, ordinal, selection_rect, | |
5044 final_status_update); | |
5045 | |
5046 // Scoping effort begins, starting with the mainframe. | |
Charlie Reis
2016/01/21 00:02:28
nit: main frame.
paulmeyer
2016/01/21 14:25:46
Done.
| |
5047 search_frame = main_frame; | |
5048 | |
5049 main_frame->resetMatchCount(); | |
5050 | |
5051 do { | |
5052 // Cancel all old scoping requests before starting a new one. | |
5053 search_frame->cancelPendingScopingEffort(); | |
5054 | |
5055 // We don't start another scoping effort unless at least one match has | |
5056 // been found. | |
5057 if (result) { | |
5058 // Start new scoping request. If the scoping function determines that it | |
5059 // needs to scope, it will defer until later. | |
5060 search_frame->scopeStringMatches(request_id, search_text, options, | |
5061 true); // reset the tickmarks | |
5062 } | |
5063 | |
5064 // Iterate to the next frame. The frame will not necessarily scope, for | |
5065 // example if it is not visible. | |
5066 search_frame = search_frame->traverseNext(true); | |
5067 } while (search_frame != main_frame); | |
5068 } | |
5069 } | |
5070 | |
5071 void RenderFrameImpl::OnStopFinding(StopFindAction action) { | |
5072 // This should only be received on the main frame, since find-in-page is | |
5073 // currently orchestrated by the main frame. | |
5074 if (!is_main_frame_) { | |
5075 NOTREACHED(); | |
5076 return; | |
5077 } | |
5078 | |
5079 WebView* view = render_view_->webview(); | |
5080 if (!view) | |
5081 return; | |
5082 | |
5083 blink::WebPlugin* plugin = GetWebPluginForFind(); | |
5084 if (plugin) { | |
5085 plugin->stopFind(); | |
5086 return; | |
5087 } | |
5088 | |
5089 bool clear_selection = action == STOP_FIND_ACTION_CLEAR_SELECTION; | |
5090 if (clear_selection) { | |
5091 view->focusedFrame()->executeCommand(WebString::fromUTF8("Unselect"), | |
5092 GetFocusedElement()); | |
5093 } | |
5094 | |
5095 WebFrame* frame = view->mainFrame(); | |
5096 while (frame) { | |
5097 frame->stopFinding(clear_selection); | |
5098 frame = frame->traverseNext(false); | |
5099 } | |
5100 | |
5101 if (action == STOP_FIND_ACTION_ACTIVATE_SELECTION) { | |
5102 WebFrame* focused_frame = view->focusedFrame(); | |
5103 if (focused_frame) { | |
5104 WebDocument doc = focused_frame->document(); | |
5105 if (!doc.isNull()) { | |
5106 WebElement element = doc.focusedElement(); | |
5107 if (!element.isNull()) | |
5108 element.simulateClick(); | |
5109 } | |
5110 } | |
5111 } | |
5112 } | |
5113 | |
5114 #if defined(OS_ANDROID) | |
5115 void RenderFrameImpl::OnActivateNearestFindResult(int request_id, | |
5116 float x, | |
5117 float y) { | |
5118 WebRect selection_rect; | |
5119 int ordinal = | |
5120 frame_->selectNearestFindMatch(WebFloatPoint(x, y), &selection_rect); | |
5121 if (ordinal == -1) { | |
5122 // Something went wrong, so send a no-op reply (force the frame to report | |
5123 // the current match count) in case the host is waiting for a response due | |
5124 // to rate-limiting). | |
Charlie Reis
2016/01/21 00:02:28
nit: Drop extra close paren.
paulmeyer
2016/01/21 14:25:46
Done.
| |
5125 frame_->increaseMatchCount(0, request_id); | |
5126 return; | |
5127 } | |
5128 | |
5129 SendFindReply(request_id, -1 /* number_of_matches */, ordinal, selection_rect, | |
5130 true /* final_update */); | |
5131 } | |
5132 | |
5133 void RenderFrameImpl::OnFindMatchRects(int current_version) { | |
5134 std::vector<gfx::RectF> match_rects; | |
5135 | |
5136 int rects_version = frame_->findMatchMarkersVersion(); | |
5137 if (current_version != rects_version) { | |
5138 WebVector<WebFloatRect> web_match_rects; | |
5139 frame_->findMatchRects(web_match_rects); | |
5140 match_rects.reserve(web_match_rects.size()); | |
5141 for (size_t i = 0; i < web_match_rects.size(); ++i) | |
5142 match_rects.push_back(gfx::RectF(web_match_rects[i])); | |
5143 } | |
5144 | |
5145 gfx::RectF active_rect = frame_->activeFindMatchRect(); | |
5146 Send(new FrameHostMsg_FindMatchRects_Reply(routing_id_, rects_version, | |
5147 match_rects, active_rect)); | |
5148 } | |
5149 | |
5150 void RenderFrameImpl::OnSelectPopupMenuItems( | |
5151 bool canceled, | |
5152 const std::vector<int>& selected_indices) { | |
5153 // It is possible to receive more than one of these calls if the user presses | |
5154 // a select faster than it takes for the show-select-popup IPC message to make | |
5155 // it to the browser UI thread. Ignore the extra-messages. | |
5156 // TODO(jcivelli): http:/b/5793321 Implement a better fix, as detailed in bug. | |
5157 if (!external_popup_menu_) | |
5158 return; | |
5159 | |
5160 external_popup_menu_->DidSelectItems(canceled, selected_indices); | |
5161 external_popup_menu_.reset(); | |
5162 } | |
5163 #elif defined(OS_MACOSX) | |
5164 void RenderFrameImpl::OnSelectPopupMenuItem(int selected_index) { | |
5165 if (external_popup_menu_ == NULL) | |
5166 return; | |
5167 external_popup_menu_->DidSelectItem(selected_index); | |
5168 external_popup_menu_.reset(); | |
5169 } | |
5170 #endif | |
5171 | |
4956 void RenderFrameImpl::OpenURL(const GURL& url, | 5172 void RenderFrameImpl::OpenURL(const GURL& url, |
4957 const Referrer& referrer, | 5173 const Referrer& referrer, |
4958 WebNavigationPolicy policy, | 5174 WebNavigationPolicy policy, |
4959 bool should_replace_current_entry, | 5175 bool should_replace_current_entry, |
4960 bool is_history_navigation_in_new_child) { | 5176 bool is_history_navigation_in_new_child) { |
4961 FrameHostMsg_OpenURL_Params params; | 5177 FrameHostMsg_OpenURL_Params params; |
4962 params.url = url; | 5178 params.url = url; |
4963 params.referrer = referrer; | 5179 params.referrer = referrer; |
4964 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy); | 5180 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy); |
4965 | 5181 |
(...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5766 media::SwitchOutputDeviceCB callback = | 5982 media::SwitchOutputDeviceCB callback = |
5767 media::ConvertToSwitchOutputDeviceCB(web_callbacks); | 5983 media::ConvertToSwitchOutputDeviceCB(web_callbacks); |
5768 scoped_refptr<media::AudioOutputDevice> device = | 5984 scoped_refptr<media::AudioOutputDevice> device = |
5769 AudioDeviceFactory::NewOutputDevice(routing_id_, 0, sink_id.utf8(), | 5985 AudioDeviceFactory::NewOutputDevice(routing_id_, 0, sink_id.utf8(), |
5770 security_origin); | 5986 security_origin); |
5771 media::OutputDeviceStatus status = device->GetDeviceStatus(); | 5987 media::OutputDeviceStatus status = device->GetDeviceStatus(); |
5772 device->Stop(); | 5988 device->Stop(); |
5773 callback.Run(status); | 5989 callback.Run(status); |
5774 } | 5990 } |
5775 | 5991 |
5992 blink::WebPlugin* RenderFrameImpl::GetWebPluginForFind() { | |
5993 if (!is_main_frame_) | |
5994 return nullptr; | |
5995 | |
5996 if (frame_->isWebLocalFrame() && frame_->document().isPluginDocument()) | |
nasko
2016/01/20 23:38:26
frame_ will always be WebLocalFrame. No need to ch
paulmeyer
2016/01/21 14:25:46
Done.
| |
5997 return frame_->document().to<WebPluginDocument>().plugin(); | |
5998 | |
5999 #if defined(ENABLE_PLUGINS) | |
6000 if (plugin_find_handler_) | |
6001 return plugin_find_handler_->container()->plugin(); | |
6002 #endif | |
6003 | |
6004 return nullptr; | |
6005 } | |
6006 | |
6007 void RenderFrameImpl::SendFindReply(int request_id, | |
6008 int match_count, | |
6009 int ordinal, | |
6010 const WebRect& selection_rect, | |
6011 bool final_status_update) { | |
6012 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, | |
6013 selection_rect, ordinal, | |
6014 final_status_update)); | |
6015 } | |
6016 | |
5776 } // namespace content | 6017 } // namespace content |
OLD | NEW |