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

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

Issue 628773002: replace OVERRIDE and FINAL with override and final in chrome/browser/ui/[t-v]* (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 2 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
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/profile_chooser_view.h" 5 #include "chrome/browser/ui/views/profiles/profile_chooser_view.h"
6 6
7 #include "base/prefs/pref_service.h" 7 #include "base/prefs/pref_service.h"
8 #include "base/strings/utf_string_conversions.h" 8 #include "base/strings/utf_string_conversions.h"
9 #include "chrome/browser/browser_process.h" 9 #include "chrome/browser/browser_process.h"
10 #include "chrome/browser/lifetime/application_lifetime.h" 10 #include "chrome/browser/lifetime/application_lifetime.h"
(...skipping 134 matching lines...) Expand 10 before | Expand all | Expand 10 after
145 SetMinSize(gfx::Size(0, 145 SetMinSize(gfx::Size(0,
146 kButtonHeight + views::kRelatedControlVerticalSpacing)); 146 kButtonHeight + views::kRelatedControlVerticalSpacing));
147 SetImage(STATE_NORMAL, icon); 147 SetImage(STATE_NORMAL, icon);
148 SetFocusable(true); 148 SetFocusable(true);
149 } 149 }
150 150
151 virtual ~BackgroundColorHoverButton() {} 151 virtual ~BackgroundColorHoverButton() {}
152 152
153 private: 153 private:
154 // views::LabelButton: 154 // views::LabelButton:
155 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { 155 virtual void OnPaint(gfx::Canvas* canvas) override {
156 if ((state() == STATE_PRESSED) || 156 if ((state() == STATE_PRESSED) ||
157 (state() == STATE_HOVERED) || 157 (state() == STATE_HOVERED) ||
158 HasFocus()) { 158 HasFocus()) {
159 canvas->DrawColor(GetNativeTheme()->GetSystemColor( 159 canvas->DrawColor(GetNativeTheme()->GetSystemColor(
160 ui::NativeTheme::kColorId_ButtonHoverBackgroundColor)); 160 ui::NativeTheme::kColorId_ButtonHoverBackgroundColor));
161 } 161 }
162 LabelButton::OnPaint(canvas); 162 LabelButton::OnPaint(canvas);
163 } 163 }
164 164
165 DISALLOW_COPY_AND_ASSIGN(BackgroundColorHoverButton); 165 DISALLOW_COPY_AND_ASSIGN(BackgroundColorHoverButton);
166 }; 166 };
167 167
168 // SizedContainer ------------------------------------------------- 168 // SizedContainer -------------------------------------------------
169 169
170 // A simple container view that takes an explicit preferred size. 170 // A simple container view that takes an explicit preferred size.
171 class SizedContainer : public views::View { 171 class SizedContainer : public views::View {
172 public: 172 public:
173 explicit SizedContainer(const gfx::Size& preferred_size) 173 explicit SizedContainer(const gfx::Size& preferred_size)
174 : preferred_size_(preferred_size) {} 174 : preferred_size_(preferred_size) {}
175 175
176 virtual gfx::Size GetPreferredSize() const OVERRIDE { 176 virtual gfx::Size GetPreferredSize() const override {
177 return preferred_size_; 177 return preferred_size_;
178 } 178 }
179 179
180 private: 180 private:
181 gfx::Size preferred_size_; 181 gfx::Size preferred_size_;
182 }; 182 };
183 183
184 } // namespace 184 } // namespace
185 185
186 // RightAlignedIconLabelButton ------------------------------------------------- 186 // RightAlignedIconLabelButton -------------------------------------------------
187 187
188 // A custom LabelButton that has a centered text and right aligned icon. 188 // A custom LabelButton that has a centered text and right aligned icon.
189 class RightAlignedIconLabelButton : public views::LabelButton { 189 class RightAlignedIconLabelButton : public views::LabelButton {
190 public: 190 public:
191 RightAlignedIconLabelButton(views::ButtonListener* listener, 191 RightAlignedIconLabelButton(views::ButtonListener* listener,
192 const base::string16& text) 192 const base::string16& text)
193 : views::LabelButton(listener, text) { 193 : views::LabelButton(listener, text) {
194 } 194 }
195 195
196 protected: 196 protected:
197 virtual void Layout() OVERRIDE { 197 virtual void Layout() override {
198 // This layout trick keeps the text left-aligned and the icon right-aligned. 198 // This layout trick keeps the text left-aligned and the icon right-aligned.
199 SetHorizontalAlignment(gfx::ALIGN_RIGHT); 199 SetHorizontalAlignment(gfx::ALIGN_RIGHT);
200 views::LabelButton::Layout(); 200 views::LabelButton::Layout();
201 label()->SetHorizontalAlignment(gfx::ALIGN_CENTER); 201 label()->SetHorizontalAlignment(gfx::ALIGN_CENTER);
202 } 202 }
203 203
204 private: 204 private:
205 DISALLOW_COPY_AND_ASSIGN(RightAlignedIconLabelButton); 205 DISALLOW_COPY_AND_ASSIGN(RightAlignedIconLabelButton);
206 }; 206 };
207 207
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
241 photo_overlay_->set_background( 241 photo_overlay_->set_background(
242 views::Background::CreateSolidBackground(kBackgroundColor)); 242 views::Background::CreateSolidBackground(kBackgroundColor));
243 photo_overlay_->SetImage(*ui::ResourceBundle::GetSharedInstance(). 243 photo_overlay_->SetImage(*ui::ResourceBundle::GetSharedInstance().
244 GetImageSkiaNamed(IDR_ICON_PROFILES_EDIT_CAMERA)); 244 GetImageSkiaNamed(IDR_ICON_PROFILES_EDIT_CAMERA));
245 245
246 photo_overlay_->SetSize(bounds.size()); 246 photo_overlay_->SetSize(bounds.size());
247 photo_overlay_->SetVisible(false); 247 photo_overlay_->SetVisible(false);
248 AddChildView(photo_overlay_); 248 AddChildView(photo_overlay_);
249 } 249 }
250 250
251 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { 251 virtual void OnPaint(gfx::Canvas* canvas) override {
252 // Display the profile picture as a circle. 252 // Display the profile picture as a circle.
253 canvas->ClipPath(circular_mask_, true); 253 canvas->ClipPath(circular_mask_, true);
254 views::LabelButton::OnPaint(canvas); 254 views::LabelButton::OnPaint(canvas);
255 } 255 }
256 256
257 virtual void PaintChildren(gfx::Canvas* canvas, 257 virtual void PaintChildren(gfx::Canvas* canvas,
258 const views::CullSet& cull_set) OVERRIDE { 258 const views::CullSet& cull_set) override {
259 // Display any children (the "change photo" overlay) as a circle. 259 // Display any children (the "change photo" overlay) as a circle.
260 canvas->ClipPath(circular_mask_, true); 260 canvas->ClipPath(circular_mask_, true);
261 View::PaintChildren(canvas, cull_set); 261 View::PaintChildren(canvas, cull_set);
262 } 262 }
263 263
264 private: 264 private:
265 // views::CustomButton: 265 // views::CustomButton:
266 virtual void StateChanged() OVERRIDE { 266 virtual void StateChanged() override {
267 bool show_overlay = 267 bool show_overlay =
268 (state() == STATE_PRESSED || state() == STATE_HOVERED || HasFocus()); 268 (state() == STATE_PRESSED || state() == STATE_HOVERED || HasFocus());
269 if (photo_overlay_) 269 if (photo_overlay_)
270 photo_overlay_->SetVisible(show_overlay); 270 photo_overlay_->SetVisible(show_overlay);
271 } 271 }
272 272
273 virtual void OnFocus() OVERRIDE { 273 virtual void OnFocus() override {
274 views::LabelButton::OnFocus(); 274 views::LabelButton::OnFocus();
275 if (photo_overlay_) 275 if (photo_overlay_)
276 photo_overlay_->SetVisible(true); 276 photo_overlay_->SetVisible(true);
277 } 277 }
278 278
279 virtual void OnBlur() OVERRIDE { 279 virtual void OnBlur() override {
280 views::LabelButton::OnBlur(); 280 views::LabelButton::OnBlur();
281 // Don't hide the overlay if it's being shown as a result of a mouseover. 281 // Don't hide the overlay if it's being shown as a result of a mouseover.
282 if (photo_overlay_ && state() != STATE_HOVERED) 282 if (photo_overlay_ && state() != STATE_HOVERED)
283 photo_overlay_->SetVisible(false); 283 photo_overlay_->SetVisible(false);
284 } 284 }
285 285
286 gfx::Path circular_mask_; 286 gfx::Path circular_mask_;
287 287
288 // Image that is shown when hovering over the image button. Can be NULL if 288 // Image that is shown when hovering over the image button. Can be NULL if
289 // the photo isn't allowed to be edited (e.g. for guest profiles). 289 // the photo isn't allowed to be edited (e.g. for guest profiles).
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
346 346
347 // Hide the editable textfield to show the profile name button instead. 347 // Hide the editable textfield to show the profile name button instead.
348 void ShowReadOnlyView() { 348 void ShowReadOnlyView() {
349 if (profile_name_textfield_) 349 if (profile_name_textfield_)
350 profile_name_textfield_->SetVisible(false); 350 profile_name_textfield_->SetVisible(false);
351 } 351 }
352 352
353 private: 353 private:
354 // views::ButtonListener: 354 // views::ButtonListener:
355 virtual void ButtonPressed(views::Button* sender, 355 virtual void ButtonPressed(views::Button* sender,
356 const ui::Event& event) OVERRIDE { 356 const ui::Event& event) override {
357 if (profile_name_textfield_) { 357 if (profile_name_textfield_) {
358 profile_name_textfield_->SetVisible(true); 358 profile_name_textfield_->SetVisible(true);
359 profile_name_textfield_->SetText(GetText()); 359 profile_name_textfield_->SetText(GetText());
360 profile_name_textfield_->SelectAll(false); 360 profile_name_textfield_->SelectAll(false);
361 profile_name_textfield_->RequestFocus(); 361 profile_name_textfield_->RequestFocus();
362 } 362 }
363 } 363 }
364 364
365 // views::LabelButton: 365 // views::LabelButton:
366 virtual bool OnKeyReleased(const ui::KeyEvent& event) OVERRIDE { 366 virtual bool OnKeyReleased(const ui::KeyEvent& event) override {
367 // Override CustomButton's implementation, which presses the button when 367 // Override CustomButton's implementation, which presses the button when
368 // you press space and clicks it when you release space, as the space can be 368 // you press space and clicks it when you release space, as the space can be
369 // part of the new profile name typed in the textfield. 369 // part of the new profile name typed in the textfield.
370 return false; 370 return false;
371 } 371 }
372 372
373 virtual void Layout() OVERRIDE { 373 virtual void Layout() override {
374 if (profile_name_textfield_) 374 if (profile_name_textfield_)
375 profile_name_textfield_->SetBounds(0, 0, width(), height()); 375 profile_name_textfield_->SetBounds(0, 0, width(), height());
376 RightAlignedIconLabelButton::Layout(); 376 RightAlignedIconLabelButton::Layout();
377 } 377 }
378 378
379 virtual void OnFocus() OVERRIDE { 379 virtual void OnFocus() override {
380 RightAlignedIconLabelButton::OnFocus(); 380 RightAlignedIconLabelButton::OnFocus();
381 SetState(STATE_HOVERED); 381 SetState(STATE_HOVERED);
382 } 382 }
383 383
384 virtual void OnBlur() OVERRIDE { 384 virtual void OnBlur() override {
385 RightAlignedIconLabelButton::OnBlur(); 385 RightAlignedIconLabelButton::OnBlur();
386 SetState(STATE_NORMAL); 386 SetState(STATE_NORMAL);
387 } 387 }
388 388
389 // Textfield that is shown when editing the profile name. Can be NULL if 389 // Textfield that is shown when editing the profile name. Can be NULL if
390 // the profile name isn't allowed to be edited (e.g. for guest profiles). 390 // the profile name isn't allowed to be edited (e.g. for guest profiles).
391 views::Textfield* profile_name_textfield_; 391 views::Textfield* profile_name_textfield_;
392 392
393 DISALLOW_COPY_AND_ASSIGN(EditableProfileName); 393 DISALLOW_COPY_AND_ASSIGN(EditableProfileName);
394 }; 394 };
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
449 layout->StartRowWithPadding(1, 1, 0, kVerticalSpacing); 449 layout->StartRowWithPadding(1, 1, 0, kVerticalSpacing);
450 layout->AddView(new views::Separator(views::Separator::HORIZONTAL)); 450 layout->AddView(new views::Separator(views::Separator::HORIZONTAL));
451 451
452 layout->StartRow(1, 1); 452 layout->StartRow(1, 1);
453 layout->AddView(view); 453 layout->AddView(view);
454 454
455 return titled_view; 455 return titled_view;
456 } 456 }
457 457
458 private: 458 private:
459 virtual void Layout() OVERRIDE { 459 virtual void Layout() override {
460 int back_button_width = back_button_->GetPreferredSize().width(); 460 int back_button_width = back_button_->GetPreferredSize().width();
461 back_button_->SetBounds(0, 0, back_button_width, height()); 461 back_button_->SetBounds(0, 0, back_button_width, height());
462 int label_padding = back_button_width + views::kButtonHEdgeMarginNew; 462 int label_padding = back_button_width + views::kButtonHEdgeMarginNew;
463 int label_width = width() - 2 * label_padding; 463 int label_width = width() - 2 * label_padding;
464 DCHECK_GT(label_width, 0); 464 DCHECK_GT(label_width, 0);
465 title_label_->SetBounds(label_padding, 0, label_width, height()); 465 title_label_->SetBounds(label_padding, 0, label_width, height());
466 } 466 }
467 467
468 virtual gfx::Size GetPreferredSize() const OVERRIDE { 468 virtual gfx::Size GetPreferredSize() const override {
469 int height = std::max(title_label_->GetPreferredSize().height(), 469 int height = std::max(title_label_->GetPreferredSize().height(),
470 back_button_->GetPreferredSize().height()); 470 back_button_->GetPreferredSize().height());
471 return gfx::Size(width(), height); 471 return gfx::Size(width(), height);
472 } 472 }
473 473
474 views::ImageButton* back_button_; 474 views::ImageButton* back_button_;
475 views::Label* title_label_; 475 views::Label* title_label_;
476 476
477 DISALLOW_COPY_AND_ASSIGN(TitleCard); 477 DISALLOW_COPY_AND_ASSIGN(TitleCard);
478 }; 478 };
(...skipping 1178 matching lines...) Expand 10 before | Expand all | Expand 10 after
1657 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) != 1657 IncognitoModePrefs::GetAvailability(browser_->profile()->GetPrefs()) !=
1658 IncognitoModePrefs::DISABLED; 1658 IncognitoModePrefs::DISABLED;
1659 return incognito_available && !browser_->profile()->IsGuestSession(); 1659 return incognito_available && !browser_->profile()->IsGuestSession();
1660 } 1660 }
1661 1661
1662 void ProfileChooserView::PostActionPerformed( 1662 void ProfileChooserView::PostActionPerformed(
1663 ProfileMetrics::ProfileDesktopMenu action_performed) { 1663 ProfileMetrics::ProfileDesktopMenu action_performed) {
1664 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_); 1664 ProfileMetrics::LogProfileDesktopMenu(action_performed, gaia_service_type_);
1665 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE; 1665 gaia_service_type_ = signin::GAIA_SERVICE_TYPE_NONE;
1666 } 1666 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698