Chromium Code Reviews| 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 678 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 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) | 2074 #if defined(OS_ANDROID) |
| 2075 void RenderFrameImpl::OnActivateNearestFindResult(int request_id, | |
| 2076 float x, float y) { | |
| 2077 WebRect selection_rect; | |
| 2078 int ordinal = frame_->selectNearestFindMatch(WebFloatPoint(x, y), | |
| 2079 &selection_rect); | |
| 2080 if (ordinal == -1) { | |
| 2081 // Something went wrong, so send a no-op reply (force the frame to report | |
| 2082 // the current match count) in case the host is waiting for a response due | |
| 2083 // to rate-limiting). | |
| 2084 frame_->increaseMatchCount(0, request_id); | |
| 2085 return; | |
| 2086 } | |
| 2087 | |
| 2088 SendFindReply(request_id, | |
| 2089 -1 /* number_of_matches */, | |
| 2090 ordinal, | |
| 2091 selection_rect, | |
| 2092 true /* final_update */); | |
| 2093 } | |
| 2094 | |
| 2095 void RenderFrameImpl::OnFindMatchRects(int current_version) { | |
| 2096 std::vector<gfx::RectF> match_rects; | |
| 2097 | |
| 2098 int rects_version = frame_->findMatchMarkersVersion(); | |
| 2099 if (current_version != rects_version) { | |
| 2100 WebVector<WebFloatRect> web_match_rects; | |
| 2101 frame_->findMatchRects(web_match_rects); | |
| 2102 match_rects.reserve(web_match_rects.size()); | |
| 2103 for (size_t i = 0; i < web_match_rects.size(); ++i) | |
| 2104 match_rects.push_back(gfx::RectF(web_match_rects[i])); | |
| 2105 } | |
| 2106 | |
| 2107 gfx::RectF active_rect = frame_->activeFindMatchRect(); | |
| 2108 Send(new FrameHostMsg_FindMatchRects_Reply(routing_id_, rects_version, | |
| 2109 match_rects, active_rect)); | |
| 2110 } | |
| 2111 | |
| 2057 void RenderFrameImpl::OnSelectPopupMenuItems( | 2112 void RenderFrameImpl::OnSelectPopupMenuItems( |
| 2058 bool canceled, | 2113 bool canceled, |
| 2059 const std::vector<int>& selected_indices) { | 2114 const std::vector<int>& selected_indices) { |
| 2060 // It is possible to receive more than one of these calls if the user presses | 2115 // 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 | 2116 // 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. | 2117 // it to the browser UI thread. Ignore the extra-messages. |
| 2063 // TODO(jcivelli): http:/b/5793321 Implement a better fix, as detailed in bug. | 2118 // TODO(jcivelli): http:/b/5793321 Implement a better fix, as detailed in bug. |
| 2064 if (!external_popup_menu_) | 2119 if (!external_popup_menu_) |
| 2065 return; | 2120 return; |
| 2066 | 2121 |
| (...skipping 1896 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3963 } | 4018 } |
| 3964 } | 4019 } |
| 3965 | 4020 |
| 3966 void RenderFrameImpl::reportFindInPageMatchCount(int request_id, | 4021 void RenderFrameImpl::reportFindInPageMatchCount(int request_id, |
| 3967 int count, | 4022 int count, |
| 3968 bool final_update) { | 4023 bool final_update) { |
| 3969 int active_match_ordinal = -1; // -1 = don't update active match ordinal | 4024 int active_match_ordinal = -1; // -1 = don't update active match ordinal |
| 3970 if (!count) | 4025 if (!count) |
| 3971 active_match_ordinal = 0; | 4026 active_match_ordinal = 0; |
| 3972 | 4027 |
| 3973 render_view_->Send(new ViewHostMsg_Find_Reply( | 4028 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, count, gfx::Rect(), |
| 3974 render_view_->GetRoutingID(), request_id, count, | 4029 active_match_ordinal, final_update)); |
| 3975 gfx::Rect(), active_match_ordinal, final_update)); | |
| 3976 } | 4030 } |
| 3977 | 4031 |
| 3978 void RenderFrameImpl::reportFindInPageSelection( | 4032 void RenderFrameImpl::reportFindInPageSelection( |
| 3979 int request_id, | 4033 int request_id, |
| 3980 int active_match_ordinal, | 4034 int active_match_ordinal, |
| 3981 const blink::WebRect& selection_rect) { | 4035 const blink::WebRect& selection_rect) { |
| 3982 render_view_->Send(new ViewHostMsg_Find_Reply( | 4036 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, -1, selection_rect, |
| 3983 render_view_->GetRoutingID(), request_id, -1, selection_rect, | 4037 active_match_ordinal, false)); |
| 3984 active_match_ordinal, false)); | |
| 3985 } | 4038 } |
| 3986 | 4039 |
| 3987 void RenderFrameImpl::requestStorageQuota( | 4040 void RenderFrameImpl::requestStorageQuota( |
| 3988 blink::WebLocalFrame* frame, | 4041 blink::WebLocalFrame* frame, |
| 3989 blink::WebStorageQuotaType type, | 4042 blink::WebStorageQuotaType type, |
| 3990 unsigned long long requested_size, | 4043 unsigned long long requested_size, |
| 3991 blink::WebStorageQuotaCallbacks callbacks) { | 4044 blink::WebStorageQuotaCallbacks callbacks) { |
| 3992 DCHECK(!frame_ || frame_ == frame); | 4045 DCHECK(!frame_ || frame_ == frame); |
| 3993 WebSecurityOrigin origin = frame->document().securityOrigin(); | 4046 WebSecurityOrigin origin = frame->document().securityOrigin(); |
| 3994 if (origin.isUnique()) { | 4047 if (origin.isUnique()) { |
| (...skipping 951 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 4946 } | 4999 } |
| 4947 } | 5000 } |
| 4948 | 5001 |
| 4949 // Cleanup and notify the browser process about completion. | 5002 // Cleanup and notify the browser process about completion. |
| 4950 file.Close(); // Need to flush file contents before sending IPC response. | 5003 file.Close(); // Need to flush file contents before sending IPC response. |
| 4951 Send(new FrameHostMsg_SerializeAsMHTMLResponse( | 5004 Send(new FrameHostMsg_SerializeAsMHTMLResponse( |
| 4952 routing_id_, params.job_id, success, | 5005 routing_id_, params.job_id, success, |
| 4953 digests_of_uris_of_serialized_resources)); | 5006 digests_of_uris_of_serialized_resources)); |
| 4954 } | 5007 } |
| 4955 | 5008 |
| 5009 void RenderFrameImpl::OnFind(int request_id, | |
| 5010 const base::string16& search_text, | |
| 5011 const WebFindOptions& options) { | |
| 5012 if (!is_main_frame_) { | |
|
nasko
2016/01/20 21:43:32
Is this intentional? If so, it warrants a comment
paulmeyer
2016/01/20 22:54:15
Done.
| |
| 5013 NOTREACHED(); | |
| 5014 return; | |
| 5015 } | |
| 5016 | |
| 5017 DCHECK(!search_text.empty()); | |
| 5018 | |
| 5019 blink::WebPlugin* plugin = GetWebPluginForFind(); | |
| 5020 // Check if the plugin still exists in the document. | |
| 5021 if (plugin) { | |
| 5022 if (options.findNext) { | |
| 5023 // Just navigate back/forward. | |
| 5024 plugin->selectFindResult(options.forward); | |
| 5025 } else { | |
| 5026 if (!plugin->startFind( | |
| 5027 search_text, options.matchCase, request_id)) { | |
| 5028 // Send "no results". | |
| 5029 SendFindReply(request_id, 0, 0, gfx::Rect(), true); | |
| 5030 } | |
| 5031 } | |
| 5032 return; | |
| 5033 } | |
| 5034 | |
| 5035 WebFrame* main_frame = GetWebFrame(); | |
| 5036 WebFrame* frame_after_main = main_frame->traverseNext(true); | |
| 5037 WebFrame* focused_frame = render_view_->webview()->focusedFrame(); | |
| 5038 WebFrame* search_frame = focused_frame; // start searching focused frame. | |
| 5039 | |
| 5040 bool multi_frame = (frame_after_main != main_frame); | |
| 5041 | |
| 5042 // If we have multiple frames, we don't want to wrap the search within the | |
| 5043 // frame, so we check here if we only have main_frame in the chain. | |
| 5044 bool wrap_within_frame = !multi_frame; | |
| 5045 | |
| 5046 WebRect selection_rect; | |
| 5047 bool result = false; | |
| 5048 | |
| 5049 // If something is selected when we start searching it means we cannot just | |
| 5050 // increment the current match ordinal; we need to re-generate it. | |
| 5051 WebRange current_selection = focused_frame->selectionRange(); | |
| 5052 | |
| 5053 do { | |
| 5054 result = search_frame->find( | |
| 5055 request_id, search_text, options, wrap_within_frame, &selection_rect); | |
| 5056 | |
| 5057 if (!result) { | |
| 5058 // don't leave text selected as you move to the next frame. | |
| 5059 search_frame->executeCommand(WebString::fromUTF8("Unselect"), | |
| 5060 GetFocusedElement()); | |
| 5061 | |
| 5062 // Find the next frame, but skip the invisible ones. | |
| 5063 do { | |
| 5064 // What is the next frame to search? (we might be going backwards). Note | |
| 5065 // that we specify wrap=true so that search_frame never becomes NULL. | |
| 5066 search_frame = options.forward ? | |
| 5067 search_frame->traverseNext(true) : | |
| 5068 search_frame->traversePrevious(true); | |
| 5069 } while (!search_frame->hasVisibleContent() && | |
| 5070 search_frame != focused_frame); | |
| 5071 | |
| 5072 // Make sure selection doesn't affect the search operation in new frame. | |
| 5073 search_frame->executeCommand(WebString::fromUTF8("Unselect"), | |
| 5074 GetFocusedElement()); | |
| 5075 | |
| 5076 // If we have multiple frames and we have wrapped back around to the | |
| 5077 // focused frame, we need to search it once more allowing wrap within | |
| 5078 // the frame, otherwise it will report 'no match' if the focused frame has | |
| 5079 // reported matches, but no frames after the focused_frame contain a | |
| 5080 // match for the search word(s). | |
| 5081 if (multi_frame && search_frame == focused_frame) { | |
| 5082 result = search_frame->find( | |
| 5083 request_id, search_text, options, true, // Force wrapping. | |
| 5084 &selection_rect); | |
| 5085 } | |
| 5086 } | |
| 5087 | |
| 5088 render_view_->webview()->setFocusedFrame(search_frame); | |
| 5089 } while (!result && search_frame != focused_frame); | |
| 5090 | |
| 5091 if (options.findNext && current_selection.isNull()) { | |
| 5092 // Force the main_frame to report the actual count. | |
| 5093 main_frame->increaseMatchCount(0, request_id); | |
| 5094 } else { | |
| 5095 // If nothing is found, set result to "0 of 0", otherwise, set it to | |
| 5096 // "-1 of 1" to indicate that we found at least one item, but we don't know | |
| 5097 // yet what is active. | |
| 5098 int ordinal = result ? -1 : 0; // -1 here means, we might know more later. | |
| 5099 int match_count = result ? 1 : 0; // 1 here means possibly more coming. | |
| 5100 | |
| 5101 // If we find no matches then this will be our last status update. | |
| 5102 // Otherwise the scoping effort will send more results. | |
| 5103 bool final_status_update = !result; | |
| 5104 | |
| 5105 SendFindReply(request_id, match_count, ordinal, selection_rect, | |
| 5106 final_status_update); | |
| 5107 | |
| 5108 // Scoping effort begins, starting with the mainframe. | |
| 5109 search_frame = main_frame; | |
| 5110 | |
| 5111 main_frame->resetMatchCount(); | |
| 5112 | |
| 5113 do { | |
| 5114 // Cancel all old scoping requests before starting a new one. | |
| 5115 search_frame->cancelPendingScopingEffort(); | |
| 5116 | |
| 5117 // We don't start another scoping effort unless at least one match has | |
| 5118 // been found. | |
| 5119 if (result) { | |
| 5120 // Start new scoping request. If the scoping function determines that it | |
| 5121 // needs to scope, it will defer until later. | |
| 5122 search_frame->scopeStringMatches(request_id, | |
| 5123 search_text, | |
| 5124 options, | |
| 5125 true); // reset the tickmarks | |
| 5126 } | |
| 5127 | |
| 5128 // Iterate to the next frame. The frame will not necessarily scope, for | |
| 5129 // example if it is not visible. | |
| 5130 search_frame = search_frame->traverseNext(true); | |
| 5131 } while (search_frame != main_frame); | |
| 5132 } | |
| 5133 } | |
| 5134 | |
| 5135 void RenderFrameImpl::OnStopFinding(StopFindAction action) { | |
| 5136 WebView* view = render_view_->webview(); | |
| 5137 if (!view) | |
| 5138 return; | |
| 5139 | |
| 5140 blink::WebPlugin* plugin = GetWebPluginForFind(); | |
| 5141 if (plugin) { | |
| 5142 plugin->stopFind(); | |
| 5143 return; | |
| 5144 } | |
| 5145 | |
| 5146 bool clear_selection = action == STOP_FIND_ACTION_CLEAR_SELECTION; | |
| 5147 if (clear_selection) { | |
| 5148 view->focusedFrame()->executeCommand(WebString::fromUTF8("Unselect"), | |
| 5149 GetFocusedElement()); | |
| 5150 } | |
| 5151 | |
| 5152 WebFrame* frame = view->mainFrame(); | |
| 5153 while (frame) { | |
| 5154 frame->stopFinding(clear_selection); | |
| 5155 frame = frame->traverseNext(false); | |
| 5156 } | |
| 5157 | |
| 5158 if (action == STOP_FIND_ACTION_ACTIVATE_SELECTION) { | |
| 5159 WebFrame* focused_frame = view->focusedFrame(); | |
| 5160 if (focused_frame) { | |
| 5161 WebDocument doc = focused_frame->document(); | |
| 5162 if (!doc.isNull()) { | |
| 5163 WebElement element = doc.focusedElement(); | |
| 5164 if (!element.isNull()) | |
| 5165 element.simulateClick(); | |
| 5166 } | |
| 5167 } | |
| 5168 } | |
| 5169 } | |
| 5170 | |
| 4956 void RenderFrameImpl::OpenURL(const GURL& url, | 5171 void RenderFrameImpl::OpenURL(const GURL& url, |
| 4957 const Referrer& referrer, | 5172 const Referrer& referrer, |
| 4958 WebNavigationPolicy policy, | 5173 WebNavigationPolicy policy, |
| 4959 bool should_replace_current_entry, | 5174 bool should_replace_current_entry, |
| 4960 bool is_history_navigation_in_new_child) { | 5175 bool is_history_navigation_in_new_child) { |
| 4961 FrameHostMsg_OpenURL_Params params; | 5176 FrameHostMsg_OpenURL_Params params; |
| 4962 params.url = url; | 5177 params.url = url; |
| 4963 params.referrer = referrer; | 5178 params.referrer = referrer; |
| 4964 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy); | 5179 params.disposition = RenderViewImpl::NavigationPolicyToDisposition(policy); |
| 4965 | 5180 |
| (...skipping 800 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 5766 media::SwitchOutputDeviceCB callback = | 5981 media::SwitchOutputDeviceCB callback = |
| 5767 media::ConvertToSwitchOutputDeviceCB(web_callbacks); | 5982 media::ConvertToSwitchOutputDeviceCB(web_callbacks); |
| 5768 scoped_refptr<media::AudioOutputDevice> device = | 5983 scoped_refptr<media::AudioOutputDevice> device = |
| 5769 AudioDeviceFactory::NewOutputDevice(routing_id_, 0, sink_id.utf8(), | 5984 AudioDeviceFactory::NewOutputDevice(routing_id_, 0, sink_id.utf8(), |
| 5770 security_origin); | 5985 security_origin); |
| 5771 media::OutputDeviceStatus status = device->GetDeviceStatus(); | 5986 media::OutputDeviceStatus status = device->GetDeviceStatus(); |
| 5772 device->Stop(); | 5987 device->Stop(); |
| 5773 callback.Run(status); | 5988 callback.Run(status); |
| 5774 } | 5989 } |
| 5775 | 5990 |
| 5991 blink::WebPlugin* RenderFrameImpl::GetWebPluginForFind() { | |
| 5992 if (!render_view_->webview()) | |
|
nasko
2016/01/20 21:43:32
Hmm, this method hasn't been converted to be Rende
paulmeyer
2016/01/20 22:54:15
No, I just missed that reference to |render_view_|
| |
| 5993 return nullptr; | |
| 5994 | |
| 5995 WebFrame* main_frame = render_view_->webview()->mainFrame(); | |
| 5996 if (main_frame->isWebLocalFrame() && | |
| 5997 main_frame->document().isPluginDocument()) | |
| 5998 return main_frame->document().to<WebPluginDocument>().plugin(); | |
| 5999 | |
| 6000 #if defined(ENABLE_PLUGINS) | |
| 6001 if (plugin_find_handler_) | |
| 6002 return plugin_find_handler_->container()->plugin(); | |
| 6003 #endif | |
| 6004 | |
| 6005 return nullptr; | |
| 6006 } | |
| 6007 | |
| 6008 void RenderFrameImpl::SendFindReply(int request_id, | |
| 6009 int match_count, | |
|
nasko
2016/01/20 21:43:32
Incorrect indentation. It will be easiest if you j
paulmeyer
2016/01/20 22:54:14
Hmm... I usually only run "git cl format" when I g
| |
| 6010 int ordinal, | |
| 6011 const WebRect& selection_rect, | |
| 6012 bool final_status_update) { | |
| 6013 Send(new FrameHostMsg_Find_Reply(routing_id_, | |
| 6014 request_id, | |
| 6015 match_count, | |
| 6016 selection_rect, | |
| 6017 ordinal, | |
| 6018 final_status_update)); | |
| 6019 } | |
| 6020 | |
| 5776 } // namespace content | 6021 } // namespace content |
| OLD | NEW |