OLD | NEW |
1 // Copyright 2012 The Chromium Authors. All rights reserved. | 1 // Copyright 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/views/frame/browser_view.h" | 5 #include "chrome/browser/ui/views/frame/browser_view.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/auto_reset.h" | 9 #include "base/auto_reset.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 764 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
775 // WebContents. | 775 // WebContents. |
776 | 776 |
777 // When we toggle the NTP floating bookmarks bar and/or the info bar, | 777 // When we toggle the NTP floating bookmarks bar and/or the info bar, |
778 // we don't want any WebContents to be attached, so that we | 778 // we don't want any WebContents to be attached, so that we |
779 // avoid an unnecessary resize and re-layout of a WebContents. | 779 // avoid an unnecessary resize and re-layout of a WebContents. |
780 if (change_tab_contents) { | 780 if (change_tab_contents) { |
781 contents_web_view_->SetWebContents(NULL); | 781 contents_web_view_->SetWebContents(NULL); |
782 devtools_web_view_->SetWebContents(NULL); | 782 devtools_web_view_->SetWebContents(NULL); |
783 } | 783 } |
784 | 784 |
| 785 // Do this before updating InfoBarContainer as the InfoBarContainer may |
| 786 // callback to us and trigger layout. |
| 787 if (bookmark_bar_view_.get()) { |
| 788 bookmark_bar_view_->SetBookmarkBarState( |
| 789 browser_->bookmark_bar_state(), |
| 790 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); |
| 791 } |
| 792 |
785 infobar_container_->ChangeInfoBarManager( | 793 infobar_container_->ChangeInfoBarManager( |
786 InfoBarService::FromWebContents(new_contents)); | 794 InfoBarService::FromWebContents(new_contents)); |
787 | 795 |
788 if (old_contents && PermissionBubbleManager::FromWebContents(old_contents)) | 796 if (old_contents && PermissionBubbleManager::FromWebContents(old_contents)) |
789 PermissionBubbleManager::FromWebContents(old_contents)->SetView(NULL); | 797 PermissionBubbleManager::FromWebContents(old_contents)->SetView(NULL); |
790 | 798 |
791 if (new_contents && PermissionBubbleManager::FromWebContents(new_contents)) { | 799 if (new_contents && PermissionBubbleManager::FromWebContents(new_contents)) { |
792 PermissionBubbleManager::FromWebContents(new_contents)->SetView( | 800 PermissionBubbleManager::FromWebContents(new_contents)->SetView( |
793 permission_bubble_view_.get()); | 801 permission_bubble_view_.get()); |
794 } | 802 } |
795 | 803 |
796 if (bookmark_bar_view_.get()) { | |
797 bookmark_bar_view_->SetBookmarkBarState( | |
798 browser_->bookmark_bar_state(), | |
799 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); | |
800 } | |
801 UpdateUIForContents(new_contents); | 804 UpdateUIForContents(new_contents); |
802 | 805 |
803 // Layout for DevTools _before_ setting the both main and devtools WebContents | 806 // Layout for DevTools _before_ setting the both main and devtools WebContents |
804 // to avoid toggling the size of any of them. | 807 // to avoid toggling the size of any of them. |
805 UpdateDevToolsForContents(new_contents, !change_tab_contents); | 808 UpdateDevToolsForContents(new_contents, !change_tab_contents); |
806 | 809 |
807 if (change_tab_contents) { | 810 if (change_tab_contents) { |
808 web_contents_close_handler_->ActiveTabChanged(); | 811 web_contents_close_handler_->ActiveTabChanged(); |
809 contents_web_view_->SetWebContents(new_contents); | 812 contents_web_view_->SetWebContents(new_contents); |
810 // The second layout update should be no-op. It will just set the | 813 // The second layout update should be no-op. It will just set the |
(...skipping 1229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2040 bookmark_bar_view_->set_owned_by_client(); | 2043 bookmark_bar_view_->set_owned_by_client(); |
2041 bookmark_bar_view_->set_background( | 2044 bookmark_bar_view_->set_background( |
2042 new BookmarkExtensionBackground(this, | 2045 new BookmarkExtensionBackground(this, |
2043 bookmark_bar_view_.get(), | 2046 bookmark_bar_view_.get(), |
2044 browser_.get())); | 2047 browser_.get())); |
2045 bookmark_bar_view_->SetBookmarkBarState( | 2048 bookmark_bar_view_->SetBookmarkBarState( |
2046 browser_->bookmark_bar_state(), | 2049 browser_->bookmark_bar_state(), |
2047 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); | 2050 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); |
2048 GetBrowserViewLayout()->set_bookmark_bar(bookmark_bar_view_.get()); | 2051 GetBrowserViewLayout()->set_bookmark_bar(bookmark_bar_view_.get()); |
2049 } | 2052 } |
2050 bookmark_bar_view_->SetVisible(show_bookmark_bar); | 2053 // Don't change the visibility of the BookmarkBarView. BrowserViewLayout |
2051 bookmark_bar_view_->SetPageNavigator(contents); | 2054 // handles it. |
| 2055 bookmark_bar_view_->SetPageNavigator(GetActiveWebContents()); |
2052 | 2056 |
2053 // Update parenting for the bookmark bar. This may detach it from all views. | 2057 // Update parenting for the bookmark bar. This may detach it from all views. |
2054 bool needs_layout = false; | 2058 bool needs_layout = false; |
2055 views::View* new_parent = NULL; | 2059 views::View* new_parent = NULL; |
2056 if (show_bookmark_bar) { | 2060 if (show_bookmark_bar) { |
2057 if (bookmark_bar_view_->IsDetached()) | 2061 if (bookmark_bar_view_->IsDetached()) |
2058 new_parent = this; | 2062 new_parent = this; |
2059 else | 2063 else |
2060 new_parent = top_container_; | 2064 new_parent = top_container_; |
2061 } | 2065 } |
(...skipping 451 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2513 !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) { | 2517 !GetLocationBar()->GetOmniboxView()->model()->popup_model()->IsOpen()) { |
2514 gfx::Point icon_bottom( | 2518 gfx::Point icon_bottom( |
2515 toolbar_->location_bar()->GetLocationBarAnchorPoint()); | 2519 toolbar_->location_bar()->GetLocationBarAnchorPoint()); |
2516 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom); | 2520 ConvertPointToTarget(toolbar_->location_bar(), this, &icon_bottom); |
2517 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL)); | 2521 gfx::Point infobar_top(0, infobar_container_->GetVerticalOverlap(NULL)); |
2518 ConvertPointToTarget(infobar_container_, this, &infobar_top); | 2522 ConvertPointToTarget(infobar_container_, this, &infobar_top); |
2519 top_arrow_height = infobar_top.y() - icon_bottom.y(); | 2523 top_arrow_height = infobar_top.y() - icon_bottom.y(); |
2520 } | 2524 } |
2521 return top_arrow_height; | 2525 return top_arrow_height; |
2522 } | 2526 } |
OLD | NEW |