| 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 #include "chrome/browser/ui/gtk/download/download_shelf_gtk.h" | 5 #include "chrome/browser/ui/gtk/download/download_shelf_gtk.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "chrome/browser/download/download_item_model.h" | 10 #include "chrome/browser/download/download_item_model.h" |
| (...skipping 365 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 376 | 376 |
| 377 bool DownloadShelfGtk::IsCursorInShelfZone( | 377 bool DownloadShelfGtk::IsCursorInShelfZone( |
| 378 const gfx::Point& cursor_screen_coords) { | 378 const gfx::Point& cursor_screen_coords) { |
| 379 bool realized = (shelf_.get() && | 379 bool realized = (shelf_.get() && |
| 380 gtk_widget_get_window(shelf_.get())); | 380 gtk_widget_get_window(shelf_.get())); |
| 381 // Do nothing if we've been unrealized in order to avoid a NOTREACHED in | 381 // Do nothing if we've been unrealized in order to avoid a NOTREACHED in |
| 382 // GetWidgetScreenPosition. | 382 // GetWidgetScreenPosition. |
| 383 if (!realized) | 383 if (!realized) |
| 384 return false; | 384 return false; |
| 385 | 385 |
| 386 GtkAllocation allocation; | 386 gfx::Rect bounds = ui::GetWidgetScreenBounds(shelf_.get()); |
| 387 gtk_widget_get_allocation(shelf_.get(), &allocation); | |
| 388 | |
| 389 gfx::Rect bounds(ui::GetWidgetScreenPosition(shelf_.get()), | |
| 390 gfx::Size(allocation.width, allocation.height)); | |
| 391 | 387 |
| 392 // Negative insets expand the rectangle. We only expand the top. | 388 // Negative insets expand the rectangle. We only expand the top. |
| 393 bounds.Inset(gfx::Insets(-kShelfAuraSize, 0, 0, 0)); | 389 bounds.Inset(gfx::Insets(-kShelfAuraSize, 0, 0, 0)); |
| 394 | 390 |
| 395 return bounds.Contains(cursor_screen_coords); | 391 return bounds.Contains(cursor_screen_coords); |
| 396 } | 392 } |
| 397 | 393 |
| 398 void DownloadShelfGtk::MouseLeftShelf() { | 394 void DownloadShelfGtk::MouseLeftShelf() { |
| 399 DCHECK(close_on_mouse_out_); | 395 DCHECK(close_on_mouse_out_); |
| 400 | 396 |
| 401 MessageLoop::current()->PostDelayedTask( | 397 MessageLoop::current()->PostDelayedTask( |
| 402 FROM_HERE, | 398 FROM_HERE, |
| 403 base::Bind(&DownloadShelfGtk::Close, weak_factory_.GetWeakPtr()), | 399 base::Bind(&DownloadShelfGtk::Close, weak_factory_.GetWeakPtr()), |
| 404 base::TimeDelta::FromMilliseconds(kAutoCloseDelayMs)); | 400 base::TimeDelta::FromMilliseconds(kAutoCloseDelayMs)); |
| 405 } | 401 } |
| 406 | 402 |
| 407 void DownloadShelfGtk::MouseEnteredShelf() { | 403 void DownloadShelfGtk::MouseEnteredShelf() { |
| 408 weak_factory_.InvalidateWeakPtrs(); | 404 weak_factory_.InvalidateWeakPtrs(); |
| 409 } | 405 } |
| OLD | NEW |