| 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 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 581 if (state.image.IsEmpty()) { | 582 if (state.image.IsEmpty()) { |
| 582 SetVisible(false); | 583 SetVisible(false); |
| 583 return; | 584 return; |
| 584 } | 585 } |
| 585 | 586 |
| 586 image_view_->SetImage(state.image.ToImageSkia()); | 587 image_view_->SetImage(state.image.ToImageSkia()); |
| 587 | 588 |
| 588 message_view_->SetVisible(!state.string.text.empty()); | 589 message_view_->SetVisible(!state.string.text.empty()); |
| 589 message_view_->SetText(state.string.text); | 590 message_view_->SetText(state.string.text); |
| 590 message_view_->SetFontList(gfx::FontList(state.string.font)); | 591 message_view_->SetFontList(gfx::FontList(state.string.font)); |
| 591 message_view_->SetEnabledColor(state.string.text_color); | 592 message_view_->SetEnabledColor(GetNativeTheme()->GetSystemColor( |
| 593 ui::NativeTheme::kColorId_TextfieldReadOnlyColor)); |
| 594 |
| 592 message_view_->set_border( | 595 message_view_->set_border( |
| 593 views::Border::CreateEmptyBorder(kOverlayMessageVerticalPadding, | 596 views::Border::CreateEmptyBorder(kOverlayMessageVerticalPadding, |
| 594 kDialogEdgePadding, | 597 kDialogEdgePadding, |
| 595 kOverlayMessageVerticalPadding, | 598 kOverlayMessageVerticalPadding, |
| 596 kDialogEdgePadding)); | 599 kDialogEdgePadding)); |
| 597 | 600 |
| 598 SetVisible(true); | 601 SetVisible(true); |
| 599 } | 602 } |
| 600 | 603 |
| 601 gfx::Insets AutofillDialogViews::OverlayView::GetInsets() const { | 604 gfx::Insets AutofillDialogViews::OverlayView::GetInsets() const { |
| (...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 644 // stroke is hidden on the sides. | 647 // stroke is hidden on the sides. |
| 645 arrow.moveTo(rect.x() - 1, y); | 648 arrow.moveTo(rect.x() - 1, y); |
| 646 arrow.rLineTo(rect.width() / 2 - arrow_half_width, 0); | 649 arrow.rLineTo(rect.width() / 2 - arrow_half_width, 0); |
| 647 arrow.rLineTo(arrow_half_width, -kArrowHeight); | 650 arrow.rLineTo(arrow_half_width, -kArrowHeight); |
| 648 arrow.rLineTo(arrow_half_width, kArrowHeight); | 651 arrow.rLineTo(arrow_half_width, kArrowHeight); |
| 649 arrow.lineTo(rect.right() + 1, y); | 652 arrow.lineTo(rect.right() + 1, y); |
| 650 arrow.lineTo(rect.right() + 1, rect.bottom() + 1); | 653 arrow.lineTo(rect.right() + 1, rect.bottom() + 1); |
| 651 arrow.lineTo(rect.x() - 1, rect.bottom() + 1); | 654 arrow.lineTo(rect.x() - 1, rect.bottom() + 1); |
| 652 arrow.close(); | 655 arrow.close(); |
| 653 | 656 |
| 657 // The mocked alpha blends were 7 for background & 10 for the border against |
| 658 // a very bright background. The eye perceives luminance differences of |
| 659 // darker colors much less than lighter colors, so increase the alpha blend |
| 660 // amount the darker the color (lower the luminance). |
| 654 SkPaint paint; | 661 SkPaint paint; |
| 655 paint.setColor(kShadingColor); | 662 SkColor background_color = background()->get_color(); |
| 663 int background_luminance = |
| 664 color_utils::GetLuminanceForColor(background_color); |
| 665 int background_alpha = static_cast<int>( |
| 666 7 + 15 * (255 - background_luminance) / 255); |
| 667 int subtle_border_alpha = static_cast<int>( |
| 668 10 + 20 * (255 - background_luminance) / 255); |
| 669 |
| 670 paint.setColor(color_utils::BlendTowardOppositeLuminance( |
| 671 background_color, background_alpha)); |
| 656 paint.setStyle(SkPaint::kFill_Style); | 672 paint.setStyle(SkPaint::kFill_Style); |
| 657 canvas->DrawPath(arrow, paint); | 673 canvas->DrawPath(arrow, paint); |
| 658 paint.setColor(kSubtleBorderColor); | 674 paint.setColor(color_utils::BlendTowardOppositeLuminance( |
| 675 background_color, subtle_border_alpha)); |
| 659 paint.setStyle(SkPaint::kStroke_Style); | 676 paint.setStyle(SkPaint::kStroke_Style); |
| 660 canvas->DrawPath(arrow, paint); | 677 canvas->DrawPath(arrow, paint); |
| 661 } | 678 } |
| 662 | 679 |
| 663 PaintChildren(canvas); | 680 PaintChildren(canvas); |
| 664 } | 681 } |
| 665 | 682 |
| 666 void AutofillDialogViews::OverlayView::OnNativeThemeChanged( | 683 void AutofillDialogViews::OverlayView::OnNativeThemeChanged( |
| 667 const ui::NativeTheme* theme) { | 684 const ui::NativeTheme* theme) { |
| 668 set_background(views::Background::CreateSolidBackground( | 685 set_background(views::Background::CreateSolidBackground( |
| (...skipping 1782 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2451 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) | 2468 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) |
| 2452 : section(section), | 2469 : section(section), |
| 2453 container(NULL), | 2470 container(NULL), |
| 2454 manual_input(NULL), | 2471 manual_input(NULL), |
| 2455 suggested_info(NULL), | 2472 suggested_info(NULL), |
| 2456 suggested_button(NULL) {} | 2473 suggested_button(NULL) {} |
| 2457 | 2474 |
| 2458 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} | 2475 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} |
| 2459 | 2476 |
| 2460 } // namespace autofill | 2477 } // namespace autofill |
| OLD | NEW |