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 2721 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2732 WebContentsImpl::GetOrCreateRootBrowserAccessibilityManager() { | 2732 WebContentsImpl::GetOrCreateRootBrowserAccessibilityManager() { |
2733 RenderFrameHostImpl* rfh = GetMainFrame(); | 2733 RenderFrameHostImpl* rfh = GetMainFrame(); |
2734 return rfh ? rfh->GetOrCreateBrowserAccessibilityManager() : nullptr; | 2734 return rfh ? rfh->GetOrCreateBrowserAccessibilityManager() : nullptr; |
2735 } | 2735 } |
2736 | 2736 |
2737 void WebContentsImpl::MoveRangeSelectionExtent(const gfx::Point& extent) { | 2737 void WebContentsImpl::MoveRangeSelectionExtent(const gfx::Point& extent) { |
2738 RenderFrameHost* focused_frame = GetFocusedFrame(); | 2738 RenderFrameHost* focused_frame = GetFocusedFrame(); |
2739 if (!focused_frame) | 2739 if (!focused_frame) |
2740 return; | 2740 return; |
2741 | 2741 |
2742 focused_frame->Send(new InputMsg_MoveRangeSelectionExtent( | 2742 focused_frame->GetFrameInputHandler()->MoveRangeSelectionExtent(extent); |
2743 focused_frame->GetRoutingID(), extent)); | |
2744 } | 2743 } |
2745 | 2744 |
2746 void WebContentsImpl::SelectRange(const gfx::Point& base, | 2745 void WebContentsImpl::SelectRange(const gfx::Point& base, |
2747 const gfx::Point& extent) { | 2746 const gfx::Point& extent) { |
2748 RenderFrameHost* focused_frame = GetFocusedFrame(); | 2747 RenderFrameHost* focused_frame = GetFocusedFrame(); |
2749 if (!focused_frame) | 2748 if (!focused_frame) |
2750 return; | 2749 return; |
2751 | 2750 |
2752 focused_frame->Send( | 2751 focused_frame->GetFrameInputHandler()->SelectRange(base, extent); |
2753 new InputMsg_SelectRange(focused_frame->GetRoutingID(), base, extent)); | |
2754 } | 2752 } |
2755 | 2753 |
2756 void WebContentsImpl::AdjustSelectionByCharacterOffset(int start_adjust, | 2754 void WebContentsImpl::AdjustSelectionByCharacterOffset(int start_adjust, |
2757 int end_adjust) { | 2755 int end_adjust) { |
2758 RenderFrameHost* focused_frame = GetFocusedFrame(); | 2756 RenderFrameHost* focused_frame = GetFocusedFrame(); |
2759 if (!focused_frame) | 2757 if (!focused_frame) |
2760 return; | 2758 return; |
2761 | 2759 |
2762 focused_frame->Send(new InputMsg_AdjustSelectionByCharacterOffset( | 2760 focused_frame->GetFrameInputHandler()->AdjustSelectionByCharacterOffset( |
2763 focused_frame->GetRoutingID(), start_adjust, end_adjust)); | 2761 start_adjust, end_adjust); |
2764 } | 2762 } |
2765 | 2763 |
2766 void WebContentsImpl::UpdatePreferredSize(const gfx::Size& pref_size) { | 2764 void WebContentsImpl::UpdatePreferredSize(const gfx::Size& pref_size) { |
2767 const gfx::Size old_size = GetPreferredSize(); | 2765 const gfx::Size old_size = GetPreferredSize(); |
2768 preferred_size_ = pref_size; | 2766 preferred_size_ = pref_size; |
2769 OnPreferredSizeChanged(old_size); | 2767 OnPreferredSizeChanged(old_size); |
2770 } | 2768 } |
2771 | 2769 |
2772 void WebContentsImpl::ResizeDueToAutoResize( | 2770 void WebContentsImpl::ResizeDueToAutoResize( |
2773 RenderWidgetHostImpl* render_widget_host, | 2771 RenderWidgetHostImpl* render_widget_host, |
(...skipping 139 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2913 | 2911 |
2914 void WebContentsImpl::ReloadLoFiImages() { | 2912 void WebContentsImpl::ReloadLoFiImages() { |
2915 SendToAllFrames(new FrameMsg_ReloadLoFiImages(MSG_ROUTING_NONE)); | 2913 SendToAllFrames(new FrameMsg_ReloadLoFiImages(MSG_ROUTING_NONE)); |
2916 } | 2914 } |
2917 | 2915 |
2918 void WebContentsImpl::Undo() { | 2916 void WebContentsImpl::Undo() { |
2919 RenderFrameHost* focused_frame = GetFocusedFrame(); | 2917 RenderFrameHost* focused_frame = GetFocusedFrame(); |
2920 if (!focused_frame) | 2918 if (!focused_frame) |
2921 return; | 2919 return; |
2922 | 2920 |
2923 focused_frame->Send(new InputMsg_Undo(focused_frame->GetRoutingID())); | 2921 focused_frame->GetFrameInputHandler()->Undo(); |
2924 RecordAction(base::UserMetricsAction("Undo")); | 2922 RecordAction(base::UserMetricsAction("Undo")); |
2925 } | 2923 } |
2926 | 2924 |
2927 void WebContentsImpl::Redo() { | 2925 void WebContentsImpl::Redo() { |
2928 RenderFrameHost* focused_frame = GetFocusedFrame(); | 2926 RenderFrameHost* focused_frame = GetFocusedFrame(); |
2929 if (!focused_frame) | 2927 if (!focused_frame) |
2930 return; | 2928 return; |
2931 focused_frame->Send(new InputMsg_Redo(focused_frame->GetRoutingID())); | 2929 focused_frame->GetFrameInputHandler()->Redo(); |
2932 RecordAction(base::UserMetricsAction("Redo")); | 2930 RecordAction(base::UserMetricsAction("Redo")); |
2933 } | 2931 } |
2934 | 2932 |
2935 void WebContentsImpl::Cut() { | 2933 void WebContentsImpl::Cut() { |
2936 RenderFrameHost* focused_frame = GetFocusedFrame(); | 2934 RenderFrameHost* focused_frame = GetFocusedFrame(); |
2937 if (!focused_frame) | 2935 if (!focused_frame) |
2938 return; | 2936 return; |
2939 | 2937 |
2940 focused_frame->Send(new InputMsg_Cut(focused_frame->GetRoutingID())); | 2938 focused_frame->GetFrameInputHandler()->Cut(); |
2941 RecordAction(base::UserMetricsAction("Cut")); | 2939 RecordAction(base::UserMetricsAction("Cut")); |
2942 } | 2940 } |
2943 | 2941 |
2944 void WebContentsImpl::Copy() { | 2942 void WebContentsImpl::Copy() { |
2945 RenderFrameHost* focused_frame = GetFocusedFrame(); | 2943 RenderFrameHost* focused_frame = GetFocusedFrame(); |
2946 if (!focused_frame) | 2944 if (!focused_frame) |
2947 return; | 2945 return; |
2948 | 2946 |
2949 focused_frame->Send(new InputMsg_Copy(focused_frame->GetRoutingID())); | 2947 focused_frame->GetFrameInputHandler()->Copy(); |
2950 RecordAction(base::UserMetricsAction("Copy")); | 2948 RecordAction(base::UserMetricsAction("Copy")); |
2951 } | 2949 } |
2952 | 2950 |
2953 void WebContentsImpl::CopyToFindPboard() { | 2951 void WebContentsImpl::CopyToFindPboard() { |
2954 #if defined(OS_MACOSX) | 2952 #if defined(OS_MACOSX) |
2955 RenderFrameHost* focused_frame = GetFocusedFrame(); | 2953 RenderFrameHost* focused_frame = GetFocusedFrame(); |
2956 if (!focused_frame) | 2954 if (!focused_frame) |
2957 return; | 2955 return; |
2958 | 2956 |
2959 // Windows/Linux don't have the concept of a find pasteboard. | 2957 // Windows/Linux don't have the concept of a find pasteboard. |
2960 focused_frame->Send( | 2958 focused_frame->GetFrameInputHandler()->CopyToFindPboard(); |
2961 new InputMsg_CopyToFindPboard(focused_frame->GetRoutingID())); | |
2962 RecordAction(base::UserMetricsAction("CopyToFindPboard")); | 2959 RecordAction(base::UserMetricsAction("CopyToFindPboard")); |
2963 #endif | 2960 #endif |
2964 } | 2961 } |
2965 | 2962 |
2966 void WebContentsImpl::Paste() { | 2963 void WebContentsImpl::Paste() { |
2967 RenderFrameHost* focused_frame = GetFocusedFrame(); | 2964 RenderFrameHost* focused_frame = GetFocusedFrame(); |
2968 if (!focused_frame) | 2965 if (!focused_frame) |
2969 return; | 2966 return; |
2970 | 2967 |
2971 focused_frame->Send(new InputMsg_Paste(focused_frame->GetRoutingID())); | 2968 focused_frame->GetFrameInputHandler()->Paste(); |
2972 RecordAction(base::UserMetricsAction("Paste")); | 2969 RecordAction(base::UserMetricsAction("Paste")); |
2973 } | 2970 } |
2974 | 2971 |
2975 void WebContentsImpl::PasteAndMatchStyle() { | 2972 void WebContentsImpl::PasteAndMatchStyle() { |
2976 RenderFrameHost* focused_frame = GetFocusedFrame(); | 2973 RenderFrameHost* focused_frame = GetFocusedFrame(); |
2977 if (!focused_frame) | 2974 if (!focused_frame) |
2978 return; | 2975 return; |
2979 | 2976 |
2980 focused_frame->Send(new InputMsg_PasteAndMatchStyle( | 2977 focused_frame->GetFrameInputHandler()->PasteAndMatchStyle(); |
2981 focused_frame->GetRoutingID())); | |
2982 RecordAction(base::UserMetricsAction("PasteAndMatchStyle")); | 2978 RecordAction(base::UserMetricsAction("PasteAndMatchStyle")); |
2983 } | 2979 } |
2984 | 2980 |
2985 void WebContentsImpl::Delete() { | 2981 void WebContentsImpl::Delete() { |
2986 RenderFrameHost* focused_frame = GetFocusedFrame(); | 2982 RenderFrameHost* focused_frame = GetFocusedFrame(); |
2987 if (!focused_frame) | 2983 if (!focused_frame) |
2988 return; | 2984 return; |
2989 | 2985 |
2990 focused_frame->Send(new InputMsg_Delete(focused_frame->GetRoutingID())); | 2986 focused_frame->GetFrameInputHandler()->Delete(); |
2991 RecordAction(base::UserMetricsAction("DeleteSelection")); | 2987 RecordAction(base::UserMetricsAction("DeleteSelection")); |
2992 } | 2988 } |
2993 | 2989 |
2994 void WebContentsImpl::SelectAll() { | 2990 void WebContentsImpl::SelectAll() { |
2995 RenderFrameHost* focused_frame = GetFocusedFrame(); | 2991 RenderFrameHost* focused_frame = GetFocusedFrame(); |
2996 if (!focused_frame) | 2992 if (!focused_frame) |
2997 return; | 2993 return; |
2998 | 2994 |
2999 focused_frame->Send(new InputMsg_SelectAll(focused_frame->GetRoutingID())); | 2995 focused_frame->GetFrameInputHandler()->SelectAll(); |
3000 RecordAction(base::UserMetricsAction("SelectAll")); | 2996 RecordAction(base::UserMetricsAction("SelectAll")); |
3001 } | 2997 } |
3002 | 2998 |
3003 void WebContentsImpl::CollapseSelection() { | 2999 void WebContentsImpl::CollapseSelection() { |
3004 RenderFrameHost* focused_frame = GetFocusedFrame(); | 3000 RenderFrameHost* focused_frame = GetFocusedFrame(); |
3005 if (!focused_frame) | 3001 if (!focused_frame) |
3006 return; | 3002 return; |
3007 | 3003 |
3008 focused_frame->Send( | 3004 focused_frame->GetFrameInputHandler()->CollapseSelection(); |
3009 new InputMsg_CollapseSelection(focused_frame->GetRoutingID())); | |
3010 } | 3005 } |
3011 | 3006 |
3012 void WebContentsImpl::Replace(const base::string16& word) { | 3007 void WebContentsImpl::Replace(const base::string16& word) { |
3013 RenderFrameHost* focused_frame = GetFocusedFrame(); | 3008 RenderFrameHost* focused_frame = GetFocusedFrame(); |
3014 if (!focused_frame) | 3009 if (!focused_frame) |
3015 return; | 3010 return; |
3016 | 3011 |
3017 focused_frame->Send(new InputMsg_Replace( | 3012 focused_frame->GetFrameInputHandler()->Replace(base::UTF16ToUTF8(word)); |
3018 focused_frame->GetRoutingID(), word)); | |
3019 } | 3013 } |
3020 | 3014 |
3021 void WebContentsImpl::ReplaceMisspelling(const base::string16& word) { | 3015 void WebContentsImpl::ReplaceMisspelling(const base::string16& word) { |
3022 RenderFrameHost* focused_frame = GetFocusedFrame(); | 3016 RenderFrameHost* focused_frame = GetFocusedFrame(); |
3023 if (!focused_frame) | 3017 if (!focused_frame) |
3024 return; | 3018 return; |
3025 | 3019 |
3026 focused_frame->Send(new InputMsg_ReplaceMisspelling( | 3020 focused_frame->GetFrameInputHandler()->ReplaceMisspelling( |
3027 focused_frame->GetRoutingID(), word)); | 3021 base::UTF16ToUTF8(word)); |
dcheng
2017/05/17 04:49:06
Btw, should we have a bug tracking cleaning this u
dtapuska
2017/05/17 17:08:07
Changed interface to support string16 instead.
| |
3028 } | 3022 } |
3029 | 3023 |
3030 void WebContentsImpl::NotifyContextMenuClosed( | 3024 void WebContentsImpl::NotifyContextMenuClosed( |
3031 const CustomContextMenuContext& context) { | 3025 const CustomContextMenuContext& context) { |
3032 RenderFrameHost* focused_frame = GetFocusedFrame(); | 3026 RenderFrameHost* focused_frame = GetFocusedFrame(); |
3033 if (!focused_frame) | 3027 if (!focused_frame) |
3034 return; | 3028 return; |
3035 | 3029 |
3036 focused_frame->Send(new FrameMsg_ContextMenuClosed( | 3030 focused_frame->Send(new FrameMsg_ContextMenuClosed( |
3037 focused_frame->GetRoutingID(), context)); | 3031 focused_frame->GetRoutingID(), context)); |
(...skipping 2593 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
5631 RenderViewHost* render_view_host = RenderViewHost::From(render_widget_host); | 5625 RenderViewHost* render_view_host = RenderViewHost::From(render_widget_host); |
5632 if (!render_view_host) | 5626 if (!render_view_host) |
5633 continue; | 5627 continue; |
5634 render_view_host_set.insert(render_view_host); | 5628 render_view_host_set.insert(render_view_host); |
5635 } | 5629 } |
5636 for (RenderViewHost* render_view_host : render_view_host_set) | 5630 for (RenderViewHost* render_view_host : render_view_host_set) |
5637 render_view_host->OnWebkitPreferencesChanged(); | 5631 render_view_host->OnWebkitPreferencesChanged(); |
5638 } | 5632 } |
5639 | 5633 |
5640 } // namespace content | 5634 } // namespace content |
OLD | NEW |