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

Side by Side Diff: chrome/browser/ui/views/autofill/autofill_dialog_views.cc

Issue 686543002: Standardize usage of virtual/override/final specifiers. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 6 years, 1 month 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 (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/autofill/autofill_dialog_views.h" 5 #include "chrome/browser/ui/views/autofill/autofill_dialog_views.h"
6 6
7 #include <utility> 7 #include <utility>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/location.h" 10 #include "base/location.h"
(...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after
151 } 151 }
152 152
153 // This class handles layout for the first row of a SuggestionView. 153 // This class handles layout for the first row of a SuggestionView.
154 // It exists to circumvent shortcomings of GridLayout and BoxLayout (namely that 154 // It exists to circumvent shortcomings of GridLayout and BoxLayout (namely that
155 // the former doesn't fully respect child visibility, and that the latter won't 155 // the former doesn't fully respect child visibility, and that the latter won't
156 // expand a single child). 156 // expand a single child).
157 class SectionRowView : public views::View { 157 class SectionRowView : public views::View {
158 public: 158 public:
159 SectionRowView() { SetBorder(views::Border::CreateEmptyBorder(10, 0, 0, 0)); } 159 SectionRowView() { SetBorder(views::Border::CreateEmptyBorder(10, 0, 0, 0)); }
160 160
161 virtual ~SectionRowView() {} 161 ~SectionRowView() override {}
162 162
163 // views::View implementation: 163 // views::View implementation:
164 virtual gfx::Size GetPreferredSize() const override { 164 gfx::Size GetPreferredSize() const override {
165 int height = 0; 165 int height = 0;
166 int width = 0; 166 int width = 0;
167 for (int i = 0; i < child_count(); ++i) { 167 for (int i = 0; i < child_count(); ++i) {
168 if (child_at(i)->visible()) { 168 if (child_at(i)->visible()) {
169 if (width > 0) 169 if (width > 0)
170 width += kAroundTextPadding; 170 width += kAroundTextPadding;
171 171
172 gfx::Size size = child_at(i)->GetPreferredSize(); 172 gfx::Size size = child_at(i)->GetPreferredSize();
173 height = std::max(height, size.height()); 173 height = std::max(height, size.height());
174 width += size.width(); 174 width += size.width();
175 } 175 }
176 } 176 }
177 177
178 gfx::Insets insets = GetInsets(); 178 gfx::Insets insets = GetInsets();
179 return gfx::Size(width + insets.width(), height + insets.height()); 179 return gfx::Size(width + insets.width(), height + insets.height());
180 } 180 }
181 181
182 virtual void Layout() override { 182 void Layout() override {
183 const gfx::Rect bounds = GetContentsBounds(); 183 const gfx::Rect bounds = GetContentsBounds();
184 184
185 // Icon is left aligned. 185 // Icon is left aligned.
186 int start_x = bounds.x(); 186 int start_x = bounds.x();
187 views::View* icon = child_at(0); 187 views::View* icon = child_at(0);
188 if (icon->visible()) { 188 if (icon->visible()) {
189 icon->SizeToPreferredSize(); 189 icon->SizeToPreferredSize();
190 icon->SetX(start_x); 190 icon->SetX(start_x);
191 icon->SetY(bounds.y() + 191 icon->SetY(bounds.y() +
192 (bounds.height() - icon->bounds().height()) / 2); 192 (bounds.height() - icon->bounds().height()) / 2);
(...skipping 19 matching lines...) Expand all
212 } 212 }
213 213
214 private: 214 private:
215 DISALLOW_COPY_AND_ASSIGN(SectionRowView); 215 DISALLOW_COPY_AND_ASSIGN(SectionRowView);
216 }; 216 };
217 217
218 // A view that propagates visibility and preferred size changes. 218 // A view that propagates visibility and preferred size changes.
219 class LayoutPropagationView : public views::View { 219 class LayoutPropagationView : public views::View {
220 public: 220 public:
221 LayoutPropagationView() {} 221 LayoutPropagationView() {}
222 virtual ~LayoutPropagationView() {} 222 ~LayoutPropagationView() override {}
223 223
224 protected: 224 protected:
225 virtual void ChildVisibilityChanged(views::View* child) override { 225 void ChildVisibilityChanged(views::View* child) override {
226 PreferredSizeChanged(); 226 PreferredSizeChanged();
227 } 227 }
228 virtual void ChildPreferredSizeChanged(views::View* child) override { 228 void ChildPreferredSizeChanged(views::View* child) override {
229 PreferredSizeChanged(); 229 PreferredSizeChanged();
230 } 230 }
231 231
232 private: 232 private:
233 DISALLOW_COPY_AND_ASSIGN(LayoutPropagationView); 233 DISALLOW_COPY_AND_ASSIGN(LayoutPropagationView);
234 }; 234 };
235 235
236 // A View for a single notification banner. 236 // A View for a single notification banner.
237 class NotificationView : public views::View, 237 class NotificationView : public views::View,
238 public views::ButtonListener, 238 public views::ButtonListener,
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 291
292 if (!data.tooltip_text().empty()) 292 if (!data.tooltip_text().empty())
293 AddChildView(new TooltipIcon(data.tooltip_text())); 293 AddChildView(new TooltipIcon(data.tooltip_text()));
294 294
295 set_background( 295 set_background(
296 views::Background::CreateSolidBackground(data.GetBackgroundColor())); 296 views::Background::CreateSolidBackground(data.GetBackgroundColor()));
297 SetBorder(views::Border::CreateSolidSidedBorder( 297 SetBorder(views::Border::CreateSolidSidedBorder(
298 1, 0, 1, 0, data.GetBorderColor())); 298 1, 0, 1, 0, data.GetBorderColor()));
299 } 299 }
300 300
301 virtual ~NotificationView() {} 301 ~NotificationView() override {}
302 302
303 views::Checkbox* checkbox() { 303 views::Checkbox* checkbox() {
304 return checkbox_; 304 return checkbox_;
305 } 305 }
306 306
307 // views::View implementation. 307 // views::View implementation.
308 virtual gfx::Insets GetInsets() const override { 308 gfx::Insets GetInsets() const override {
309 int vertical_padding = kNotificationPadding; 309 int vertical_padding = kNotificationPadding;
310 if (checkbox_) 310 if (checkbox_)
311 vertical_padding -= 3; 311 vertical_padding -= 3;
312 return gfx::Insets(vertical_padding, kDialogEdgePadding, 312 return gfx::Insets(vertical_padding, kDialogEdgePadding,
313 vertical_padding, kDialogEdgePadding); 313 vertical_padding, kDialogEdgePadding);
314 } 314 }
315 315
316 virtual int GetHeightForWidth(int width) const override { 316 int GetHeightForWidth(int width) const override {
317 int label_width = width - GetInsets().width(); 317 int label_width = width - GetInsets().width();
318 if (child_count() > 1) { 318 if (child_count() > 1) {
319 const views::View* tooltip_icon = child_at(1); 319 const views::View* tooltip_icon = child_at(1);
320 label_width -= tooltip_icon->GetPreferredSize().width() + 320 label_width -= tooltip_icon->GetPreferredSize().width() +
321 kDialogEdgePadding; 321 kDialogEdgePadding;
322 } 322 }
323 323
324 return child_at(0)->GetHeightForWidth(label_width) + GetInsets().height(); 324 return child_at(0)->GetHeightForWidth(label_width) + GetInsets().height();
325 } 325 }
326 326
327 virtual void Layout() override { 327 void Layout() override {
328 // Surprisingly, GetContentsBounds() doesn't consult GetInsets(). 328 // Surprisingly, GetContentsBounds() doesn't consult GetInsets().
329 gfx::Rect bounds = GetLocalBounds(); 329 gfx::Rect bounds = GetLocalBounds();
330 bounds.Inset(GetInsets()); 330 bounds.Inset(GetInsets());
331 int right_bound = bounds.right(); 331 int right_bound = bounds.right();
332 332
333 if (child_count() > 1) { 333 if (child_count() > 1) {
334 // The icon takes up the entire vertical space and an extra 20px on 334 // The icon takes up the entire vertical space and an extra 20px on
335 // each side. This increases the hover target for the tooltip. 335 // each side. This increases the hover target for the tooltip.
336 views::View* tooltip_icon = child_at(1); 336 views::View* tooltip_icon = child_at(1);
337 gfx::Size icon_size = tooltip_icon->GetPreferredSize(); 337 gfx::Size icon_size = tooltip_icon->GetPreferredSize();
338 int icon_width = icon_size.width() + kDialogEdgePadding; 338 int icon_width = icon_size.width() + kDialogEdgePadding;
339 right_bound -= icon_width; 339 right_bound -= icon_width;
340 tooltip_icon->SetBounds( 340 tooltip_icon->SetBounds(
341 right_bound, 0, 341 right_bound, 0,
342 icon_width + kDialogEdgePadding, GetLocalBounds().height()); 342 icon_width + kDialogEdgePadding, GetLocalBounds().height());
343 } 343 }
344 344
345 child_at(0)->SetBounds(bounds.x(), bounds.y(), 345 child_at(0)->SetBounds(bounds.x(), bounds.y(),
346 right_bound - bounds.x(), bounds.height()); 346 right_bound - bounds.x(), bounds.height());
347 } 347 }
348 348
349 // views::ButtonListener implementation. 349 // views::ButtonListener implementation.
350 virtual void ButtonPressed(views::Button* sender, 350 void ButtonPressed(views::Button* sender, const ui::Event& event) override {
351 const ui::Event& event) override {
352 DCHECK_EQ(sender, checkbox_); 351 DCHECK_EQ(sender, checkbox_);
353 delegate_->NotificationCheckboxStateChanged(data_.type(), 352 delegate_->NotificationCheckboxStateChanged(data_.type(),
354 checkbox_->checked()); 353 checkbox_->checked());
355 } 354 }
356 355
357 // views::StyledLabelListener implementation. 356 // views::StyledLabelListener implementation.
358 virtual void StyledLabelLinkClicked(const gfx::Range& range, int event_flags) 357 void StyledLabelLinkClicked(const gfx::Range& range,
359 override { 358 int event_flags) override {
360 delegate_->LinkClicked(data_.link_url()); 359 delegate_->LinkClicked(data_.link_url());
361 } 360 }
362 361
363 private: 362 private:
364 // The model data for this notification. 363 // The model data for this notification.
365 DialogNotification data_; 364 DialogNotification data_;
366 365
367 // The delegate that handles interaction with |this|. 366 // The delegate that handles interaction with |this|.
368 AutofillDialogViewDelegate* delegate_; 367 AutofillDialogViewDelegate* delegate_;
369 368
(...skipping 19 matching lines...) Expand all
389 animation_.reset(new LoadingAnimation(this, font_list.GetHeight())); 388 animation_.reset(new LoadingAnimation(this, font_list.GetHeight()));
390 389
391 container_->AddChildView(new views::Label(text, font_list)); 390 container_->AddChildView(new views::Label(text, font_list));
392 391
393 for (size_t i = 0; i < 3; ++i) { 392 for (size_t i = 0; i < 3; ++i) {
394 container_->AddChildView( 393 container_->AddChildView(
395 new views::Label(base::ASCIIToUTF16("."), font_list)); 394 new views::Label(base::ASCIIToUTF16("."), font_list));
396 } 395 }
397 } 396 }
398 397
399 virtual ~LoadingAnimationView() {} 398 ~LoadingAnimationView() override {}
400 399
401 // views::View implementation. 400 // views::View implementation.
402 virtual void SetVisible(bool visible) override { 401 void SetVisible(bool visible) override {
403 if (visible) 402 if (visible)
404 animation_->Start(); 403 animation_->Start();
405 else 404 else
406 animation_->Reset(); 405 animation_->Reset();
407 406
408 views::View::SetVisible(visible); 407 views::View::SetVisible(visible);
409 } 408 }
410 409
411 virtual void Layout() override { 410 void Layout() override {
412 gfx::Size container_size = container_->GetPreferredSize(); 411 gfx::Size container_size = container_->GetPreferredSize();
413 gfx::Rect container_bounds((width() - container_size.width()) / 2, 412 gfx::Rect container_bounds((width() - container_size.width()) / 2,
414 (height() - container_size.height()) / 2, 413 (height() - container_size.height()) / 2,
415 container_size.width(), 414 container_size.width(),
416 container_size.height()); 415 container_size.height());
417 container_->SetBoundsRect(container_bounds); 416 container_->SetBoundsRect(container_bounds);
418 container_->Layout(); 417 container_->Layout();
419 418
420 for (size_t i = 0; i < 3; ++i) { 419 for (size_t i = 0; i < 3; ++i) {
421 views::View* dot = container_->child_at(i + 1); 420 views::View* dot = container_->child_at(i + 1);
422 dot->SetY(dot->y() + animation_->GetCurrentValueForDot(i)); 421 dot->SetY(dot->y() + animation_->GetCurrentValueForDot(i));
423 } 422 }
424 } 423 }
425 424
426 virtual void OnNativeThemeChanged(const ui::NativeTheme* theme) override { 425 void OnNativeThemeChanged(const ui::NativeTheme* theme) override {
427 set_background(views::Background::CreateSolidBackground( 426 set_background(views::Background::CreateSolidBackground(
428 theme->GetSystemColor(ui::NativeTheme::kColorId_DialogBackground))); 427 theme->GetSystemColor(ui::NativeTheme::kColorId_DialogBackground)));
429 } 428 }
430 429
431 // gfx::AnimationDelegate implementation. 430 // gfx::AnimationDelegate implementation.
432 virtual void AnimationProgressed(const gfx::Animation* animation) override { 431 void AnimationProgressed(const gfx::Animation* animation) override {
433 DCHECK_EQ(animation, animation_.get()); 432 DCHECK_EQ(animation, animation_.get());
434 Layout(); 433 Layout();
435 } 434 }
436 435
437 private: 436 private:
438 // Contains the "Loading" label and the dots. 437 // Contains the "Loading" label and the dots.
439 views::View* container_; 438 views::View* container_;
440 439
441 scoped_ptr<LoadingAnimation> animation_; 440 scoped_ptr<LoadingAnimation> animation_;
442 441
443 DISALLOW_COPY_AND_ASSIGN(LoadingAnimationView); 442 DISALLOW_COPY_AND_ASSIGN(LoadingAnimationView);
444 }; 443 };
445 444
446 // Gets either the Combobox or ExpandingTextfield that is an ancestor (including 445 // Gets either the Combobox or ExpandingTextfield that is an ancestor (including
447 // self) of |view|. 446 // self) of |view|.
448 views::View* GetAncestralInputView(views::View* view) { 447 views::View* GetAncestralInputView(views::View* view) {
449 if (view->GetClassName() == views::Combobox::kViewClassName) 448 if (view->GetClassName() == views::Combobox::kViewClassName)
450 return view; 449 return view;
451 450
452 return view->GetAncestorWithClassName(ExpandingTextfield::kViewClassName); 451 return view->GetAncestorWithClassName(ExpandingTextfield::kViewClassName);
453 } 452 }
454 453
455 // A class that informs |delegate_| when an unhandled mouse press occurs. 454 // A class that informs |delegate_| when an unhandled mouse press occurs.
456 class MousePressedHandler : public ui::EventHandler { 455 class MousePressedHandler : public ui::EventHandler {
457 public: 456 public:
458 explicit MousePressedHandler(AutofillDialogViewDelegate* delegate) 457 explicit MousePressedHandler(AutofillDialogViewDelegate* delegate)
459 : delegate_(delegate) {} 458 : delegate_(delegate) {}
460 459
461 // ui::EventHandler implementation. 460 // ui::EventHandler implementation.
462 virtual void OnMouseEvent(ui::MouseEvent* event) override { 461 void OnMouseEvent(ui::MouseEvent* event) override {
463 if (event->type() == ui::ET_MOUSE_PRESSED && !event->handled()) 462 if (event->type() == ui::ET_MOUSE_PRESSED && !event->handled())
464 delegate_->FocusMoved(); 463 delegate_->FocusMoved();
465 } 464 }
466 465
467 private: 466 private:
468 AutofillDialogViewDelegate* const delegate_; 467 AutofillDialogViewDelegate* const delegate_;
469 468
470 DISALLOW_COPY_AND_ASSIGN(MousePressedHandler); 469 DISALLOW_COPY_AND_ASSIGN(MousePressedHandler);
471 }; 470 };
472 471
(...skipping 2031 matching lines...) Expand 10 before | Expand all | Expand 10 after
2504 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) 2503 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section)
2505 : section(section), 2504 : section(section),
2506 container(NULL), 2505 container(NULL),
2507 manual_input(NULL), 2506 manual_input(NULL),
2508 suggested_info(NULL), 2507 suggested_info(NULL),
2509 suggested_button(NULL) {} 2508 suggested_button(NULL) {}
2510 2509
2511 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} 2510 AutofillDialogViews::DetailsGroup::~DetailsGroup() {}
2512 2511
2513 } // namespace autofill 2512 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698