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

Side by Side Diff: ash/system/logout_button/logout_button_tray.cc

Issue 145033006: views: Make View::set_border() take a scoped_ptr<>. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Rebase to ToT 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « ash/system/ime/tray_ime.cc ('k') | ash/system/logout_button/logout_confirmation_dialog_view.cc » ('j') | 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 "ash/system/logout_button/logout_button_tray.h" 5 #include "ash/system/logout_button/logout_button_tray.h"
6 6
7 #include "ash/shelf/shelf_types.h" 7 #include "ash/shelf/shelf_types.h"
8 #include "ash/shell.h" 8 #include "ash/shell.h"
9 #include "ash/system/status_area_widget.h" 9 #include "ash/system/status_area_widget.h"
10 #include "ash/system/tray/system_tray_delegate.h" 10 #include "ash/system/tray/system_tray_delegate.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 } // namespace 81 } // namespace
82 82
83 LogoutButton::LogoutButton(views::ButtonListener* listener) 83 LogoutButton::LogoutButton(views::ButtonListener* listener)
84 : views::LabelButton(listener, base::string16()) { 84 : views::LabelButton(listener, base::string16()) {
85 SetupLabelForTray(label()); 85 SetupLabelForTray(label());
86 SetFontList( 86 SetFontList(
87 GetFontList().DeriveFontListWithSizeDeltaAndStyle(0, gfx::Font::NORMAL)); 87 GetFontList().DeriveFontListWithSizeDeltaAndStyle(0, gfx::Font::NORMAL));
88 for (size_t state = 0; state < views::Button::STATE_COUNT; ++state) 88 for (size_t state = 0; state < views::Button::STATE_COUNT; ++state)
89 SetTextColor(static_cast<views::Button::ButtonState>(state), SK_ColorWHITE); 89 SetTextColor(static_cast<views::Button::ButtonState>(state), SK_ColorWHITE);
90 90
91 views::LabelButtonBorder* border = 91 scoped_ptr<views::LabelButtonBorder> border(
92 new views::LabelButtonBorder(views::Button::STYLE_TEXTBUTTON); 92 new views::LabelButtonBorder(views::Button::STYLE_TEXTBUTTON));
93 border->SetPainter(false, views::Button::STATE_NORMAL, 93 border->SetPainter(false, views::Button::STATE_NORMAL,
94 views::Painter::CreateImageGridPainter(kLogoutButtonNormalImages)); 94 views::Painter::CreateImageGridPainter(kLogoutButtonNormalImages));
95 border->SetPainter(false, views::Button::STATE_HOVERED, 95 border->SetPainter(false, views::Button::STATE_HOVERED,
96 views::Painter::CreateImageGridPainter(kLogoutButtonNormalImages)); 96 views::Painter::CreateImageGridPainter(kLogoutButtonNormalImages));
97 border->SetPainter(false, views::Button::STATE_PRESSED, 97 border->SetPainter(false, views::Button::STATE_PRESSED,
98 views::Painter::CreateImageGridPainter(kLogoutButtonPushedImages)); 98 views::Painter::CreateImageGridPainter(kLogoutButtonPushedImages));
99 gfx::Insets insets = border->GetInsets(); 99 gfx::Insets insets = border->GetInsets();
100 insets += gfx::Insets(0, kLogoutButtonHorizontalExtraPadding, 100 insets += gfx::Insets(0, kLogoutButtonHorizontalExtraPadding,
101 0, kLogoutButtonHorizontalExtraPadding); 101 0, kLogoutButtonHorizontalExtraPadding);
102 border->set_insets(insets); 102 border->set_insets(insets);
103 set_border(border); 103 SetBorder(border.PassAs<views::Border>());
104 set_animate_on_state_change(false); 104 set_animate_on_state_change(false);
105 105
106 set_min_size(gfx::Size(0, GetShelfItemHeight())); 106 set_min_size(gfx::Size(0, GetShelfItemHeight()));
107 } 107 }
108 108
109 LogoutButton::~LogoutButton() { 109 LogoutButton::~LogoutButton() {
110 } 110 }
111 111
112 void LogoutConfirmationDialogDelegate::LogoutCurrentUser() { 112 void LogoutConfirmationDialogDelegate::LogoutCurrentUser() {
113 Shell::GetInstance()->system_tray_delegate()->SignOut(); 113 Shell::GetInstance()->system_tray_delegate()->SignOut();
(...skipping 12 matching lines...) Expand all
126 126
127 LogoutButtonTray::LogoutButtonTray(StatusAreaWidget* status_area_widget) 127 LogoutButtonTray::LogoutButtonTray(StatusAreaWidget* status_area_widget)
128 : TrayBackgroundView(status_area_widget), 128 : TrayBackgroundView(status_area_widget),
129 button_(NULL), 129 button_(NULL),
130 login_status_(user::LOGGED_IN_NONE), 130 login_status_(user::LOGGED_IN_NONE),
131 show_logout_button_in_tray_(false), 131 show_logout_button_in_tray_(false),
132 confirmation_dialog_(NULL), 132 confirmation_dialog_(NULL),
133 confirmation_delegate_(new LogoutConfirmationDialogDelegate) { 133 confirmation_delegate_(new LogoutConfirmationDialogDelegate) {
134 button_ = new LogoutButton(this); 134 button_ = new LogoutButton(this);
135 tray_container()->AddChildView(button_); 135 tray_container()->AddChildView(button_);
136 tray_container()->set_border(NULL); 136 tray_container()->SetBorder(views::Border::NullBorder());
137 // The Shell may not exist in some unit tests. 137 // The Shell may not exist in some unit tests.
138 if (Shell::HasInstance()) { 138 if (Shell::HasInstance()) {
139 Shell::GetInstance()->system_tray_notifier()-> 139 Shell::GetInstance()->system_tray_notifier()->
140 AddLogoutButtonObserver(this); 140 AddLogoutButtonObserver(this);
141 } 141 }
142 } 142 }
143 143
144 LogoutButtonTray::~LogoutButtonTray() { 144 LogoutButtonTray::~LogoutButtonTray() {
145 EnsureConfirmationDialogIsClosed(); 145 EnsureConfirmationDialogIsClosed();
146 // The Shell may not exist in some unit tests. 146 // The Shell may not exist in some unit tests.
(...skipping 15 matching lines...) Expand all
162 } 162 }
163 } 163 }
164 164
165 void LogoutButtonTray::EnsureConfirmationDialogIsClosed() { 165 void LogoutButtonTray::EnsureConfirmationDialogIsClosed() {
166 if (confirmation_dialog_) 166 if (confirmation_dialog_)
167 confirmation_dialog_->Close(); 167 confirmation_dialog_->Close();
168 } 168 }
169 169
170 void LogoutButtonTray::SetShelfAlignment(ShelfAlignment alignment) { 170 void LogoutButtonTray::SetShelfAlignment(ShelfAlignment alignment) {
171 TrayBackgroundView::SetShelfAlignment(alignment); 171 TrayBackgroundView::SetShelfAlignment(alignment);
172 tray_container()->set_border(NULL); 172 tray_container()->SetBorder(views::Border::NullBorder());
173 } 173 }
174 174
175 base::string16 LogoutButtonTray::GetAccessibleNameForTray() { 175 base::string16 LogoutButtonTray::GetAccessibleNameForTray() {
176 return button_->GetText(); 176 return button_->GetText();
177 } 177 }
178 178
179 void LogoutButtonTray::HideBubbleWithView( 179 void LogoutButtonTray::HideBubbleWithView(
180 const views::TrayBubbleView* bubble_view) { 180 const views::TrayBubbleView* bubble_view) {
181 } 181 }
182 182
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
227 void LogoutButtonTray::UpdateVisibility() { 227 void LogoutButtonTray::UpdateVisibility() {
228 SetVisible(show_logout_button_in_tray_ && 228 SetVisible(show_logout_button_in_tray_ &&
229 login_status_ != user::LOGGED_IN_NONE && 229 login_status_ != user::LOGGED_IN_NONE &&
230 login_status_ != user::LOGGED_IN_LOCKED); 230 login_status_ != user::LOGGED_IN_LOCKED);
231 if (!show_logout_button_in_tray_) 231 if (!show_logout_button_in_tray_)
232 EnsureConfirmationDialogIsClosed(); 232 EnsureConfirmationDialogIsClosed();
233 } 233 }
234 234
235 } // namespace internal 235 } // namespace internal
236 } // namespace ash 236 } // namespace ash
OLDNEW
« no previous file with comments | « ash/system/ime/tray_ime.cc ('k') | ash/system/logout_button/logout_confirmation_dialog_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698