| 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 4372 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4383 #if defined(ENABLE_PLUGINS) | 4383 #if defined(ENABLE_PLUGINS) |
| 4384 for (auto* plugin : active_pepper_instances_) | 4384 for (auto* plugin : active_pepper_instances_) |
| 4385 plugin->PageVisibilityChanged(true); | 4385 plugin->PageVisibilityChanged(true); |
| 4386 #endif // ENABLE_PLUGINS | 4386 #endif // ENABLE_PLUGINS |
| 4387 } | 4387 } |
| 4388 | 4388 |
| 4389 void RenderFrameImpl::WidgetWillClose() { | 4389 void RenderFrameImpl::WidgetWillClose() { |
| 4390 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WidgetWillClose()); | 4390 FOR_EACH_OBSERVER(RenderFrameObserver, observers_, WidgetWillClose()); |
| 4391 } | 4391 } |
| 4392 | 4392 |
| 4393 void RenderFrameImpl::OnImeSetComposition( |
| 4394 RenderWidget* render_widget, |
| 4395 const base::string16& text, |
| 4396 const std::vector<blink::WebCompositionUnderline>& underlines, |
| 4397 const gfx::Range& replacement_range, |
| 4398 int selection_start, |
| 4399 int selection_end) { |
| 4400 if (render_widget_ != render_widget) |
| 4401 return; |
| 4402 |
| 4403 #if defined(ENABLE_PLUGINS) |
| 4404 if (focused_pepper_plugin_) { |
| 4405 focused_pepper_plugin_->render_frame()->OnImeSetComposition( |
| 4406 text, underlines, selection_start, selection_end); |
| 4407 return; |
| 4408 } |
| 4409 #endif |
| 4410 AdjustReplacementRangeForAccentedCharacters(replacement_range); |
| 4411 render_widget_->HandleImeSetComposition(text, underlines, replacement_range, |
| 4412 selection_start, selection_end); |
| 4413 } |
| 4414 |
| 4415 void RenderFrameImpl::OnImeConfirmComposition( |
| 4416 RenderWidget* render_widget, |
| 4417 const base::string16& text, |
| 4418 const gfx::Range& replacement_range, |
| 4419 bool keep_selection) { |
| 4420 if (render_widget_ != render_widget) |
| 4421 return; |
| 4422 #if defined(ENABLE_PLUGINS) |
| 4423 if (focused_pepper_plugin_) { |
| 4424 focused_pepper_plugin_->render_frame()->OnImeConfirmComposition( |
| 4425 text, replacement_range, keep_selection); |
| 4426 return; |
| 4427 } |
| 4428 #endif |
| 4429 AdjustReplacementRangeForAccentedCharacters(replacement_range); |
| 4430 render_widget_->HandleImeConfirmComposition(text, replacement_range, |
| 4431 keep_selection); |
| 4432 } |
| 4433 |
| 4393 bool RenderFrameImpl::IsMainFrame() { | 4434 bool RenderFrameImpl::IsMainFrame() { |
| 4394 return is_main_frame_; | 4435 return is_main_frame_; |
| 4395 } | 4436 } |
| 4396 | 4437 |
| 4397 bool RenderFrameImpl::IsHidden() { | 4438 bool RenderFrameImpl::IsHidden() { |
| 4398 return GetRenderWidget()->is_hidden(); | 4439 return GetRenderWidget()->is_hidden(); |
| 4399 } | 4440 } |
| 4400 | 4441 |
| 4401 bool RenderFrameImpl::IsLocalRoot() const { | 4442 bool RenderFrameImpl::IsLocalRoot() const { |
| 4402 bool is_local_root = static_cast<bool>(render_widget_); | 4443 bool is_local_root = static_cast<bool>(render_widget_); |
| (...skipping 213 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 4616 // allowImages(), allowPlugins() is called for the new page, so that when | 4657 // allowImages(), allowPlugins() is called for the new page, so that when |
| 4617 // these functions send a ViewHostMsg_ContentBlocked message, it arrives | 4658 // these functions send a ViewHostMsg_ContentBlocked message, it arrives |
| 4618 // after the FrameHostMsg_DidCommitProvisionalLoad message. | 4659 // after the FrameHostMsg_DidCommitProvisionalLoad message. |
| 4619 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); | 4660 Send(new FrameHostMsg_DidCommitProvisionalLoad(routing_id_, params)); |
| 4620 | 4661 |
| 4621 // If we end up reusing this WebRequest (for example, due to a #ref click), | 4662 // If we end up reusing this WebRequest (for example, due to a #ref click), |
| 4622 // we don't want the transition type to persist. Just clear it. | 4663 // we don't want the transition type to persist. Just clear it. |
| 4623 navigation_state->set_transition_type(ui::PAGE_TRANSITION_LINK); | 4664 navigation_state->set_transition_type(ui::PAGE_TRANSITION_LINK); |
| 4624 } | 4665 } |
| 4625 | 4666 |
| 4667 void RenderFrameImpl::AdjustReplacementRangeForAccentedCharacters( |
| 4668 const gfx::Range& replacement_range) const { |
| 4669 if (!replacement_range.IsValid()) |
| 4670 return; |
| 4671 |
| 4672 if (WebLocalFrame* frame = |
| 4673 render_view_->webview()->focusedFrame()->toWebLocalFrame()) { |
| 4674 WebRange webrange = WebRange::fromDocumentRange( |
| 4675 frame, replacement_range.start(), replacement_range.length()); |
| 4676 if (!webrange.isNull()) |
| 4677 frame->selectRange(webrange); |
| 4678 } |
| 4679 } |
| 4680 |
| 4626 void RenderFrameImpl::didStartLoading(bool to_different_document) { | 4681 void RenderFrameImpl::didStartLoading(bool to_different_document) { |
| 4627 TRACE_EVENT1("navigation", "RenderFrameImpl::didStartLoading", | 4682 TRACE_EVENT1("navigation", "RenderFrameImpl::didStartLoading", |
| 4628 "id", routing_id_); | 4683 "id", routing_id_); |
| 4629 render_view_->FrameDidStartLoading(frame_); | 4684 render_view_->FrameDidStartLoading(frame_); |
| 4630 | 4685 |
| 4631 // PlzNavigate: the browser is responsible for knowing the start of all | 4686 // PlzNavigate: the browser is responsible for knowing the start of all |
| 4632 // non-synchronous navigations. | 4687 // non-synchronous navigations. |
| 4633 if (!IsBrowserSideNavigationEnabled() || !to_different_document) | 4688 if (!IsBrowserSideNavigationEnabled() || !to_different_document) |
| 4634 Send(new FrameHostMsg_DidStartLoading(routing_id_, to_different_document)); | 4689 Send(new FrameHostMsg_DidStartLoading(routing_id_, to_different_document)); |
| 4635 } | 4690 } |
| (...skipping 1489 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 6125 new FrameHostMsg_PepperInstanceDeleted(render_frame->GetRoutingID())); | 6180 new FrameHostMsg_PepperInstanceDeleted(render_frame->GetRoutingID())); |
| 6126 } | 6181 } |
| 6127 | 6182 |
| 6128 void RenderFrameImpl::PepperFocusChanged(PepperPluginInstanceImpl* instance, | 6183 void RenderFrameImpl::PepperFocusChanged(PepperPluginInstanceImpl* instance, |
| 6129 bool focused) { | 6184 bool focused) { |
| 6130 if (focused) | 6185 if (focused) |
| 6131 focused_pepper_plugin_ = instance; | 6186 focused_pepper_plugin_ = instance; |
| 6132 else if (focused_pepper_plugin_ == instance) | 6187 else if (focused_pepper_plugin_ == instance) |
| 6133 focused_pepper_plugin_ = nullptr; | 6188 focused_pepper_plugin_ = nullptr; |
| 6134 | 6189 |
| 6190 GetRenderWidget()->set_focused_pepper_plugin(focused_pepper_plugin_); |
| 6191 |
| 6135 GetRenderWidget()->UpdateTextInputState(ShowIme::HIDE_IME, | 6192 GetRenderWidget()->UpdateTextInputState(ShowIme::HIDE_IME, |
| 6136 ChangeSource::FROM_NON_IME); | 6193 ChangeSource::FROM_NON_IME); |
| 6137 GetRenderWidget()->UpdateSelectionBounds(); | 6194 GetRenderWidget()->UpdateSelectionBounds(); |
| 6138 } | 6195 } |
| 6139 | 6196 |
| 6140 #endif // ENABLE_PLUGINS | 6197 #endif // ENABLE_PLUGINS |
| 6141 | 6198 |
| 6142 void RenderFrameImpl::RenderWidgetSetFocus(bool enable) { | 6199 void RenderFrameImpl::RenderWidgetSetFocus(bool enable) { |
| 6143 #if defined(ENABLE_PLUGINS) | 6200 #if defined(ENABLE_PLUGINS) |
| 6144 // Notify all Pepper plugins. | 6201 // Notify all Pepper plugins. |
| 6145 for (auto* plugin : active_pepper_instances_) | 6202 for (auto* plugin : active_pepper_instances_) |
| 6146 plugin->SetContentAreaFocus(enable); | 6203 plugin->SetContentAreaFocus(enable); |
| 6147 #endif | 6204 #endif |
| 6148 } | 6205 } |
| 6149 | 6206 |
| 6150 void RenderFrameImpl::RenderWidgetWillHandleMouseEvent() { | 6207 void RenderFrameImpl::RenderWidgetWillHandleMouseEvent() { |
| 6151 #if defined(ENABLE_PLUGINS) | 6208 #if defined(ENABLE_PLUGINS) |
| 6152 // This method is called for every mouse event that the RenderWidget receives. | 6209 // This method is called for every mouse event that the RenderWidget receives. |
| 6153 // And then the mouse event is forwarded to blink, which dispatches it to the | 6210 // And then the mouse event is forwarded to blink, which dispatches it to the |
| 6154 // event target. Potentially a Pepper plugin will receive the event. | 6211 // event target. Potentially a Pepper plugin will receive the event. |
| 6155 // In order to tell whether a plugin gets the last mouse event and which it | 6212 // In order to tell whether a plugin gets the last mouse event and which it |
| 6156 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets | 6213 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets |
| 6157 // the event, it will notify us via DidReceiveMouseEvent() and set itself as | 6214 // the event, it will notify us via DidReceiveMouseEvent() and set itself as |
| 6158 // |pepper_last_mouse_event_target_|. | 6215 // |pepper_last_mouse_event_target_|. |
| 6159 pepper_last_mouse_event_target_ = nullptr; | 6216 pepper_last_mouse_event_target_ = nullptr; |
| 6160 #endif | 6217 #endif |
| 6161 } | 6218 } |
| 6162 | 6219 |
| 6163 } // namespace content | 6220 } // namespace content |
| OLD | NEW |