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

Unified Diff: chrome/browser/ui/views/tabs/tab_drag_controller2.cc

Issue 10162017: Re-reland Propagate OnNativeWidgetMove to delegate/observers, etc. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Sync and merge. 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/ui/views/tabs/tab_drag_controller2.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/ui/views/tabs/tab_drag_controller2.cc
diff --git a/chrome/browser/ui/views/tabs/tab_drag_controller2.cc b/chrome/browser/ui/views/tabs/tab_drag_controller2.cc
index 6e52681d83d6045757cbc2f2a0f6b9d9c78f0d3b..a664f83e026fd3509be76f471b9a8c637ebec672 100644
--- a/chrome/browser/ui/views/tabs/tab_drag_controller2.cc
+++ b/chrome/browser/ui/views/tabs/tab_drag_controller2.cc
@@ -38,7 +38,6 @@
#include "ui/gfx/screen.h"
#include "ui/views/events/event.h"
#include "ui/views/widget/root_view.h"
-#include "ui/views/widget/widget.h"
#if defined(USE_ASH)
#include "ash/wm/property_util.h"
@@ -314,7 +313,7 @@ TabDragController2::TabDragController2()
end_run_loop_behavior_(END_RUN_LOOP_STOP_DRAGGING),
waiting_for_run_loop_to_exit_(false),
tab_strip_to_attach_to_after_exit_(NULL),
- move_loop_browser_view_(NULL),
+ move_loop_widget_(NULL),
destroyed_(NULL) {
instance_ = this;
}
@@ -326,10 +325,9 @@ TabDragController2::~TabDragController2() {
if (destroyed_)
*destroyed_ = true;
- if (move_loop_browser_view_) {
- move_loop_browser_view_->set_move_observer(NULL);
- SetTrackedByWorkspace(
- move_loop_browser_view_->GetWidget()->GetNativeView(), true);
+ if (move_loop_widget_) {
+ move_loop_widget_->RemoveObserver(this);
+ SetTrackedByWorkspace(move_loop_widget_->GetNativeView(), true);
}
if (source_tabstrip_)
@@ -467,7 +465,7 @@ void TabDragController2::DidProcessEvent(const base::NativeEvent& event) {
}
#endif
-void TabDragController2::OnWidgetMoved() {
+void TabDragController2::OnWidgetMoved(views::Widget* widget) {
Drag();
}
@@ -603,21 +601,21 @@ void TabDragController2::ContinueDragging() {
// ReleaseMouseCapture() is going to result in calling back to us (because
// it results in a move). That'll cause all sorts of problems. Reset the
// observer so we don't get notified and process the event.
- move_loop_browser_view_->set_move_observer(NULL);
- move_loop_browser_view_ = NULL;
+ move_loop_widget_->RemoveObserver(this);
+ move_loop_widget_ = NULL;
#endif
- BrowserView* browser_view = GetAttachedBrowserView();
+ views::Widget* browser_widget = GetAttachedBrowserWidget();
// Need to release the drag controller before starting the move loop as
// it's going to trigger capture lost, which cancels drag.
attached_tabstrip_->ReleaseDragController();
target_tabstrip->OwnDragController(this);
// Disable animations so that we don't see a close animation on aero.
- browser_view->GetWidget()->SetVisibilityChangedAnimationsEnabled(false);
- browser_view->GetWidget()->ReleaseMouseCapture();
+ browser_widget->SetVisibilityChangedAnimationsEnabled(false);
+ browser_widget->ReleaseMouseCapture();
// EndMoveLoop is going to snap the window back to its original location.
// Hide it so users don't see this.
- browser_view->GetWidget()->Hide();
- browser_view->GetWidget()->EndMoveLoop();
+ browser_widget->Hide();
+ browser_widget->EndMoveLoop();
// Ideally we would always swap the tabs now, but on windows it seems that
// running the move loop implicitly activates the window when done,
@@ -982,9 +980,8 @@ void TabDragController2::DetachIntoNewBrowserAndRunMoveLoop(
}
void TabDragController2::RunMoveLoop() {
- move_loop_browser_view_ = GetAttachedBrowserView();
- DCHECK(move_loop_browser_view_);
- move_loop_browser_view_->set_move_observer(this);
+ move_loop_widget_ = GetAttachedBrowserWidget();
+ move_loop_widget_->AddObserver(this);
is_dragging_window_ = true;
bool destroyed = false;
destroyed_ = &destroyed;
@@ -994,8 +991,7 @@ void TabDragController2::RunMoveLoop() {
attached_tabstrip_->ReleaseDragController();
attached_tabstrip_->GetWidget()->ReleaseMouseCapture();
attached_tabstrip_->OwnDragController(this);
- views::Widget::MoveLoopResult result =
- move_loop_browser_view_->GetWidget()->RunMoveLoop();
+ views::Widget::MoveLoopResult result = move_loop_widget_->RunMoveLoop();
content::NotificationService::current()->Notify(
chrome::NOTIFICATION_TAB_DRAG_LOOP_DONE,
content::NotificationService::AllBrowserContextsAndSources(),
@@ -1004,10 +1000,10 @@ void TabDragController2::RunMoveLoop() {
if (destroyed)
return;
destroyed_ = NULL;
- // Under chromeos we immediately set the |move_loop_browser_view_| to NULL.
- if (move_loop_browser_view_) {
- move_loop_browser_view_->set_move_observer(NULL);
- move_loop_browser_view_ = NULL;
+ // Under chromeos we immediately set the |move_loop_widget_| to NULL.
+ if (move_loop_widget_) {
+ move_loop_widget_->RemoveObserver(this);
+ move_loop_widget_ = NULL;
}
is_dragging_window_ = false;
waiting_for_run_loop_to_exit_ = false;
@@ -1129,13 +1125,11 @@ void TabDragController2::EndDragImpl(EndDragType type) {
bring_to_front_timer_.Stop();
if (is_dragging_window_) {
- if (type == NORMAL || (type == TAB_DESTROYED && drag_data_.size() > 1)) {
- SetTrackedByWorkspace(
- GetAttachedBrowserView()->GetWidget()->GetNativeView(), true);
- }
+ if (type == NORMAL || (type == TAB_DESTROYED && drag_data_.size() > 1))
+ SetTrackedByWorkspace(GetAttachedBrowserWidget()->GetNativeView(), true);
// End the nested drag loop.
- GetAttachedBrowserView()->GetWidget()->EndMoveLoop();
+ GetAttachedBrowserWidget()->EndMoveLoop();
waiting_for_run_loop_to_exit_ = true;
}
@@ -1384,9 +1378,9 @@ TabStripModel* TabDragController2::GetModel(TabStrip* tabstrip) {
model();
}
-BrowserView* TabDragController2::GetAttachedBrowserView() {
+views::Widget* TabDragController2::GetAttachedBrowserWidget() {
return BrowserView::GetBrowserViewForNativeWindow(
- attached_tabstrip_->GetWidget()->GetNativeView());
+ attached_tabstrip_->GetWidget()->GetNativeView())->GetWidget();
}
bool TabDragController2::AreTabsConsecutive() {
« no previous file with comments | « chrome/browser/ui/views/tabs/tab_drag_controller2.h ('k') | chrome/chrome_browser.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698