| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 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/views/frame/browser_view.h" | 5 #include "chrome/browser/views/frame/browser_view.h" |
| 6 | 6 |
| 7 #if defined(OS_LINUX) | 7 #if defined(OS_LINUX) |
| 8 #include <gtk/gtk.h> | 8 #include <gtk/gtk.h> |
| 9 #endif | 9 #endif |
| 10 | 10 |
| (...skipping 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1240 // BrowserView, TabStripModelObserver implementation: | 1240 // BrowserView, TabStripModelObserver implementation: |
| 1241 | 1241 |
| 1242 void BrowserView::TabDetachedAt(TabContents* contents, int index) { | 1242 void BrowserView::TabDetachedAt(TabContents* contents, int index) { |
| 1243 // We use index here rather than comparing |contents| because by this time | 1243 // We use index here rather than comparing |contents| because by this time |
| 1244 // the model has already removed |contents| from its list, so | 1244 // the model has already removed |contents| from its list, so |
| 1245 // browser_->GetSelectedTabContents() will return NULL or something else. | 1245 // browser_->GetSelectedTabContents() will return NULL or something else. |
| 1246 if (index == browser_->tabstrip_model()->selected_index()) { | 1246 if (index == browser_->tabstrip_model()->selected_index()) { |
| 1247 // We need to reset the current tab contents to NULL before it gets | 1247 // We need to reset the current tab contents to NULL before it gets |
| 1248 // freed. This is because the focus manager performs some operations | 1248 // freed. This is because the focus manager performs some operations |
| 1249 // on the selected TabContents when it is removed. | 1249 // on the selected TabContents when it is removed. |
| 1250 contents_container_->ChangeTabContents(NULL); |
| 1250 infobar_container_->ChangeTabContents(NULL); | 1251 infobar_container_->ChangeTabContents(NULL); |
| 1251 contents_container_->ChangeTabContents(NULL); | |
| 1252 UpdateDevToolsForContents(NULL); | 1252 UpdateDevToolsForContents(NULL); |
| 1253 } | 1253 } |
| 1254 } | 1254 } |
| 1255 | 1255 |
| 1256 void BrowserView::TabDeselectedAt(TabContents* contents, int index) { | 1256 void BrowserView::TabDeselectedAt(TabContents* contents, int index) { |
| 1257 // We do not store the focus when closing the tab to work-around bug 4633. | 1257 // We do not store the focus when closing the tab to work-around bug 4633. |
| 1258 // Some reports seem to show that the focus manager and/or focused view can | 1258 // Some reports seem to show that the focus manager and/or focused view can |
| 1259 // be garbage at that point, it is not clear why. | 1259 // be garbage at that point, it is not clear why. |
| 1260 if (!contents->is_being_destroyed()) | 1260 if (!contents->is_being_destroyed()) |
| 1261 contents->view()->StoreFocus(); | 1261 contents->view()->StoreFocus(); |
| 1262 } | 1262 } |
| 1263 | 1263 |
| 1264 void BrowserView::TabSelectedAt(TabContents* old_contents, | 1264 void BrowserView::TabSelectedAt(TabContents* old_contents, |
| 1265 TabContents* new_contents, | 1265 TabContents* new_contents, |
| 1266 int index, | 1266 int index, |
| 1267 bool user_gesture) { | 1267 bool user_gesture) { |
| 1268 DCHECK(old_contents != new_contents); | 1268 DCHECK(old_contents != new_contents); |
| 1269 | 1269 |
| 1270 // Update various elements that are interested in knowing the current | 1270 // Update various elements that are interested in knowing the current |
| 1271 // TabContents. | 1271 // TabContents. |
| 1272 |
| 1273 // When we toggle the NTP floating bookmarks bar, |
| 1274 // we don't want any TabContents to be attached, so that we |
| 1275 // avoid an unnecessary resize and re-layout of a TabContents. |
| 1276 contents_container_->ChangeTabContents(NULL); |
| 1277 |
| 1272 infobar_container_->ChangeTabContents(new_contents); | 1278 infobar_container_->ChangeTabContents(new_contents); |
| 1279 |
| 1280 // Update all the UI bits. |
| 1281 UpdateTitleBar(); |
| 1282 toolbar_->SetProfile(new_contents->profile()); |
| 1283 UpdateToolbar(new_contents, true); |
| 1284 UpdateUIForContents(new_contents); |
| 1285 |
| 1273 contents_container_->ChangeTabContents(new_contents); | 1286 contents_container_->ChangeTabContents(new_contents); |
| 1287 |
| 1274 UpdateDevToolsForContents(new_contents); | 1288 UpdateDevToolsForContents(new_contents); |
| 1275 // TODO(beng): This should be called automatically by ChangeTabContents, but I | 1289 // TODO(beng): This should be called automatically by ChangeTabContents, but I |
| 1276 // am striving for parity now rather than cleanliness. This is | 1290 // am striving for parity now rather than cleanliness. This is |
| 1277 // required to make features like Duplicate Tab, Undo Close Tab, | 1291 // required to make features like Duplicate Tab, Undo Close Tab, |
| 1278 // etc not result in sad tab. | 1292 // etc not result in sad tab. |
| 1279 new_contents->DidBecomeSelected(); | 1293 new_contents->DidBecomeSelected(); |
| 1280 if (BrowserList::GetLastActive() == browser_ && | 1294 if (BrowserList::GetLastActive() == browser_ && |
| 1281 !browser_->tabstrip_model()->closing_all() && GetWindow()->IsVisible()) { | 1295 !browser_->tabstrip_model()->closing_all() && GetWindow()->IsVisible()) { |
| 1282 // We only restore focus if our window is visible, to avoid invoking blur | 1296 // We only restore focus if our window is visible, to avoid invoking blur |
| 1283 // handlers when we are eventually shown. | 1297 // handlers when we are eventually shown. |
| 1284 new_contents->view()->RestoreFocus(); | 1298 new_contents->view()->RestoreFocus(); |
| 1285 } | 1299 } |
| 1286 | |
| 1287 // Update all the UI bits. | |
| 1288 UpdateTitleBar(); | |
| 1289 toolbar_->SetProfile(new_contents->profile()); | |
| 1290 UpdateToolbar(new_contents, true); | |
| 1291 UpdateUIForContents(new_contents); | |
| 1292 } | 1300 } |
| 1293 | 1301 |
| 1294 void BrowserView::TabStripEmpty() { | 1302 void BrowserView::TabStripEmpty() { |
| 1295 // Make sure all optional UI is removed before we are destroyed, otherwise | 1303 // Make sure all optional UI is removed before we are destroyed, otherwise |
| 1296 // there will be consequences (since our view hierarchy will still have | 1304 // there will be consequences (since our view hierarchy will still have |
| 1297 // references to freed views). | 1305 // references to freed views). |
| 1298 UpdateUIForContents(NULL); | 1306 UpdateUIForContents(NULL); |
| 1299 } | 1307 } |
| 1300 | 1308 |
| 1301 /////////////////////////////////////////////////////////////////////////////// | 1309 /////////////////////////////////////////////////////////////////////////////// |
| (...skipping 954 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2256 | 2264 |
| 2257 // static | 2265 // static |
| 2258 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { | 2266 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { |
| 2259 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); | 2267 return browser::CreateFindBar(static_cast<BrowserView*>(browser->window())); |
| 2260 } | 2268 } |
| 2261 | 2269 |
| 2262 // static | 2270 // static |
| 2263 void BrowserList::AllBrowsersClosed() { | 2271 void BrowserList::AllBrowsersClosed() { |
| 2264 views::Window::CloseAllSecondaryWindows(); | 2272 views::Window::CloseAllSecondaryWindows(); |
| 2265 } | 2273 } |
| OLD | NEW |