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

Side by Side Diff: athena/content/web_contents_view_delegate_factory_impl.cc

Issue 678653003: Remove Downcasting RVContextMenuBase in ContextMenuDeleagate implementations. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove virtual keyword when override is specified Created 6 years, 1 month 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
« no previous file with comments | « athena/content/render_view_context_menu_impl.cc ('k') | chrome/browser/apps/app_browsertest.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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "athena/content/public/web_contents_view_delegate_creator.h" 5 #include "athena/content/public/web_contents_view_delegate_creator.h"
6 6
7 #include "athena/content/render_view_context_menu_impl.h" 7 #include "athena/content/render_view_context_menu_impl.h"
8 #include "components/web_modal/popup_manager.h" 8 #include "components/web_modal/popup_manager.h"
9 #include "components/web_modal/single_web_contents_dialog_manager.h" 9 #include "components/web_modal/single_web_contents_dialog_manager.h"
10 #include "components/web_modal/web_contents_modal_dialog_host.h" 10 #include "components/web_modal/web_contents_modal_dialog_host.h"
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 if (focused_frame) { 74 if (focused_frame) {
75 menu.reset(new RenderViewContextMenuImpl(focused_frame, params)); 75 menu.reset(new RenderViewContextMenuImpl(focused_frame, params));
76 menu->Init(); 76 menu->Init();
77 } 77 }
78 return menu.Pass(); 78 return menu.Pass();
79 } 79 }
80 80
81 void ShowMenu(scoped_ptr<RenderViewContextMenuImpl> menu) { 81 void ShowMenu(scoped_ptr<RenderViewContextMenuImpl> menu) {
82 context_menu_.reset(menu.release()); 82 context_menu_.reset(menu.release());
83 83
84 if (!context_menu_.get()) 84 if (!context_menu_)
85 return; 85 return;
86 86
87 // Menus need a Widget to work. If we're not the active tab we won't 87 context_menu_->Show();
88 // necessarily be in a widget.
89 views::Widget* top_level_widget = GetTopLevelWidget();
90 if (!top_level_widget)
91 return;
92
93 const content::ContextMenuParams& params = context_menu_->params();
94 // Don't show empty menus.
95 if (context_menu_->menu_model().GetItemCount() == 0)
96 return;
97
98 gfx::Point screen_point(params.x, params.y);
99
100 // Convert from target window coordinates to root window coordinates.
101 aura::Window* target_window = GetActiveNativeView();
102 aura::Window* root_window = target_window->GetRootWindow();
103 aura::client::ScreenPositionClient* screen_position_client =
104 aura::client::GetScreenPositionClient(root_window);
105 if (screen_position_client) {
106 screen_position_client->ConvertPointToScreen(target_window,
107 &screen_point);
108 }
109 // Enable recursive tasks on the message loop so we can get updates while
110 // the context menu is being displayed.
111 base::MessageLoop::ScopedNestableTaskAllower allow(
112 base::MessageLoop::current());
113 context_menu_->RunMenuAt(
114 top_level_widget, screen_point, params.source_type);
115 } 88 }
116 89
117 aura::Window* GetActiveNativeView() { 90 aura::Window* GetActiveNativeView() {
118 return web_contents_->GetFullscreenRenderWidgetHostView() 91 return web_contents_->GetFullscreenRenderWidgetHostView()
119 ? web_contents_->GetFullscreenRenderWidgetHostView() 92 ? web_contents_->GetFullscreenRenderWidgetHostView()
120 ->GetNativeView() 93 ->GetNativeView()
121 : web_contents_->GetNativeView(); 94 : web_contents_->GetNativeView();
122 } 95 }
123 96
124 views::Widget* GetTopLevelWidget() { 97 views::Widget* GetTopLevelWidget() {
(...skipping 19 matching lines...) Expand all
144 }; 117 };
145 118
146 } // namespace 119 } // namespace
147 120
148 content::WebContentsViewDelegate* CreateWebContentsViewDelegate( 121 content::WebContentsViewDelegate* CreateWebContentsViewDelegate(
149 content::WebContents* web_contents) { 122 content::WebContents* web_contents) {
150 return new WebContentsViewDelegateImpl(web_contents); 123 return new WebContentsViewDelegateImpl(web_contents);
151 } 124 }
152 125
153 } // namespace athena 126 } // namespace athena
OLDNEW
« no previous file with comments | « athena/content/render_view_context_menu_impl.cc ('k') | chrome/browser/apps/app_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698