| 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 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 wakelock_dispatcher_(nullptr), | 757 wakelock_dispatcher_(nullptr), |
| 758 geolocation_dispatcher_(NULL), | 758 geolocation_dispatcher_(NULL), |
| 759 push_messaging_dispatcher_(NULL), | 759 push_messaging_dispatcher_(NULL), |
| 760 presentation_dispatcher_(NULL), | 760 presentation_dispatcher_(NULL), |
| 761 screen_orientation_dispatcher_(NULL), | 761 screen_orientation_dispatcher_(NULL), |
| 762 manifest_manager_(NULL), | 762 manifest_manager_(NULL), |
| 763 accessibility_mode_(AccessibilityModeOff), | 763 accessibility_mode_(AccessibilityModeOff), |
| 764 renderer_accessibility_(NULL), | 764 renderer_accessibility_(NULL), |
| 765 media_player_delegate_(NULL), | 765 media_player_delegate_(NULL), |
| 766 is_using_lofi_(false), | 766 is_using_lofi_(false), |
| 767 is_pasting_(false), |
| 767 weak_factory_(this) { | 768 weak_factory_(this) { |
| 768 std::pair<RoutingIDFrameMap::iterator, bool> result = | 769 std::pair<RoutingIDFrameMap::iterator, bool> result = |
| 769 g_routing_id_frame_map.Get().insert(std::make_pair(routing_id_, this)); | 770 g_routing_id_frame_map.Get().insert(std::make_pair(routing_id_, this)); |
| 770 CHECK(result.second) << "Inserting a duplicate item."; | 771 CHECK(result.second) << "Inserting a duplicate item."; |
| 771 | 772 |
| 772 RenderThread::Get()->AddRoute(routing_id_, this); | 773 RenderThread::Get()->AddRoute(routing_id_, this); |
| 773 | 774 |
| 774 render_view_->RegisterRenderFrame(this); | 775 render_view_->RegisterRenderFrame(this); |
| 775 | 776 |
| 776 // Everything below subclasses RenderFrameObserver and is automatically | 777 // Everything below subclasses RenderFrameObserver and is automatically |
| (...skipping 636 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1413 | 1414 |
| 1414 void RenderFrameImpl::OnCopy() { | 1415 void RenderFrameImpl::OnCopy() { |
| 1415 base::AutoReset<bool> handling_select_range(&handling_select_range_, true); | 1416 base::AutoReset<bool> handling_select_range(&handling_select_range_, true); |
| 1416 WebNode current_node = context_menu_node_.isNull() ? | 1417 WebNode current_node = context_menu_node_.isNull() ? |
| 1417 GetFocusedElement() : context_menu_node_; | 1418 GetFocusedElement() : context_menu_node_; |
| 1418 frame_->executeCommand(WebString::fromUTF8("Copy"), current_node); | 1419 frame_->executeCommand(WebString::fromUTF8("Copy"), current_node); |
| 1419 } | 1420 } |
| 1420 | 1421 |
| 1421 void RenderFrameImpl::OnPaste() { | 1422 void RenderFrameImpl::OnPaste() { |
| 1422 base::AutoReset<bool> handling_select_range(&handling_select_range_, true); | 1423 base::AutoReset<bool> handling_select_range(&handling_select_range_, true); |
| 1424 base::AutoReset<bool> handling_paste(&is_pasting_, true); |
| 1423 frame_->executeCommand(WebString::fromUTF8("Paste"), GetFocusedElement()); | 1425 frame_->executeCommand(WebString::fromUTF8("Paste"), GetFocusedElement()); |
| 1424 } | 1426 } |
| 1425 | 1427 |
| 1426 void RenderFrameImpl::OnPasteAndMatchStyle() { | 1428 void RenderFrameImpl::OnPasteAndMatchStyle() { |
| 1427 base::AutoReset<bool> handling_select_range(&handling_select_range_, true); | 1429 base::AutoReset<bool> handling_select_range(&handling_select_range_, true); |
| 1428 frame_->executeCommand( | 1430 frame_->executeCommand( |
| 1429 WebString::fromUTF8("PasteAndMatchStyle"), GetFocusedElement()); | 1431 WebString::fromUTF8("PasteAndMatchStyle"), GetFocusedElement()); |
| 1430 } | 1432 } |
| 1431 | 1433 |
| 1432 #if defined(OS_MACOSX) | 1434 #if defined(OS_MACOSX) |
| (...skipping 243 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1676 } | 1678 } |
| 1677 | 1679 |
| 1678 void RenderFrameImpl::OnExecuteNoValueEditCommand(const std::string& name) { | 1680 void RenderFrameImpl::OnExecuteNoValueEditCommand(const std::string& name) { |
| 1679 frame_->executeCommand(WebString::fromUTF8(name), GetFocusedElement()); | 1681 frame_->executeCommand(WebString::fromUTF8(name), GetFocusedElement()); |
| 1680 } | 1682 } |
| 1681 | 1683 |
| 1682 void RenderFrameImpl::OnExtendSelectionAndDelete(int before, int after) { | 1684 void RenderFrameImpl::OnExtendSelectionAndDelete(int before, int after) { |
| 1683 if (!GetRenderWidget()->ShouldHandleImeEvent()) | 1685 if (!GetRenderWidget()->ShouldHandleImeEvent()) |
| 1684 return; | 1686 return; |
| 1685 | 1687 |
| 1686 DCHECK(!WebUserGestureIndicator::isProcessingUserGesture()); | |
| 1687 | |
| 1688 ImeEventGuard guard(GetRenderWidget()); | 1688 ImeEventGuard guard(GetRenderWidget()); |
| 1689 blink::WebScopedUserGesture gesture_indicator; | |
| 1690 frame_->extendSelectionAndDelete(before, after); | 1689 frame_->extendSelectionAndDelete(before, after); |
| 1691 } | 1690 } |
| 1692 | 1691 |
| 1693 void RenderFrameImpl::OnSetAccessibilityMode(AccessibilityMode new_mode) { | 1692 void RenderFrameImpl::OnSetAccessibilityMode(AccessibilityMode new_mode) { |
| 1694 if (accessibility_mode_ == new_mode) | 1693 if (accessibility_mode_ == new_mode) |
| 1695 return; | 1694 return; |
| 1696 accessibility_mode_ = new_mode; | 1695 accessibility_mode_ = new_mode; |
| 1697 if (renderer_accessibility_) { | 1696 if (renderer_accessibility_) { |
| 1698 // Note: this isn't called automatically by the destructor because | 1697 // Note: this isn't called automatically by the destructor because |
| 1699 // there'd be no point in calling it in frame teardown, only if there's | 1698 // there'd be no point in calling it in frame teardown, only if there's |
| (...skipping 384 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2084 void RenderFrameImpl::AddMessageToConsole(ConsoleMessageLevel level, | 2083 void RenderFrameImpl::AddMessageToConsole(ConsoleMessageLevel level, |
| 2085 const std::string& message) { | 2084 const std::string& message) { |
| 2086 if (devtools_agent_) | 2085 if (devtools_agent_) |
| 2087 devtools_agent_->AddMessageToConsole(level, message); | 2086 devtools_agent_->AddMessageToConsole(level, message); |
| 2088 } | 2087 } |
| 2089 | 2088 |
| 2090 bool RenderFrameImpl::IsUsingLoFi() const { | 2089 bool RenderFrameImpl::IsUsingLoFi() const { |
| 2091 return is_using_lofi_; | 2090 return is_using_lofi_; |
| 2092 } | 2091 } |
| 2093 | 2092 |
| 2093 bool RenderFrameImpl::IsPasting() const { |
| 2094 return is_pasting_; |
| 2095 } |
| 2096 |
| 2094 // blink::WebFrameClient implementation ---------------------------------------- | 2097 // blink::WebFrameClient implementation ---------------------------------------- |
| 2095 | 2098 |
| 2096 blink::WebPlugin* RenderFrameImpl::createPlugin( | 2099 blink::WebPlugin* RenderFrameImpl::createPlugin( |
| 2097 blink::WebLocalFrame* frame, | 2100 blink::WebLocalFrame* frame, |
| 2098 const blink::WebPluginParams& params) { | 2101 const blink::WebPluginParams& params) { |
| 2099 DCHECK_EQ(frame_, frame); | 2102 DCHECK_EQ(frame_, frame); |
| 2100 blink::WebPlugin* plugin = NULL; | 2103 blink::WebPlugin* plugin = NULL; |
| 2101 if (GetContentClient()->renderer()->OverrideCreatePlugin( | 2104 if (GetContentClient()->renderer()->OverrideCreatePlugin( |
| 2102 this, frame, params, &plugin)) { | 2105 this, frame, params, &plugin)) { |
| 2103 return plugin; | 2106 return plugin; |
| (...skipping 3268 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5372 media::ConvertToSwitchOutputDeviceCB(web_callbacks); | 5375 media::ConvertToSwitchOutputDeviceCB(web_callbacks); |
| 5373 scoped_refptr<media::AudioOutputDevice> device = | 5376 scoped_refptr<media::AudioOutputDevice> device = |
| 5374 AudioDeviceFactory::NewOutputDevice(routing_id_, 0, sink_id.utf8(), | 5377 AudioDeviceFactory::NewOutputDevice(routing_id_, 0, sink_id.utf8(), |
| 5375 security_origin); | 5378 security_origin); |
| 5376 media::OutputDeviceStatus status = device->GetDeviceStatus(); | 5379 media::OutputDeviceStatus status = device->GetDeviceStatus(); |
| 5377 device->Stop(); | 5380 device->Stop(); |
| 5378 callback.Run(status); | 5381 callback.Run(status); |
| 5379 } | 5382 } |
| 5380 | 5383 |
| 5381 } // namespace content | 5384 } // namespace content |
| OLD | NEW |