| 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 "chrome/browser/tab_contents/chrome_web_contents_view_mac_delegate.h" | 5 #import "chrome/browser/tab_contents/chrome_web_contents_view_mac_delegate.h" |
| 6 | 6 |
| 7 #import "chrome/browser/renderer_host/chrome_render_widget_host_view_mac_delegat
e.h" | 7 #import "chrome/browser/renderer_host/chrome_render_widget_host_view_mac_delegat
e.h" |
| 8 #include "chrome/browser/tab_contents/render_view_context_menu_mac.h" | 8 #include "chrome/browser/tab_contents/render_view_context_menu_mac.h" |
| 9 #include "chrome/browser/tab_contents/web_drag_bookmark_handler_mac.h" | 9 #include "chrome/browser/tab_contents/web_drag_bookmark_handler_mac.h" |
| 10 #import "chrome/browser/ui/cocoa/view_id_util.h" | 10 #import "chrome/browser/ui/cocoa/view_id_util.h" |
| (...skipping 21 matching lines...) Expand all Loading... |
| 32 RenderWidgetHost* render_widget_host) { | 32 RenderWidgetHost* render_widget_host) { |
| 33 return [[ChromeRenderWidgetHostViewMacDelegate alloc] | 33 return [[ChromeRenderWidgetHostViewMacDelegate alloc] |
| 34 initWithRenderWidgetHost:render_widget_host]; | 34 initWithRenderWidgetHost:render_widget_host]; |
| 35 } | 35 } |
| 36 | 36 |
| 37 content::WebDragDestDelegate* ChromeWebContentsViewMacDelegate::DragDelegate() { | 37 content::WebDragDestDelegate* ChromeWebContentsViewMacDelegate::DragDelegate() { |
| 38 return static_cast<content::WebDragDestDelegate*>(bookmark_handler_.get()); | 38 return static_cast<content::WebDragDestDelegate*>(bookmark_handler_.get()); |
| 39 } | 39 } |
| 40 | 40 |
| 41 void ChromeWebContentsViewMacDelegate::ShowContextMenu( | 41 void ChromeWebContentsViewMacDelegate::ShowContextMenu( |
| 42 const ContextMenuParams& params) { | 42 const content::ContextMenuParams& params) { |
| 43 // The renderer may send the "show context menu" message multiple times, one | 43 // The renderer may send the "show context menu" message multiple times, one |
| 44 // for each right click mouse event it receives. Normally, this doesn't happen | 44 // for each right click mouse event it receives. Normally, this doesn't happen |
| 45 // because mouse events are not forwarded once the context menu is showing. | 45 // because mouse events are not forwarded once the context menu is showing. |
| 46 // However, there's a race - the context menu may not yet be showing when | 46 // However, there's a race - the context menu may not yet be showing when |
| 47 // the second mouse event arrives. In this case, |ShowContextMenu()| will | 47 // the second mouse event arrives. In this case, |ShowContextMenu()| will |
| 48 // get called multiple times - if so, don't create another context menu. | 48 // get called multiple times - if so, don't create another context menu. |
| 49 // TODO(asvitkine): Fix the renderer so that it doesn't do this. | 49 // TODO(asvitkine): Fix the renderer so that it doesn't do this. |
| 50 RenderWidgetHostView* widget_view = web_contents_->GetRenderWidgetHostView(); | 50 RenderWidgetHostView* widget_view = web_contents_->GetRenderWidgetHostView(); |
| 51 if (widget_view && widget_view->showing_context_menu()) | 51 if (widget_view && widget_view->showing_context_menu()) |
| 52 return; | 52 return; |
| 53 | 53 |
| 54 context_menu_.reset( | 54 context_menu_.reset( |
| 55 new RenderViewContextMenuMac(web_contents_, | 55 new RenderViewContextMenuMac(web_contents_, |
| 56 params, | 56 params, |
| 57 web_contents_->GetContentNativeView())); | 57 web_contents_->GetContentNativeView())); |
| 58 context_menu_->Init(); | 58 context_menu_->Init(); |
| 59 } | 59 } |
| 60 | 60 |
| 61 void ChromeWebContentsViewMacDelegate::NativeViewCreated(NSView* view) { | 61 void ChromeWebContentsViewMacDelegate::NativeViewCreated(NSView* view) { |
| 62 view_id_util::SetID(view, VIEW_ID_TAB_CONTAINER); | 62 view_id_util::SetID(view, VIEW_ID_TAB_CONTAINER); |
| 63 } | 63 } |
| 64 | 64 |
| 65 void ChromeWebContentsViewMacDelegate::NativeViewDestroyed(NSView* view) { | 65 void ChromeWebContentsViewMacDelegate::NativeViewDestroyed(NSView* view) { |
| 66 view_id_util::UnsetID(view); | 66 view_id_util::UnsetID(view); |
| 67 } | 67 } |
| OLD | NEW |