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

Side by Side Diff: chrome/browser/tab_contents/chrome_web_contents_view_delegate_views.cc

Issue 10409011: Aura/ash: On Desktops, use a aura::client to resolve screen coordinates. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Fix merge with trunk. Created 8 years, 7 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
« no previous file with comments | « no previous file | ui/aura/aura.gyp » ('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 (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 "chrome/browser/tab_contents/chrome_web_contents_view_delegate_views.h" 5 #include "chrome/browser/tab_contents/chrome_web_contents_view_delegate_views.h"
6 6
7 #include "chrome/browser/browser_shutdown.h" 7 #include "chrome/browser/browser_shutdown.h"
8 #include "chrome/browser/ui/constrained_window_tab_helper.h" 8 #include "chrome/browser/ui/constrained_window_tab_helper.h"
9 #include "chrome/browser/ui/sad_tab_helper.h" 9 #include "chrome/browser/ui/sad_tab_helper.h"
10 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 10 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
11 #include "chrome/browser/ui/views/constrained_window_views.h" 11 #include "chrome/browser/ui/views/constrained_window_views.h"
12 #include "chrome/browser/ui/views/tab_contents/render_view_context_menu_views.h" 12 #include "chrome/browser/ui/views/tab_contents/render_view_context_menu_views.h"
13 #include "content/public/browser/render_process_host.h" 13 #include "content/public/browser/render_process_host.h"
14 #include "content/public/browser/render_view_host.h" 14 #include "content/public/browser/render_view_host.h"
15 #include "content/public/browser/render_widget_host_view.h" 15 #include "content/public/browser/render_widget_host_view.h"
16 #include "content/public/browser/web_contents.h" 16 #include "content/public/browser/web_contents.h"
17 #include "content/public/browser/web_contents_view.h" 17 #include "content/public/browser/web_contents_view.h"
18 #include "ui/views/focus/focus_manager.h" 18 #include "ui/views/focus/focus_manager.h"
19 #include "ui/views/focus/view_storage.h" 19 #include "ui/views/focus/view_storage.h"
20 #include "ui/views/widget/widget.h" 20 #include "ui/views/widget/widget.h"
21 21
22 #if defined(USE_AURA) 22 #if defined(USE_AURA)
23 #include "chrome/browser/tab_contents/web_drag_bookmark_handler_aura.h" 23 #include "chrome/browser/tab_contents/web_drag_bookmark_handler_aura.h"
24 #include "ui/aura/client/screen_position_client.h"
25 #include "ui/aura/root_window.h"
24 #include "ui/aura/window.h" 26 #include "ui/aura/window.h"
25 #else 27 #else
26 #include "chrome/browser/tab_contents/web_drag_bookmark_handler_win.h" 28 #include "chrome/browser/tab_contents/web_drag_bookmark_handler_win.h"
27 #endif 29 #endif
28 30
29 ChromeWebContentsViewDelegateViews::ChromeWebContentsViewDelegateViews( 31 ChromeWebContentsViewDelegateViews::ChromeWebContentsViewDelegateViews(
30 content::WebContents* web_contents) 32 content::WebContents* web_contents)
31 : web_contents_(web_contents) { 33 : web_contents_(web_contents) {
32 last_focused_view_storage_id_ = 34 last_focused_view_storage_id_ =
33 views::ViewStorage::GetInstance()->CreateStorageID(); 35 views::ViewStorage::GetInstance()->CreateStorageID();
34 } 36 }
35 37
36 ChromeWebContentsViewDelegateViews::~ChromeWebContentsViewDelegateViews() { 38 ChromeWebContentsViewDelegateViews::~ChromeWebContentsViewDelegateViews() {
37 // Makes sure to remove any stored view we may still have in the ViewStorage. 39 // Makes sure to remove any stored view we may still have in the ViewStorage.
38 // 40 //
39 // It is possible the view went away before us, so we only do this if the 41 // It is possible the view went away before us, so we only do this if the
40 // view is registered. 42 // view is registered.
41 views::ViewStorage* view_storage = views::ViewStorage::GetInstance(); 43 views::ViewStorage* view_storage = views::ViewStorage::GetInstance();
42 if (view_storage->RetrieveView(last_focused_view_storage_id_) != NULL) 44 if (view_storage->RetrieveView(last_focused_view_storage_id_) != NULL)
43 view_storage->RemoveView(last_focused_view_storage_id_); 45 view_storage->RemoveView(last_focused_view_storage_id_);
44
45 } 46 }
46 47
47 content::WebDragDestDelegate* 48 content::WebDragDestDelegate*
48 ChromeWebContentsViewDelegateViews::GetDragDestDelegate() { 49 ChromeWebContentsViewDelegateViews::GetDragDestDelegate() {
49 // We install a chrome specific handler to intercept bookmark drags for the 50 // We install a chrome specific handler to intercept bookmark drags for the
50 // bookmark manager/extension API. 51 // bookmark manager/extension API.
51 #if defined(USE_AURA) 52 #if defined(USE_AURA)
52 bookmark_handler_.reset(new WebDragBookmarkHandlerAura); 53 bookmark_handler_.reset(new WebDragBookmarkHandlerAura);
53 #else 54 #else
54 bookmark_handler_.reset(new WebDragBookmarkHandlerWin); 55 bookmark_handler_.reset(new WebDragBookmarkHandlerWin);
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 context_menu_.reset(new RenderViewContextMenuViews(web_contents_, params)); 127 context_menu_.reset(new RenderViewContextMenuViews(web_contents_, params));
127 context_menu_->Init(); 128 context_menu_->Init();
128 129
129 // Don't show empty menus. 130 // Don't show empty menus.
130 if (context_menu_->menu_model().GetItemCount() == 0) 131 if (context_menu_->menu_model().GetItemCount() == 0)
131 return; 132 return;
132 133
133 gfx::Point screen_point(params.x, params.y); 134 gfx::Point screen_point(params.x, params.y);
134 135
135 #if defined(USE_AURA) 136 #if defined(USE_AURA)
136 gfx::Point view_origin = web_contents_->GetView()->GetNativeView()-> 137 // Convert from content coordinates to window coordinates.
137 GetBoundsInRootWindow().origin(); 138 aura::Window* web_contents_window =
138 screen_point.Offset(view_origin.x(), view_origin.y()); 139 web_contents_->GetView()->GetNativeView();
140 aura::RootWindow* root_window = web_contents_window->GetRootWindow();
141 aura::Window::ConvertPointToWindow(web_contents_window, root_window,
142 &screen_point);
143
144 // If we are on the desktop, transform the data from our toplevel window
145 // coordinates to screen coordinates.
146 aura::Window* toplevel_window =
147 web_contents_->GetView()->GetTopLevelNativeWindow();
148 aura::client::ScreenPositionClient* screen_position_client =
149 aura::client::GetScreenPositionClient(toplevel_window);
150 if (screen_position_client)
151 screen_position_client->ConvertToScreenPoint(&screen_point);
139 #else 152 #else
140 POINT temp = screen_point.ToPOINT(); 153 POINT temp = screen_point.ToPOINT();
141 ClientToScreen(web_contents_->GetView()->GetNativeView(), &temp); 154 ClientToScreen(web_contents_->GetView()->GetNativeView(), &temp);
142 screen_point = temp; 155 screen_point = temp;
143 #endif 156 #endif
144 157
145 // Enable recursive tasks on the message loop so we can get updates while 158 // Enable recursive tasks on the message loop so we can get updates while
146 // the context menu is being displayed. 159 // the context menu is being displayed.
147 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); 160 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current());
148 context_menu_->RunMenuAt(GetTopLevelWidget(), screen_point); 161 context_menu_->RunMenuAt(GetTopLevelWidget(), screen_point);
(...skipping 23 matching lines...) Expand all
172 return toplevel_widget ? toplevel_widget->GetFocusManager() : NULL; 185 return toplevel_widget ? toplevel_widget->GetFocusManager() : NULL;
173 } 186 }
174 187
175 void ChromeWebContentsViewDelegateViews::SetInitialFocus() { 188 void ChromeWebContentsViewDelegateViews::SetInitialFocus() {
176 if (web_contents_->FocusLocationBarByDefault()) { 189 if (web_contents_->FocusLocationBarByDefault()) {
177 web_contents_->SetFocusToLocationBar(false); 190 web_contents_->SetFocusToLocationBar(false);
178 } else { 191 } else {
179 web_contents_->GetView()->Focus(); 192 web_contents_->GetView()->Focus();
180 } 193 }
181 } 194 }
OLDNEW
« no previous file with comments | « no previous file | ui/aura/aura.gyp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698