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

Side by Side Diff: content/browser/web_contents/web_contents_view_guest.cc

Issue 130773004: Start moving context menu code to RenderFrame. (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: Created 6 years, 10 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
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_guest.h" 5 #include "content/browser/web_contents/web_contents_view_guest.h"
6 6
7 #include "build/build_config.h" 7 #include "build/build_config.h"
8 #include "content/browser/browser_plugin/browser_plugin_embedder.h" 8 #include "content/browser/browser_plugin/browser_plugin_embedder.h"
9 #include "content/browser/browser_plugin/browser_plugin_guest.h" 9 #include "content/browser/browser_plugin/browser_plugin_guest.h"
10 #include "content/browser/frame_host/interstitial_page_impl.h" 10 #include "content/browser/frame_host/interstitial_page_impl.h"
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after
210 if (view) 210 if (view)
211 view->UpdateDragCursor(operation); 211 view->UpdateDragCursor(operation);
212 } 212 }
213 213
214 void WebContentsViewGuest::GotFocus() { 214 void WebContentsViewGuest::GotFocus() {
215 } 215 }
216 216
217 void WebContentsViewGuest::TakeFocus(bool reverse) { 217 void WebContentsViewGuest::TakeFocus(bool reverse) {
218 } 218 }
219 219
220 void WebContentsViewGuest::ShowContextMenu(const ContextMenuParams& params) { 220 void WebContentsViewGuest::ShowContextMenu(RenderFrameHost* render_frame_host,
221 const ContextMenuParams& params) {
221 #if defined(USE_AURA) || defined(OS_WIN) 222 #if defined(USE_AURA) || defined(OS_WIN)
222 // Context menu uses ScreenPositionClient::ConvertPointToScreen() in aura and 223 // Context menu uses ScreenPositionClient::ConvertPointToScreen() in aura and
223 // windows to calculate popup position. Guest's native view 224 // windows to calculate popup position. Guest's native view
224 // (platform_view_->GetNativeView()) is part of the embedder's view hierarchy, 225 // (platform_view_->GetNativeView()) is part of the embedder's view hierarchy,
225 // but is placed at (0, 0) w.r.t. the embedder's position. Therefore, |offset| 226 // but is placed at (0, 0) w.r.t. the embedder's position. Therefore, |offset|
226 // is added to |params|. 227 // is added to |params|.
227 gfx::Rect embedder_bounds; 228 gfx::Rect embedder_bounds;
228 guest_->embedder_web_contents()->GetView()->GetContainerBounds( 229 guest_->embedder_web_contents()->GetView()->GetContainerBounds(
229 &embedder_bounds); 230 &embedder_bounds);
230 gfx::Rect guest_bounds; 231 gfx::Rect guest_bounds;
231 GetContainerBounds(&guest_bounds); 232 GetContainerBounds(&guest_bounds);
232 233
233 gfx::Vector2d offset = guest_bounds.origin() - embedder_bounds.origin(); 234 gfx::Vector2d offset = guest_bounds.origin() - embedder_bounds.origin();
234 ContextMenuParams params_in_embedder = params; 235 ContextMenuParams params_in_embedder = params;
235 params_in_embedder.x += offset.x(); 236 params_in_embedder.x += offset.x();
236 params_in_embedder.y += offset.y(); 237 params_in_embedder.y += offset.y();
237 platform_view_delegate_view_->ShowContextMenu(params_in_embedder); 238 platform_view_delegate_view_->ShowContextMenu(
239 render_frame_host, params_in_embedder);
238 #else 240 #else
239 platform_view_delegate_view_->ShowContextMenu(params); 241 platform_view_delegate_view_->ShowContextMenu(render_frame_host, params);
240 #endif // defined(USE_AURA) || defined(OS_WIN) 242 #endif // defined(USE_AURA) || defined(OS_WIN)
241 } 243 }
242 244
243 void WebContentsViewGuest::ShowPopupMenu(const gfx::Rect& bounds, 245 void WebContentsViewGuest::ShowPopupMenu(const gfx::Rect& bounds,
244 int item_height, 246 int item_height,
245 double item_font_size, 247 double item_font_size,
246 int selected_item, 248 int selected_item,
247 const std::vector<MenuItem>& items, 249 const std::vector<MenuItem>& items,
248 bool right_aligned, 250 bool right_aligned,
249 bool allow_multiple_selection) { 251 bool allow_multiple_selection) {
(...skipping 15 matching lines...) Expand all
265 CHECK(embedder_render_view_host); 267 CHECK(embedder_render_view_host);
266 RenderViewHostDelegateView* view = 268 RenderViewHostDelegateView* view =
267 embedder_render_view_host->GetDelegate()->GetDelegateView(); 269 embedder_render_view_host->GetDelegate()->GetDelegateView();
268 if (view) 270 if (view)
269 view->StartDragging(drop_data, ops, image, image_offset, event_info); 271 view->StartDragging(drop_data, ops, image, image_offset, event_info);
270 else 272 else
271 embedder_web_contents->SystemDragEnded(); 273 embedder_web_contents->SystemDragEnded();
272 } 274 }
273 275
274 } // namespace content 276 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698