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

Side by Side Diff: content/browser/web_contents/web_contents_view_aura.cc

Issue 10031044: TabContents -> WebContentsImpl, part 5. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase (fixed) Created 8 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 | Annotate | Revision Log
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 "content/browser/tab_contents/tab_contents_view_aura.h" 5 #include "content/browser/web_contents/web_contents_view_aura.h"
6 6
7 #include "base/utf_string_conversions.h" 7 #include "base/utf_string_conversions.h"
8 #include "content/browser/renderer_host/render_view_host_factory.h" 8 #include "content/browser/renderer_host/render_view_host_factory.h"
9 #include "content/browser/tab_contents/tab_contents.h" 9 #include "content/browser/tab_contents/tab_contents.h"
10 #include "content/browser/web_contents/interstitial_page_impl.h" 10 #include "content/browser/web_contents/interstitial_page_impl.h"
11 #include "content/public/browser/render_view_host.h" 11 #include "content/public/browser/render_view_host.h"
12 #include "content/public/browser/render_widget_host.h" 12 #include "content/public/browser/render_widget_host.h"
13 #include "content/public/browser/render_widget_host_view.h" 13 #include "content/public/browser/render_widget_host_view.h"
14 #include "content/public/browser/web_contents_delegate.h" 14 #include "content/public/browser/web_contents_delegate.h"
15 #include "content/public/browser/web_contents_view_delegate.h" 15 #include "content/public/browser/web_contents_view_delegate.h"
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
153 web_drag_op |= WebKit::WebDragOperationMove; 153 web_drag_op |= WebKit::WebDragOperationMove;
154 if (drag_op & ui::DragDropTypes::DRAG_LINK) 154 if (drag_op & ui::DragDropTypes::DRAG_LINK)
155 web_drag_op |= WebKit::WebDragOperationLink; 155 web_drag_op |= WebKit::WebDragOperationLink;
156 return (WebKit::WebDragOperationsMask) web_drag_op; 156 return (WebKit::WebDragOperationsMask) web_drag_op;
157 } 157 }
158 158
159 } // namespace 159 } // namespace
160 160
161 161
162 //////////////////////////////////////////////////////////////////////////////// 162 ////////////////////////////////////////////////////////////////////////////////
163 // TabContentsViewAura, public: 163 // WebContentsViewAura, public:
164 164
165 TabContentsViewAura::TabContentsViewAura( 165 WebContentsViewAura::WebContentsViewAura(
166 TabContents* tab_contents, 166 TabContents* tab_contents,
167 content::WebContentsViewDelegate* delegate) 167 content::WebContentsViewDelegate* delegate)
168 : tab_contents_(tab_contents), 168 : tab_contents_(tab_contents),
169 view_(NULL), 169 view_(NULL),
170 delegate_(delegate), 170 delegate_(delegate),
171 current_drag_op_(WebKit::WebDragOperationNone), 171 current_drag_op_(WebKit::WebDragOperationNone),
172 close_tab_after_drag_ends_(false) { 172 close_tab_after_drag_ends_(false) {
173 } 173 }
174 174
175 TabContentsViewAura::~TabContentsViewAura() { 175 WebContentsViewAura::~WebContentsViewAura() {
176 } 176 }
177 177
178 //////////////////////////////////////////////////////////////////////////////// 178 ////////////////////////////////////////////////////////////////////////////////
179 // TabContentsViewAura, private: 179 // WebContentsViewAura, private:
180 180
181 void TabContentsViewAura::SizeChangedCommon(const gfx::Size& size) { 181 void WebContentsViewAura::SizeChangedCommon(const gfx::Size& size) {
182 if (tab_contents_->GetInterstitialPage()) 182 if (tab_contents_->GetInterstitialPage())
183 tab_contents_->GetInterstitialPage()->SetSize(size); 183 tab_contents_->GetInterstitialPage()->SetSize(size);
184 content::RenderWidgetHostView* rwhv = 184 content::RenderWidgetHostView* rwhv =
185 tab_contents_->GetRenderWidgetHostView(); 185 tab_contents_->GetRenderWidgetHostView();
186 if (rwhv) 186 if (rwhv)
187 rwhv->SetSize(size); 187 rwhv->SetSize(size);
188 } 188 }
189 189
190 void TabContentsViewAura::EndDrag(WebKit::WebDragOperationsMask ops) { 190 void WebContentsViewAura::EndDrag(WebKit::WebDragOperationsMask ops) {
191 aura::RootWindow* root_window = GetNativeView()->GetRootWindow(); 191 aura::RootWindow* root_window = GetNativeView()->GetRootWindow();
192 gfx::Point screen_loc = root_window->last_mouse_location(); 192 gfx::Point screen_loc = root_window->last_mouse_location();
193 gfx::Point client_loc = screen_loc; 193 gfx::Point client_loc = screen_loc;
194 content::RenderViewHost* rvh = tab_contents_->GetRenderViewHost(); 194 content::RenderViewHost* rvh = tab_contents_->GetRenderViewHost();
195 aura::Window* window = rvh->GetView()->GetNativeView(); 195 aura::Window* window = rvh->GetView()->GetNativeView();
196 aura::Window::ConvertPointToWindow(root_window, window, &client_loc); 196 aura::Window::ConvertPointToWindow(root_window, window, &client_loc);
197 rvh->DragSourceEndedAt(client_loc.x(), client_loc.y(), screen_loc.x(), 197 rvh->DragSourceEndedAt(client_loc.x(), client_loc.y(), screen_loc.x(),
198 screen_loc.y(), ops); 198 screen_loc.y(), ops);
199 } 199 }
200 200
201 content::WebDragDestDelegate* TabContentsViewAura::GetDragDestDelegate() { 201 content::WebDragDestDelegate* WebContentsViewAura::GetDragDestDelegate() {
202 return delegate_.get() ? delegate_->GetDragDestDelegate() : NULL; 202 return delegate_.get() ? delegate_->GetDragDestDelegate() : NULL;
203 } 203 }
204 204
205 //////////////////////////////////////////////////////////////////////////////// 205 ////////////////////////////////////////////////////////////////////////////////
206 // TabContentsViewAura, WebContentsView implementation: 206 // WebContentsViewAura, WebContentsView implementation:
207 207
208 void TabContentsViewAura::CreateView(const gfx::Size& initial_size) { 208 void WebContentsViewAura::CreateView(const gfx::Size& initial_size) {
209 initial_size_ = initial_size; 209 initial_size_ = initial_size;
210 210
211 window_.reset(new aura::Window(this)); 211 window_.reset(new aura::Window(this));
212 window_->set_owned_by_parent(false); 212 window_->set_owned_by_parent(false);
213 window_->SetType(aura::client::WINDOW_TYPE_CONTROL); 213 window_->SetType(aura::client::WINDOW_TYPE_CONTROL);
214 window_->SetTransparent(false); 214 window_->SetTransparent(false);
215 window_->Init(ui::LAYER_NOT_DRAWN); 215 window_->Init(ui::LAYER_NOT_DRAWN);
216 window_->SetParent(NULL); 216 window_->SetParent(NULL);
217 window_->layer()->SetMasksToBounds(true); 217 window_->layer()->SetMasksToBounds(true);
218 window_->SetName("TabContentsViewAura"); 218 window_->SetName("WebContentsViewAura");
219 } 219 }
220 220
221 content::RenderWidgetHostView* TabContentsViewAura::CreateViewForWidget( 221 content::RenderWidgetHostView* WebContentsViewAura::CreateViewForWidget(
222 content::RenderWidgetHost* render_widget_host) { 222 content::RenderWidgetHost* render_widget_host) {
223 if (render_widget_host->GetView()) { 223 if (render_widget_host->GetView()) {
224 // During testing, the view will already be set up in most cases to the 224 // During testing, the view will already be set up in most cases to the
225 // test view, so we don't want to clobber it with a real one. To verify that 225 // test view, so we don't want to clobber it with a real one. To verify that
226 // this actually is happening (and somebody isn't accidentally creating the 226 // this actually is happening (and somebody isn't accidentally creating the
227 // view twice), we check for the RVH Factory, which will be set when we're 227 // view twice), we check for the RVH Factory, which will be set when we're
228 // making special ones (which go along with the special views). 228 // making special ones (which go along with the special views).
229 DCHECK(RenderViewHostFactory::has_factory()); 229 DCHECK(RenderViewHostFactory::has_factory());
230 return render_widget_host->GetView(); 230 return render_widget_host->GetView();
231 } 231 }
232 232
233 view_ = content::RenderWidgetHostView::CreateViewForWidget( 233 view_ = content::RenderWidgetHostView::CreateViewForWidget(
234 render_widget_host); 234 render_widget_host);
235 view_->InitAsChild(NULL); 235 view_->InitAsChild(NULL);
236 GetNativeView()->AddChild(view_->GetNativeView()); 236 GetNativeView()->AddChild(view_->GetNativeView());
237 view_->Show(); 237 view_->Show();
238 238
239 // We listen to drag drop events in the newly created view's window. 239 // We listen to drag drop events in the newly created view's window.
240 aura::client::SetDragDropDelegate(view_->GetNativeView(), this); 240 aura::client::SetDragDropDelegate(view_->GetNativeView(), this);
241 return view_; 241 return view_;
242 } 242 }
243 243
244 gfx::NativeView TabContentsViewAura::GetNativeView() const { 244 gfx::NativeView WebContentsViewAura::GetNativeView() const {
245 return window_.get(); 245 return window_.get();
246 } 246 }
247 247
248 gfx::NativeView TabContentsViewAura::GetContentNativeView() const { 248 gfx::NativeView WebContentsViewAura::GetContentNativeView() const {
249 return view_->GetNativeView(); 249 return view_->GetNativeView();
250 } 250 }
251 251
252 gfx::NativeWindow TabContentsViewAura::GetTopLevelNativeWindow() const { 252 gfx::NativeWindow WebContentsViewAura::GetTopLevelNativeWindow() const {
253 return window_->GetToplevelWindow(); 253 return window_->GetToplevelWindow();
254 } 254 }
255 255
256 void TabContentsViewAura::GetContainerBounds(gfx::Rect *out) const { 256 void WebContentsViewAura::GetContainerBounds(gfx::Rect *out) const {
257 *out = window_->GetScreenBounds(); 257 *out = window_->GetScreenBounds();
258 } 258 }
259 259
260 void TabContentsViewAura::SetPageTitle(const string16& title) { 260 void WebContentsViewAura::SetPageTitle(const string16& title) {
261 window_->set_title(title); 261 window_->set_title(title);
262 } 262 }
263 263
264 void TabContentsViewAura::OnTabCrashed(base::TerminationStatus status, 264 void WebContentsViewAura::OnTabCrashed(base::TerminationStatus status,
265 int error_code) { 265 int error_code) {
266 view_ = NULL; 266 view_ = NULL;
267 } 267 }
268 268
269 void TabContentsViewAura::SizeContents(const gfx::Size& size) { 269 void WebContentsViewAura::SizeContents(const gfx::Size& size) {
270 gfx::Rect bounds = window_->bounds(); 270 gfx::Rect bounds = window_->bounds();
271 if (bounds.size() != size) { 271 if (bounds.size() != size) {
272 bounds.set_size(size); 272 bounds.set_size(size);
273 window_->SetBounds(bounds); 273 window_->SetBounds(bounds);
274 } else { 274 } else {
275 // Our size matches what we want but the renderers size may not match. 275 // Our size matches what we want but the renderers size may not match.
276 // Pretend we were resized so that the renderers size is updated too. 276 // Pretend we were resized so that the renderers size is updated too.
277 SizeChangedCommon(size); 277 SizeChangedCommon(size);
278 278
279 } 279 }
280 } 280 }
281 281
282 void TabContentsViewAura::RenderViewCreated(content::RenderViewHost* host) { 282 void WebContentsViewAura::RenderViewCreated(content::RenderViewHost* host) {
283 } 283 }
284 284
285 void TabContentsViewAura::Focus() { 285 void WebContentsViewAura::Focus() {
286 if (tab_contents_->GetInterstitialPage()) { 286 if (tab_contents_->GetInterstitialPage()) {
287 tab_contents_->GetInterstitialPage()->Focus(); 287 tab_contents_->GetInterstitialPage()->Focus();
288 return; 288 return;
289 } 289 }
290 290
291 if (delegate_.get() && delegate_->Focus()) 291 if (delegate_.get() && delegate_->Focus())
292 return; 292 return;
293 293
294 content::RenderWidgetHostView* rwhv = 294 content::RenderWidgetHostView* rwhv =
295 tab_contents_->GetRenderWidgetHostView(); 295 tab_contents_->GetRenderWidgetHostView();
296 if (rwhv) 296 if (rwhv)
297 rwhv->Focus(); 297 rwhv->Focus();
298 } 298 }
299 299
300 void TabContentsViewAura::SetInitialFocus() { 300 void WebContentsViewAura::SetInitialFocus() {
301 if (tab_contents_->FocusLocationBarByDefault()) 301 if (tab_contents_->FocusLocationBarByDefault())
302 tab_contents_->SetFocusToLocationBar(false); 302 tab_contents_->SetFocusToLocationBar(false);
303 else 303 else
304 Focus(); 304 Focus();
305 } 305 }
306 306
307 void TabContentsViewAura::StoreFocus() { 307 void WebContentsViewAura::StoreFocus() {
308 if (delegate_.get()) 308 if (delegate_.get())
309 delegate_->StoreFocus(); 309 delegate_->StoreFocus();
310 } 310 }
311 311
312 void TabContentsViewAura::RestoreFocus() { 312 void WebContentsViewAura::RestoreFocus() {
313 if (delegate_.get()) 313 if (delegate_.get())
314 delegate_->RestoreFocus(); 314 delegate_->RestoreFocus();
315 } 315 }
316 316
317 bool TabContentsViewAura::IsDoingDrag() const { 317 bool WebContentsViewAura::IsDoingDrag() const {
318 aura::RootWindow* root_window = GetNativeView()->GetRootWindow(); 318 aura::RootWindow* root_window = GetNativeView()->GetRootWindow();
319 if (aura::client::GetDragDropClient(root_window)) 319 if (aura::client::GetDragDropClient(root_window))
320 return aura::client::GetDragDropClient(root_window)->IsDragDropInProgress(); 320 return aura::client::GetDragDropClient(root_window)->IsDragDropInProgress();
321 return false; 321 return false;
322 } 322 }
323 323
324 void TabContentsViewAura::CancelDragAndCloseTab() { 324 void WebContentsViewAura::CancelDragAndCloseTab() {
325 DCHECK(IsDoingDrag()); 325 DCHECK(IsDoingDrag());
326 // We can't close the tab while we're in the drag and 326 // We can't close the tab while we're in the drag and
327 // |drag_handler_->CancelDrag()| is async. Instead, set a flag to cancel 327 // |drag_handler_->CancelDrag()| is async. Instead, set a flag to cancel
328 // the drag and when the drag nested message loop ends, close the tab. 328 // the drag and when the drag nested message loop ends, close the tab.
329 aura::RootWindow* root_window = GetNativeView()->GetRootWindow(); 329 aura::RootWindow* root_window = GetNativeView()->GetRootWindow();
330 if (aura::client::GetDragDropClient(root_window)) 330 if (aura::client::GetDragDropClient(root_window))
331 aura::client::GetDragDropClient(root_window)->DragCancel(); 331 aura::client::GetDragDropClient(root_window)->DragCancel();
332 332
333 close_tab_after_drag_ends_ = true; 333 close_tab_after_drag_ends_ = true;
334 } 334 }
335 335
336 bool TabContentsViewAura::IsEventTracking() const { 336 bool WebContentsViewAura::IsEventTracking() const {
337 return false; 337 return false;
338 } 338 }
339 339
340 void TabContentsViewAura::CloseTabAfterEventTracking() { 340 void WebContentsViewAura::CloseTabAfterEventTracking() {
341 } 341 }
342 342
343 void TabContentsViewAura::GetViewBounds(gfx::Rect* out) const { 343 void WebContentsViewAura::GetViewBounds(gfx::Rect* out) const {
344 *out = window_->GetScreenBounds(); 344 *out = window_->GetScreenBounds();
345 } 345 }
346 346
347 //////////////////////////////////////////////////////////////////////////////// 347 ////////////////////////////////////////////////////////////////////////////////
348 // TabContentsViewAura, RenderViewHostDelegate::View implementation: 348 // WebContentsViewAura, RenderViewHostDelegate::View implementation:
349 349
350 void TabContentsViewAura::CreateNewWindow( 350 void WebContentsViewAura::CreateNewWindow(
351 int route_id, 351 int route_id,
352 const ViewHostMsg_CreateWindow_Params& params) { 352 const ViewHostMsg_CreateWindow_Params& params) {
353 tab_contents_view_helper_.CreateNewWindow(tab_contents_, route_id, params); 353 web_contents_view_helper_.CreateNewWindow(tab_contents_, route_id, params);
354 } 354 }
355 355
356 void TabContentsViewAura::CreateNewWidget(int route_id, 356 void WebContentsViewAura::CreateNewWidget(int route_id,
357 WebKit::WebPopupType popup_type) { 357 WebKit::WebPopupType popup_type) {
358 tab_contents_view_helper_.CreateNewWidget(tab_contents_, 358 web_contents_view_helper_.CreateNewWidget(tab_contents_,
359 route_id, 359 route_id,
360 false, 360 false,
361 popup_type); 361 popup_type);
362 } 362 }
363 363
364 void TabContentsViewAura::CreateNewFullscreenWidget(int route_id) { 364 void WebContentsViewAura::CreateNewFullscreenWidget(int route_id) {
365 tab_contents_view_helper_.CreateNewWidget(tab_contents_, 365 web_contents_view_helper_.CreateNewWidget(tab_contents_,
366 route_id, 366 route_id,
367 true, 367 true,
368 WebKit::WebPopupTypeNone); 368 WebKit::WebPopupTypeNone);
369 } 369 }
370 370
371 void TabContentsViewAura::ShowCreatedWindow(int route_id, 371 void WebContentsViewAura::ShowCreatedWindow(int route_id,
372 WindowOpenDisposition disposition, 372 WindowOpenDisposition disposition,
373 const gfx::Rect& initial_pos, 373 const gfx::Rect& initial_pos,
374 bool user_gesture) { 374 bool user_gesture) {
375 tab_contents_view_helper_.ShowCreatedWindow( 375 web_contents_view_helper_.ShowCreatedWindow(
376 tab_contents_, route_id, disposition, initial_pos, user_gesture); 376 tab_contents_, route_id, disposition, initial_pos, user_gesture);
377 } 377 }
378 378
379 void TabContentsViewAura::ShowCreatedWidget(int route_id, 379 void WebContentsViewAura::ShowCreatedWidget(int route_id,
380 const gfx::Rect& initial_pos) { 380 const gfx::Rect& initial_pos) {
381 tab_contents_view_helper_.ShowCreatedWidget(tab_contents_, 381 web_contents_view_helper_.ShowCreatedWidget(tab_contents_,
382 route_id, 382 route_id,
383 false, 383 false,
384 initial_pos); 384 initial_pos);
385 } 385 }
386 386
387 void TabContentsViewAura::ShowCreatedFullscreenWidget(int route_id) { 387 void WebContentsViewAura::ShowCreatedFullscreenWidget(int route_id) {
388 tab_contents_view_helper_.ShowCreatedWidget(tab_contents_, 388 web_contents_view_helper_.ShowCreatedWidget(tab_contents_,
389 route_id, 389 route_id,
390 true, 390 true,
391 gfx::Rect()); 391 gfx::Rect());
392 } 392 }
393 393
394 void TabContentsViewAura::ShowContextMenu( 394 void WebContentsViewAura::ShowContextMenu(
395 const content::ContextMenuParams& params) { 395 const content::ContextMenuParams& params) {
396 // Allow WebContentsDelegates to handle the context menu operation first. 396 // Allow WebContentsDelegates to handle the context menu operation first.
397 if (tab_contents_->GetDelegate() && 397 if (tab_contents_->GetDelegate() &&
398 tab_contents_->GetDelegate()->HandleContextMenu(params)) { 398 tab_contents_->GetDelegate()->HandleContextMenu(params)) {
399 return; 399 return;
400 } 400 }
401 401
402 if (delegate_.get()) 402 if (delegate_.get())
403 delegate_->ShowContextMenu(params); 403 delegate_->ShowContextMenu(params);
404 } 404 }
405 405
406 void TabContentsViewAura::ShowPopupMenu(const gfx::Rect& bounds, 406 void WebContentsViewAura::ShowPopupMenu(const gfx::Rect& bounds,
407 int item_height, 407 int item_height,
408 double item_font_size, 408 double item_font_size,
409 int selected_item, 409 int selected_item,
410 const std::vector<WebMenuItem>& items, 410 const std::vector<WebMenuItem>& items,
411 bool right_aligned) { 411 bool right_aligned) {
412 // External popup menus are only used on Mac. 412 // External popup menus are only used on Mac.
413 NOTIMPLEMENTED(); 413 NOTIMPLEMENTED();
414 } 414 }
415 415
416 void TabContentsViewAura::StartDragging( 416 void WebContentsViewAura::StartDragging(
417 const WebDropData& drop_data, 417 const WebDropData& drop_data,
418 WebKit::WebDragOperationsMask operations, 418 WebKit::WebDragOperationsMask operations,
419 const SkBitmap& image, 419 const SkBitmap& image,
420 const gfx::Point& image_offset) { 420 const gfx::Point& image_offset) {
421 aura::RootWindow* root_window = GetNativeView()->GetRootWindow(); 421 aura::RootWindow* root_window = GetNativeView()->GetRootWindow();
422 if (!aura::client::GetDragDropClient(root_window)) 422 if (!aura::client::GetDragDropClient(root_window))
423 return; 423 return;
424 424
425 ui::OSExchangeDataProviderAura* provider = new ui::OSExchangeDataProviderAura; 425 ui::OSExchangeDataProviderAura* provider = new ui::OSExchangeDataProviderAura;
426 PrepareDragData(drop_data, provider); 426 PrepareDragData(drop_data, provider);
427 if (!image.isNull()) { 427 if (!image.isNull())
428 provider->set_drag_image(image); 428 provider->set_drag_image(image);
429 provider->set_drag_image_offset(image_offset);
varunjain 2012/04/23 17:39:45 Hi Avi... was this intentionally removed?
Ben Goodger (Google) 2012/04/23 17:41:47 Looks like a bad merge.
Avi (use Gerrit) 2012/04/23 17:54:34 Indeed. Oops. :(
430 }
431 ui::OSExchangeData data(provider); // takes ownership of |provider|. 429 ui::OSExchangeData data(provider); // takes ownership of |provider|.
432 430
433 scoped_ptr<WebDragSourceAura> drag_source( 431 scoped_ptr<WebDragSourceAura> drag_source(
434 new WebDragSourceAura(tab_contents_)); 432 new WebDragSourceAura(tab_contents_));
435 433
436 // We need to enable recursive tasks on the message loop so we can get 434 // We need to enable recursive tasks on the message loop so we can get
437 // updates while in the system DoDragDrop loop. 435 // updates while in the system DoDragDrop loop.
438 int result_op = 0; 436 int result_op = 0;
439 { 437 {
440 // TODO(sad): Avoid using last_mouse_location here, since the drag may not 438 // TODO(sad): Avoid using last_mouse_location here, since the drag may not
441 // always start from a mouse-event (e.g. a touch or gesture event could 439 // always start from a mouse-event (e.g. a touch or gesture event could
442 // initiate the drag). The location information should be carried over from 440 // initiate the drag). The location information should be carried over from
443 // webkit. http://crbug.com/114754 441 // webkit. http://crbug.com/114754
444 gfx::Point location(root_window->last_mouse_location()); 442 gfx::Point location(root_window->last_mouse_location());
443 location.Offset(-image_offset.x(), -image_offset.y());
445 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current()); 444 MessageLoop::ScopedNestableTaskAllower allow(MessageLoop::current());
446 result_op = aura::client::GetDragDropClient(root_window)->StartDragAndDrop( 445 result_op = aura::client::GetDragDropClient(root_window)->StartDragAndDrop(
447 data, location, ConvertFromWeb(operations)); 446 data, location, ConvertFromWeb(operations));
448 } 447 }
449 448
450 EndDrag(ConvertToWeb(result_op)); 449 EndDrag(ConvertToWeb(result_op));
451 tab_contents_->GetRenderViewHost()->DragSourceSystemDragEnded();} 450 tab_contents_->GetRenderViewHost()->DragSourceSystemDragEnded();}
452 451
453 void TabContentsViewAura::UpdateDragCursor(WebKit::WebDragOperation operation) { 452 void WebContentsViewAura::UpdateDragCursor(WebKit::WebDragOperation operation) {
454 current_drag_op_ = operation; 453 current_drag_op_ = operation;
455 } 454 }
456 455
457 void TabContentsViewAura::GotFocus() { 456 void WebContentsViewAura::GotFocus() {
458 if (tab_contents_->GetDelegate()) 457 if (tab_contents_->GetDelegate())
459 tab_contents_->GetDelegate()->WebContentsFocused(tab_contents_); 458 tab_contents_->GetDelegate()->WebContentsFocused(tab_contents_);
460 } 459 }
461 460
462 void TabContentsViewAura::TakeFocus(bool reverse) { 461 void WebContentsViewAura::TakeFocus(bool reverse) {
463 if (tab_contents_->GetDelegate() && 462 if (tab_contents_->GetDelegate() &&
464 !tab_contents_->GetDelegate()->TakeFocus(reverse) && 463 !tab_contents_->GetDelegate()->TakeFocus(reverse) &&
465 delegate_.get()) { 464 delegate_.get()) {
466 delegate_->TakeFocus(reverse); 465 delegate_->TakeFocus(reverse);
467 } 466 }
468 } 467 }
469 468
470 //////////////////////////////////////////////////////////////////////////////// 469 ////////////////////////////////////////////////////////////////////////////////
471 // TabContentsViewAura, aura::WindowDelegate implementation: 470 // WebContentsViewAura, aura::WindowDelegate implementation:
472 471
473 gfx::Size TabContentsViewAura::GetMinimumSize() const { 472 gfx::Size WebContentsViewAura::GetMinimumSize() const {
474 return gfx::Size(); 473 return gfx::Size();
475 } 474 }
476 475
477 void TabContentsViewAura::OnBoundsChanged(const gfx::Rect& old_bounds, 476 void WebContentsViewAura::OnBoundsChanged(const gfx::Rect& old_bounds,
478 const gfx::Rect& new_bounds) { 477 const gfx::Rect& new_bounds) {
479 SizeChangedCommon(new_bounds.size()); 478 SizeChangedCommon(new_bounds.size());
480 if (delegate_.get()) 479 if (delegate_.get())
481 delegate_->SizeChanged(new_bounds.size()); 480 delegate_->SizeChanged(new_bounds.size());
482 } 481 }
483 482
484 void TabContentsViewAura::OnFocus() { 483 void WebContentsViewAura::OnFocus() {
485 } 484 }
486 485
487 void TabContentsViewAura::OnBlur() { 486 void WebContentsViewAura::OnBlur() {
488 } 487 }
489 488
490 bool TabContentsViewAura::OnKeyEvent(aura::KeyEvent* event) { 489 bool WebContentsViewAura::OnKeyEvent(aura::KeyEvent* event) {
491 return false; 490 return false;
492 } 491 }
493 492
494 gfx::NativeCursor TabContentsViewAura::GetCursor(const gfx::Point& point) { 493 gfx::NativeCursor WebContentsViewAura::GetCursor(const gfx::Point& point) {
495 return gfx::kNullCursor; 494 return gfx::kNullCursor;
496 } 495 }
497 496
498 int TabContentsViewAura::GetNonClientComponent(const gfx::Point& point) const { 497 int WebContentsViewAura::GetNonClientComponent(const gfx::Point& point) const {
499 return HTCLIENT; 498 return HTCLIENT;
500 } 499 }
501 500
502 bool TabContentsViewAura::OnMouseEvent(aura::MouseEvent* event) { 501 bool WebContentsViewAura::OnMouseEvent(aura::MouseEvent* event) {
503 if (!tab_contents_->GetDelegate()) 502 if (!tab_contents_->GetDelegate())
504 return false; 503 return false;
505 504
506 switch (event->type()) { 505 switch (event->type()) {
507 case ui::ET_MOUSE_PRESSED: 506 case ui::ET_MOUSE_PRESSED:
508 tab_contents_->GetDelegate()->ActivateContents(tab_contents_); 507 tab_contents_->GetDelegate()->ActivateContents(tab_contents_);
509 break; 508 break;
510 case ui::ET_MOUSE_MOVED: 509 case ui::ET_MOUSE_MOVED:
511 tab_contents_->GetDelegate()->ContentsMouseEvent( 510 tab_contents_->GetDelegate()->ContentsMouseEvent(
512 tab_contents_, gfx::Screen::GetCursorScreenPoint(), true); 511 tab_contents_, gfx::Screen::GetCursorScreenPoint(), true);
513 break; 512 break;
514 default: 513 default:
515 break; 514 break;
516 } 515 }
517 return false; 516 return false;
518 } 517 }
519 518
520 ui::TouchStatus TabContentsViewAura::OnTouchEvent(aura::TouchEvent* event) { 519 ui::TouchStatus WebContentsViewAura::OnTouchEvent(aura::TouchEvent* event) {
521 return ui::TOUCH_STATUS_UNKNOWN; 520 return ui::TOUCH_STATUS_UNKNOWN;
522 } 521 }
523 522
524 ui::GestureStatus TabContentsViewAura::OnGestureEvent( 523 ui::GestureStatus WebContentsViewAura::OnGestureEvent(
525 aura::GestureEvent* event) { 524 aura::GestureEvent* event) {
526 return ui::GESTURE_STATUS_UNKNOWN; 525 return ui::GESTURE_STATUS_UNKNOWN;
527 } 526 }
528 527
529 bool TabContentsViewAura::CanFocus() { 528 bool WebContentsViewAura::CanFocus() {
530 return true; 529 return true;
531 } 530 }
532 531
533 void TabContentsViewAura::OnCaptureLost() { 532 void WebContentsViewAura::OnCaptureLost() {
534 } 533 }
535 534
536 void TabContentsViewAura::OnPaint(gfx::Canvas* canvas) { 535 void WebContentsViewAura::OnPaint(gfx::Canvas* canvas) {
537 } 536 }
538 537
539 void TabContentsViewAura::OnWindowDestroying() { 538 void WebContentsViewAura::OnWindowDestroying() {
540 } 539 }
541 540
542 void TabContentsViewAura::OnWindowDestroyed() { 541 void WebContentsViewAura::OnWindowDestroyed() {
543 } 542 }
544 543
545 void TabContentsViewAura::OnWindowVisibilityChanged(bool visible) { 544 void WebContentsViewAura::OnWindowVisibilityChanged(bool visible) {
546 if (visible) 545 if (visible)
547 tab_contents_->ShowContents(); 546 tab_contents_->ShowContents();
548 else 547 else
549 tab_contents_->HideContents(); 548 tab_contents_->HideContents();
550 } 549 }
551 //////////////////////////////////////////////////////////////////////////////// 550 ////////////////////////////////////////////////////////////////////////////////
552 // TabContentsViewAura, aura::client::DragDropDelegate implementation: 551 // WebContentsViewAura, aura::client::DragDropDelegate implementation:
553 552
554 void TabContentsViewAura::OnDragEntered(const aura::DropTargetEvent& event) { 553 void WebContentsViewAura::OnDragEntered(const aura::DropTargetEvent& event) {
555 if (GetDragDestDelegate()) 554 if (GetDragDestDelegate())
556 GetDragDestDelegate()->DragInitialize(tab_contents_); 555 GetDragDestDelegate()->DragInitialize(tab_contents_);
557 556
558 WebDropData drop_data; 557 WebDropData drop_data;
559 PrepareWebDropData(&drop_data, event.data()); 558 PrepareWebDropData(&drop_data, event.data());
560 WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); 559 WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations());
561 560
562 gfx::Point screen_pt = 561 gfx::Point screen_pt =
563 GetNativeView()->GetRootWindow()->last_mouse_location(); 562 GetNativeView()->GetRootWindow()->last_mouse_location();
564 tab_contents_->GetRenderViewHost()->DragTargetDragEnter( 563 tab_contents_->GetRenderViewHost()->DragTargetDragEnter(
565 drop_data, event.location(), screen_pt, op); 564 drop_data, event.location(), screen_pt, op);
566 565
567 if (GetDragDestDelegate()) { 566 if (GetDragDestDelegate()) {
568 GetDragDestDelegate()->OnReceiveDragData(event.data()); 567 GetDragDestDelegate()->OnReceiveDragData(event.data());
569 GetDragDestDelegate()->OnDragEnter(); 568 GetDragDestDelegate()->OnDragEnter();
570 } 569 }
571 } 570 }
572 571
573 int TabContentsViewAura::OnDragUpdated(const aura::DropTargetEvent& event) { 572 int WebContentsViewAura::OnDragUpdated(const aura::DropTargetEvent& event) {
574 WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations()); 573 WebKit::WebDragOperationsMask op = ConvertToWeb(event.source_operations());
575 gfx::Point screen_pt = 574 gfx::Point screen_pt =
576 GetNativeView()->GetRootWindow()->last_mouse_location(); 575 GetNativeView()->GetRootWindow()->last_mouse_location();
577 tab_contents_->GetRenderViewHost()->DragTargetDragOver( 576 tab_contents_->GetRenderViewHost()->DragTargetDragOver(
578 event.location(), screen_pt, op); 577 event.location(), screen_pt, op);
579 578
580 if (GetDragDestDelegate()) 579 if (GetDragDestDelegate())
581 GetDragDestDelegate()->OnDragOver(); 580 GetDragDestDelegate()->OnDragOver();
582 581
583 return ConvertFromWeb(current_drag_op_); 582 return ConvertFromWeb(current_drag_op_);
584 } 583 }
585 584
586 void TabContentsViewAura::OnDragExited() { 585 void WebContentsViewAura::OnDragExited() {
587 tab_contents_->GetRenderViewHost()->DragTargetDragLeave(); 586 tab_contents_->GetRenderViewHost()->DragTargetDragLeave();
588 if (GetDragDestDelegate()) 587 if (GetDragDestDelegate())
589 GetDragDestDelegate()->OnDragLeave(); 588 GetDragDestDelegate()->OnDragLeave();
590 } 589 }
591 590
592 int TabContentsViewAura::OnPerformDrop(const aura::DropTargetEvent& event) { 591 int WebContentsViewAura::OnPerformDrop(const aura::DropTargetEvent& event) {
593 tab_contents_->GetRenderViewHost()->DragTargetDrop( 592 tab_contents_->GetRenderViewHost()->DragTargetDrop(
594 event.location(), 593 event.location(),
595 GetNativeView()->GetRootWindow()->last_mouse_location()); 594 GetNativeView()->GetRootWindow()->last_mouse_location());
596 if (GetDragDestDelegate()) 595 if (GetDragDestDelegate())
597 GetDragDestDelegate()->OnDrop(); 596 GetDragDestDelegate()->OnDrop();
598 return current_drag_op_; 597 return current_drag_op_;
599 } 598 }
OLDNEW
« no previous file with comments | « content/browser/web_contents/web_contents_view_aura.h ('k') | content/browser/web_contents/web_contents_view_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698