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

Side by Side Diff: chrome/browser/ui/views/toolbar/browser_actions_container.cc

Issue 387773002: Fix badge display for extension action overflow menu (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 5 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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/toolbar/browser_actions_container.h" 5 #include "chrome/browser/ui/views/toolbar/browser_actions_container.h"
6 6
7 #include "base/compiler_specific.h" 7 #include "base/compiler_specific.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "base/stl_util.h" 9 #include "base/stl_util.h"
10 #include "chrome/browser/extensions/extension_service.h" 10 #include "chrome/browser/extensions/extension_service.h"
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
51 51
52 namespace { 52 namespace {
53 53
54 // Horizontal spacing between most items in the container, as well as after the 54 // Horizontal spacing between most items in the container, as well as after the
55 // last item or chevron (if visible). 55 // last item or chevron (if visible).
56 const int kItemSpacing = ToolbarView::kStandardSpacing; 56 const int kItemSpacing = ToolbarView::kStandardSpacing;
57 57
58 // Horizontal spacing before the chevron (if visible). 58 // Horizontal spacing before the chevron (if visible).
59 const int kChevronSpacing = kItemSpacing - 2; 59 const int kChevronSpacing = kItemSpacing - 2;
60 60
61 // Padding to make sure the badge appears in the right location vertically when
62 // in overflow mode (inside the Chrome menu).
63 // TODO(devlin): Remove this hard coding and make sure the badge appears
64 // correctly.
65 const int kPaddingForBadge = 9;
66
67 // The maximum number of icons to show per row when in overflow mode (showing 61 // The maximum number of icons to show per row when in overflow mode (showing
68 // icons in the application menu). 62 // icons in the application menu).
69 // TODO(devlin): Compute the right number of icons to show, depending on the 63 // TODO(devlin): Compute the right number of icons to show, depending on the
70 // menu width. 64 // menu width.
71 #if defined(OS_LINUX) 65 #if defined(OS_LINUX)
72 const int kIconsPerMenuRow = 8; // The menu on Linux is wider. 66 const int kIconsPerMenuRow = 8; // The menu on Linux is wider.
73 #else 67 #else
74 const int kIconsPerMenuRow = 7; 68 const int kIconsPerMenuRow = 7;
75 #endif 69 #endif
76 70
(...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after
350 } 344 }
351 345
352 for (size_t i = main_container_->VisibleBrowserActionsAfterAnimation(); 346 for (size_t i = main_container_->VisibleBrowserActionsAfterAnimation();
353 i < browser_action_views_.size(); ++i) { 347 i < browser_action_views_.size(); ++i) {
354 BrowserActionView* view = browser_action_views_[i]; 348 BrowserActionView* view = browser_action_views_[i];
355 size_t index = i - main_container_->VisibleBrowserActionsAfterAnimation(); 349 size_t index = i - main_container_->VisibleBrowserActionsAfterAnimation();
356 int row_index = static_cast<int>(index) / kIconsPerMenuRow; 350 int row_index = static_cast<int>(index) / kIconsPerMenuRow;
357 int x = (index * IconWidth(true)) - 351 int x = (index * IconWidth(true)) -
358 (row_index * IconWidth(true) * kIconsPerMenuRow); 352 (row_index * IconWidth(true) * kIconsPerMenuRow);
359 gfx::Rect rect_bounds( 353 gfx::Rect rect_bounds(
360 x, 354 x, IconHeight() * row_index, icon_width, IconHeight());
361 IconHeight() * row_index,
362 icon_width,
363 IconHeight() + kPaddingForBadge);
364 view->SetBoundsRect(rect_bounds); 355 view->SetBoundsRect(rect_bounds);
365 view->SetVisible(true); 356 view->SetVisible(true);
366 } 357 }
367 } else { 358 } else {
368 for (BrowserActionViews::const_iterator it = browser_action_views_.begin(); 359 for (BrowserActionViews::const_iterator it = browser_action_views_.begin();
369 it < browser_action_views_.end(); ++it) { 360 it < browser_action_views_.end(); ++it) {
370 BrowserActionView* view = *it; 361 BrowserActionView* view = *it;
371 int x = ToolbarView::kStandardSpacing + 362 int x = ToolbarView::kStandardSpacing +
372 ((it - browser_action_views_.begin()) * IconWidth(true)); 363 ((it - browser_action_views_.begin()) * IconWidth(true));
373 view->SetVisible(x + icon_width <= max_x); 364 view->SetVisible(x + icon_width <= max_x);
(...skipping 679 matching lines...) Expand 10 before | Expand all | Expand 10 after
1053 views::BubbleBorder::TOP_RIGHT, 1044 views::BubbleBorder::TOP_RIGHT,
1054 show_action); 1045 show_action);
1055 popup_->GetWidget()->AddObserver(this); 1046 popup_->GetWidget()->AddObserver(this);
1056 popup_button_ = button; 1047 popup_button_ = button;
1057 1048
1058 // Only set button as pushed if it was triggered by a user click. 1049 // Only set button as pushed if it was triggered by a user click.
1059 if (should_grant) 1050 if (should_grant)
1060 popup_button_->SetButtonPushed(); 1051 popup_button_->SetButtonPushed();
1061 return true; 1052 return true;
1062 } 1053 }
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698