| 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 #include "third_party/WebKit/public/web/WebRange.h" | 178 #include "third_party/WebKit/public/web/WebRange.h" |
| 179 #include "third_party/WebKit/public/web/WebScopedUserGesture.h" | 179 #include "third_party/WebKit/public/web/WebScopedUserGesture.h" |
| 180 #include "third_party/WebKit/public/web/WebScriptSource.h" | 180 #include "third_party/WebKit/public/web/WebScriptSource.h" |
| 181 #include "third_party/WebKit/public/web/WebSearchableFormData.h" | 181 #include "third_party/WebKit/public/web/WebSearchableFormData.h" |
| 182 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" | 182 #include "third_party/WebKit/public/web/WebSecurityPolicy.h" |
| 183 #include "third_party/WebKit/public/web/WebSerializedScriptValue.h" | 183 #include "third_party/WebKit/public/web/WebSerializedScriptValue.h" |
| 184 #include "third_party/WebKit/public/web/WebSettings.h" | 184 #include "third_party/WebKit/public/web/WebSettings.h" |
| 185 #include "third_party/WebKit/public/web/WebSurroundingText.h" | 185 #include "third_party/WebKit/public/web/WebSurroundingText.h" |
| 186 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" | 186 #include "third_party/WebKit/public/web/WebUserGestureIndicator.h" |
| 187 #include "third_party/WebKit/public/web/WebView.h" | 187 #include "third_party/WebKit/public/web/WebView.h" |
| 188 #include "third_party/WebKit/public/web/WebWidget.h" |
| 188 #include "url/url_constants.h" | 189 #include "url/url_constants.h" |
| 189 #include "url/url_util.h" | 190 #include "url/url_util.h" |
| 190 | 191 |
| 191 #if defined(ENABLE_PLUGINS) | 192 #if defined(ENABLE_PLUGINS) |
| 192 #include "content/renderer/pepper/pepper_browser_connection.h" | 193 #include "content/renderer/pepper/pepper_browser_connection.h" |
| 193 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" | 194 #include "content/renderer/pepper/pepper_plugin_instance_impl.h" |
| 195 #include "content/renderer/pepper/pepper_plugin_registry.h" |
| 194 #include "content/renderer/pepper/pepper_webplugin_impl.h" | 196 #include "content/renderer/pepper/pepper_webplugin_impl.h" |
| 195 #include "content/renderer/pepper/plugin_module.h" | 197 #include "content/renderer/pepper/plugin_module.h" |
| 196 #endif | 198 #endif |
| 197 | 199 |
| 198 #if defined(ENABLE_WEBRTC) | 200 #if defined(ENABLE_WEBRTC) |
| 199 #include "content/renderer/media/rtc_peer_connection_handler.h" | 201 #include "content/renderer/media/rtc_peer_connection_handler.h" |
| 200 #endif | 202 #endif |
| 201 | 203 |
| 202 #if defined(OS_ANDROID) | 204 #if defined(OS_ANDROID) |
| 203 #include <cpu-features.h> | 205 #include <cpu-features.h> |
| (...skipping 816 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1020 blink_service_registry_(service_registry_.GetWeakPtr()), | 1022 blink_service_registry_(service_registry_.GetWeakPtr()), |
| 1021 screen_orientation_dispatcher_(NULL), | 1023 screen_orientation_dispatcher_(NULL), |
| 1022 manifest_manager_(NULL), | 1024 manifest_manager_(NULL), |
| 1023 accessibility_mode_(AccessibilityModeOff), | 1025 accessibility_mode_(AccessibilityModeOff), |
| 1024 renderer_accessibility_(NULL), | 1026 renderer_accessibility_(NULL), |
| 1025 media_player_delegate_(NULL), | 1027 media_player_delegate_(NULL), |
| 1026 is_using_lofi_(false), | 1028 is_using_lofi_(false), |
| 1027 is_pasting_(false), | 1029 is_pasting_(false), |
| 1028 suppress_further_dialogs_(false), | 1030 suppress_further_dialogs_(false), |
| 1029 blame_context_(nullptr), | 1031 blame_context_(nullptr), |
| 1032 #if defined(ENABLE_PLUGINS) |
| 1033 focused_pepper_plugin_(nullptr), |
| 1034 pepper_last_mouse_event_target_(nullptr), |
| 1035 #endif |
| 1030 weak_factory_(this) { | 1036 weak_factory_(this) { |
| 1031 std::pair<RoutingIDFrameMap::iterator, bool> result = | 1037 std::pair<RoutingIDFrameMap::iterator, bool> result = |
| 1032 g_routing_id_frame_map.Get().insert(std::make_pair(routing_id_, this)); | 1038 g_routing_id_frame_map.Get().insert(std::make_pair(routing_id_, this)); |
| 1033 CHECK(result.second) << "Inserting a duplicate item."; | 1039 CHECK(result.second) << "Inserting a duplicate item."; |
| 1034 | 1040 |
| 1035 RenderThread::Get()->AddRoute(routing_id_, this); | 1041 RenderThread::Get()->AddRoute(routing_id_, this); |
| 1036 | 1042 |
| 1037 render_view_->RegisterRenderFrame(this); | 1043 render_view_->RegisterRenderFrame(this); |
| 1038 | 1044 |
| 1039 // Everything below subclasses RenderFrameObserver and is automatically | 1045 // Everything below subclasses RenderFrameObserver and is automatically |
| (...skipping 104 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1144 } | 1150 } |
| 1145 | 1151 |
| 1146 void RenderFrameImpl::PepperDidChangeCursor( | 1152 void RenderFrameImpl::PepperDidChangeCursor( |
| 1147 PepperPluginInstanceImpl* instance, | 1153 PepperPluginInstanceImpl* instance, |
| 1148 const blink::WebCursorInfo& cursor) { | 1154 const blink::WebCursorInfo& cursor) { |
| 1149 // Update the cursor appearance immediately if the requesting plugin is the | 1155 // Update the cursor appearance immediately if the requesting plugin is the |
| 1150 // one which receives the last mouse event. Otherwise, the new cursor won't be | 1156 // one which receives the last mouse event. Otherwise, the new cursor won't be |
| 1151 // picked up until the plugin gets the next input event. That is bad if, e.g., | 1157 // picked up until the plugin gets the next input event. That is bad if, e.g., |
| 1152 // the plugin would like to set an invisible cursor when there isn't any user | 1158 // the plugin would like to set an invisible cursor when there isn't any user |
| 1153 // input for a while. | 1159 // input for a while. |
| 1154 if (instance == render_view_->pepper_last_mouse_event_target()) | 1160 if (instance == pepper_last_mouse_event_target_) |
| 1155 GetRenderWidget()->didChangeCursor(cursor); | 1161 GetRenderWidget()->didChangeCursor(cursor); |
| 1156 } | 1162 } |
| 1157 | 1163 |
| 1158 void RenderFrameImpl::PepperDidReceiveMouseEvent( | 1164 void RenderFrameImpl::PepperDidReceiveMouseEvent( |
| 1159 PepperPluginInstanceImpl* instance) { | 1165 PepperPluginInstanceImpl* instance) { |
| 1160 render_view_->set_pepper_last_mouse_event_target(instance); | 1166 set_pepper_last_mouse_event_target(instance); |
| 1161 } | 1167 } |
| 1162 | 1168 |
| 1163 void RenderFrameImpl::PepperTextInputTypeChanged( | 1169 void RenderFrameImpl::PepperTextInputTypeChanged( |
| 1164 PepperPluginInstanceImpl* instance) { | 1170 PepperPluginInstanceImpl* instance) { |
| 1165 if (instance != render_view_->focused_pepper_plugin()) | 1171 if (instance != focused_pepper_plugin_) |
| 1166 return; | 1172 return; |
| 1167 | 1173 |
| 1168 GetRenderWidget()->UpdateTextInputState(ShowIme::HIDE_IME, | 1174 GetRenderWidget()->UpdateTextInputState(ShowIme::HIDE_IME, |
| 1169 ChangeSource::FROM_NON_IME); | 1175 ChangeSource::FROM_NON_IME); |
| 1170 | 1176 |
| 1171 FocusedNodeChangedForAccessibility(WebNode()); | 1177 FocusedNodeChangedForAccessibility(WebNode()); |
| 1172 } | 1178 } |
| 1173 | 1179 |
| 1174 void RenderFrameImpl::PepperCaretPositionChanged( | 1180 void RenderFrameImpl::PepperCaretPositionChanged( |
| 1175 PepperPluginInstanceImpl* instance) { | 1181 PepperPluginInstanceImpl* instance) { |
| 1176 if (instance != render_view_->focused_pepper_plugin()) | 1182 if (instance != focused_pepper_plugin_) |
| 1177 return; | 1183 return; |
| 1178 GetRenderWidget()->UpdateSelectionBounds(); | 1184 GetRenderWidget()->UpdateSelectionBounds(); |
| 1179 } | 1185 } |
| 1180 | 1186 |
| 1181 void RenderFrameImpl::PepperCancelComposition( | 1187 void RenderFrameImpl::PepperCancelComposition( |
| 1182 PepperPluginInstanceImpl* instance) { | 1188 PepperPluginInstanceImpl* instance) { |
| 1183 if (instance != render_view_->focused_pepper_plugin()) | 1189 if (instance != focused_pepper_plugin_) |
| 1184 return; | 1190 return; |
| 1185 Send(new InputHostMsg_ImeCancelComposition(render_view_->GetRoutingID())); | 1191 Send(new InputHostMsg_ImeCancelComposition(render_view_->GetRoutingID())); |
| 1186 #if defined(OS_MACOSX) || defined(USE_AURA) | 1192 #if defined(OS_MACOSX) || defined(USE_AURA) |
| 1187 GetRenderWidget()->UpdateCompositionInfo(true); | 1193 GetRenderWidget()->UpdateCompositionInfo(true); |
| 1188 #endif | 1194 #endif |
| 1189 } | 1195 } |
| 1190 | 1196 |
| 1191 void RenderFrameImpl::PepperSelectionChanged( | 1197 void RenderFrameImpl::PepperSelectionChanged( |
| 1192 PepperPluginInstanceImpl* instance) { | 1198 PepperPluginInstanceImpl* instance) { |
| 1193 if (instance != render_view_->focused_pepper_plugin()) | 1199 if (instance != focused_pepper_plugin_) |
| 1194 return; | 1200 return; |
| 1195 SyncSelectionIfRequired(); | 1201 SyncSelectionIfRequired(); |
| 1196 } | 1202 } |
| 1197 | 1203 |
| 1198 RenderWidgetFullscreenPepper* RenderFrameImpl::CreatePepperFullscreenContainer( | 1204 RenderWidgetFullscreenPepper* RenderFrameImpl::CreatePepperFullscreenContainer( |
| 1199 PepperPluginInstanceImpl* plugin) { | 1205 PepperPluginInstanceImpl* plugin) { |
| 1200 GURL active_url; | 1206 GURL active_url; |
| 1201 if (render_view_->webview() && render_view_->webview()->mainFrame()) | 1207 if (render_view_->webview() && render_view_->webview()->mainFrame()) |
| 1202 active_url = GURL(render_view_->webview()->mainFrame()->document().url()); | 1208 active_url = GURL(render_view_->webview()->mainFrame()->document().url()); |
| 1203 RenderWidgetFullscreenPepper* widget = RenderWidgetFullscreenPepper::Create( | 1209 RenderWidgetFullscreenPepper* widget = RenderWidgetFullscreenPepper::Create( |
| 1204 GetRenderWidget()->routing_id(), GetRenderWidget()->compositor_deps(), | 1210 GetRenderWidget()->routing_id(), GetRenderWidget()->compositor_deps(), |
| 1205 plugin, active_url, GetRenderWidget()->screenInfo()); | 1211 plugin, active_url, GetRenderWidget()->screenInfo()); |
| 1206 widget->show(blink::WebNavigationPolicyIgnore); | 1212 widget->show(blink::WebNavigationPolicyIgnore); |
| 1207 return widget; | 1213 return widget; |
| 1208 } | 1214 } |
| 1209 | 1215 |
| 1210 bool RenderFrameImpl::IsPepperAcceptingCompositionEvents() const { | 1216 bool RenderFrameImpl::IsPepperAcceptingCompositionEvents() const { |
| 1211 if (!render_view_->focused_pepper_plugin()) | 1217 if (!focused_pepper_plugin_) |
| 1212 return false; | 1218 return false; |
| 1213 return render_view_->focused_pepper_plugin()-> | 1219 return focused_pepper_plugin_->IsPluginAcceptingCompositionEvents(); |
| 1214 IsPluginAcceptingCompositionEvents(); | |
| 1215 } | 1220 } |
| 1216 | 1221 |
| 1217 void RenderFrameImpl::PluginCrashed(const base::FilePath& plugin_path, | 1222 void RenderFrameImpl::PluginCrashed(const base::FilePath& plugin_path, |
| 1218 base::ProcessId plugin_pid) { | 1223 base::ProcessId plugin_pid) { |
| 1219 // TODO(jam): dispatch this IPC in RenderFrameHost and switch to use | 1224 // TODO(jam): dispatch this IPC in RenderFrameHost and switch to use |
| 1220 // routing_id_ as a result. | 1225 // routing_id_ as a result. |
| 1221 Send(new FrameHostMsg_PluginCrashed(routing_id_, plugin_path, plugin_pid)); | 1226 Send(new FrameHostMsg_PluginCrashed(routing_id_, plugin_path, plugin_pid)); |
| 1222 } | 1227 } |
| 1223 | 1228 |
| 1224 void RenderFrameImpl::SimulateImeSetComposition( | 1229 void RenderFrameImpl::SimulateImeSetComposition( |
| (...skipping 21 matching lines...) Expand all Loading... |
| 1246 if (!IsPepperAcceptingCompositionEvents()) { | 1251 if (!IsPepperAcceptingCompositionEvents()) { |
| 1247 pepper_composition_text_ = text; | 1252 pepper_composition_text_ = text; |
| 1248 } else { | 1253 } else { |
| 1249 // TODO(kinaba) currently all composition events are sent directly to | 1254 // TODO(kinaba) currently all composition events are sent directly to |
| 1250 // plugins. Use DOM event mechanism after WebKit is made aware about | 1255 // plugins. Use DOM event mechanism after WebKit is made aware about |
| 1251 // plugins that support composition. | 1256 // plugins that support composition. |
| 1252 // The code below mimics the behavior of WebCore::Editor::setComposition. | 1257 // The code below mimics the behavior of WebCore::Editor::setComposition. |
| 1253 | 1258 |
| 1254 // Empty -> nonempty: composition started. | 1259 // Empty -> nonempty: composition started. |
| 1255 if (pepper_composition_text_.empty() && !text.empty()) { | 1260 if (pepper_composition_text_.empty() && !text.empty()) { |
| 1256 render_view_->focused_pepper_plugin()->HandleCompositionStart( | 1261 focused_pepper_plugin_->HandleCompositionStart(base::string16()); |
| 1257 base::string16()); | |
| 1258 } | 1262 } |
| 1259 // Nonempty -> empty: composition canceled. | 1263 // Nonempty -> empty: composition canceled. |
| 1260 if (!pepper_composition_text_.empty() && text.empty()) { | 1264 if (!pepper_composition_text_.empty() && text.empty()) { |
| 1261 render_view_->focused_pepper_plugin()->HandleCompositionEnd( | 1265 focused_pepper_plugin_->HandleCompositionEnd(base::string16()); |
| 1262 base::string16()); | |
| 1263 } | 1266 } |
| 1264 pepper_composition_text_ = text; | 1267 pepper_composition_text_ = text; |
| 1265 // Nonempty: composition is ongoing. | 1268 // Nonempty: composition is ongoing. |
| 1266 if (!pepper_composition_text_.empty()) { | 1269 if (!pepper_composition_text_.empty()) { |
| 1267 render_view_->focused_pepper_plugin()->HandleCompositionUpdate( | 1270 focused_pepper_plugin_->HandleCompositionUpdate( |
| 1268 pepper_composition_text_, underlines, selection_start, | 1271 pepper_composition_text_, underlines, selection_start, selection_end); |
| 1269 selection_end); | |
| 1270 } | 1272 } |
| 1271 } | 1273 } |
| 1272 } | 1274 } |
| 1273 | 1275 |
| 1274 void RenderFrameImpl::OnImeConfirmComposition( | 1276 void RenderFrameImpl::OnImeConfirmComposition( |
| 1275 const base::string16& text, | 1277 const base::string16& text, |
| 1276 const gfx::Range& replacement_range, | 1278 const gfx::Range& replacement_range, |
| 1277 bool keep_selection) { | 1279 bool keep_selection) { |
| 1278 // When a PPAPI plugin has focus, we bypass WebKit. | 1280 // When a PPAPI plugin has focus, we bypass WebKit. |
| 1279 // Here, text.empty() has a special meaning. It means to commit the last | 1281 // Here, text.empty() has a special meaning. It means to commit the last |
| (...skipping 23 matching lines...) Expand all Loading... |
| 1303 char_event.text[i - char_start] = last_text[i]; | 1305 char_event.text[i - char_start] = last_text[i]; |
| 1304 char_event.unmodifiedText[i - char_start] = last_text[i]; | 1306 char_event.unmodifiedText[i - char_start] = last_text[i]; |
| 1305 } | 1307 } |
| 1306 | 1308 |
| 1307 if (GetRenderWidget()->webwidget()) | 1309 if (GetRenderWidget()->webwidget()) |
| 1308 GetRenderWidget()->webwidget()->handleInputEvent(char_event); | 1310 GetRenderWidget()->webwidget()->handleInputEvent(char_event); |
| 1309 } | 1311 } |
| 1310 } else { | 1312 } else { |
| 1311 // Mimics the order of events sent by WebKit. | 1313 // Mimics the order of events sent by WebKit. |
| 1312 // See WebCore::Editor::setComposition() for the corresponding code. | 1314 // See WebCore::Editor::setComposition() for the corresponding code. |
| 1313 render_view_->focused_pepper_plugin()->HandleCompositionEnd(last_text); | 1315 focused_pepper_plugin_->HandleCompositionEnd(last_text); |
| 1314 render_view_->focused_pepper_plugin()->HandleTextInput(last_text); | 1316 focused_pepper_plugin_->HandleTextInput(last_text); |
| 1315 } | 1317 } |
| 1316 pepper_composition_text_.clear(); | 1318 pepper_composition_text_.clear(); |
| 1317 } | 1319 } |
| 1318 #endif // defined(ENABLE_PLUGINS) | 1320 #endif // defined(ENABLE_PLUGINS) |
| 1319 | 1321 |
| 1320 MediaStreamDispatcher* RenderFrameImpl::GetMediaStreamDispatcher() { | 1322 MediaStreamDispatcher* RenderFrameImpl::GetMediaStreamDispatcher() { |
| 1321 if (!web_user_media_client_) | 1323 if (!web_user_media_client_) |
| 1322 InitializeUserMediaClient(); | 1324 InitializeUserMediaClient(); |
| 1323 return web_user_media_client_ ? | 1325 return web_user_media_client_ ? |
| 1324 web_user_media_client_->media_stream_dispatcher() : NULL; | 1326 web_user_media_client_->media_stream_dispatcher() : NULL; |
| (...skipping 850 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2175 DidMeaningfulLayout(layout_type)); | 2177 DidMeaningfulLayout(layout_type)); |
| 2176 } | 2178 } |
| 2177 | 2179 |
| 2178 void RenderFrameImpl::DidCommitCompositorFrame() { | 2180 void RenderFrameImpl::DidCommitCompositorFrame() { |
| 2179 if (BrowserPluginManager::Get()) | 2181 if (BrowserPluginManager::Get()) |
| 2180 BrowserPluginManager::Get()->DidCommitCompositorFrame(GetRoutingID()); | 2182 BrowserPluginManager::Get()->DidCommitCompositorFrame(GetRoutingID()); |
| 2181 FOR_EACH_OBSERVER( | 2183 FOR_EACH_OBSERVER( |
| 2182 RenderFrameObserver, observers_, DidCommitCompositorFrame()); | 2184 RenderFrameObserver, observers_, DidCommitCompositorFrame()); |
| 2183 } | 2185 } |
| 2184 | 2186 |
| 2187 void RenderFrameImpl::DidCommitAndDrawCompositorFrame() { |
| 2188 #if defined(ENABLE_PLUGINS) |
| 2189 // Notify all instances that we painted. The same caveats apply as for |
| 2190 // ViewFlushedPaint regarding instances closing themselves, so we take |
| 2191 // similar precautions. |
| 2192 PepperPluginSet plugins = active_pepper_instances_; |
| 2193 for (auto* plugin : plugins) { |
| 2194 if (active_pepper_instances_.find(plugin) != active_pepper_instances_.end()) |
| 2195 plugin->ViewInitiatedPaint(); |
| 2196 } |
| 2197 #endif |
| 2198 } |
| 2199 |
| 2185 RenderView* RenderFrameImpl::GetRenderView() { | 2200 RenderView* RenderFrameImpl::GetRenderView() { |
| 2186 return render_view_.get(); | 2201 return render_view_.get(); |
| 2187 } | 2202 } |
| 2188 | 2203 |
| 2189 int RenderFrameImpl::GetRoutingID() { | 2204 int RenderFrameImpl::GetRoutingID() { |
| 2190 return routing_id_; | 2205 return routing_id_; |
| 2191 } | 2206 } |
| 2192 | 2207 |
| 2193 blink::WebLocalFrame* RenderFrameImpl::GetWebFrame() { | 2208 blink::WebLocalFrame* RenderFrameImpl::GetWebFrame() { |
| 2194 DCHECK(frame_); | 2209 DCHECK(frame_); |
| (...skipping 2111 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4306 DCHECK(frame_); | 4321 DCHECK(frame_); |
| 4307 frame_->stopLoading(); | 4322 frame_->stopLoading(); |
| 4308 if (!frame_->parent()) | 4323 if (!frame_->parent()) |
| 4309 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers_, OnStop()); | 4324 FOR_EACH_OBSERVER(RenderViewObserver, render_view_->observers_, OnStop()); |
| 4310 | 4325 |
| 4311 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, OnStop()); | 4326 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, OnStop()); |
| 4312 } | 4327 } |
| 4313 | 4328 |
| 4314 void RenderFrameImpl::WasHidden() { | 4329 void RenderFrameImpl::WasHidden() { |
| 4315 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasHidden()); | 4330 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasHidden()); |
| 4331 |
| 4332 #if defined(ENABLE_PLUGINS) |
| 4333 for (auto* plugin : active_pepper_instances_) |
| 4334 plugin->PageVisibilityChanged(false); |
| 4335 #endif // ENABLE_PLUGINS |
| 4316 } | 4336 } |
| 4317 | 4337 |
| 4318 void RenderFrameImpl::WasShown() { | 4338 void RenderFrameImpl::WasShown() { |
| 4319 // TODO(kenrb): Need to figure out how to do this better. Should | 4339 // TODO(kenrb): Need to figure out how to do this better. Should |
| 4320 // VisibilityState remain a page-level concept or move to frames? | 4340 // VisibilityState remain a page-level concept or move to frames? |
| 4321 // The semantics of 'Show' might have to change here. | 4341 // The semantics of 'Show' might have to change here. |
| 4322 // TODO(avi): This DCHECK is to track cleanup for https://crbug.com/545684 | 4342 // TODO(avi): This DCHECK is to track cleanup for https://crbug.com/545684 |
| 4323 DCHECK(!IsMainFrame() || render_widget_.get() == render_view_.get()) | 4343 DCHECK(!IsMainFrame() || render_widget_.get() == render_view_.get()) |
| 4324 << "The main render frame is no longer reusing the RenderView as its " | 4344 << "The main render frame is no longer reusing the RenderView as its " |
| 4325 << "RenderWidget!"; | 4345 << "RenderWidget!"; |
| 4326 if (render_widget_ && render_widget_->webwidget() && | 4346 if (render_widget_ && render_widget_->webwidget() && |
| 4327 render_view_.get() != render_widget_.get()) { | 4347 render_view_.get() != render_widget_.get()) { |
| 4328 static_cast<blink::WebFrameWidget*>(render_widget_->webwidget())-> | 4348 static_cast<blink::WebFrameWidget*>(render_widget_->webwidget())-> |
| 4329 setVisibilityState(blink::WebPageVisibilityStateVisible, false); | 4349 setVisibilityState(blink::WebPageVisibilityStateVisible, false); |
| 4330 } | 4350 } |
| 4331 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasShown()); | 4351 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WasShown()); |
| 4352 |
| 4353 #if defined(ENABLE_PLUGINS) |
| 4354 for (auto* plugin : active_pepper_instances_) |
| 4355 plugin->PageVisibilityChanged(true); |
| 4356 #endif // ENABLE_PLUGINS |
| 4332 } | 4357 } |
| 4333 | 4358 |
| 4334 void RenderFrameImpl::WidgetWillClose() { | 4359 void RenderFrameImpl::WidgetWillClose() { |
| 4335 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WidgetWillClose()); | 4360 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WidgetWillClose()); |
| 4336 } | 4361 } |
| 4337 | 4362 |
| 4338 bool RenderFrameImpl::IsMainFrame() { | 4363 bool RenderFrameImpl::IsMainFrame() { |
| 4339 return is_main_frame_; | 4364 return is_main_frame_; |
| 4340 } | 4365 } |
| 4341 | 4366 |
| (...skipping 1106 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5448 // Only update main frame's encoding_name. | 5473 // Only update main frame's encoding_name. |
| 5449 if (!frame->parent()) | 5474 if (!frame->parent()) |
| 5450 Send(new FrameHostMsg_UpdateEncoding(routing_id_, encoding_name)); | 5475 Send(new FrameHostMsg_UpdateEncoding(routing_id_, encoding_name)); |
| 5451 } | 5476 } |
| 5452 | 5477 |
| 5453 void RenderFrameImpl::SyncSelectionIfRequired() { | 5478 void RenderFrameImpl::SyncSelectionIfRequired() { |
| 5454 base::string16 text; | 5479 base::string16 text; |
| 5455 size_t offset; | 5480 size_t offset; |
| 5456 gfx::Range range; | 5481 gfx::Range range; |
| 5457 #if defined(ENABLE_PLUGINS) | 5482 #if defined(ENABLE_PLUGINS) |
| 5458 if (render_view_->focused_pepper_plugin_) { | 5483 if (focused_pepper_plugin_) { |
| 5459 render_view_->focused_pepper_plugin_->GetSurroundingText(&text, &range); | 5484 focused_pepper_plugin_->GetSurroundingText(&text, &range); |
| 5460 offset = 0; // Pepper API does not support offset reporting. | 5485 offset = 0; // Pepper API does not support offset reporting. |
| 5461 // TODO(kinaba): cut as needed. | 5486 // TODO(kinaba): cut as needed. |
| 5462 } else | 5487 } else |
| 5463 #endif | 5488 #endif |
| 5464 { | 5489 { |
| 5465 size_t location, length; | 5490 size_t location, length; |
| 5466 if (!GetRenderWidget()->webwidget()->caretOrSelectionRange( | 5491 if (!GetRenderWidget()->webwidget()->caretOrSelectionRange( |
| 5467 &location, &length)) { | 5492 &location, &length)) { |
| 5468 return; | 5493 return; |
| 5469 } | 5494 } |
| (...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6019 void RenderFrameImpl::SendFindReply(int request_id, | 6044 void RenderFrameImpl::SendFindReply(int request_id, |
| 6020 int match_count, | 6045 int match_count, |
| 6021 int ordinal, | 6046 int ordinal, |
| 6022 const WebRect& selection_rect, | 6047 const WebRect& selection_rect, |
| 6023 bool final_status_update) { | 6048 bool final_status_update) { |
| 6024 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, | 6049 Send(new FrameHostMsg_Find_Reply(routing_id_, request_id, match_count, |
| 6025 selection_rect, ordinal, | 6050 selection_rect, ordinal, |
| 6026 final_status_update)); | 6051 final_status_update)); |
| 6027 } | 6052 } |
| 6028 | 6053 |
| 6054 #if defined(ENABLE_PLUGINS) |
| 6055 void RenderFrameImpl::PepperInstanceCreated( |
| 6056 PepperPluginInstanceImpl* instance) { |
| 6057 active_pepper_instances_.insert(instance); |
| 6058 |
| 6059 Send(new FrameHostMsg_PepperInstanceCreated(routing_id_)); |
| 6060 } |
| 6061 |
| 6062 void RenderFrameImpl::PepperInstanceDeleted( |
| 6063 PepperPluginInstanceImpl* instance) { |
| 6064 active_pepper_instances_.erase(instance); |
| 6065 |
| 6066 if (pepper_last_mouse_event_target_ == instance) |
| 6067 pepper_last_mouse_event_target_ = nullptr; |
| 6068 if (focused_pepper_plugin_ == instance) |
| 6069 PepperFocusChanged(instance, false); |
| 6070 |
| 6071 RenderFrameImpl* const render_frame = instance->render_frame(); |
| 6072 if (render_frame) |
| 6073 render_frame->Send( |
| 6074 new FrameHostMsg_PepperInstanceDeleted(render_frame->GetRoutingID())); |
| 6075 } |
| 6076 |
| 6077 void RenderFrameImpl::PepperFocusChanged(PepperPluginInstanceImpl* instance, |
| 6078 bool focused) { |
| 6079 if (focused) |
| 6080 focused_pepper_plugin_ = instance; |
| 6081 else if (focused_pepper_plugin_ == instance) |
| 6082 focused_pepper_plugin_ = nullptr; |
| 6083 |
| 6084 GetRenderWidget()->UpdateTextInputState(ShowIme::HIDE_IME, |
| 6085 ChangeSource::FROM_NON_IME); |
| 6086 GetRenderWidget()->UpdateSelectionBounds(); |
| 6087 } |
| 6088 |
| 6089 #endif // ENABLE_PLUGINS |
| 6090 |
| 6091 void RenderFrameImpl::RenderWidgetSetFocus(bool enable) { |
| 6092 #if defined(ENABLE_PLUGINS) |
| 6093 // Notify all Pepper plugins. |
| 6094 for (auto* plugin : active_pepper_instances_) |
| 6095 plugin->SetContentAreaFocus(enable); |
| 6096 #endif |
| 6097 } |
| 6098 |
| 6099 void RenderFrameImpl::RenderWidgetWillHandleMouseEvent() { |
| 6100 #if defined(ENABLE_PLUGINS) |
| 6101 // This method is called for every mouse event that the RenderWidget receives. |
| 6102 // And then the mouse event is forwarded to blink, which dispatches it to the |
| 6103 // event target. Potentially a Pepper plugin will receive the event. |
| 6104 // In order to tell whether a plugin gets the last mouse event and which it |
| 6105 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
| 6106 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
| 6107 // |pepper_last_mouse_event_target_|. |
| 6108 pepper_last_mouse_event_target_ = nullptr; |
| 6109 #endif |
| 6110 } |
| 6111 |
| 6029 } // namespace content | 6112 } // namespace content |
| OLD | NEW |