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

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

Issue 297143008: [Win] UI fixes for the new avatar button/bubble auth errors. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 6 years, 6 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 | Annotate | Revision Log
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/new_avatar_button.h" 5 #include "chrome/browser/ui/views/profiles/new_avatar_button.h"
6 6
7 #include "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "base/win/windows_version.h" 8 #include "base/win/windows_version.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/profiles/profile_manager.h" 10 #include "chrome/browser/profiles/profile_manager.h"
(...skipping 14 matching lines...) Expand all
25 #include "ui/views/controls/button/label_button_border.h" 25 #include "ui/views/controls/button/label_button_border.h"
26 #include "ui/views/painter.h" 26 #include "ui/views/painter.h"
27 27
28 namespace { 28 namespace {
29 29
30 scoped_ptr<views::Border> CreateBorder(const int normal_image_set[], 30 scoped_ptr<views::Border> CreateBorder(const int normal_image_set[],
31 const int hot_image_set[], 31 const int hot_image_set[],
32 const int pushed_image_set[]) { 32 const int pushed_image_set[]) {
33 scoped_ptr<views::LabelButtonBorder> border( 33 scoped_ptr<views::LabelButtonBorder> border(
34 new views::LabelButtonBorder(views::Button::STYLE_TEXTBUTTON)); 34 new views::LabelButtonBorder(views::Button::STYLE_TEXTBUTTON));
35
36 border->SetPainter(false, views::Button::STATE_NORMAL, 35 border->SetPainter(false, views::Button::STATE_NORMAL,
37 views::Painter::CreateImageGridPainter(normal_image_set)); 36 views::Painter::CreateImageGridPainter(normal_image_set));
38 border->SetPainter(false, views::Button::STATE_HOVERED, 37 border->SetPainter(false, views::Button::STATE_HOVERED,
39 views::Painter::CreateImageGridPainter(hot_image_set)); 38 views::Painter::CreateImageGridPainter(hot_image_set));
40 border->SetPainter(false, views::Button::STATE_PRESSED, 39 border->SetPainter(false, views::Button::STATE_PRESSED,
41 views::Painter::CreateImageGridPainter(pushed_image_set)); 40 views::Painter::CreateImageGridPainter(pushed_image_set));
42 41
43 const int kLeftRightInset = 10; 42 const int kLeftRightInset = 10;
44 const int kTopInset = 0; 43 const int kTopInset = 0;
45 const int kBottomInset = 4; 44 const int kBottomInset = 4;
(...skipping 105 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 UpdateAvatarButtonAndRelayoutParent(); 150 UpdateAvatarButtonAndRelayoutParent();
152 } 151 }
153 152
154 void NewAvatarButton::OnErrorChanged() { 153 void NewAvatarButton::OnErrorChanged() {
155 gfx::ImageSkia icon; 154 gfx::ImageSkia icon;
156 155
157 // If there is an error, show an warning icon. 156 // If there is an error, show an warning icon.
158 const SigninErrorController* error = 157 const SigninErrorController* error =
159 profiles::GetSigninErrorController(browser_->profile()); 158 profiles::GetSigninErrorController(browser_->profile());
160 if (error && error->HasError()) { 159 if (error && error->HasError()) {
161 ui::ResourceBundle* rb = &ui::ResourceBundle::GetSharedInstance(); 160 icon = *ui::ResourceBundle::GetSharedInstance().GetImageNamed(
162 icon = *rb->GetImageNamed(IDR_WARNING).ToImageSkia(); 161 IDR_ICON_PROFILES_AVATAR_BUTTON_ERROR).ToImageSkia();
163 } 162 }
164 163
165 SetImage(views::Button::STATE_NORMAL, icon); 164 SetImage(views::Button::STATE_NORMAL, icon);
166 UpdateAvatarButtonAndRelayoutParent(); 165 UpdateAvatarButtonAndRelayoutParent();
167 } 166 }
168 167
169 void NewAvatarButton::UpdateAvatarButtonAndRelayoutParent() { 168 void NewAvatarButton::UpdateAvatarButtonAndRelayoutParent() {
170 // We want the button to resize if the new text is shorter. 169 // We want the button to resize if the new text is shorter.
171 SetText(GetButtonText(browser_->profile())); 170 SetText(GetButtonText(browser_->profile()));
172 set_min_size(gfx::Size()); 171 set_min_size(gfx::Size());
173 InvalidateLayout(); 172 InvalidateLayout();
174 173
175 // Because the width of the button might have changed, the parent browser 174 // Because the width of the button might have changed, the parent browser
176 // frame needs to recalculate the button bounds and redraw it. 175 // frame needs to recalculate the button bounds and redraw it.
177 if (parent()) 176 if (parent())
178 parent()->Layout(); 177 parent()->Layout();
179 } 178 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/views/frame/glass_browser_frame_view.cc ('k') | chrome/browser/ui/views/profiles/profile_chooser_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698