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

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

Issue 18850006: retry r210334 with fix for android (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 5 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
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/strings/utf_string_conversions.h" 10 #include "base/strings/utf_string_conversions.h"
11 #include "chrome/browser/profiles/profile.h" 11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h" 12 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h"
13 #include "chrome/browser/ui/autofill/autofill_dialog_sign_in_delegate.h" 13 #include "chrome/browser/ui/autofill/autofill_dialog_sign_in_delegate.h"
14 #include "chrome/browser/ui/views/constrained_window_views.h" 14 #include "chrome/browser/ui/views/constrained_window_views.h"
15 #include "components/autofill/content/browser/wallet/wallet_service_url.h" 15 #include "components/autofill/content/browser/wallet/wallet_service_url.h"
16 #include "components/autofill/core/browser/autofill_type.h" 16 #include "components/autofill/core/browser/autofill_type.h"
17 #include "components/web_modal/web_contents_modal_dialog_manager.h" 17 #include "components/web_modal/web_contents_modal_dialog_manager.h"
18 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h" 18 #include "components/web_modal/web_contents_modal_dialog_manager_delegate.h"
19 #include "content/public/browser/native_web_keyboard_event.h" 19 #include "content/public/browser/native_web_keyboard_event.h"
20 #include "content/public/browser/navigation_controller.h" 20 #include "content/public/browser/navigation_controller.h"
21 #include "content/public/browser/web_contents.h" 21 #include "content/public/browser/web_contents.h"
22 #include "content/public/browser/web_contents_view.h" 22 #include "content/public/browser/web_contents_view.h"
23 #include "grit/theme_resources.h" 23 #include "grit/theme_resources.h"
24 #include "grit/ui_resources.h" 24 #include "grit/ui_resources.h"
25 #include "third_party/skia/include/core/SkColor.h" 25 #include "third_party/skia/include/core/SkColor.h"
26 #include "ui/base/animation/animation_delegate.h"
27 #include "ui/base/animation/multi_animation.h" 26 #include "ui/base/animation/multi_animation.h"
28 #include "ui/base/l10n/l10n_util.h" 27 #include "ui/base/l10n/l10n_util.h"
29 #include "ui/base/models/combobox_model.h" 28 #include "ui/base/models/combobox_model.h"
30 #include "ui/base/models/menu_model.h" 29 #include "ui/base/models/menu_model.h"
31 #include "ui/base/resource/resource_bundle.h" 30 #include "ui/base/resource/resource_bundle.h"
32 #include "ui/gfx/canvas.h" 31 #include "ui/gfx/canvas.h"
33 #include "ui/gfx/path.h" 32 #include "ui/gfx/path.h"
34 #include "ui/gfx/skia_util.h" 33 #include "ui/gfx/skia_util.h"
35 #include "ui/views/background.h" 34 #include "ui/views/background.h"
36 #include "ui/views/border.h" 35 #include "ui/views/border.h"
(...skipping 24 matching lines...) Expand all
61 60
62 namespace { 61 namespace {
63 62
64 // The minimum useful height of the contents area of the dialog. 63 // The minimum useful height of the contents area of the dialog.
65 const int kMinimumContentsHeight = 100; 64 const int kMinimumContentsHeight = 100;
66 65
67 // Horizontal padding between text and other elements (in pixels). 66 // Horizontal padding between text and other elements (in pixels).
68 const int kAroundTextPadding = 4; 67 const int kAroundTextPadding = 4;
69 68
70 // Padding around icons inside DecoratedTextfields. 69 // Padding around icons inside DecoratedTextfields.
71 const size_t kTextfieldIconPadding = 3; 70 const int kTextfieldIconPadding = 3;
72 71
73 // Size of the triangular mark that indicates an invalid textfield (in pixels). 72 // Size of the triangular mark that indicates an invalid textfield (in pixels).
74 const size_t kDogEarSize = 10; 73 const int kDogEarSize = 10;
75 74
76 // The space between the edges of a notification bar and the text within (in 75 // The space between the edges of a notification bar and the text within (in
77 // pixels). 76 // pixels).
78 const size_t kNotificationPadding = 14; 77 const int kNotificationPadding = 14;
79 78
80 // Vertical padding above and below each detail section (in pixels). 79 // Vertical padding above and below each detail section (in pixels).
81 const size_t kDetailSectionInset = 10; 80 const int kDetailSectionInset = 10;
82 81
83 const size_t kAutocheckoutStepsAreaPadding = 28; 82 const int kAutocheckoutStepsAreaPadding = 28;
84 const size_t kAutocheckoutStepInset = 20; 83 const int kAutocheckoutStepInset = 20;
85 84
86 const size_t kAutocheckoutProgressBarWidth = 375; 85 const int kAutocheckoutProgressBarWidth = 375;
87 const size_t kAutocheckoutProgressBarHeight = 15; 86 const int kAutocheckoutProgressBarHeight = 15;
88 87
89 const size_t kArrowHeight = 7; 88 const int kArrowHeight = 7;
90 const size_t kArrowWidth = 2 * kArrowHeight; 89 const int kArrowWidth = 2 * kArrowHeight;
91 90
92 // The padding around the edges of the legal documents text, in pixels. 91 // The padding around the edges of the legal documents text, in pixels.
93 const size_t kLegalDocPadding = 20; 92 const int kLegalDocPadding = 20;
94 93
95 // Slight shading for mouse hover and legal document background. 94 // Slight shading for mouse hover and legal document background.
96 SkColor kShadingColor = SkColorSetARGB(7, 0, 0, 0); 95 SkColor kShadingColor = SkColorSetARGB(7, 0, 0, 0);
97 96
98 // A border color for the legal document view. 97 // A border color for the legal document view.
99 SkColor kSubtleBorderColor = SkColorSetARGB(10, 0, 0, 0); 98 SkColor kSubtleBorderColor = SkColorSetARGB(10, 0, 0, 0);
100 99
101 // The top padding, in pixels, for the suggestions menu dropdown arrows. 100 // The top padding, in pixels, for the suggestions menu dropdown arrows.
102 const size_t kMenuButtonTopOffset = 5; 101 const int kMenuButtonTopOffset = 5;
103 102
104 // The side padding, in pixels, for the suggestions menu dropdown arrows. 103 // The side padding, in pixels, for the suggestions menu dropdown arrows.
105 const size_t kMenuButtonHorizontalPadding = 20; 104 const int kMenuButtonHorizontalPadding = 20;
105
106 // The padding around text in the overlay view.
107 const int kOverlayTextPadding = 20;
108
109 // Spacing between lines of text in the overlay view.
110 const int kOverlayTextInterlineSpacing = 10;
106 111
107 const char kDecoratedTextfieldClassName[] = "autofill/DecoratedTextfield"; 112 const char kDecoratedTextfieldClassName[] = "autofill/DecoratedTextfield";
108 const char kNotificationAreaClassName[] = "autofill/NotificationArea"; 113 const char kNotificationAreaClassName[] = "autofill/NotificationArea";
114 const char kOverlayViewClassName[] = "autofill/OverlayView";
115
116 typedef ui::MultiAnimation::Part Part;
117 typedef ui::MultiAnimation::Parts Parts;
109 118
110 views::Border* CreateLabelAlignmentBorder() { 119 views::Border* CreateLabelAlignmentBorder() {
111 // TODO(estade): this should be made to match the native textfield top 120 // TODO(estade): this should be made to match the native textfield top
112 // inset. It's hard to get at, so for now it's hard-coded. 121 // inset. It's hard to get at, so for now it's hard-coded.
113 return views::Border::CreateEmptyBorder(4, 0, 0, 0); 122 return views::Border::CreateEmptyBorder(4, 0, 0, 0);
114 } 123 }
115 124
116 // Returns a label that describes a details section. 125 // Returns a label that describes a details section.
117 views::Label* CreateDetailsSectionLabel(const string16& text) { 126 views::Label* CreateDetailsSectionLabel(const string16& text) {
118 views::Label* label = new views::Label(text); 127 views::Label* label = new views::Label(text);
119 label->SetHorizontalAlignment(gfx::ALIGN_RIGHT); 128 label->SetHorizontalAlignment(gfx::ALIGN_RIGHT);
120 label->SetFont(label->font().DeriveFont(0, gfx::Font::BOLD)); 129 label->SetFont(label->font().DeriveFont(0, gfx::Font::BOLD));
121 label->set_border(CreateLabelAlignmentBorder()); 130 label->set_border(CreateLabelAlignmentBorder());
122 return label; 131 return label;
123 } 132 }
124 133
125 // Draws an arrow at the top of |canvas| pointing to |tip_x|. 134 // Draws an arrow at the top of |canvas| pointing to |tip_x|.
126 void DrawArrow(gfx::Canvas* canvas, int tip_x, const SkColor& color) { 135 void DrawArrow(gfx::Canvas* canvas, int tip_x, const SkColor& color) {
127 const int arrow_half_width = kArrowWidth / 2.0f; 136 const int arrow_half_width = kArrowWidth / 2.0f;
128 const int arrow_middle = tip_x - arrow_half_width;
129 137
130 SkPath arrow; 138 SkPath arrow;
131 arrow.moveTo(arrow_middle - arrow_half_width, kArrowHeight); 139 arrow.moveTo(tip_x, 0);
132 arrow.lineTo(arrow_middle + arrow_half_width, kArrowHeight); 140 arrow.rLineTo(arrow_half_width, kArrowHeight);
133 arrow.lineTo(arrow_middle, 0); 141 arrow.rLineTo(-kArrowWidth, 0);
134 arrow.close(); 142 arrow.close();
135 canvas->ClipPath(arrow); 143 SkPaint paint;
136 canvas->DrawColor(color); 144 paint.setColor(color);
145 canvas->DrawPath(arrow, paint);
137 } 146 }
138 147
139 typedef ui::MultiAnimation::Part Part;
140 typedef ui::MultiAnimation::Parts Parts;
141
142 class OverlayView : public views::View,
143 public ui::AnimationDelegate {
144 public:
145 OverlayView() {
146 SetLayoutManager(new views::FillLayout());
147
148 set_background(views::Background::CreateSolidBackground(GetNativeTheme()->
149 GetSystemColor(ui::NativeTheme::kColorId_DialogBackground)));
150
151 Parts parts;
152 // For this part of the animation, simply show the splash image.
153 parts.push_back(Part(kSplashDisplayDurationMs, ui::Tween::ZERO));
154 // For this part of the animation, fade out the splash image.
155 parts.push_back(Part(kSplashFadeOutDurationMs, ui::Tween::EASE_IN));
156 // For this part of the animation, fade out |this| (fade in the dialog).
157 parts.push_back(Part(kSplashFadeInDialogDurationMs, ui::Tween::EASE_OUT));
158 fade_out_.reset(
159 new ui::MultiAnimation(parts,
160 ui::MultiAnimation::GetDefaultTimerInterval()));
161 fade_out_->set_delegate(this);
162 fade_out_->set_continuous(false);
163 fade_out_->Start();
164 }
165
166 virtual ~OverlayView() {}
167
168 // ui::AnimationDelegate implementation:
169 virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE {
170 DCHECK_EQ(animation, fade_out_.get());
171 if (fade_out_->current_part_index() != 0)
172 SchedulePaint();
173 }
174
175 virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE {
176 DCHECK_EQ(animation, fade_out_.get());
177 SetVisible(false);
178 }
179
180 // views::View implementation:
181 virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE {
182 // BubbleFrameView doesn't mask the window, it just draws the border via
183 // image assets. Match that rounding here.
184 static const SkScalar kCornerRadius = SkIntToScalar(2);
185 gfx::Rect rect =
186 GetWidget()->non_client_view()->frame_view()->GetLocalBounds();
187 rect.Inset(12, 12, 12, 12);
188 gfx::Path window_mask;
189 window_mask.addRoundRect(gfx::RectToSkRect(rect),
190 kCornerRadius, kCornerRadius);
191 canvas->ClipPath(window_mask);
192
193 if (fade_out_->current_part_index() == 2) {
194 canvas->SaveLayerAlpha((1 - fade_out_->GetCurrentValue()) * 255);
195 views::View::OnPaint(canvas);
196 canvas->Restore();
197 } else {
198 views::View::OnPaint(canvas);
199 }
200 }
201
202 virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE {
203 if (fade_out_->current_part_index() == 0) {
204 views::View::PaintChildren(canvas);
205 } else if (fade_out_->current_part_index() == 1) {
206 canvas->SaveLayerAlpha((1 - fade_out_->GetCurrentValue()) * 255);
207 views::View::PaintChildren(canvas);
208 canvas->Restore();
209 }
210 }
211
212 private:
213 // This MultiAnimation is used to first fade out the contents of the overlay,
214 // then fade out the background of the overlay (revealing the dialog behind
215 // the overlay). This avoids cross-fade.
216 scoped_ptr<ui::MultiAnimation> fade_out_;
217
218 DISALLOW_COPY_AND_ASSIGN(OverlayView);
219 };
220
221 // This class handles layout for the first row of a SuggestionView. 148 // This class handles layout for the first row of a SuggestionView.
222 // It exists to circumvent shortcomings of GridLayout and BoxLayout (namely that 149 // It exists to circumvent shortcomings of GridLayout and BoxLayout (namely that
223 // the former doesn't fully respect child visibility, and that the latter won't 150 // the former doesn't fully respect child visibility, and that the latter won't
224 // expand a single child). 151 // expand a single child).
225 class SectionRowView : public views::View { 152 class SectionRowView : public views::View {
226 public: 153 public:
227 SectionRowView() {} 154 SectionRowView() {}
228 virtual ~SectionRowView() {} 155 virtual ~SectionRowView() {}
229 156
230 // views::View implementation: 157 // views::View implementation:
(...skipping 371 matching lines...) Expand 10 before | Expand all | Expand 10 after
602 views::MenuItemView::TOPRIGHT, 529 views::MenuItemView::TOPRIGHT,
603 ui::MENU_SOURCE_MOUSE, 530 ui::MENU_SOURCE_MOUSE,
604 0)); 531 0));
605 } 532 }
606 533
607 void AutofillDialogViews::AccountChooser::LinkClicked(views::Link* source, 534 void AutofillDialogViews::AccountChooser::LinkClicked(views::Link* source,
608 int event_flags) { 535 int event_flags) {
609 controller_->SignInLinkClicked(); 536 controller_->SignInLinkClicked();
610 } 537 }
611 538
539 // AutofillDialogViews::OverlayView --------------------------------------------
540
541 AutofillDialogViews::OverlayView::OverlayView(views::ButtonListener* listener)
542 : image_view_(new views::ImageView()),
543 message_stack_(new views::View()),
544 button_(new views::LabelButton(listener, string16())) {
545 set_border(views::Border::CreateEmptyBorder(12, 12, 12, 12));
546 set_background(views::Background::CreateSolidBackground(GetNativeTheme()->
547 GetSystemColor(ui::NativeTheme::kColorId_DialogBackground)));
548
549 AddChildView(image_view_);
550
551 AddChildView(message_stack_);
552 message_stack_->SetLayoutManager(
553 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0,
554 kOverlayTextInterlineSpacing));
555 message_stack_->set_border(views::Border::CreateEmptyBorder(
556 kOverlayTextPadding, kOverlayTextPadding, 0, kOverlayTextPadding));
557
558 AddChildView(button_);
559 button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON);
560 button_->set_focusable(true);
561 }
562
563 AutofillDialogViews::OverlayView::~OverlayView() {}
564
565 void AutofillDialogViews::OverlayView::SetState(
566 const DialogOverlayState& state,
567 views::ButtonListener* listener) {
568 // Don't update anything if we're still fading out the old state.
569 if (fade_out_)
570 return;
571
572 if (state.image.IsEmpty()) {
573 SetVisible(false);
574 return;
575 }
576
577 image_view_->SetImage(state.image.ToImageSkia());
578
579 message_stack_->RemoveAllChildViews(true);
580 for (size_t i = 0; i < state.strings.size(); ++i) {
581 views::Label* label = new views::Label();
582 label->SetMultiLine(true);
583 label->SetText(state.strings[i].text);
584 label->SetFont(state.strings[i].font);
585 label->SetHorizontalAlignment(state.strings[i].alignment);
586 message_stack_->AddChildView(label);
587 }
588 message_stack_->SetVisible(message_stack_->child_count() > 0);
589
590 button_->SetVisible(!state.button_text.empty());
591 if (!state.button_text.empty())
592 button_->SetText(state.button_text);
593
594 SetVisible(true);
595 if (parent())
596 parent()->Layout();
597 }
598
599 void AutofillDialogViews::OverlayView::BeginFadeOut() {
600 Parts parts;
601 // For this part of the animation, simply show the splash image.
602 parts.push_back(Part(kSplashDisplayDurationMs, ui::Tween::ZERO));
603 // For this part of the animation, fade out the splash image.
604 parts.push_back(Part(kSplashFadeOutDurationMs, ui::Tween::EASE_IN));
605 // For this part of the animation, fade out |this| (fade in the dialog).
606 parts.push_back(Part(kSplashFadeInDialogDurationMs, ui::Tween::EASE_OUT));
607 fade_out_.reset(
608 new ui::MultiAnimation(parts,
609 ui::MultiAnimation::GetDefaultTimerInterval()));
610 fade_out_->set_delegate(this);
611 fade_out_->set_continuous(false);
612 fade_out_->Start();
613 }
614
615 void AutofillDialogViews::OverlayView::AnimationProgressed(
616 const ui::Animation* animation) {
617 DCHECK_EQ(animation, fade_out_.get());
618 if (fade_out_->current_part_index() != 0)
619 SchedulePaint();
620 }
621
622 void AutofillDialogViews::OverlayView::AnimationEnded(
623 const ui::Animation* animation) {
624 DCHECK_EQ(animation, fade_out_.get());
625 SetVisible(false);
626 fade_out_.reset();
627 }
628
629 void AutofillDialogViews::OverlayView::Layout() {
630 gfx::Rect bounds = GetContentsBounds();
631 if (!message_stack_->visible()) {
632 image_view_->SetBoundsRect(bounds);
633 return;
634 }
635
636 int y = bounds.bottom() - views::kButtonVEdgeMarginNew;
637 if (button_->visible()) {
638 button_->SizeToPreferredSize();
639 y -= button_->height();
640 button_->SetPosition(gfx::Point(
641 bounds.width() - button_->width() -
642 views::kButtonHEdgeMarginNew,
643 y));
644 y -= views::kButtonVEdgeMarginNew;
645 }
646
647 int message_height = message_stack_->GetHeightForWidth(bounds.width());
648 y -= message_height;
649 message_stack_->SetBounds(bounds.x(), y, bounds.width(), message_height);
650
651 gfx::Size image_size = image_view_->GetPreferredSize();
652 const int kImageBottomMargin = 40;
653 y -= image_size.height() + kImageBottomMargin;
654 image_view_->SetBounds(bounds.x(), y, bounds.width(), image_size.height());
655 }
656
657 const char* AutofillDialogViews::OverlayView::GetClassName() const {
658 return kOverlayViewClassName;
659 }
660
661 void AutofillDialogViews::OverlayView::OnPaint(gfx::Canvas* canvas) {
662 // BubbleFrameView doesn't mask the window, it just draws the border via
663 // image assets. Match that rounding here.
664 static const SkScalar kCornerRadius = SkIntToScalar(2);
665 gfx::Rect rect = GetContentsBounds();
666 gfx::Path window_mask;
667 window_mask.addRoundRect(gfx::RectToSkRect(rect),
668 kCornerRadius, kCornerRadius);
669 canvas->ClipPath(window_mask);
670
671 // Fade out background (i.e. fade in what's behind |this|).
672 if (fade_out_ && fade_out_->current_part_index() == 2)
673 canvas->SaveLayerAlpha((1 - fade_out_->GetCurrentValue()) * 255);
674
675 OnPaintBackground(canvas);
676
677 // Draw the arrow, border, and fill for the bottom area.
678 if (message_stack_->visible()) {
679 const int arrow_half_width = kArrowWidth / 2.0f;
680 SkPath arrow;
681 int y = message_stack_->y() - 1;
682 // Note that we purposely draw slightly outside of |rect| so that the
683 // stroke is hidden on the sides.
684 arrow.moveTo(rect.x() - 1, y);
685 arrow.rLineTo(rect.width() / 2 - arrow_half_width, 0);
686 arrow.rLineTo(arrow_half_width, -kArrowHeight);
687 arrow.rLineTo(arrow_half_width, kArrowHeight);
688 arrow.lineTo(rect.right() + 1, y);
689 arrow.lineTo(rect.right() + 1, rect.bottom() + 1);
690 arrow.lineTo(rect.x() - 1, rect.bottom() + 1);
691 arrow.close();
692
693 SkPaint paint;
694 paint.setColor(kShadingColor);
695 paint.setStyle(SkPaint::kFill_Style);
696 canvas->DrawPath(arrow, paint);
697 paint.setColor(kSubtleBorderColor);
698 paint.setStyle(SkPaint::kStroke_Style);
699 canvas->DrawPath(arrow, paint);
700 }
701
702 PaintChildren(canvas);
703 }
704
705 void AutofillDialogViews::OverlayView::PaintChildren(gfx::Canvas* canvas) {
706 // Don't draw children.
707 if (fade_out_ && fade_out_->current_part_index() == 2)
708 return;
709
710 // Fade out children.
711 if (fade_out_ && fade_out_->current_part_index() == 1)
712 canvas->SaveLayerAlpha((1 - fade_out_->GetCurrentValue()) * 255);
713
714 views::View::PaintChildren(canvas);
715 }
716
612 // AutofillDialogViews::NotificationArea --------------------------------------- 717 // AutofillDialogViews::NotificationArea ---------------------------------------
613 718
614 AutofillDialogViews::NotificationArea::NotificationArea( 719 AutofillDialogViews::NotificationArea::NotificationArea(
615 AutofillDialogController* controller) 720 AutofillDialogController* controller)
616 : controller_(controller), 721 : controller_(controller),
617 checkbox_(NULL) { 722 checkbox_(NULL) {
618 // Reserve vertical space for the arrow (regardless of whether one exists). 723 // Reserve vertical space for the arrow (regardless of whether one exists).
619 set_border(views::Border::CreateEmptyBorder(kArrowHeight, 0, 0, 0)); 724 set_border(views::Border::CreateEmptyBorder(kArrowHeight, 0, 0, 0));
620 725
621 views::BoxLayout* box_layout = 726 views::BoxLayout* box_layout =
(...skipping 389 matching lines...) Expand 10 before | Expand all | Expand 10 after
1011 ui::Accelerator backspace(ui::VKEY_BACK, ui::EF_NONE); 1116 ui::Accelerator backspace(ui::VKEY_BACK, ui::EF_NONE);
1012 focus_manager_->RegisterAccelerator( 1117 focus_manager_->RegisterAccelerator(
1013 backspace, ui::AcceleratorManager::kNormalPriority, this); 1118 backspace, ui::AcceleratorManager::kNormalPriority, this);
1014 #endif 1119 #endif
1015 1120
1016 // Listen for size changes on the browser. 1121 // Listen for size changes on the browser.
1017 views::Widget* browser_widget = 1122 views::Widget* browser_widget =
1018 views::Widget::GetTopLevelWidgetForNativeView( 1123 views::Widget::GetTopLevelWidgetForNativeView(
1019 controller_->web_contents()->GetView()->GetNativeView()); 1124 controller_->web_contents()->GetView()->GetNativeView());
1020 observer_.Add(browser_widget); 1125 observer_.Add(browser_widget);
1126
1127 gfx::Image splash_image = controller_->SplashPageImage();
1128 if (!splash_image.IsEmpty()) {
1129 DialogOverlayState state;
1130 state.image = splash_image;
1131 overlay_view_->SetState(state, NULL);
1132 overlay_view_->BeginFadeOut();
1133 }
1021 } 1134 }
1022 1135
1023 void AutofillDialogViews::Hide() { 1136 void AutofillDialogViews::Hide() {
1024 if (window_) 1137 if (window_)
1025 window_->Close(); 1138 window_->Close();
1026 } 1139 }
1027 1140
1028 void AutofillDialogViews::UpdateAccountChooser() { 1141 void AutofillDialogViews::UpdateAccountChooser() {
1029 account_chooser_->Update(); 1142 account_chooser_->Update();
1030 // TODO(estade): replace this with a better loading image/animation. 1143 // TODO(estade): replace this with a better loading image/animation.
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
1062 ContentsPreferredSizeChanged(); 1175 ContentsPreferredSizeChanged();
1063 } 1176 }
1064 1177
1065 void AutofillDialogViews::UpdateButtonStrip() { 1178 void AutofillDialogViews::UpdateButtonStrip() {
1066 button_strip_extra_view_->SetVisible( 1179 button_strip_extra_view_->SetVisible(
1067 GetDialogButtons() != ui::DIALOG_BUTTON_NONE); 1180 GetDialogButtons() != ui::DIALOG_BUTTON_NONE);
1068 UpdateSaveInChromeCheckbox(); 1181 UpdateSaveInChromeCheckbox();
1069 autocheckout_progress_bar_view_->SetVisible( 1182 autocheckout_progress_bar_view_->SetVisible(
1070 controller_->ShouldShowProgressBar()); 1183 controller_->ShouldShowProgressBar());
1071 GetDialogClientView()->UpdateDialogButtons(); 1184 GetDialogClientView()->UpdateDialogButtons();
1185
1186 overlay_view_->SetState(controller_->GetDialogOverlay(), this);
1187
1072 ContentsPreferredSizeChanged(); 1188 ContentsPreferredSizeChanged();
1073 } 1189 }
1074 1190
1075 void AutofillDialogViews::UpdateDetailArea() { 1191 void AutofillDialogViews::UpdateDetailArea() {
1076 scrollable_area_->SetVisible(controller_->ShouldShowDetailArea()); 1192 scrollable_area_->SetVisible(controller_->ShouldShowDetailArea());
1077 ContentsPreferredSizeChanged(); 1193 ContentsPreferredSizeChanged();
1078 } 1194 }
1079 1195
1080 void AutofillDialogViews::UpdateForErrors() { 1196 void AutofillDialogViews::UpdateForErrors() {
1081 ValidateForm(); 1197 ValidateForm();
(...skipping 312 matching lines...) Expand 10 before | Expand all | Expand 10 after
1394 views::Background::CreateSolidBackground(kShadingColor)); 1510 views::Background::CreateSolidBackground(kShadingColor));
1395 1511
1396 legal_document_view_ = new views::StyledLabel(string16(), this); 1512 legal_document_view_ = new views::StyledLabel(string16(), this);
1397 footnote_view_->AddChildView(legal_document_view_); 1513 footnote_view_->AddChildView(legal_document_view_);
1398 footnote_view_->SetVisible(false); 1514 footnote_view_->SetVisible(false);
1399 1515
1400 return footnote_view_; 1516 return footnote_view_;
1401 } 1517 }
1402 1518
1403 views::View* AutofillDialogViews::CreateOverlayView() { 1519 views::View* AutofillDialogViews::CreateOverlayView() {
1404 gfx::Image splash_image = controller_->SplashPageImage();
1405 if (splash_image.IsEmpty())
1406 return NULL;
1407
1408 overlay_view_ = new OverlayView();
1409 views::ImageView* image = new views::ImageView();
1410 image->SetImage(splash_image.ToImageSkia());
1411 overlay_view_->AddChildView(image);
1412
1413 return overlay_view_; 1520 return overlay_view_;
1414 } 1521 }
1415 1522
1416 bool AutofillDialogViews::Cancel() { 1523 bool AutofillDialogViews::Cancel() {
1417 controller_->OnCancel(); 1524 controller_->OnCancel();
1418 return true; 1525 return true;
1419 } 1526 }
1420 1527
1421 bool AutofillDialogViews::Accept() { 1528 bool AutofillDialogViews::Accept() {
1422 if (ValidateForm()) 1529 if (ValidateForm())
1423 controller_->OnAccept(); 1530 controller_->OnAccept();
1424 else if (!validity_map_.empty()) 1531 else if (!validity_map_.empty())
1425 validity_map_.begin()->first->RequestFocus(); 1532 validity_map_.begin()->first->RequestFocus();
1426 1533
1427 // |controller_| decides when to hide the dialog. 1534 // |controller_| decides when to hide the dialog.
1428 return false; 1535 return false;
1429 } 1536 }
1430 1537
1431 // TODO(wittman): Remove this override once we move to the new style frame view 1538 // TODO(wittman): Remove this override once we move to the new style frame view
1432 // on all dialogs. 1539 // on all dialogs.
1433 views::NonClientFrameView* AutofillDialogViews::CreateNonClientFrameView( 1540 views::NonClientFrameView* AutofillDialogViews::CreateNonClientFrameView(
1434 views::Widget* widget) { 1541 views::Widget* widget) {
1435 return CreateConstrainedStyleNonClientFrameView( 1542 return CreateConstrainedStyleNonClientFrameView(
1436 widget, 1543 widget,
1437 controller_->web_contents()->GetBrowserContext()); 1544 controller_->web_contents()->GetBrowserContext());
1438 } 1545 }
1439 1546
1440 void AutofillDialogViews::ButtonPressed(views::Button* sender, 1547 void AutofillDialogViews::ButtonPressed(views::Button* sender,
1441 const ui::Event& event) { 1548 const ui::Event& event) {
1549 if (sender->GetAncestorWithClassName(kOverlayViewClassName)) {
1550 controller_->OverlayButtonPressed();
1551 return;
1552 }
1553
1442 // TODO(estade): Should the menu be shown on mouse down? 1554 // TODO(estade): Should the menu be shown on mouse down?
1443 DetailsGroup* group = NULL; 1555 DetailsGroup* group = NULL;
1444 for (DetailGroupMap::iterator iter = detail_groups_.begin(); 1556 for (DetailGroupMap::iterator iter = detail_groups_.begin();
1445 iter != detail_groups_.end(); ++iter) { 1557 iter != detail_groups_.end(); ++iter) {
1446 if (sender == iter->second.suggested_button) { 1558 if (sender == iter->second.suggested_button) {
1447 group = &iter->second; 1559 group = &iter->second;
1448 break; 1560 break;
1449 } 1561 }
1450 } 1562 }
1451 DCHECK(group); 1563 DCHECK(group);
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after
1574 loading_shield_->SetFont(ui::ResourceBundle::GetSharedInstance().GetFont( 1686 loading_shield_->SetFont(ui::ResourceBundle::GetSharedInstance().GetFont(
1575 ui::ResourceBundle::BaseFont).DeriveFont(15)); 1687 ui::ResourceBundle::BaseFont).DeriveFont(15));
1576 AddChildView(loading_shield_); 1688 AddChildView(loading_shield_);
1577 1689
1578 sign_in_webview_ = new views::WebView(controller_->profile()); 1690 sign_in_webview_ = new views::WebView(controller_->profile());
1579 sign_in_webview_->SetVisible(false); 1691 sign_in_webview_->SetVisible(false);
1580 AddChildView(sign_in_webview_); 1692 AddChildView(sign_in_webview_);
1581 sign_in_delegate_.reset( 1693 sign_in_delegate_.reset(
1582 new AutofillDialogSignInDelegate(this, 1694 new AutofillDialogSignInDelegate(this,
1583 sign_in_webview_->GetWebContents())); 1695 sign_in_webview_->GetWebContents()));
1696
1697 overlay_view_ = new OverlayView(this);
1698 overlay_view_->SetVisible(false);
1584 } 1699 }
1585 1700
1586 views::View* AutofillDialogViews::CreateDetailsContainer() { 1701 views::View* AutofillDialogViews::CreateDetailsContainer() {
1587 details_container_ = new DetailsContainerView( 1702 details_container_ = new DetailsContainerView(
1588 base::Bind(&AutofillDialogViews::DetailsContainerBoundsChanged, 1703 base::Bind(&AutofillDialogViews::DetailsContainerBoundsChanged,
1589 base::Unretained(this))); 1704 base::Unretained(this)));
1590 // A box layout is used because it respects widget visibility. 1705 // A box layout is used because it respects widget visibility.
1591 details_container_->SetLayoutManager( 1706 details_container_->SetLayoutManager(
1592 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0)); 1707 new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, 0));
1593 for (DetailGroupMap::iterator iter = detail_groups_.begin(); 1708 for (DetailGroupMap::iterator iter = detail_groups_.begin();
(...skipping 511 matching lines...) Expand 10 before | Expand all | Expand 10 after
2105 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section) 2220 AutofillDialogViews::DetailsGroup::DetailsGroup(DialogSection section)
2106 : section(section), 2221 : section(section),
2107 container(NULL), 2222 container(NULL),
2108 manual_input(NULL), 2223 manual_input(NULL),
2109 suggested_info(NULL), 2224 suggested_info(NULL),
2110 suggested_button(NULL) {} 2225 suggested_button(NULL) {}
2111 2226
2112 AutofillDialogViews::DetailsGroup::~DetailsGroup() {} 2227 AutofillDialogViews::DetailsGroup::~DetailsGroup() {}
2113 2228
2114 } // namespace autofill 2229 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698