| OLD | NEW |
| 1 // Copyright (c) 2006-2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-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 #include "base/command_line.h" | 7 #include "base/command_line.h" |
| 8 #include "base/file_version_info.h" | 8 #include "base/file_version_info.h" |
| 9 #include "base/time.h" | 9 #include "base/time.h" |
| 10 #include "chrome/app/chrome_dll_resource.h" | 10 #include "chrome/app/chrome_dll_resource.h" |
| (...skipping 883 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 894 | 894 |
| 895 void BrowserView::TabSelectedAt(TabContents* old_contents, | 895 void BrowserView::TabSelectedAt(TabContents* old_contents, |
| 896 TabContents* new_contents, | 896 TabContents* new_contents, |
| 897 int index, | 897 int index, |
| 898 bool user_gesture) { | 898 bool user_gesture) { |
| 899 DCHECK(old_contents != new_contents); | 899 DCHECK(old_contents != new_contents); |
| 900 | 900 |
| 901 // We do not store the focus when closing the tab to work-around bug 4633. | 901 // We do not store the focus when closing the tab to work-around bug 4633. |
| 902 // Some reports seem to show that the focus manager and/or focused view can | 902 // Some reports seem to show that the focus manager and/or focused view can |
| 903 // be garbage at that point, it is not clear why. | 903 // be garbage at that point, it is not clear why. |
| 904 if (old_contents && !old_contents->is_being_destroyed() && | 904 if (old_contents && !old_contents->is_being_destroyed()) |
| 905 old_contents->AsWebContents()) | 905 old_contents->view()->StoreFocus(); |
| 906 old_contents->AsWebContents()->view()->StoreFocus(); | |
| 907 | 906 |
| 908 // Update various elements that are interested in knowing the current | 907 // Update various elements that are interested in knowing the current |
| 909 // TabContents. | 908 // TabContents. |
| 910 infobar_container_->ChangeTabContents(new_contents); | 909 infobar_container_->ChangeTabContents(new_contents); |
| 911 contents_container_->SetTabContents(new_contents); | 910 contents_container_->SetTabContents(new_contents); |
| 912 // TODO(beng): This should be called automatically by SetTabContents, but I | 911 // TODO(beng): This should be called automatically by SetTabContents, but I |
| 913 // am striving for parity now rather than cleanliness. This is | 912 // am striving for parity now rather than cleanliness. This is |
| 914 // required to make features like Duplicate Tab, Undo Close Tab, | 913 // required to make features like Duplicate Tab, Undo Close Tab, |
| 915 // etc not result in sad tab. | 914 // etc not result in sad tab. |
| 916 new_contents->DidBecomeSelected(); | 915 new_contents->DidBecomeSelected(); |
| 917 if (BrowserList::GetLastActive() == browser_ && | 916 if (BrowserList::GetLastActive() == browser_ && |
| 918 !browser_->tabstrip_model()->closing_all() && | 917 !browser_->tabstrip_model()->closing_all() && |
| 919 new_contents->AsWebContents()) { | 918 GetWidget()->GetWindow()->IsVisible()) { |
| 920 new_contents->AsWebContents()->view()->RestoreFocus(); | 919 // We only restore focus if our window is visible, to avoid invoking blur |
| 920 // handlers when we are eventually shown. |
| 921 new_contents->view()->RestoreFocus(); |
| 921 } | 922 } |
| 922 | 923 |
| 923 // Update all the UI bits. | 924 // Update all the UI bits. |
| 924 UpdateTitleBar(); | 925 UpdateTitleBar(); |
| 925 toolbar_->SetProfile(new_contents->profile()); | 926 toolbar_->SetProfile(new_contents->profile()); |
| 926 UpdateToolbar(new_contents, true); | 927 UpdateToolbar(new_contents, true); |
| 927 UpdateUIForContents(new_contents); | 928 UpdateUIForContents(new_contents); |
| 928 } | 929 } |
| 929 | 930 |
| 930 void BrowserView::TabStripEmpty() { | 931 void BrowserView::TabStripEmpty() { |
| (...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1633 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { | 1634 BrowserWindow* BrowserWindow::CreateBrowserWindow(Browser* browser) { |
| 1634 BrowserView* browser_view = new BrowserView(browser); | 1635 BrowserView* browser_view = new BrowserView(browser); |
| 1635 (new BrowserFrame(browser_view))->Init(); | 1636 (new BrowserFrame(browser_view))->Init(); |
| 1636 return browser_view; | 1637 return browser_view; |
| 1637 } | 1638 } |
| 1638 | 1639 |
| 1639 // static | 1640 // static |
| 1640 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { | 1641 FindBar* BrowserWindow::CreateFindBar(Browser* browser) { |
| 1641 return new FindBarWin(static_cast<BrowserView*>(browser->window())); | 1642 return new FindBarWin(static_cast<BrowserView*>(browser->window())); |
| 1642 } | 1643 } |
| OLD | NEW |