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

Side by Side Diff: content/browser/web_contents/web_contents_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: Address review comments and fix ASAN build redness 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/web_contents/web_contents_view_aura.h" 5 #include "content/browser/web_contents/web_contents_view_aura.h"
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 #include <stdint.h> 8 #include <stdint.h>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after
84 84
85 namespace { 85 namespace {
86 86
87 bool IsScrollEndEffectEnabled() { 87 bool IsScrollEndEffectEnabled() {
88 return base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII( 88 return base::CommandLine::ForCurrentProcess()->GetSwitchValueASCII(
89 switches::kScrollEndEffect) == "1"; 89 switches::kScrollEndEffect) == "1";
90 } 90 }
91 91
92 RenderWidgetHostViewAura* ToRenderWidgetHostViewAura( 92 RenderWidgetHostViewAura* ToRenderWidgetHostViewAura(
93 RenderWidgetHostView* view) { 93 RenderWidgetHostView* view) {
94 if (!view || RenderViewHostFactory::has_factory()) 94 if (!view ||
95 (RenderViewHostFactory::has_factory()
96 &&
jam 2016/01/21 21:31:09 this indentation seems odd? why isn't this on the
ananta 2016/01/21 22:17:48 Fixed
97 !RenderViewHostFactory::allow_host_view_cast_in_test())) {
95 return NULL; // Can't cast to RenderWidgetHostViewAura in unit tests. 98 return NULL; // Can't cast to RenderWidgetHostViewAura in unit tests.
99 }
96 100
97 RenderViewHost* rvh = RenderViewHost::From(view->GetRenderWidgetHost()); 101 RenderViewHost* rvh = RenderViewHost::From(view->GetRenderWidgetHost());
98 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>( 102 WebContentsImpl* web_contents = static_cast<WebContentsImpl*>(
99 rvh ? WebContents::FromRenderViewHost(rvh) : NULL); 103 rvh ? WebContents::FromRenderViewHost(rvh) : NULL);
100 if (BrowserPluginGuest::IsGuest(web_contents)) 104 if (BrowserPluginGuest::IsGuest(web_contents))
101 return NULL; 105 return NULL;
102 return static_cast<RenderWidgetHostViewAura*>(view); 106 return static_cast<RenderWidgetHostViewAura*>(view);
103 } 107 }
104 108
105 // Listens to all mouse drag events during a drag and drop and sends them to 109 // Listens to all mouse drag events during a drag and drop and sends them to
(...skipping 549 matching lines...) Expand 10 before | Expand all | Expand 10 after
655 delegate_(delegate), 659 delegate_(delegate),
656 current_drag_op_(blink::WebDragOperationNone), 660 current_drag_op_(blink::WebDragOperationNone),
657 drag_dest_delegate_(NULL), 661 drag_dest_delegate_(NULL),
658 current_rvh_for_drag_(NULL), 662 current_rvh_for_drag_(NULL),
659 current_overscroll_gesture_(OVERSCROLL_NONE), 663 current_overscroll_gesture_(OVERSCROLL_NONE),
660 completed_overscroll_gesture_(OVERSCROLL_NONE), 664 completed_overscroll_gesture_(OVERSCROLL_NONE),
661 navigation_overlay_(nullptr), 665 navigation_overlay_(nullptr),
662 is_or_was_visible_(false) { 666 is_or_was_visible_(false) {
663 } 667 }
664 668
669 void WebContentsViewAura::SetDelegate(WebContentsViewDelegate* delegate) {
670 delegate_.reset(delegate);
671 }
672
665 //////////////////////////////////////////////////////////////////////////////// 673 ////////////////////////////////////////////////////////////////////////////////
666 // WebContentsViewAura, private: 674 // WebContentsViewAura, private:
667 675
668 WebContentsViewAura::~WebContentsViewAura() { 676 WebContentsViewAura::~WebContentsViewAura() {
669 if (!window_) 677 if (!window_)
670 return; 678 return;
671 679
672 window_observer_.reset(); 680 window_observer_.reset();
673 window_->RemoveObserver(this); 681 window_->RemoveObserver(this);
674 682
(...skipping 269 matching lines...) Expand 10 before | Expand all | Expand 10 after
944 // WebContentsViewAura, RenderViewHostDelegateView implementation: 952 // WebContentsViewAura, RenderViewHostDelegateView implementation:
945 953
946 void WebContentsViewAura::ShowContextMenu(RenderFrameHost* render_frame_host, 954 void WebContentsViewAura::ShowContextMenu(RenderFrameHost* render_frame_host,
947 const ContextMenuParams& params) { 955 const ContextMenuParams& params) {
948 TouchSelectionControllerClientAura* selection_controller_client = 956 TouchSelectionControllerClientAura* selection_controller_client =
949 GetSelectionControllerClient(); 957 GetSelectionControllerClient();
950 if (selection_controller_client && 958 if (selection_controller_client &&
951 selection_controller_client->HandleContextMenu(params)) { 959 selection_controller_client->HandleContextMenu(params)) {
952 return; 960 return;
953 } 961 }
962
954 if (delegate_) { 963 if (delegate_) {
955 RenderWidgetHostViewAura* view = ToRenderWidgetHostViewAura( 964 RenderWidgetHostViewAura* view = ToRenderWidgetHostViewAura(
956 web_contents_->GetRenderWidgetHostView()); 965 web_contents_->GetRenderWidgetHostView());
957 if (view) 966 if (view && !view->OnShowContextMenu(params))
958 view->OnShowContextMenu(); 967 return;
959 968
960 delegate_->ShowContextMenu(render_frame_host, params); 969 delegate_->ShowContextMenu(render_frame_host, params);
961 // WARNING: we may have been deleted during the call to ShowContextMenu(). 970 // WARNING: we may have been deleted during the call to ShowContextMenu().
962 } 971 }
963 } 972 }
964 973
965 void WebContentsViewAura::StartDragging( 974 void WebContentsViewAura::StartDragging(
966 const DropData& drop_data, 975 const DropData& drop_data,
967 blink::WebDragOperationsMask operations, 976 blink::WebDragOperationsMask operations,
968 const gfx::ImageSkia& image, 977 const gfx::ImageSkia& image,
(...skipping 346 matching lines...) Expand 10 before | Expand all | Expand 10 after
1315 if (visible) { 1324 if (visible) {
1316 if (!web_contents_->should_normally_be_visible()) 1325 if (!web_contents_->should_normally_be_visible())
1317 web_contents_->WasShown(); 1326 web_contents_->WasShown();
1318 } else { 1327 } else {
1319 if (web_contents_->should_normally_be_visible()) 1328 if (web_contents_->should_normally_be_visible())
1320 web_contents_->WasHidden(); 1329 web_contents_->WasHidden();
1321 } 1330 }
1322 } 1331 }
1323 1332
1324 } // namespace content 1333 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698