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

Side by Side Diff: ui/views/view.cc

Issue 16979002: Add ContextMenuSourceType to views::ContextMenuController::ShowContextMenuForView. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: patch Created 7 years, 6 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/view.h ('k') | ui/views/widget/root_view.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. 5 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first.
6 6
7 #include "ui/views/view.h" 7 #include "ui/views/view.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
130 } 130 }
131 } 131 }
132 } 132 }
133 133
134 if (owner_->context_menu_controller() && 134 if (owner_->context_menu_controller() &&
135 (event->type() == ui::ET_GESTURE_LONG_PRESS || 135 (event->type() == ui::ET_GESTURE_LONG_PRESS ||
136 event->type() == ui::ET_GESTURE_LONG_TAP || 136 event->type() == ui::ET_GESTURE_LONG_TAP ||
137 event->type() == ui::ET_GESTURE_TWO_FINGER_TAP)) { 137 event->type() == ui::ET_GESTURE_TWO_FINGER_TAP)) {
138 gfx::Point location(event->location()); 138 gfx::Point location(event->location());
139 View::ConvertPointToScreen(owner_, &location); 139 View::ConvertPointToScreen(owner_, &location);
140 owner_->ShowContextMenu(location, true); 140 owner_->ShowContextMenu(location, ui::MENU_SOURCE_TOUCH);
141 event->StopPropagation(); 141 event->StopPropagation();
142 } 142 }
143 } 143 }
144 144
145 View* owner_; 145 View* owner_;
146 bool touch_dnd_enabled_; 146 bool touch_dnd_enabled_;
147 147
148 DISALLOW_COPY_AND_ASSIGN(PostEventDispatchHandler); 148 DISALLOW_COPY_AND_ASSIGN(PostEventDispatchHandler);
149 }; 149 };
150 150
(...skipping 990 matching lines...) Expand 10 before | Expand all | Expand 10 after
1141 bool View::GetTooltipText(const gfx::Point& p, string16* tooltip) const { 1141 bool View::GetTooltipText(const gfx::Point& p, string16* tooltip) const {
1142 return false; 1142 return false;
1143 } 1143 }
1144 1144
1145 bool View::GetTooltipTextOrigin(const gfx::Point& p, gfx::Point* loc) const { 1145 bool View::GetTooltipTextOrigin(const gfx::Point& p, gfx::Point* loc) const {
1146 return false; 1146 return false;
1147 } 1147 }
1148 1148
1149 // Context menus --------------------------------------------------------------- 1149 // Context menus ---------------------------------------------------------------
1150 1150
1151 void View::ShowContextMenu(const gfx::Point& p, bool is_mouse_gesture) { 1151 void View::ShowContextMenu(const gfx::Point& p,
1152 ui::MenuSourceType source_type) {
1152 if (!context_menu_controller_) 1153 if (!context_menu_controller_)
1153 return; 1154 return;
1154 1155
1155 context_menu_controller_->ShowContextMenuForView(this, p); 1156 context_menu_controller_->ShowContextMenuForView(this, p, source_type);
1156 } 1157 }
1157 1158
1158 // static 1159 // static
1159 bool View::ShouldShowContextMenuOnMousePress() { 1160 bool View::ShouldShowContextMenuOnMousePress() {
1160 return kContextMenuOnMousePress; 1161 return kContextMenuOnMousePress;
1161 } 1162 }
1162 1163
1163 // Drag and drop --------------------------------------------------------------- 1164 // Drag and drop ---------------------------------------------------------------
1164 1165
1165 bool View::GetDropFormats( 1166 bool View::GetDropFormats(
(...skipping 944 matching lines...) Expand 10 before | Expand all | Expand 10 after
2110 if (!enabled) 2111 if (!enabled)
2111 return result; 2112 return result;
2112 2113
2113 if (event.IsOnlyRightMouseButton() && context_menu_controller && 2114 if (event.IsOnlyRightMouseButton() && context_menu_controller &&
2114 kContextMenuOnMousePress) { 2115 kContextMenuOnMousePress) {
2115 // Assume that if there is a context menu controller we won't be deleted 2116 // Assume that if there is a context menu controller we won't be deleted
2116 // from mouse pressed. 2117 // from mouse pressed.
2117 gfx::Point location(event.location()); 2118 gfx::Point location(event.location());
2118 if (HitTestPoint(location)) { 2119 if (HitTestPoint(location)) {
2119 ConvertPointToScreen(this, &location); 2120 ConvertPointToScreen(this, &location);
2120 ShowContextMenu(location, true); 2121 ShowContextMenu(location, ui::MENU_SOURCE_MOUSE);
2121 return true; 2122 return true;
2122 } 2123 }
2123 } 2124 }
2124 2125
2125 // WARNING: we may have been deleted, don't use any View variables. 2126 // WARNING: we may have been deleted, don't use any View variables.
2126 if (drag_operations != ui::DragDropTypes::DRAG_NONE) { 2127 if (drag_operations != ui::DragDropTypes::DRAG_NONE) {
2127 drag_info->PossibleDrag(event.location()); 2128 drag_info->PossibleDrag(event.location());
2128 return true; 2129 return true;
2129 } 2130 }
2130 return !!context_menu_controller || result; 2131 return !!context_menu_controller || result;
(...skipping 22 matching lines...) Expand all
2153 2154
2154 void View::ProcessMouseReleased(const ui::MouseEvent& event) { 2155 void View::ProcessMouseReleased(const ui::MouseEvent& event) {
2155 if (!kContextMenuOnMousePress && context_menu_controller_ && 2156 if (!kContextMenuOnMousePress && context_menu_controller_ &&
2156 event.IsOnlyRightMouseButton()) { 2157 event.IsOnlyRightMouseButton()) {
2157 // Assume that if there is a context menu controller we won't be deleted 2158 // Assume that if there is a context menu controller we won't be deleted
2158 // from mouse released. 2159 // from mouse released.
2159 gfx::Point location(event.location()); 2160 gfx::Point location(event.location());
2160 OnMouseReleased(event); 2161 OnMouseReleased(event);
2161 if (HitTestPoint(location)) { 2162 if (HitTestPoint(location)) {
2162 ConvertPointToScreen(this, &location); 2163 ConvertPointToScreen(this, &location);
2163 ShowContextMenu(location, true); 2164 ShowContextMenu(location, ui::MENU_SOURCE_MOUSE);
2164 } 2165 }
2165 } else { 2166 } else {
2166 OnMouseReleased(event); 2167 OnMouseReleased(event);
2167 } 2168 }
2168 // WARNING: we may have been deleted. 2169 // WARNING: we may have been deleted.
2169 } 2170 }
2170 2171
2171 // Accelerators ---------------------------------------------------------------- 2172 // Accelerators ----------------------------------------------------------------
2172 2173
2173 void View::RegisterPendingAccelerators() { 2174 void View::RegisterPendingAccelerators() {
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
2307 ConvertPointToWidget(this, &widget_location); 2308 ConvertPointToWidget(this, &widget_location);
2308 GetWidget()->RunShellDrag(this, data, widget_location, drag_operations, 2309 GetWidget()->RunShellDrag(this, data, widget_location, drag_operations,
2309 source); 2310 source);
2310 return true; 2311 return true;
2311 #else 2312 #else
2312 return false; 2313 return false;
2313 #endif // !defined(OS_MACOSX) 2314 #endif // !defined(OS_MACOSX)
2314 } 2315 }
2315 2316
2316 } // namespace views 2317 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/view.h ('k') | ui/views/widget/root_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698