Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(27)

Unified Diff: chrome/browser/ui/toolbar/toolbar_actions_bar.cc

Issue 1330423003: [Extensions Toolbar] Protect against crazy bounds (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years, 3 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/ui/toolbar/toolbar_actions_bar.cc
diff --git a/chrome/browser/ui/toolbar/toolbar_actions_bar.cc b/chrome/browser/ui/toolbar/toolbar_actions_bar.cc
index 4760d0b7903c6dbe1887bb26b198c55157dded11..cd3347a0ad6913887434e2c150e7ff023ede8dcf 100644
--- a/chrome/browser/ui/toolbar/toolbar_actions_bar.cc
+++ b/chrome/browser/ui/toolbar/toolbar_actions_bar.cc
@@ -264,9 +264,24 @@ size_t ToolbarActionsBar::GetIconCount() const {
return visible_icons;
}
-gfx::Rect ToolbarActionsBar::GetFrameForIndex(size_t index) const {
- size_t start_index = in_overflow_mode() ?
- toolbar_actions_.size() - GetIconCount() : 0u;
+size_t ToolbarActionsBar::GetStartIndexInBounds() const {
+ return in_overflow_mode() ?
+ main_bar_->GetEndIndexInBounds() : 0u;
Peter Kasting 2015/09/15 00:13:38 Nit: Don't add 'u' here unless the code won't comp
Devlin 2015/09/15 18:22:39 Done.
+}
+
+size_t ToolbarActionsBar::GetEndIndexInBounds() const {
+ return in_overflow_mode() ?
+ toolbar_actions_.size() : WidthToIconCount(delegate_->GetWidth());
+}
+
+bool ToolbarActionsBar::NeedsOverflow() const {
+ DCHECK(!in_overflow_mode());
+ return GetEndIndexInBounds() != toolbar_actions_.size();
+}
+
+gfx::Rect ToolbarActionsBar::GetFrameForIndex(
+ size_t index) const {
+ size_t start_index = GetStartIndexInBounds();
// If the index is for an action that is before range we show (i.e., is for
// a button that's on the main bar, and this is the overflow), send back an

Powered by Google App Engine
This is Rietveld 408576698