| 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 #include <algorithm> | 8 #include <algorithm> |
| 9 #include <utility> | 9 #include <utility> |
| 10 | 10 |
| (...skipping 2196 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2207 | 2207 |
| 2208 // Check for updates to the desired size. | 2208 // Check for updates to the desired size. |
| 2209 if (bookmark_bar_view_->GetPreferredSize().height() != | 2209 if (bookmark_bar_view_->GetPreferredSize().height() != |
| 2210 bookmark_bar_view_->height()) | 2210 bookmark_bar_view_->height()) |
| 2211 needs_layout = true; | 2211 needs_layout = true; |
| 2212 | 2212 |
| 2213 return needs_layout; | 2213 return needs_layout; |
| 2214 } | 2214 } |
| 2215 | 2215 |
| 2216 void BrowserView::SetBookmarkBarParent(views::View* new_parent) { | 2216 void BrowserView::SetBookmarkBarParent(views::View* new_parent) { |
| 2217 // Because children are drawn in order, the child order also affects z-order: |
| 2218 // earlier children will appear "below" later ones. This is important for ink |
| 2219 // drops, which are drawn with the z-order of the view that parents them. Ink |
| 2220 // drops in the toolbar can spread beyond the toolbar bounds, so if the |
| 2221 // bookmark bar is attached, we want it to be below the toolbar so the toolbar |
| 2222 // ink drops draw atop it. This doesn't cause a problem for interactions with |
| 2223 // the bookmark bar, since it does not host any ink drops that spread beyond |
| 2224 // its bounds. If it did, we would need to change how ink drops are drawn. |
| 2225 // TODO(bruthig): Consider a more general mechanism for manipulating the |
| 2226 // z-order of the ink drops. |
| 2227 |
| 2217 if (new_parent == this) { | 2228 if (new_parent == this) { |
| 2218 // Add it underneath |top_container_| or at the end if top container isn't | 2229 // BookmarkBarView is detached. |
| 2219 // found. | 2230 const int top_container_index = GetIndexOf(top_container_); |
| 2220 int top_container_index = GetIndexOf(top_container_); | 2231 DCHECK_GE(top_container_index, 0); |
| 2221 if (top_container_index >= 0) | 2232 // |top_container_| contains the toolbar, so putting the bookmark bar ahead |
| 2222 AddChildViewAt(bookmark_bar_view_.get(), top_container_index); | 2233 // of it will ensure it's drawn before the toolbar. |
| 2223 else | 2234 AddChildViewAt(bookmark_bar_view_.get(), top_container_index); |
| 2224 AddChildView(bookmark_bar_view_.get()); | 2235 } else if (new_parent == top_container_) { |
| 2225 } else if (new_parent) { | 2236 // BookmarkBarView is attached. |
| 2226 // No special stacking is required for other parents. | 2237 |
| 2227 new_parent->AddChildView(bookmark_bar_view_.get()); | 2238 // The toolbar is a child of |top_container_|, so making the bookmark bar |
| 2239 // the first child ensures it's drawn before the toolbar. |
| 2240 new_parent->AddChildViewAt(bookmark_bar_view_.get(), 0); |
| 2228 } else { | 2241 } else { |
| 2242 DCHECK(!new_parent); |
| 2229 // Bookmark bar is being detached from all views because it is hidden. | 2243 // Bookmark bar is being detached from all views because it is hidden. |
| 2230 bookmark_bar_view_->parent()->RemoveChildView(bookmark_bar_view_.get()); | 2244 bookmark_bar_view_->parent()->RemoveChildView(bookmark_bar_view_.get()); |
| 2231 } | 2245 } |
| 2232 } | 2246 } |
| 2233 | 2247 |
| 2234 bool BrowserView::MaybeShowInfoBar(WebContents* contents) { | 2248 bool BrowserView::MaybeShowInfoBar(WebContents* contents) { |
| 2235 // TODO(beng): Remove this function once the interface between | 2249 // TODO(beng): Remove this function once the interface between |
| 2236 // InfoBarContainer, DownloadShelfView and WebContents and this | 2250 // InfoBarContainer, DownloadShelfView and WebContents and this |
| 2237 // view is sorted out. | 2251 // view is sorted out. |
| 2238 return true; | 2252 return true; |
| (...skipping 406 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2645 } | 2659 } |
| 2646 | 2660 |
| 2647 extensions::ActiveTabPermissionGranter* | 2661 extensions::ActiveTabPermissionGranter* |
| 2648 BrowserView::GetActiveTabPermissionGranter() { | 2662 BrowserView::GetActiveTabPermissionGranter() { |
| 2649 content::WebContents* web_contents = GetActiveWebContents(); | 2663 content::WebContents* web_contents = GetActiveWebContents(); |
| 2650 if (!web_contents) | 2664 if (!web_contents) |
| 2651 return nullptr; | 2665 return nullptr; |
| 2652 return extensions::TabHelper::FromWebContents(web_contents) | 2666 return extensions::TabHelper::FromWebContents(web_contents) |
| 2653 ->active_tab_permission_granter(); | 2667 ->active_tab_permission_granter(); |
| 2654 } | 2668 } |
| OLD | NEW |