| OLD | NEW |
| 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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/browser/web_contents/web_contents_impl.h" | 5 #include "content/browser/web_contents/web_contents_impl.h" |
| 6 | 6 |
| 7 #include <stddef.h> | 7 #include <stddef.h> |
| 8 | 8 |
| 9 #include <cmath> | 9 #include <cmath> |
| 10 #include <utility> | 10 #include <utility> |
| (...skipping 2726 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2737 WebContentsImpl::GetOrCreateRootBrowserAccessibilityManager() { | 2737 WebContentsImpl::GetOrCreateRootBrowserAccessibilityManager() { |
| 2738 RenderFrameHostImpl* rfh = GetMainFrame(); | 2738 RenderFrameHostImpl* rfh = GetMainFrame(); |
| 2739 return rfh ? rfh->GetOrCreateBrowserAccessibilityManager() : nullptr; | 2739 return rfh ? rfh->GetOrCreateBrowserAccessibilityManager() : nullptr; |
| 2740 } | 2740 } |
| 2741 | 2741 |
| 2742 void WebContentsImpl::MoveRangeSelectionExtent(const gfx::Point& extent) { | 2742 void WebContentsImpl::MoveRangeSelectionExtent(const gfx::Point& extent) { |
| 2743 RenderFrameHost* focused_frame = GetFocusedFrame(); | 2743 RenderFrameHost* focused_frame = GetFocusedFrame(); |
| 2744 if (!focused_frame) | 2744 if (!focused_frame) |
| 2745 return; | 2745 return; |
| 2746 | 2746 |
| 2747 focused_frame->Send(new InputMsg_MoveRangeSelectionExtent( | 2747 focused_frame->GetFrameInputHandler()->MoveRangeSelectionExtent(extent); |
| 2748 focused_frame->GetRoutingID(), extent)); | |
| 2749 } | 2748 } |
| 2750 | 2749 |
| 2751 void WebContentsImpl::SelectRange(const gfx::Point& base, | 2750 void WebContentsImpl::SelectRange(const gfx::Point& base, |
| 2752 const gfx::Point& extent) { | 2751 const gfx::Point& extent) { |
| 2753 RenderFrameHost* focused_frame = GetFocusedFrame(); | 2752 RenderFrameHost* focused_frame = GetFocusedFrame(); |
| 2754 if (!focused_frame) | 2753 if (!focused_frame) |
| 2755 return; | 2754 return; |
| 2756 | 2755 |
| 2757 focused_frame->Send( | 2756 focused_frame->GetFrameInputHandler()->SelectRange(base, extent); |
| 2758 new InputMsg_SelectRange(focused_frame->GetRoutingID(), base, extent)); | |
| 2759 } | 2757 } |
| 2760 | 2758 |
| 2761 void WebContentsImpl::AdjustSelectionByCharacterOffset(int start_adjust, | 2759 void WebContentsImpl::AdjustSelectionByCharacterOffset(int start_adjust, |
| 2762 int end_adjust) { | 2760 int end_adjust) { |
| 2763 RenderFrameHost* focused_frame = GetFocusedFrame(); | 2761 RenderFrameHost* focused_frame = GetFocusedFrame(); |
| 2764 if (!focused_frame) | 2762 if (!focused_frame) |
| 2765 return; | 2763 return; |
| 2766 | 2764 |
| 2767 focused_frame->Send(new InputMsg_AdjustSelectionByCharacterOffset( | 2765 focused_frame->GetFrameInputHandler()->AdjustSelectionByCharacterOffset( |
| 2768 focused_frame->GetRoutingID(), start_adjust, end_adjust)); | 2766 start_adjust, end_adjust); |
| 2769 } | 2767 } |
| 2770 | 2768 |
| 2771 void WebContentsImpl::UpdatePreferredSize(const gfx::Size& pref_size) { | 2769 void WebContentsImpl::UpdatePreferredSize(const gfx::Size& pref_size) { |
| 2772 const gfx::Size old_size = GetPreferredSize(); | 2770 const gfx::Size old_size = GetPreferredSize(); |
| 2773 preferred_size_ = pref_size; | 2771 preferred_size_ = pref_size; |
| 2774 OnPreferredSizeChanged(old_size); | 2772 OnPreferredSizeChanged(old_size); |
| 2775 } | 2773 } |
| 2776 | 2774 |
| 2777 void WebContentsImpl::ResizeDueToAutoResize( | 2775 void WebContentsImpl::ResizeDueToAutoResize( |
| 2778 RenderWidgetHostImpl* render_widget_host, | 2776 RenderWidgetHostImpl* render_widget_host, |
| (...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2918 | 2916 |
| 2919 void WebContentsImpl::ReloadLoFiImages() { | 2917 void WebContentsImpl::ReloadLoFiImages() { |
| 2920 SendToAllFrames(new FrameMsg_ReloadLoFiImages(MSG_ROUTING_NONE)); | 2918 SendToAllFrames(new FrameMsg_ReloadLoFiImages(MSG_ROUTING_NONE)); |
| 2921 } | 2919 } |
| 2922 | 2920 |
| 2923 void WebContentsImpl::Undo() { | 2921 void WebContentsImpl::Undo() { |
| 2924 RenderFrameHost* focused_frame = GetFocusedFrame(); | 2922 RenderFrameHost* focused_frame = GetFocusedFrame(); |
| 2925 if (!focused_frame) | 2923 if (!focused_frame) |
| 2926 return; | 2924 return; |
| 2927 | 2925 |
| 2928 focused_frame->Send(new InputMsg_Undo(focused_frame->GetRoutingID())); | 2926 focused_frame->GetFrameInputHandler()->Undo(); |
| 2929 RecordAction(base::UserMetricsAction("Undo")); | 2927 RecordAction(base::UserMetricsAction("Undo")); |
| 2930 } | 2928 } |
| 2931 | 2929 |
| 2932 void WebContentsImpl::Redo() { | 2930 void WebContentsImpl::Redo() { |
| 2933 RenderFrameHost* focused_frame = GetFocusedFrame(); | 2931 RenderFrameHost* focused_frame = GetFocusedFrame(); |
| 2934 if (!focused_frame) | 2932 if (!focused_frame) |
| 2935 return; | 2933 return; |
| 2936 focused_frame->Send(new InputMsg_Redo(focused_frame->GetRoutingID())); | 2934 focused_frame->GetFrameInputHandler()->Redo(); |
| 2937 RecordAction(base::UserMetricsAction("Redo")); | 2935 RecordAction(base::UserMetricsAction("Redo")); |
| 2938 } | 2936 } |
| 2939 | 2937 |
| 2940 void WebContentsImpl::Cut() { | 2938 void WebContentsImpl::Cut() { |
| 2941 RenderFrameHost* focused_frame = GetFocusedFrame(); | 2939 RenderFrameHost* focused_frame = GetFocusedFrame(); |
| 2942 if (!focused_frame) | 2940 if (!focused_frame) |
| 2943 return; | 2941 return; |
| 2944 | 2942 |
| 2945 focused_frame->Send(new InputMsg_Cut(focused_frame->GetRoutingID())); | 2943 focused_frame->GetFrameInputHandler()->Cut(); |
| 2946 RecordAction(base::UserMetricsAction("Cut")); | 2944 RecordAction(base::UserMetricsAction("Cut")); |
| 2947 } | 2945 } |
| 2948 | 2946 |
| 2949 void WebContentsImpl::Copy() { | 2947 void WebContentsImpl::Copy() { |
| 2950 RenderFrameHost* focused_frame = GetFocusedFrame(); | 2948 RenderFrameHost* focused_frame = GetFocusedFrame(); |
| 2951 if (!focused_frame) | 2949 if (!focused_frame) |
| 2952 return; | 2950 return; |
| 2953 | 2951 |
| 2954 focused_frame->Send(new InputMsg_Copy(focused_frame->GetRoutingID())); | 2952 focused_frame->GetFrameInputHandler()->Copy(); |
| 2955 RecordAction(base::UserMetricsAction("Copy")); | 2953 RecordAction(base::UserMetricsAction("Copy")); |
| 2956 } | 2954 } |
| 2957 | 2955 |
| 2958 void WebContentsImpl::CopyToFindPboard() { | 2956 void WebContentsImpl::CopyToFindPboard() { |
| 2959 #if defined(OS_MACOSX) | 2957 #if defined(OS_MACOSX) |
| 2960 RenderFrameHost* focused_frame = GetFocusedFrame(); | 2958 RenderFrameHost* focused_frame = GetFocusedFrame(); |
| 2961 if (!focused_frame) | 2959 if (!focused_frame) |
| 2962 return; | 2960 return; |
| 2963 | 2961 |
| 2964 // Windows/Linux don't have the concept of a find pasteboard. | 2962 // Windows/Linux don't have the concept of a find pasteboard. |
| 2965 focused_frame->Send( | 2963 focused_frame->GetFrameInputHandler()->CopyToFindPboard(); |
| 2966 new InputMsg_CopyToFindPboard(focused_frame->GetRoutingID())); | |
| 2967 RecordAction(base::UserMetricsAction("CopyToFindPboard")); | 2964 RecordAction(base::UserMetricsAction("CopyToFindPboard")); |
| 2968 #endif | 2965 #endif |
| 2969 } | 2966 } |
| 2970 | 2967 |
| 2971 void WebContentsImpl::Paste() { | 2968 void WebContentsImpl::Paste() { |
| 2972 RenderFrameHost* focused_frame = GetFocusedFrame(); | 2969 RenderFrameHost* focused_frame = GetFocusedFrame(); |
| 2973 if (!focused_frame) | 2970 if (!focused_frame) |
| 2974 return; | 2971 return; |
| 2975 | 2972 |
| 2976 focused_frame->Send(new InputMsg_Paste(focused_frame->GetRoutingID())); | 2973 focused_frame->GetFrameInputHandler()->Paste(); |
| 2977 RecordAction(base::UserMetricsAction("Paste")); | 2974 RecordAction(base::UserMetricsAction("Paste")); |
| 2978 } | 2975 } |
| 2979 | 2976 |
| 2980 void WebContentsImpl::PasteAndMatchStyle() { | 2977 void WebContentsImpl::PasteAndMatchStyle() { |
| 2981 RenderFrameHost* focused_frame = GetFocusedFrame(); | 2978 RenderFrameHost* focused_frame = GetFocusedFrame(); |
| 2982 if (!focused_frame) | 2979 if (!focused_frame) |
| 2983 return; | 2980 return; |
| 2984 | 2981 |
| 2985 focused_frame->Send(new InputMsg_PasteAndMatchStyle( | 2982 focused_frame->GetFrameInputHandler()->PasteAndMatchStyle(); |
| 2986 focused_frame->GetRoutingID())); | |
| 2987 RecordAction(base::UserMetricsAction("PasteAndMatchStyle")); | 2983 RecordAction(base::UserMetricsAction("PasteAndMatchStyle")); |
| 2988 } | 2984 } |
| 2989 | 2985 |
| 2990 void WebContentsImpl::Delete() { | 2986 void WebContentsImpl::Delete() { |
| 2991 RenderFrameHost* focused_frame = GetFocusedFrame(); | 2987 RenderFrameHost* focused_frame = GetFocusedFrame(); |
| 2992 if (!focused_frame) | 2988 if (!focused_frame) |
| 2993 return; | 2989 return; |
| 2994 | 2990 |
| 2995 focused_frame->Send(new InputMsg_Delete(focused_frame->GetRoutingID())); | 2991 focused_frame->GetFrameInputHandler()->Delete(); |
| 2996 RecordAction(base::UserMetricsAction("DeleteSelection")); | 2992 RecordAction(base::UserMetricsAction("DeleteSelection")); |
| 2997 } | 2993 } |
| 2998 | 2994 |
| 2999 void WebContentsImpl::SelectAll() { | 2995 void WebContentsImpl::SelectAll() { |
| 3000 RenderFrameHost* focused_frame = GetFocusedFrame(); | 2996 RenderFrameHost* focused_frame = GetFocusedFrame(); |
| 3001 if (!focused_frame) | 2997 if (!focused_frame) |
| 3002 return; | 2998 return; |
| 3003 | 2999 |
| 3004 focused_frame->Send(new InputMsg_SelectAll(focused_frame->GetRoutingID())); | 3000 focused_frame->GetFrameInputHandler()->SelectAll(); |
| 3005 RecordAction(base::UserMetricsAction("SelectAll")); | 3001 RecordAction(base::UserMetricsAction("SelectAll")); |
| 3006 } | 3002 } |
| 3007 | 3003 |
| 3008 void WebContentsImpl::CollapseSelection() { | 3004 void WebContentsImpl::CollapseSelection() { |
| 3009 RenderFrameHost* focused_frame = GetFocusedFrame(); | 3005 RenderFrameHost* focused_frame = GetFocusedFrame(); |
| 3010 if (!focused_frame) | 3006 if (!focused_frame) |
| 3011 return; | 3007 return; |
| 3012 | 3008 |
| 3013 focused_frame->Send( | 3009 focused_frame->GetFrameInputHandler()->CollapseSelection(); |
| 3014 new InputMsg_CollapseSelection(focused_frame->GetRoutingID())); | |
| 3015 } | 3010 } |
| 3016 | 3011 |
| 3017 void WebContentsImpl::Replace(const base::string16& word) { | 3012 void WebContentsImpl::Replace(const base::string16& word) { |
| 3018 RenderFrameHost* focused_frame = GetFocusedFrame(); | 3013 RenderFrameHost* focused_frame = GetFocusedFrame(); |
| 3019 if (!focused_frame) | 3014 if (!focused_frame) |
| 3020 return; | 3015 return; |
| 3021 | 3016 |
| 3022 focused_frame->Send(new InputMsg_Replace( | 3017 focused_frame->GetFrameInputHandler()->Replace(word); |
| 3023 focused_frame->GetRoutingID(), word)); | |
| 3024 } | 3018 } |
| 3025 | 3019 |
| 3026 void WebContentsImpl::ReplaceMisspelling(const base::string16& word) { | 3020 void WebContentsImpl::ReplaceMisspelling(const base::string16& word) { |
| 3027 RenderFrameHost* focused_frame = GetFocusedFrame(); | 3021 RenderFrameHost* focused_frame = GetFocusedFrame(); |
| 3028 if (!focused_frame) | 3022 if (!focused_frame) |
| 3029 return; | 3023 return; |
| 3030 | 3024 |
| 3031 focused_frame->Send(new InputMsg_ReplaceMisspelling( | 3025 focused_frame->GetFrameInputHandler()->ReplaceMisspelling(word); |
| 3032 focused_frame->GetRoutingID(), word)); | |
| 3033 } | 3026 } |
| 3034 | 3027 |
| 3035 void WebContentsImpl::NotifyContextMenuClosed( | 3028 void WebContentsImpl::NotifyContextMenuClosed( |
| 3036 const CustomContextMenuContext& context) { | 3029 const CustomContextMenuContext& context) { |
| 3037 RenderFrameHost* focused_frame = GetFocusedFrame(); | 3030 RenderFrameHost* focused_frame = GetFocusedFrame(); |
| 3038 if (!focused_frame) | 3031 if (!focused_frame) |
| 3039 return; | 3032 return; |
| 3040 | 3033 |
| 3041 focused_frame->Send(new FrameMsg_ContextMenuClosed( | 3034 focused_frame->Send(new FrameMsg_ContextMenuClosed( |
| 3042 focused_frame->GetRoutingID(), context)); | 3035 focused_frame->GetRoutingID(), context)); |
| (...skipping 2595 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 5638 RenderViewHost* render_view_host = RenderViewHost::From(render_widget_host); | 5631 RenderViewHost* render_view_host = RenderViewHost::From(render_widget_host); |
| 5639 if (!render_view_host) | 5632 if (!render_view_host) |
| 5640 continue; | 5633 continue; |
| 5641 render_view_host_set.insert(render_view_host); | 5634 render_view_host_set.insert(render_view_host); |
| 5642 } | 5635 } |
| 5643 for (RenderViewHost* render_view_host : render_view_host_set) | 5636 for (RenderViewHost* render_view_host : render_view_host_set) |
| 5644 render_view_host->OnWebkitPreferencesChanged(); | 5637 render_view_host->OnWebkitPreferencesChanged(); |
| 5645 } | 5638 } |
| 5646 | 5639 |
| 5647 } // namespace content | 5640 } // namespace content |
| OLD | NEW |