Chromium Code Reviews| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <memory> | 10 #include <memory> |
| (...skipping 2152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2163 BrowserViewLayout* BrowserView::GetBrowserViewLayout() const { | 2163 BrowserViewLayout* BrowserView::GetBrowserViewLayout() const { |
| 2164 return static_cast<BrowserViewLayout*>(GetLayoutManager()); | 2164 return static_cast<BrowserViewLayout*>(GetLayoutManager()); |
| 2165 } | 2165 } |
| 2166 | 2166 |
| 2167 ContentsLayoutManager* BrowserView::GetContentsLayoutManager() const { | 2167 ContentsLayoutManager* BrowserView::GetContentsLayoutManager() const { |
| 2168 return static_cast<ContentsLayoutManager*>( | 2168 return static_cast<ContentsLayoutManager*>( |
| 2169 contents_container_->GetLayoutManager()); | 2169 contents_container_->GetLayoutManager()); |
| 2170 } | 2170 } |
| 2171 | 2171 |
| 2172 bool BrowserView::MaybeShowBookmarkBar(WebContents* contents) { | 2172 bool BrowserView::MaybeShowBookmarkBar(WebContents* contents) { |
| 2173 bool show_bookmark_bar = contents && | 2173 bool show_bookmark_bar = contents && |
|
sky
2017/06/26 15:28:34
I liked your earlier fix better. This code need no
| |
| 2174 browser_->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR); | 2174 browser_->SupportsWindowFeature(Browser::FEATURE_BOOKMARKBAR); |
| 2175 if (!show_bookmark_bar && !bookmark_bar_view_.get()) | 2175 if (!show_bookmark_bar && !bookmark_bar_view_.get()) |
| 2176 return false; | 2176 return false; |
| 2177 if (!bookmark_bar_view_.get()) { | 2177 if (!bookmark_bar_view_.get()) { |
| 2178 bookmark_bar_view_.reset(new BookmarkBarView(browser_.get(), this)); | 2178 bookmark_bar_view_.reset(new BookmarkBarView(browser_.get(), this)); |
| 2179 bookmark_bar_view_->set_owned_by_client(); | 2179 bookmark_bar_view_->set_owned_by_client(); |
| 2180 bookmark_bar_view_->SetBackground( | 2180 bookmark_bar_view_->SetBackground( |
| 2181 base::MakeUnique<BookmarkBarViewBackground>(this, | 2181 base::MakeUnique<BookmarkBarViewBackground>(this, |
| 2182 bookmark_bar_view_.get())); | 2182 bookmark_bar_view_.get())); |
| 2183 bookmark_bar_view_->SetBookmarkBarState( | 2183 bookmark_bar_view_->SetBookmarkBarState( |
| 2184 browser_->bookmark_bar_state(), | 2184 browser_->bookmark_bar_state(), |
| 2185 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); | 2185 BookmarkBar::DONT_ANIMATE_STATE_CHANGE); |
| 2186 GetBrowserViewLayout()->set_bookmark_bar(bookmark_bar_view_.get()); | 2186 GetBrowserViewLayout()->set_bookmark_bar(bookmark_bar_view_.get()); |
| 2187 } | 2187 } |
| 2188 // Don't change the visibility of the BookmarkBarView. BrowserViewLayout | 2188 // Don't change the visibility of the BookmarkBarView. BrowserViewLayout |
| 2189 // handles it. | 2189 // handles it. |
| 2190 bookmark_bar_view_->SetPageNavigator(GetActiveWebContents()); | 2190 bookmark_bar_view_->SetPageNavigator(GetActiveWebContents()); |
| 2191 | 2191 |
| 2192 // Update parenting for the bookmark bar. This may detach it from all views. | 2192 // Update parenting for the bookmark bar. This may detach it from all views. |
| 2193 bool needs_layout = false; | 2193 bool needs_layout = false; |
| 2194 views::View* new_parent = nullptr; | 2194 views::View* new_parent = nullptr; |
| 2195 if (show_bookmark_bar) { | 2195 if (show_bookmark_bar) { |
| 2196 if (bookmark_bar_view_->IsDetached()) | 2196 if (bookmark_bar_view_->IsDetached()) |
| 2197 new_parent = this; | 2197 new_parent = this; |
| 2198 else | 2198 else |
| 2199 new_parent = top_container_; | 2199 new_parent = top_container_; |
| 2200 } | 2200 } |
| 2201 if (new_parent != bookmark_bar_view_->parent()) { | 2201 if (new_parent != nullptr && new_parent != bookmark_bar_view_->parent()) { |
| 2202 SetBookmarkBarParent(new_parent); | 2202 SetBookmarkBarParent(new_parent); |
| 2203 needs_layout = true; | 2203 needs_layout = true; |
| 2204 } | 2204 } |
| 2205 | 2205 |
| 2206 // Check for updates to the desired size. | 2206 // Check for updates to the desired size. |
| 2207 if (bookmark_bar_view_->GetPreferredSize().height() != | 2207 if (bookmark_bar_view_->GetPreferredSize().height() != |
| 2208 bookmark_bar_view_->height()) | 2208 bookmark_bar_view_->height()) |
| 2209 needs_layout = true; | 2209 needs_layout = true; |
| 2210 | 2210 |
| 2211 return needs_layout; | 2211 return needs_layout; |
| (...skipping 445 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2657 } | 2657 } |
| 2658 | 2658 |
| 2659 extensions::ActiveTabPermissionGranter* | 2659 extensions::ActiveTabPermissionGranter* |
| 2660 BrowserView::GetActiveTabPermissionGranter() { | 2660 BrowserView::GetActiveTabPermissionGranter() { |
| 2661 content::WebContents* web_contents = GetActiveWebContents(); | 2661 content::WebContents* web_contents = GetActiveWebContents(); |
| 2662 if (!web_contents) | 2662 if (!web_contents) |
| 2663 return nullptr; | 2663 return nullptr; |
| 2664 return extensions::TabHelper::FromWebContents(web_contents) | 2664 return extensions::TabHelper::FromWebContents(web_contents) |
| 2665 ->active_tab_permission_granter(); | 2665 ->active_tab_permission_granter(); |
| 2666 } | 2666 } |
| OLD | NEW |