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

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..bf40fd6370394d81067351ff25b76ec4c1b929ef 100644
--- a/chrome/browser/ui/toolbar/toolbar_actions_bar.cc
+++ b/chrome/browser/ui/toolbar/toolbar_actions_bar.cc
@@ -227,7 +227,7 @@ size_t ToolbarActionsBar::WidthToIconCount(int pixels) const {
size_t ToolbarActionsBar::GetIconCount() const {
if (!model_)
- return 0u;
+ return 0;
int pop_out_modifier = 0;
// If there is a popped out action, it could affect the number of visible
@@ -264,9 +264,23 @@ 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() : 0;
+}
+
+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