summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-02 21:33:40 +0000
committerpkasting@chromium.org <pkasting@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-08-02 21:33:40 +0000
commitf431704be7dfe258834c19c1c18d837fb46a3d16 (patch)
treed9d106fe2525ced0af163d45771ed9ed666b29ee
parent6b847b31ab8c19ba2637359d1a6b4ecf9d8983a3 (diff)
downloadchromium_src-f431704be7dfe258834c19c1c18d837fb46a3d16.zip
chromium_src-f431704be7dfe258834c19c1c18d837fb46a3d16.tar.gz
chromium_src-f431704be7dfe258834c19c1c18d837fb46a3d16.tar.bz2
When dropping a tab torn from a maximized window, inherit the restored size and maximized state, instead of creating a restored window at the maximized size.
BUG=22154 TEST=Drag a tab from a maximized window and drop it; it should create a maximized window. Review URL: http://codereview.chromium.org/3032039 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@54607 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r--chrome/browser/browser.cc4
-rw-r--r--chrome/browser/browser.h3
-rw-r--r--chrome/browser/cocoa/browser_window_controller.mm6
-rw-r--r--chrome/browser/cocoa/tab_strip_controller_unittest.mm3
-rw-r--r--chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc2
-rw-r--r--chrome/browser/tabs/tab_strip_model.cc8
-rw-r--r--chrome/browser/tabs/tab_strip_model.h9
-rw-r--r--chrome/browser/tabs/tab_strip_model_unittest.cc3
-rw-r--r--chrome/browser/views/tabs/dragged_tab_controller.cc9
9 files changed, 17 insertions, 30 deletions
diff --git a/chrome/browser/browser.cc b/chrome/browser/browser.cc
index cdd32ae..3c9361b 100644
--- a/chrome/browser/browser.cc
+++ b/chrome/browser/browser.cc
@@ -2191,11 +2191,11 @@ TabContents* Browser::AddBlankTabAt(int index, bool foreground) {
Browser* Browser::CreateNewStripWithContents(TabContents* detached_contents,
const gfx::Rect& window_bounds,
- const DockInfo& dock_info) {
+ const DockInfo& dock_info,
+ bool maximize) {
DCHECK(CanSupportWindowFeature(FEATURE_TABSTRIP));
gfx::Rect new_window_bounds = window_bounds;
- bool maximize = false;
if (dock_info.GetNewWindowBounds(&new_window_bounds, &maximize))
dock_info.AdjustOtherWindowBounds();
diff --git a/chrome/browser/browser.h b/chrome/browser/browser.h
index 87456fb..593fa8d 100644
--- a/chrome/browser/browser.h
+++ b/chrome/browser/browser.h
@@ -630,7 +630,8 @@ class Browser : public TabStripModelDelegate,
virtual TabContents* AddBlankTabAt(int index, bool foreground);
virtual Browser* CreateNewStripWithContents(TabContents* detached_contents,
const gfx::Rect& window_bounds,
- const DockInfo& dock_info);
+ const DockInfo& dock_info,
+ bool maximize);
virtual void ContinueDraggingDetachedTab(TabContents* contents,
const gfx::Rect& window_bounds,
const gfx::Rect& tab_bounds);
diff --git a/chrome/browser/cocoa/browser_window_controller.mm b/chrome/browser/cocoa/browser_window_controller.mm
index b6eb3b1..d4186b1 100644
--- a/chrome/browser/cocoa/browser_window_controller.mm
+++ b/chrome/browser/cocoa/browser_window_controller.mm
@@ -1157,10 +1157,8 @@
// Create the new window with a single tab in its model, the one being
// dragged.
DockInfo dockInfo;
- Browser* newBrowser =
- browser_->tabstrip_model()->TearOffTabContents(contents,
- browserRect,
- dockInfo);
+ Browser* newBrowser = browser_->tabstrip_model()->delegate()->
+ CreateNewStripWithContents(contents, browserRect, dockInfo, false);
// Propagate the tab pinned state of the new tab (which is the only tab in
// this new window).
diff --git a/chrome/browser/cocoa/tab_strip_controller_unittest.mm b/chrome/browser/cocoa/tab_strip_controller_unittest.mm
index 2a161ab..aadea16 100644
--- a/chrome/browser/cocoa/tab_strip_controller_unittest.mm
+++ b/chrome/browser/cocoa/tab_strip_controller_unittest.mm
@@ -27,7 +27,8 @@ class TestTabStripDelegate : public TabStripModelDelegate {
}
virtual Browser* CreateNewStripWithContents(TabContents* contents,
const gfx::Rect& window_bounds,
- const DockInfo& dock_info) {
+ const DockInfo& dock_info,
+ bool maximize) {
return NULL;
}
virtual void ContinueDraggingDetachedTab(TabContents* contents,
diff --git a/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc b/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc
index 194704b..64c314d 100644
--- a/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc
+++ b/chrome/browser/gtk/tabs/dragged_tab_controller_gtk.cc
@@ -667,7 +667,7 @@ bool DraggedTabControllerGtk::CompleteDrag() {
window_bounds.set_origin(GetWindowCreatePoint());
Browser* new_browser =
source_tabstrip_->model()->delegate()->CreateNewStripWithContents(
- dragged_contents_, window_bounds, dock_info_);
+ dragged_contents_, window_bounds, dock_info_, window->IsMaximized());
TabStripModel* new_model = new_browser->tabstrip_model();
new_model->SetTabPinned(new_model->GetIndexOfTabContents(dragged_contents_),
pinned_);
diff --git a/chrome/browser/tabs/tab_strip_model.cc b/chrome/browser/tabs/tab_strip_model.cc
index ba697dc..8ac8fc4 100644
--- a/chrome/browser/tabs/tab_strip_model.cc
+++ b/chrome/browser/tabs/tab_strip_model.cc
@@ -662,14 +662,6 @@ void TabStripModel::MoveTabPrevious() {
MoveTabContentsAt(selected_index_, new_index, true);
}
-Browser* TabStripModel::TearOffTabContents(TabContents* detached_contents,
- const gfx::Rect& window_bounds,
- const DockInfo& dock_info) {
- DCHECK(detached_contents);
- return delegate_->CreateNewStripWithContents(detached_contents, window_bounds,
- dock_info);
-}
-
// Context menu functions.
bool TabStripModel::IsContextMenuCommandEnabled(
int context_index, ContextMenuCommand command_id) const {
diff --git a/chrome/browser/tabs/tab_strip_model.h b/chrome/browser/tabs/tab_strip_model.h
index f93bfc5..805c951 100644
--- a/chrome/browser/tabs/tab_strip_model.h
+++ b/chrome/browser/tabs/tab_strip_model.h
@@ -161,7 +161,8 @@ class TabStripModelDelegate {
// show the window, it's up to the caller to do so.
virtual Browser* CreateNewStripWithContents(TabContents* contents,
const gfx::Rect& window_bounds,
- const DockInfo& dock_info) = 0;
+ const DockInfo& dock_info,
+ bool maximize) = 0;
// Creates a new Browser object and window containing the specified
// |contents|, and continues a drag operation that began within the source
@@ -611,12 +612,6 @@ class TabStripModel : public NotificationObserver {
// View API //////////////////////////////////////////////////////////////////
- // The specified contents should be opened in a new tabstrip. Returns the
- // Browser that holds it.
- Browser* TearOffTabContents(TabContents* detached_contents,
- const gfx::Rect& window_bounds,
- const DockInfo& dock_info);
-
// Context menu functions.
enum ContextMenuCommand {
CommandFirst = 0,
diff --git a/chrome/browser/tabs/tab_strip_model_unittest.cc b/chrome/browser/tabs/tab_strip_model_unittest.cc
index c885d5f..08f2c7b 100644
--- a/chrome/browser/tabs/tab_strip_model_unittest.cc
+++ b/chrome/browser/tabs/tab_strip_model_unittest.cc
@@ -47,7 +47,8 @@ class TabStripDummyDelegate : public TabStripModelDelegate {
}
virtual Browser* CreateNewStripWithContents(TabContents* contents,
const gfx::Rect& window_bounds,
- const DockInfo& dock_info) {
+ const DockInfo& dock_info,
+ bool maximize) {
return NULL;
}
virtual void ContinueDraggingDetachedTab(TabContents* contents,
diff --git a/chrome/browser/views/tabs/dragged_tab_controller.cc b/chrome/browser/views/tabs/dragged_tab_controller.cc
index 68863c1..4de14ad 100644
--- a/chrome/browser/views/tabs/dragged_tab_controller.cc
+++ b/chrome/browser/views/tabs/dragged_tab_controller.cc
@@ -1210,10 +1210,9 @@ void DraggedTabController::CompleteDrag() {
}
}
// Compel the model to construct a new window for the detached TabContents.
- gfx::Rect browser_rect = source_tabstrip_->GetWindow()->GetBounds();
- gfx::Rect window_bounds(
- GetWindowCreatePoint(),
- gfx::Size(browser_rect.width(), browser_rect.height()));
+ views::Window* window = source_tabstrip_->GetWindow();
+ gfx::Rect window_bounds(window->GetNormalBounds());
+ window_bounds.set_origin(GetWindowCreatePoint());
// When modifying the following if statement, please make sure not to
// introduce issue listed in http://crbug.com/6223 comment #11.
bool rtl_ui = base::i18n::IsRTL();
@@ -1225,7 +1224,7 @@ void DraggedTabController::CompleteDrag() {
}
Browser* new_browser =
GetModel(source_tabstrip_)->delegate()->CreateNewStripWithContents(
- dragged_contents_, window_bounds, dock_info_);
+ dragged_contents_, window_bounds, dock_info_, window->IsMaximized());
TabStripModel* new_model = new_browser->tabstrip_model();
new_model->SetTabPinned(new_model->GetIndexOfTabContents(dragged_contents_),
pinned_);