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

Side by Side Diff: chrome/browser/ui/views/profiles/avatar_menu_button.cc

Issue 1139773003: Avoid CHECK() failure when painting avatar menu button (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: AsImageSkia() does not return a pointer Created 5 years, 7 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/profiles/avatar_menu_button.h" 5 #include "chrome/browser/ui/views/profiles/avatar_menu_button.h"
6 6
7 #include "base/command_line.h" 7 #include "base/command_line.h"
8 #include "base/prefs/pref_service.h" 8 #include "base/prefs/pref_service.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/chrome_notification_types.h" 10 #include "chrome/browser/chrome_notification_types.h"
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 const char* AvatarMenuButton::GetClassName() const { 56 const char* AvatarMenuButton::GetClassName() const {
57 return kViewClassName; 57 return kViewClassName;
58 } 58 }
59 59
60 void AvatarMenuButton::OnPaint(gfx::Canvas* canvas) { 60 void AvatarMenuButton::OnPaint(gfx::Canvas* canvas) {
61 if (!icon_.get()) 61 if (!icon_.get())
62 return; 62 return;
63 63
64 if (old_height_ != height() || button_icon_.isNull()) { 64 if (old_height_ != height() || button_icon_.isNull()) {
65 old_height_ = height(); 65 old_height_ = height();
66 button_icon_ = *profiles::GetAvatarIconForTitleBar( 66 button_icon_ = profiles::GetAvatarIconForTitleBar(
67 *icon_, is_rectangle_, width(), height()).ToImageSkia(); 67 *icon_, is_rectangle_, width(), height()).AsImageSkia();
68 } 68 }
69 69
70 // Scale the image to fit the width of the button. 70 // Scale the image to fit the width of the button.
71 int dst_width = std::min(button_icon_.width(), width()); 71 int dst_width = std::min(button_icon_.width(), width());
72 // Truncate rather than rounding, so that for odd widths we put the extra 72 // Truncate rather than rounding, so that for odd widths we put the extra
73 // pixel on the left. 73 // pixel on the left.
74 int dst_x = (width() - dst_width) / 2; 74 int dst_x = (width() - dst_width) / 2;
75 75
76 // Scale the height and maintain aspect ratio. This means that the 76 // Scale the height and maintain aspect ratio. This means that the
77 // icon may not fit in the view. That's ok, we just vertically center it. 77 // icon may not fit in the view. That's ok, we just vertically center it.
(...skipping 93 matching lines...) Expand 10 before | Expand all | Expand 10 after
171 return !disabled_ && 171 return !disabled_ &&
172 views::ViewTargeterDelegate::DoesIntersectRect(target, rect); 172 views::ViewTargeterDelegate::DoesIntersectRect(target, rect);
173 } 173 }
174 174
175 // views::MenuButtonListener implementation 175 // views::MenuButtonListener implementation
176 void AvatarMenuButton::OnMenuButtonClicked(views::View* source, 176 void AvatarMenuButton::OnMenuButtonClicked(views::View* source,
177 const gfx::Point& point) { 177 const gfx::Point& point) {
178 if (!disabled_) 178 if (!disabled_)
179 chrome::ShowAvatarMenu(browser()); 179 chrome::ShowAvatarMenu(browser());
180 } 180 }
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