Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(850)

Side by Side Diff: content/browser/renderer_host/render_widget_host_view_aura.cc

Issue 1602903003: Display the context menu on Windows on long press release (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove space Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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/renderer_host/render_widget_host_view_aura.h" 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
6 6
7 #include <set> 7 #include <set>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 2702 matching lines...) Expand 10 before | Expand all | Expand 10 after
2713 snapped = window_->GetRootWindow(); 2713 snapped = window_->GetRootWindow();
2714 } else { 2714 } else {
2715 snapped = window_->GetToplevelWindow(); 2715 snapped = window_->GetToplevelWindow();
2716 } 2716 }
2717 if (snapped && snapped != window_) 2717 if (snapped && snapped != window_)
2718 ui::SnapLayerToPhysicalPixelBoundary(snapped->layer(), window_->layer()); 2718 ui::SnapLayerToPhysicalPixelBoundary(snapped->layer(), window_->layer());
2719 2719
2720 has_snapped_to_boundary_ = true; 2720 has_snapped_to_boundary_ = true;
2721 } 2721 }
2722 2722
2723 void RenderWidgetHostViewAura::OnShowContextMenu() { 2723 bool RenderWidgetHostViewAura::OnShowContextMenu(
2724 const ContextMenuParams& params) {
2724 #if defined(OS_WIN) 2725 #if defined(OS_WIN)
2725 showing_context_menu_ = true; 2726 showing_context_menu_ = true;
tdresser 2016/01/20 15:26:12 Should showing_context_menu_ be true in the case w
ananta 2016/01/21 02:08:53 Yeah. Good point. Moved it to after the if check
2727 last_context_menu_params_.reset();
2728
2729 if (params.source_type == ui::MENU_SOURCE_TOUCH) {
2730 last_context_menu_params_.reset(new ContextMenuParams);
2731 *last_context_menu_params_ = params;
2732 return false;
2733 }
2726 #endif 2734 #endif
2735 return true;
2727 } 2736 }
2728 2737
2729 void RenderWidgetHostViewAura::SetSelectionControllerClientForTest( 2738 void RenderWidgetHostViewAura::SetSelectionControllerClientForTest(
2730 scoped_ptr<TouchSelectionControllerClientAura> client) { 2739 scoped_ptr<TouchSelectionControllerClientAura> client) {
2731 selection_controller_client_.swap(client); 2740 selection_controller_client_.swap(client);
2732 CreateSelectionController(); 2741 CreateSelectionController();
2733 } 2742 }
2734 2743
2735 void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) { 2744 void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) {
2736 SnapToPhysicalPixelBoundary(); 2745 SnapToPhysicalPixelBoundary();
(...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after
2924 event->SetHandled(); 2933 event->SetHandled();
2925 } 2934 }
2926 break; 2935 break;
2927 case ui::ET_GESTURE_TAP: 2936 case ui::ET_GESTURE_TAP:
2928 if (selection_controller_->WillHandleTapEvent( 2937 if (selection_controller_->WillHandleTapEvent(
2929 event->location_f(), event->details().tap_count())) { 2938 event->location_f(), event->details().tap_count())) {
2930 event->SetHandled(); 2939 event->SetHandled();
2931 } 2940 }
2932 break; 2941 break;
2933 case ui::ET_GESTURE_SCROLL_BEGIN: 2942 case ui::ET_GESTURE_SCROLL_BEGIN:
2934 selection_controller_->OnScrollBeginEvent();
2935 selection_controller_client_->OnScrollStarted(); 2943 selection_controller_client_->OnScrollStarted();
2936 break; 2944 break;
2937 case ui::ET_GESTURE_SCROLL_END: 2945 case ui::ET_GESTURE_SCROLL_END:
2938 selection_controller_client_->OnScrollCompleted(); 2946 selection_controller_client_->OnScrollCompleted();
2939 break; 2947 break;
2948 #if defined(OS_WIN)
2949 case ui::ET_GESTURE_LONG_TAP: {
2950 if (!last_context_menu_params_)
2951 break;
2952
2953 ContextMenuParams params = *last_context_menu_params_;
tdresser 2016/01/20 15:26:12 You shouldn't need to copy the ContextMenuParams h
ananta 2016/01/21 02:08:53 Done.
2954 DCHECK(params.source_type == ui::MENU_SOURCE_TOUCH);
2955 params.source_type = ui::MENU_SOURCE_MOUSE;
tdresser 2016/01/20 15:26:12 It might be worth adding a comment here - settings
ananta 2016/01/21 02:08:53 Done.
2956
2957 last_context_menu_params_.reset();
2958
2959 RenderViewHostDelegateView* delegate_view =
2960 GetRenderViewHostDelegateView();
2961 if (delegate_view)
2962 delegate_view->ShowContextMenu(GetFocusedFrame(), params);
2963 event->SetHandled();
2964 // WARNING: we may have been deleted during the call to ShowContextMenu().
2965 break;
2966 }
2967 #endif
2940 default: 2968 default:
2941 break; 2969 break;
2942 } 2970 }
2943 } 2971 }
2944 2972
2973 RenderViewHostDelegateView*
2974 RenderWidgetHostViewAura::GetRenderViewHostDelegateView() {
2975 // Use RenderViewHostDelegate to get to the WebContentsViewAura, which will
2976 // actually show the disambiguation popup.
2977 RenderViewHost* rvh = RenderViewHost::From(host_);
2978 if (!rvh)
2979 return nullptr;
2980
2981 RenderViewHostDelegate* delegate = rvh->GetDelegate();
2982 if (!delegate)
2983 return nullptr;
2984
2985 return delegate->GetDelegateView();
2986 }
2987
2945 //////////////////////////////////////////////////////////////////////////////// 2988 ////////////////////////////////////////////////////////////////////////////////
2946 // DelegatedFrameHost, public: 2989 // DelegatedFrameHost, public:
2947 2990
2948 ui::Layer* RenderWidgetHostViewAura::DelegatedFrameHostGetLayer() const { 2991 ui::Layer* RenderWidgetHostViewAura::DelegatedFrameHostGetLayer() const {
2949 return window_->layer(); 2992 return window_->layer();
2950 } 2993 }
2951 2994
2952 bool RenderWidgetHostViewAura::DelegatedFrameHostIsVisible() const { 2995 bool RenderWidgetHostViewAura::DelegatedFrameHostIsVisible() const {
2953 return !host_->is_hidden(); 2996 return !host_->is_hidden();
2954 } 2997 }
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
3029 3072
3030 //////////////////////////////////////////////////////////////////////////////// 3073 ////////////////////////////////////////////////////////////////////////////////
3031 // RenderWidgetHostViewBase, public: 3074 // RenderWidgetHostViewBase, public:
3032 3075
3033 // static 3076 // static
3034 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { 3077 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) {
3035 GetScreenInfoForWindow(results, NULL); 3078 GetScreenInfoForWindow(results, NULL);
3036 } 3079 }
3037 3080
3038 } // namespace content 3081 } // namespace content
OLDNEW
« no previous file with comments | « content/browser/renderer_host/render_widget_host_view_aura.h ('k') | content/browser/web_contents/web_contents_view_aura.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698