| 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 #import <Carbon/Carbon.h> | 5 #import <Carbon/Carbon.h> |
| 6 | 6 |
| 7 #include "chrome/browser/tab_contents/moving_to_content/tab_contents_view_mac.h" | 7 #include "chrome/browser/tab_contents/moving_to_content/tab_contents_view_mac.h" |
| 8 | 8 |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 345 | 345 |
| 346 void TabContentsViewMac::ShowContextMenu(const ContextMenuParams& params) { | 346 void TabContentsViewMac::ShowContextMenu(const ContextMenuParams& params) { |
| 347 // The renderer may send the "show context menu" message multiple times, one | 347 // The renderer may send the "show context menu" message multiple times, one |
| 348 // for each right click mouse event it receives. Normally, this doesn't happen | 348 // for each right click mouse event it receives. Normally, this doesn't happen |
| 349 // because mouse events are not forwarded once the context menu is showing. | 349 // because mouse events are not forwarded once the context menu is showing. |
| 350 // However, there's a race - the context menu may not yet be showing when | 350 // However, there's a race - the context menu may not yet be showing when |
| 351 // the second mouse event arrives. In this case, |ShowContextMenu()| will | 351 // the second mouse event arrives. In this case, |ShowContextMenu()| will |
| 352 // get called multiple times - if so, don't create another context menu. | 352 // get called multiple times - if so, don't create another context menu. |
| 353 // TODO(asvitkine): Fix the renderer so that it doesn't do this. | 353 // TODO(asvitkine): Fix the renderer so that it doesn't do this. |
| 354 RenderWidgetHostView* widget_view = tab_contents_->GetRenderWidgetHostView(); | 354 RenderWidgetHostView* widget_view = tab_contents_->GetRenderWidgetHostView(); |
| 355 if (widget_view) { | 355 if (widget_view && widget_view->showing_context_menu()) |
| 356 RenderWidgetHostViewMac* widget_view_mac = | 356 return; |
| 357 static_cast<RenderWidgetHostViewMac*>(widget_view); | |
| 358 if (widget_view_mac->is_showing_context_menu()) | |
| 359 return; | |
| 360 } | |
| 361 | 357 |
| 362 // Allow delegates to handle the context menu operation first. | 358 // Allow delegates to handle the context menu operation first. |
| 363 if (tab_contents_->GetDelegate() && | 359 if (tab_contents_->GetDelegate() && |
| 364 tab_contents_->GetDelegate()->HandleContextMenu(params)) { | 360 tab_contents_->GetDelegate()->HandleContextMenu(params)) { |
| 365 return; | 361 return; |
| 366 } | 362 } |
| 367 | 363 |
| 368 context_menu_.reset(new RenderViewContextMenuMac(tab_contents(), | 364 context_menu_.reset(new RenderViewContextMenuMac(tab_contents(), |
| 369 params, | 365 params, |
| 370 GetContentNativeView())); | 366 GetContentNativeView())); |
| (...skipping 247 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 618 [[[notification userInfo] objectForKey:kSelectionDirection] | 614 [[[notification userInfo] objectForKey:kSelectionDirection] |
| 619 unsignedIntegerValue]; | 615 unsignedIntegerValue]; |
| 620 if (direction == NSDirectSelection) | 616 if (direction == NSDirectSelection) |
| 621 return; | 617 return; |
| 622 | 618 |
| 623 [self tabContents]-> | 619 [self tabContents]-> |
| 624 FocusThroughTabTraversal(direction == NSSelectingPrevious); | 620 FocusThroughTabTraversal(direction == NSSelectingPrevious); |
| 625 } | 621 } |
| 626 | 622 |
| 627 @end | 623 @end |
| OLD | NEW |