OLD | NEW |
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 17 matching lines...) Expand all Loading... |
28 #include "content/public/browser/web_contents_view.h" | 28 #include "content/public/browser/web_contents_view.h" |
29 #include "grit/theme_resources.h" | 29 #include "grit/theme_resources.h" |
30 #include "grit/ui_resources.h" | 30 #include "grit/ui_resources.h" |
31 #include "third_party/skia/include/core/SkColor.h" | 31 #include "third_party/skia/include/core/SkColor.h" |
32 #include "ui/base/l10n/l10n_util.h" | 32 #include "ui/base/l10n/l10n_util.h" |
33 #include "ui/base/models/combobox_model.h" | 33 #include "ui/base/models/combobox_model.h" |
34 #include "ui/base/models/menu_model.h" | 34 #include "ui/base/models/menu_model.h" |
35 #include "ui/base/resource/resource_bundle.h" | 35 #include "ui/base/resource/resource_bundle.h" |
36 #include "ui/gfx/animation/animation_delegate.h" | 36 #include "ui/gfx/animation/animation_delegate.h" |
37 #include "ui/gfx/canvas.h" | 37 #include "ui/gfx/canvas.h" |
| 38 #include "ui/gfx/color_utils.h" |
38 #include "ui/gfx/font_list.h" | 39 #include "ui/gfx/font_list.h" |
39 #include "ui/gfx/path.h" | 40 #include "ui/gfx/path.h" |
40 #include "ui/gfx/point.h" | 41 #include "ui/gfx/point.h" |
41 #include "ui/gfx/skia_util.h" | 42 #include "ui/gfx/skia_util.h" |
42 #include "ui/views/background.h" | 43 #include "ui/views/background.h" |
43 #include "ui/views/border.h" | 44 #include "ui/views/border.h" |
44 #include "ui/views/bubble/bubble_border.h" | 45 #include "ui/views/bubble/bubble_border.h" |
45 #include "ui/views/bubble/bubble_frame_view.h" | 46 #include "ui/views/bubble/bubble_frame_view.h" |
46 #include "ui/views/controls/button/blue_button.h" | 47 #include "ui/views/controls/button/blue_button.h" |
47 #include "ui/views/controls/button/checkbox.h" | 48 #include "ui/views/controls/button/checkbox.h" |
(...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
580 if (state.image.IsEmpty()) { | 581 if (state.image.IsEmpty()) { |
581 SetVisible(false); | 582 SetVisible(false); |
582 return; | 583 return; |
583 } | 584 } |
584 | 585 |
585 image_view_->SetImage(state.image.ToImageSkia()); | 586 image_view_->SetImage(state.image.ToImageSkia()); |
586 | 587 |
587 message_view_->SetVisible(!state.string.text.empty()); | 588 message_view_->SetVisible(!state.string.text.empty()); |
588 message_view_->SetText(state.string.text); | 589 message_view_->SetText(state.string.text); |
589 message_view_->SetFontList(gfx::FontList(state.string.font)); | 590 message_view_->SetFontList(gfx::FontList(state.string.font)); |
590 message_view_->SetEnabledColor(state.string.text_color); | 591 message_view_->SetEnabledColor(GetNativeTheme()->GetSystemColor( |
| 592 ui::NativeTheme::kColorId_TextfieldReadOnlyColor)); |
| 593 |
591 message_view_->set_border( | 594 message_view_->set_border( |
592 views::Border::CreateEmptyBorder(kOverlayMessageVerticalPadding, | 595 views::Border::CreateEmptyBorder(kOverlayMessageVerticalPadding, |
593 kDialogEdgePadding, | 596 kDialogEdgePadding, |
594 kOverlayMessageVerticalPadding, | 597 kOverlayMessageVerticalPadding, |
595 kDialogEdgePadding)); | 598 kDialogEdgePadding)); |
596 | 599 |
597 SetVisible(true); | 600 SetVisible(true); |
598 } | 601 } |
599 | 602 |
600 gfx::Insets AutofillDialogViews::OverlayView::GetInsets() const { | 603 gfx::Insets AutofillDialogViews::OverlayView::GetInsets() const { |
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
643 // stroke is hidden on the sides. | 646 // stroke is hidden on the sides. |
644 arrow.moveTo(rect.x() - 1, y); | 647 arrow.moveTo(rect.x() - 1, y); |
645 arrow.rLineTo(rect.width() / 2 - arrow_half_width, 0); | 648 arrow.rLineTo(rect.width() / 2 - arrow_half_width, 0); |
646 arrow.rLineTo(arrow_half_width, -kArrowHeight); | 649 arrow.rLineTo(arrow_half_width, -kArrowHeight); |
647 arrow.rLineTo(arrow_half_width, kArrowHeight); | 650 arrow.rLineTo(arrow_half_width, kArrowHeight); |
648 arrow.lineTo(rect.right() + 1, y); | 651 arrow.lineTo(rect.right() + 1, y); |
649 arrow.lineTo(rect.right() + 1, rect.bottom() + 1); | 652 arrow.lineTo(rect.right() + 1, rect.bottom() + 1); |
650 arrow.lineTo(rect.x() - 1, rect.bottom() + 1); | 653 arrow.lineTo(rect.x() - 1, rect.bottom() + 1); |
651 arrow.close(); | 654 arrow.close(); |
652 | 655 |
| 656 // The mocked alpha blends were 7 for background & 10 for the border against |
| 657 // a very bright background. The eye perceives luminance differences of |
| 658 // darker colors much less than lighter colors, so increase the alpha blend |
| 659 // amount the darker the color (lower the luminance). |
653 SkPaint paint; | 660 SkPaint paint; |
654 paint.setColor(kShadingColor); | 661 SkColor background_color = background()->get_color(); |
| 662 int background_luminance = |
| 663 color_utils::GetLuminanceForColor(background_color); |
| 664 int background_alpha = static_cast<int>( |
| 665 7 + 15 * (255 - background_luminance) / 255); |
| 666 int subtle_border_alpha = static_cast<int>( |
| 667 10 + 20 * (255 - background_luminance) / 255); |
| 668 |
| 669 paint.setColor(color_utils::BlendTowardOppositeLuminance( |
| 670 background_color, background_alpha)); |
655 paint.setStyle(SkPaint::kFill_Style); | 671 paint.setStyle(SkPaint::kFill_Style); |
656 canvas->DrawPath(arrow, paint); | 672 canvas->DrawPath(arrow, paint); |
657 paint.setColor(kSubtleBorderColor); | 673 paint.setColor(color_utils::BlendTowardOppositeLuminance( |
| 674 background_color, subtle_border_alpha)); |
658 paint.setStyle(SkPaint::kStroke_Style); | 675 paint.setStyle(SkPaint::kStroke_Style); |
659 canvas->DrawPath(arrow, paint); | 676 canvas->DrawPath(arrow, paint); |
660 } | 677 } |
661 | 678 |
662 PaintChildren(canvas); | 679 PaintChildren(canvas); |
663 } | 680 } |
664 | 681 |
665 void AutofillDialogViews::OverlayView::OnNativeThemeChanged( | 682 void AutofillDialogViews::OverlayView::OnNativeThemeChanged( |
666 const ui::NativeTheme* theme) { | 683 const ui::NativeTheme* theme) { |
667 set_background(views::Background::CreateSolidBackground( | 684 set_background(views::Background::CreateSolidBackground( |
(...skipping 1780 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2448 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) | 2465 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) |
2449 : section(section), | 2466 : section(section), |
2450 container(NULL), | 2467 container(NULL), |
2451 manual_input(NULL), | 2468 manual_input(NULL), |
2452 suggested_info(NULL), | 2469 suggested_info(NULL), |
2453 suggested_button(NULL) {} | 2470 suggested_button(NULL) {} |
2454 | 2471 |
2455 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} | 2472 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} |
2456 | 2473 |
2457 } // namespace autofill | 2474 } // namespace autofill |
OLD | NEW |