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

Unified Diff: chrome/browser/ui/views/avatar_label.cc

Issue 127253004: Support displaying the avatar label on the right side. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Address nits. Created 6 years, 11 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/views/avatar_label.cc
diff --git a/chrome/browser/ui/views/avatar_label.cc b/chrome/browser/ui/views/avatar_label.cc
index de923dbe6968b8193fdc5e936ae9d0bab7c4c913..9b35b8a1b99ffd12c9cdd959ee846dfa7fdc94d7 100644
--- a/chrome/browser/ui/views/avatar_label.cc
+++ b/chrome/browser/ui/views/avatar_label.cc
@@ -23,7 +23,7 @@ namespace {
// A special text button border for the managed user avatar label.
class AvatarLabelBorder: public views::TextButtonBorder {
public:
- explicit AvatarLabelBorder();
+ explicit AvatarLabelBorder(bool label_on_right);
// views::TextButtonBorder:
virtual void Paint(const views::View& view, gfx::Canvas* canvas) OVERRIDE;
@@ -35,9 +35,9 @@ class AvatarLabelBorder: public views::TextButtonBorder {
DISALLOW_COPY_AND_ASSIGN(AvatarLabelBorder);
};
-AvatarLabelBorder::AvatarLabelBorder() {
- const int kHorizontalInsetRight = 10;
- const int kHorizontalInsetLeft = 43;
+AvatarLabelBorder::AvatarLabelBorder(bool label_on_right) {
+ const int kHorizontalInsetRight = label_on_right ? 43 : 10;
+ const int kHorizontalInsetLeft = label_on_right ? 10 : 43;
const int kVerticalInsetTop = 2;
const int kVerticalInsetBottom = 3;
// We want to align with the top of the tab. This works if the default font
@@ -96,7 +96,7 @@ AvatarLabel::AvatarLabel(BrowserView* browser_view)
l10n_util::GetStringUTF16(IDS_MANAGED_USER_AVATAR_LABEL)),
browser_view_(browser_view) {
ClearMaxTextSize();
- set_border(new AvatarLabelBorder);
+ SetLabelOnRight(false);
UpdateLabelStyle();
}
@@ -111,6 +111,10 @@ bool AvatarLabel::OnMousePressed(const ui::MouseEvent& event) {
}
void AvatarLabel::UpdateLabelStyle() {
+ // |browser_view_| can be NULL in unit tests.
+ if (!browser_view_)
+ return;
+
SkColor color_label = browser_view_->frame()->GetThemeProvider()->GetColor(
ThemeProperties::COLOR_MANAGED_USER_LABEL);
SetEnabledColor(color_label);
@@ -119,3 +123,7 @@ void AvatarLabel::UpdateLabelStyle() {
SetDisabledColor(color_label);
SchedulePaint();
}
+
+void AvatarLabel::SetLabelOnRight(bool label_on_right) {
+ set_border(new AvatarLabelBorder(label_on_right));
+}
« no previous file with comments | « chrome/browser/ui/views/avatar_label.h ('k') | chrome/browser/ui/views/frame/opaque_browser_frame_view_layout.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698