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

Side by Side Diff: chrome/browser/ui/cocoa/tab_contents/chrome_web_contents_view_delegate_mac.mm

Issue 1865213004: Convert //chrome/browser/ui from scoped_ptr to std::unique_ptr (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: rebase Created 4 years, 8 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 #import "chrome/browser/ui/cocoa/tab_contents/chrome_web_contents_view_delegate_ mac.h" 5 #import "chrome/browser/ui/cocoa/tab_contents/chrome_web_contents_view_delegate_ mac.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/profiler/scoped_tracker.h" 9 #include "base/profiler/scoped_tracker.h"
10 #import "chrome/browser/renderer_host/chrome_render_widget_host_view_mac_delegat e.h" 10 #import "chrome/browser/renderer_host/chrome_render_widget_host_view_mac_delegat e.h"
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
50 // TODO(erikchen): Remove ScopedTracker below once crbug.com/458401 is fixed. 50 // TODO(erikchen): Remove ScopedTracker below once crbug.com/458401 is fixed.
51 tracked_objects::ScopedTracker tracking_profile( 51 tracked_objects::ScopedTracker tracking_profile(
52 FROM_HERE_WITH_EXPLICIT_FUNCTION( 52 FROM_HERE_WITH_EXPLICIT_FUNCTION(
53 "458401 ChromeWebContentsViewDelegateMac::ShowContextMenu")); 53 "458401 ChromeWebContentsViewDelegateMac::ShowContextMenu"));
54 ShowMenu( 54 ShowMenu(
55 BuildMenu(content::WebContents::FromRenderFrameHost(render_frame_host), 55 BuildMenu(content::WebContents::FromRenderFrameHost(render_frame_host),
56 params)); 56 params));
57 } 57 }
58 58
59 void ChromeWebContentsViewDelegateMac::ShowMenu( 59 void ChromeWebContentsViewDelegateMac::ShowMenu(
60 scoped_ptr<RenderViewContextMenuBase> menu) { 60 std::unique_ptr<RenderViewContextMenuBase> menu) {
61 // TODO(erikchen): Remove ScopedTracker below once crbug.com/458401 is fixed. 61 // TODO(erikchen): Remove ScopedTracker below once crbug.com/458401 is fixed.
62 tracked_objects::ScopedTracker tracking_profile( 62 tracked_objects::ScopedTracker tracking_profile(
63 FROM_HERE_WITH_EXPLICIT_FUNCTION( 63 FROM_HERE_WITH_EXPLICIT_FUNCTION(
64 "458401 ChromeWebContentsViewDelegateMac::ShowMenu")); 64 "458401 ChromeWebContentsViewDelegateMac::ShowMenu"));
65 65
66 context_menu_ = std::move(menu); 66 context_menu_ = std::move(menu);
67 if (!context_menu_.get()) 67 if (!context_menu_.get())
68 return; 68 return;
69 69
70 // The renderer may send the "show context menu" message multiple times, one 70 // The renderer may send the "show context menu" message multiple times, one
71 // for each right click mouse event it receives. Normally, this doesn't happen 71 // for each right click mouse event it receives. Normally, this doesn't happen
72 // because mouse events are not forwarded once the context menu is showing. 72 // because mouse events are not forwarded once the context menu is showing.
73 // However, there's a race - the context menu may not yet be showing when 73 // However, there's a race - the context menu may not yet be showing when
74 // the second mouse event arrives. In this case, |ShowContextMenu()| will 74 // the second mouse event arrives. In this case, |ShowContextMenu()| will
75 // get called multiple times - if so, don't create another context menu. 75 // get called multiple times - if so, don't create another context menu.
76 // TODO(asvitkine): Fix the renderer so that it doesn't do this. 76 // TODO(asvitkine): Fix the renderer so that it doesn't do this.
77 content::RenderWidgetHostView* widget_view = GetActiveRenderWidgetHostView(); 77 content::RenderWidgetHostView* widget_view = GetActiveRenderWidgetHostView();
78 if (widget_view && widget_view->IsShowingContextMenu()) 78 if (widget_view && widget_view->IsShowingContextMenu())
79 return; 79 return;
80 80
81 context_menu_->Show(); 81 context_menu_->Show();
82 } 82 }
83 83
84 scoped_ptr<RenderViewContextMenuBase> 84 std::unique_ptr<RenderViewContextMenuBase>
85 ChromeWebContentsViewDelegateMac::BuildMenu( 85 ChromeWebContentsViewDelegateMac::BuildMenu(
86 content::WebContents* web_contents, 86 content::WebContents* web_contents,
87 const content::ContextMenuParams& params) { 87 const content::ContextMenuParams& params) {
88 // TODO(erikchen): Remove ScopedTracker below once crbug.com/458401 is fixed. 88 // TODO(erikchen): Remove ScopedTracker below once crbug.com/458401 is fixed.
89 tracked_objects::ScopedTracker tracking_profile1( 89 tracked_objects::ScopedTracker tracking_profile1(
90 FROM_HERE_WITH_EXPLICIT_FUNCTION( 90 FROM_HERE_WITH_EXPLICIT_FUNCTION(
91 "458401 ChromeWebContentsViewDelegateMac::BuildMenu")); 91 "458401 ChromeWebContentsViewDelegateMac::BuildMenu"));
92 scoped_ptr<RenderViewContextMenuBase> menu; 92 std::unique_ptr<RenderViewContextMenuBase> menu;
93 content::RenderFrameHost* focused_frame = web_contents->GetFocusedFrame(); 93 content::RenderFrameHost* focused_frame = web_contents->GetFocusedFrame();
94 // If the frame tree does not have a focused frame at this point, do not 94 // If the frame tree does not have a focused frame at this point, do not
95 // bother creating RenderViewContextMenuMac. 95 // bother creating RenderViewContextMenuMac.
96 // This happens if the frame has navigated to a different page before 96 // This happens if the frame has navigated to a different page before
97 // ContextMenu message was received by the current RenderFrameHost. 97 // ContextMenu message was received by the current RenderFrameHost.
98 if (focused_frame) { 98 if (focused_frame) {
99 content::RenderWidgetHostView* widget_view = 99 content::RenderWidgetHostView* widget_view =
100 GetActiveRenderWidgetHostView(); 100 GetActiveRenderWidgetHostView();
101 101
102 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/458401 102 // TODO(erikchen): Remove ScopedTracker below once http://crbug.com/458401
(...skipping 23 matching lines...) Expand all
126 } 126 }
127 127
128 namespace chrome { 128 namespace chrome {
129 129
130 content::WebContentsViewDelegate* CreateWebContentsViewDelegate( 130 content::WebContentsViewDelegate* CreateWebContentsViewDelegate(
131 content::WebContents* web_contents) { 131 content::WebContents* web_contents) {
132 return new ChromeWebContentsViewDelegateMac(web_contents); 132 return new ChromeWebContentsViewDelegateMac(web_contents);
133 } 133 }
134 134
135 } // namespace chrome 135 } // namespace chrome
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698