diff options
author | kinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-08 06:00:48 +0000 |
---|---|---|
committer | kinaba@chromium.org <kinaba@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-07-08 06:00:48 +0000 |
commit | 57dbf215ac02981d5ff8e1547327fde834caf59c (patch) | |
tree | cac994e2999389aed1143dc683b3434ffcbaf637 | |
parent | 5d48b004e2bf4634d9354a3b229feed2940ef7d9 (diff) | |
download | chromium_src-57dbf215ac02981d5ff8e1547327fde834caf59c.zip chromium_src-57dbf215ac02981d5ff8e1547327fde834caf59c.tar.gz chromium_src-57dbf215ac02981d5ff8e1547327fde834caf59c.tar.bz2 |
Revert 210334 "requestAutocomplete: Wallet interstitial on Views."
Android bots are broken on AutofillDialogControllerTest.WalletSecondRun
after this patch:
> C 221s Main [CRASH] AutofillDialogControllerTest.WalletSecondRun:
> C 221s Main [ERROR:platform_font_android.cc(13)] Not implemented reached in static gfx::PlatformFont* gfx::PlatformFont::CreateDefault()
> C 221s Main [ERROR:platform_font_android.cc(13)] Not implemented reached in static gfx::PlatformFont* gfx::PlatformFont::CreateDefault()
> C 221s Main [ERROR:platform_font_android.cc(13)] Not implemented reached in static gfx::PlatformFont* gfx::PlatformFont::CreateDefault()
> C 221s Main assertion "ptr_ != NULL" failed: file "../../base/memory/ref_counted.h", line 256, function "T* scoped_refptr<T>::operator->() const [with T = gfx::PlatformFont]"
> requestAutocomplete: Wallet interstitial on Views.
>
> 1. "generating card..."
> 2. "card generated" (only on first run)
>
> BUG=243571
>
> Review URL: https://chromiumcodereview.appspot.com/18110008
TBR=estade@chromium.org
Review URL: https://codereview.chromium.org/18041005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@210349 0039d316-1c4b-4281-b951-d872f2087c98
10 files changed, 122 insertions, 455 deletions
diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller.h b/chrome/browser/ui/autofill/autofill_dialog_controller.h index 7662b81..6bc0508 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_controller.h +++ b/chrome/browser/ui/autofill/autofill_dialog_controller.h @@ -80,10 +80,6 @@ class AutofillDialogController { // Whether or not the |button| should be enabled. virtual bool IsDialogButtonEnabled(ui::DialogButton button) const = 0; - // Returns a struct full of data concerning what overlay, if any, should be - // displayed on top of the dialog. - virtual DialogOverlayState GetDialogOverlay() const = 0; - // Returns ranges to linkify in the text returned by |LegalDocumentsText()|. virtual const std::vector<ui::Range>& LegalDocumentLinks() = 0; @@ -191,9 +187,6 @@ class AutofillDialogController { // A legal document link has been clicked. virtual void LegalDocumentLinkClicked(const ui::Range& range) = 0; - // A button in the dialog's overlay has been pressed. - virtual void OverlayButtonPressed() = 0; - // Called when the view has been cancelled. virtual void OnCancel() = 0; diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc index 48e1e98..d87566b 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.cc @@ -750,45 +750,6 @@ bool AutofillDialogControllerImpl::IsDialogButtonEnabled( IsSubmitPausedOn(wallet::VERIFY_CVV); } -DialogOverlayState AutofillDialogControllerImpl::GetDialogOverlay() const { - bool show_wallet_interstitial = IsPayingWithWallet() && is_submitting_ && - !IsSubmitPausedOn(wallet::VERIFY_CVV); - if (!show_wallet_interstitial) - return DialogOverlayState(); - - ui::ResourceBundle& rb = ui::ResourceBundle::GetSharedInstance(); - DialogOverlayState state; - // TODO(estade): use the correct image and strings below. - state.image = rb.GetImageNamed(IDR_PRODUCT_LOGO_NAME_48); - - // First-run, post-submit, Wallet expository page. - if (full_wallet_ && full_wallet_->required_actions().empty()) { - state.strings.push_back(DialogOverlayString()); - DialogOverlayString& string = state.strings.back(); - string.text = ASCIIToUTF16("...consectetur adipisicing elit"); - string.font = rb.GetFont(ui::ResourceBundle::BaseFont).DeriveFont(4); - - state.strings.push_back(DialogOverlayString()); - DialogOverlayString& subtext = state.strings.back(); - subtext.text = ASCIIToUTF16("sed do eiusmod tempor incididunt ut labore " - "et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud " - "exercitation ullamco laboris nisi ut aliquip ex ea commodo " - "consequat."); - subtext.font = rb.GetFont(ui::ResourceBundle::BaseFont); - - state.button_text = ASCIIToUTF16("OK, gotcha"); - } else { - // "Submitting" waiting page. - state.strings.push_back(DialogOverlayString()); - DialogOverlayString& string = state.strings.back(); - string.text = ASCIIToUTF16("Lorem ipsum dolor sit amet..."); - string.font = rb.GetFont(ui::ResourceBundle::BaseFont).DeriveFont(4); - string.alignment = gfx::ALIGN_CENTER; - } - - return state; -} - const std::vector<ui::Range>& AutofillDialogControllerImpl:: LegalDocumentLinks() { EnsureLegalDocumentsText(); @@ -1836,14 +1797,6 @@ void AutofillDialogControllerImpl::LegalDocumentLinkClicked( NOTREACHED(); } -void AutofillDialogControllerImpl::OverlayButtonPressed() { - DCHECK(is_submitting_); - DCHECK(full_wallet_); - profile_->GetPrefs()->SetBoolean(::prefs::kAutofillDialogHasPaidWithWallet, - true); - FinishSubmit(); -} - void AutofillDialogControllerImpl::OnCancel() { HidePopup(); if (autocheckout_state_ == AUTOCHECKOUT_NOT_STARTED && !is_submitting_) @@ -3110,19 +3063,6 @@ void AutofillDialogControllerImpl::HandleSaveOrUpdateRequiredActions( } void AutofillDialogControllerImpl::FinishSubmit() { - if (IsPayingWithWallet() && - !profile_->GetPrefs()->GetBoolean( - ::prefs::kAutofillDialogHasPaidWithWallet)) { - // To get past this point, the view must call back OverlayButtonPressed. -#if defined(TOOLKIT_VIEWS) - view_->UpdateButtonStrip(); -#else - // TODO(estade): implement overlays on other platforms. - OverlayButtonPressed(); -#endif - return; - } - FillOutputForSection(SECTION_EMAIL); FillOutputForSection(SECTION_CC); FillOutputForSection(SECTION_BILLING); @@ -3142,7 +3082,10 @@ void AutofillDialogControllerImpl::FinishSubmit() { FillOutputForSection(SECTION_SHIPPING); } - if (!IsPayingWithWallet()) { + if (IsPayingWithWallet()) { + profile_->GetPrefs()->SetBoolean( + ::prefs::kAutofillDialogHasPaidWithWallet, true); + } else { for (size_t i = SECTION_MIN; i <= SECTION_MAX; ++i) { DialogSection section = static_cast<DialogSection>(i); if (!SectionIsActive(section)) diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h index c152c5a..297c844 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_impl.h @@ -128,7 +128,6 @@ class AutofillDialogControllerImpl : public AutofillDialogController, virtual bool ShouldShowProgressBar() const OVERRIDE; virtual int GetDialogButtons() const OVERRIDE; virtual bool IsDialogButtonEnabled(ui::DialogButton button) const OVERRIDE; - virtual DialogOverlayState GetDialogOverlay() const OVERRIDE; virtual const std::vector<ui::Range>& LegalDocumentLinks() OVERRIDE; virtual bool SectionIsActive(DialogSection section) const OVERRIDE; virtual const DetailInputs& RequestedFieldsForSection(DialogSection section) @@ -172,7 +171,6 @@ class AutofillDialogControllerImpl : public AutofillDialogController, virtual void NotificationCheckboxStateChanged(DialogNotification::Type type, bool checked) OVERRIDE; virtual void LegalDocumentLinkClicked(const ui::Range& range) OVERRIDE; - virtual void OverlayButtonPressed() OVERRIDE; virtual void OnCancel() OVERRIDE; virtual void OnAccept() OVERRIDE; virtual Profile* profile() OVERRIDE; diff --git a/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc b/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc index 9ad1040..f73d91f 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc +++ b/chrome/browser/ui/autofill/autofill_dialog_controller_unittest.cc @@ -338,10 +338,6 @@ class AutofillDialogControllerTest : public testing::Test { test_web_contents_.reset( content::WebContentsTester::CreateTestWebContents(profile(), NULL)); - // Don't get stuck on the first run wallet interstitial. - profile()->GetPrefs()->SetBoolean(::prefs::kAutofillDialogHasPaidWithWallet, - true); - SetUpControllerWithFormData(DefaultFormData()); } @@ -1638,11 +1634,8 @@ TEST_F(AutofillDialogControllerTest, WalletServerSideValidationUnrecoverable) { TEST_F(AutofillDialogControllerTest, WalletBanners) { CommandLine* command_line = CommandLine::ForCurrentProcess(); command_line->AppendSwitch(switches::kWalletServiceUseProd); - PrefService* prefs = profile()->GetPrefs(); - - // Simulate first run. - prefs->SetBoolean(::prefs::kAutofillDialogHasPaidWithWallet, false); - SetUpControllerWithFormData(DefaultFormData()); + PrefService* prefs = controller()->profile()->GetPrefs(); + ASSERT_FALSE(prefs->GetBoolean(::prefs::kAutofillDialogHasPaidWithWallet)); EXPECT_EQ(0U, NotificationsOfType( DialogNotification::EXPLANATORY_MESSAGE).size()); @@ -1750,12 +1743,6 @@ TEST_F(AutofillDialogControllerTest, OnAutocheckoutSuccess) { command_line->AppendSwitch(switches::kWalletServiceUseProd); controller()->set_dialog_type(DIALOG_TYPE_AUTOCHECKOUT); - // Simulate first run. - profile()->GetPrefs()->SetBoolean(::prefs::kAutofillDialogHasPaidWithWallet, - false); - SetUpControllerWithFormData(DefaultFormData()); - controller()->set_dialog_type(DIALOG_TYPE_AUTOCHECKOUT); - // Sign in a user with a completed account. controller()->OnDidGetWalletItems(CompleteAndValidWalletItems()); @@ -1767,7 +1754,6 @@ TEST_F(AutofillDialogControllerTest, OnAutocheckoutSuccess) { AcceptAndLoadFakeFingerprint(); controller()->OnDidGetFullWallet(wallet::GetTestFullWallet()); - controller()->OverlayButtonPressed(); EXPECT_EQ(0U, NotificationsOfType( DialogNotification::EXPLANATORY_MESSAGE).size()); @@ -1809,60 +1795,6 @@ TEST_F(AutofillDialogControllerTest, SubmitWithSigninErrorDoesntSetPref) { ::prefs::kAutofillDialogPayWithoutWallet)); } -// Tests that there's an overlay shown while waiting for full wallet items, -// and on first run an additional expository wallet overlay shown after full -// wallet items are returned. -// TODO(estade): enable on other platforms when overlays are supported there. -#if defined(TOOLKIT_VIEWS) -TEST_F(AutofillDialogControllerTest, WalletFirstRun) { - // Simulate first run. - PrefService* prefs = profile()->GetPrefs(); - prefs->SetBoolean(::prefs::kAutofillDialogHasPaidWithWallet, false); - SetUpControllerWithFormData(DefaultFormData()); - - SwitchToWallet(); - EXPECT_TRUE(controller()->GetDialogOverlay().image.IsEmpty()); - - scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); - wallet_items->AddInstrument(wallet::GetTestMaskedInstrument()); - controller()->OnDidGetWalletItems(wallet_items.Pass()); - controller()->OnAccept(); - EXPECT_FALSE(controller()->GetDialogOverlay().image.IsEmpty()); - - EXPECT_FALSE(profile()->GetPrefs()->GetBoolean( - ::prefs::kAutofillDialogHasPaidWithWallet)); - controller()->OnDidGetFullWallet(wallet::GetTestFullWallet()); - EXPECT_FALSE(profile()->GetPrefs()->GetBoolean( - ::prefs::kAutofillDialogHasPaidWithWallet)); - EXPECT_FALSE(controller()->GetDialogOverlay().image.IsEmpty()); - EXPECT_FALSE(form_structure()); - - controller()->OverlayButtonPressed(); - EXPECT_TRUE(profile()->GetPrefs()->GetBoolean( - ::prefs::kAutofillDialogHasPaidWithWallet)); - EXPECT_TRUE(form_structure()); -} -#endif - -// On second run, the second overlay doesn't show. -TEST_F(AutofillDialogControllerTest, WalletSecondRun) { - SwitchToWallet(); - EXPECT_TRUE(controller()->GetDialogOverlay().image.IsEmpty()); - - scoped_ptr<wallet::WalletItems> wallet_items = wallet::GetTestWalletItems(); - wallet_items->AddInstrument(wallet::GetTestMaskedInstrument()); - SubmitWithWalletItems(CompleteAndValidWalletItems()); - controller()->OnAccept(); - EXPECT_FALSE(controller()->GetDialogOverlay().image.IsEmpty()); - - EXPECT_TRUE(profile()->GetPrefs()->GetBoolean( - ::prefs::kAutofillDialogHasPaidWithWallet)); - controller()->OnDidGetFullWallet(wallet::GetTestFullWallet()); - EXPECT_TRUE(profile()->GetPrefs()->GetBoolean( - ::prefs::kAutofillDialogHasPaidWithWallet)); - EXPECT_TRUE(form_structure()); -} - TEST_F(AutofillDialogControllerTest, ViewSubmitSetsPref) { ASSERT_FALSE(profile()->GetPrefs()->HasPrefPath( ::prefs::kAutofillDialogPayWithoutWallet)); diff --git a/chrome/browser/ui/autofill/autofill_dialog_types.cc b/chrome/browser/ui/autofill/autofill_dialog_types.cc index a9394e5..eb62c15 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_types.cc +++ b/chrome/browser/ui/autofill/autofill_dialog_types.cc @@ -221,12 +221,6 @@ SuggestionState::SuggestionState(const string16& text, extra_icon(extra_icon) {} SuggestionState::~SuggestionState() {} -DialogOverlayString::DialogOverlayString() : alignment(gfx::ALIGN_LEFT) {} -DialogOverlayString::~DialogOverlayString() {} - -DialogOverlayState::DialogOverlayState() {} -DialogOverlayState::~DialogOverlayState() {} - AutofillMetrics::DialogUiEvent DialogSectionToUiEditEvent( DialogSection section) { switch (section) { diff --git a/chrome/browser/ui/autofill/autofill_dialog_types.h b/chrome/browser/ui/autofill/autofill_dialog_types.h index 63e0a48..a65820b 100644 --- a/chrome/browser/ui/autofill/autofill_dialog_types.h +++ b/chrome/browser/ui/autofill/autofill_dialog_types.h @@ -15,7 +15,6 @@ #include "third_party/skia/include/core/SkColor.h" #include "ui/gfx/font.h" #include "ui/gfx/image/image.h" -#include "ui/gfx/text_constants.h" namespace autofill { @@ -190,30 +189,6 @@ struct SuggestionState { gfx::Image extra_icon; }; -// A struct to describe a textual message within a dialog overlay. -struct DialogOverlayString { - DialogOverlayString(); - ~DialogOverlayString(); - // TODO(estade): need to set a color as well. - base::string16 text; - gfx::Font font; - gfx::HorizontalAlignment alignment; -}; - -// A struct to describe a dialog overlay. If |image| is empty, no overlay should -// be shown. -struct DialogOverlayState { - DialogOverlayState(); - ~DialogOverlayState(); - // If empty, there should not be an overlay. If non-empty, an image that is - // more or less front and center. - gfx::Image image; - // If non-empty, messages to display. - std::vector<DialogOverlayString> strings; - // If non-empty, holds text that should go on a button. - base::string16 button_text; -}; - enum ValidationType { VALIDATE_EDIT, // Validate user edits. Allow for empty fields. VALIDATE_FINAL, // Full form validation. Required fields can't be empty. diff --git a/chrome/browser/ui/autofill/mock_autofill_dialog_controller.cc b/chrome/browser/ui/autofill/mock_autofill_dialog_controller.cc index cb86349..006fa2b 100644 --- a/chrome/browser/ui/autofill/mock_autofill_dialog_controller.cc +++ b/chrome/browser/ui/autofill/mock_autofill_dialog_controller.cc @@ -65,10 +65,6 @@ gfx::Image MockAutofillDialogController::AccountChooserImage() { return gfx::Image(); } -bool MockAutofillDialogController::ShouldShowDetailArea() const { - return false; -} - bool MockAutofillDialogController::ShouldShowProgressBar() const { return false; } @@ -77,13 +73,13 @@ int MockAutofillDialogController::GetDialogButtons() const { return ui::DIALOG_BUTTON_OK | ui::DIALOG_BUTTON_CANCEL; } -bool MockAutofillDialogController::IsDialogButtonEnabled( - ui::DialogButton button) const { +bool MockAutofillDialogController::ShouldShowDetailArea() const { return false; } -DialogOverlayState MockAutofillDialogController::GetDialogOverlay() const { - return DialogOverlayState(); +bool MockAutofillDialogController::IsDialogButtonEnabled( + ui::DialogButton button) const { + return false; } const std::vector<ui::Range>& @@ -175,8 +171,6 @@ void MockAutofillDialogController::NotificationCheckboxStateChanged( void MockAutofillDialogController::LegalDocumentLinkClicked( const ui::Range& range) {} -void MockAutofillDialogController::OverlayButtonPressed() {} - void MockAutofillDialogController::OnCancel() {} void MockAutofillDialogController::OnAccept() {} diff --git a/chrome/browser/ui/autofill/mock_autofill_dialog_controller.h b/chrome/browser/ui/autofill/mock_autofill_dialog_controller.h index 8fa4188..6da9ce8 100644 --- a/chrome/browser/ui/autofill/mock_autofill_dialog_controller.h +++ b/chrome/browser/ui/autofill/mock_autofill_dialog_controller.h @@ -32,7 +32,6 @@ class MockAutofillDialogController : public AutofillDialogController { virtual int GetDialogButtons() const OVERRIDE; virtual bool ShouldShowDetailArea() const OVERRIDE; virtual bool IsDialogButtonEnabled(ui::DialogButton button) const OVERRIDE; - virtual DialogOverlayState GetDialogOverlay() const OVERRIDE; virtual const std::vector<ui::Range>& LegalDocumentLinks() OVERRIDE; virtual bool SectionIsActive(DialogSection section) const OVERRIDE; MOCK_CONST_METHOD1(RequestedFieldsForSection, @@ -80,7 +79,6 @@ class MockAutofillDialogController : public AutofillDialogController { bool checked) OVERRIDE; virtual void LegalDocumentLinkClicked(const ui::Range& range) OVERRIDE; - virtual void OverlayButtonPressed() OVERRIDE; virtual void OnCancel() OVERRIDE; virtual void OnAccept() OVERRIDE; diff --git a/chrome/browser/ui/views/autofill/autofill_dialog_views.cc b/chrome/browser/ui/views/autofill/autofill_dialog_views.cc index 6b895fd..0bd2fd0 100644 --- a/chrome/browser/ui/views/autofill/autofill_dialog_views.cc +++ b/chrome/browser/ui/views/autofill/autofill_dialog_views.cc @@ -23,6 +23,7 @@ #include "grit/theme_resources.h" #include "grit/ui_resources.h" #include "third_party/skia/include/core/SkColor.h" +#include "ui/base/animation/animation_delegate.h" #include "ui/base/animation/multi_animation.h" #include "ui/base/l10n/l10n_util.h" #include "ui/base/models/combobox_model.h" @@ -67,29 +68,29 @@ const int kMinimumContentsHeight = 100; const int kAroundTextPadding = 4; // Padding around icons inside DecoratedTextfields. -const int kTextfieldIconPadding = 3; +const size_t kTextfieldIconPadding = 3; // Size of the triangular mark that indicates an invalid textfield (in pixels). -const int kDogEarSize = 10; +const size_t kDogEarSize = 10; // The space between the edges of a notification bar and the text within (in // pixels). -const int kNotificationPadding = 14; +const size_t kNotificationPadding = 14; // Vertical padding above and below each detail section (in pixels). -const int kDetailSectionInset = 10; +const size_t kDetailSectionInset = 10; -const int kAutocheckoutStepsAreaPadding = 28; -const int kAutocheckoutStepInset = 20; +const size_t kAutocheckoutStepsAreaPadding = 28; +const size_t kAutocheckoutStepInset = 20; -const int kAutocheckoutProgressBarWidth = 375; -const int kAutocheckoutProgressBarHeight = 15; +const size_t kAutocheckoutProgressBarWidth = 375; +const size_t kAutocheckoutProgressBarHeight = 15; -const int kArrowHeight = 7; -const int kArrowWidth = 2 * kArrowHeight; +const size_t kArrowHeight = 7; +const size_t kArrowWidth = 2 * kArrowHeight; // The padding around the edges of the legal documents text, in pixels. -const int kLegalDocPadding = 20; +const size_t kLegalDocPadding = 20; // Slight shading for mouse hover and legal document background. SkColor kShadingColor = SkColorSetARGB(7, 0, 0, 0); @@ -98,23 +99,13 @@ SkColor kShadingColor = SkColorSetARGB(7, 0, 0, 0); SkColor kSubtleBorderColor = SkColorSetARGB(10, 0, 0, 0); // The top padding, in pixels, for the suggestions menu dropdown arrows. -const int kMenuButtonTopOffset = 5; +const size_t kMenuButtonTopOffset = 5; // The side padding, in pixels, for the suggestions menu dropdown arrows. -const int kMenuButtonHorizontalPadding = 20; - -// The padding around text in the overlay view. -const int kOverlayTextPadding = 20; - -// Spacing between lines of text in the overlay view. -const int kOverlayTextInterlineSpacing = 10; +const size_t kMenuButtonHorizontalPadding = 20; const char kDecoratedTextfieldClassName[] = "autofill/DecoratedTextfield"; const char kNotificationAreaClassName[] = "autofill/NotificationArea"; -const char kOverlayViewClassName[] = "autofill/OverlayView"; - -typedef ui::MultiAnimation::Part Part; -typedef ui::MultiAnimation::Parts Parts; views::Border* CreateLabelAlignmentBorder() { // TODO(estade): this should be made to match the native textfield top @@ -134,17 +125,99 @@ views::Label* CreateDetailsSectionLabel(const string16& text) { // Draws an arrow at the top of |canvas| pointing to |tip_x|. void DrawArrow(gfx::Canvas* canvas, int tip_x, const SkColor& color) { const int arrow_half_width = kArrowWidth / 2.0f; + const int arrow_middle = tip_x - arrow_half_width; SkPath arrow; - arrow.moveTo(tip_x, 0); - arrow.rLineTo(arrow_half_width, kArrowHeight); - arrow.rLineTo(-kArrowWidth, 0); + arrow.moveTo(arrow_middle - arrow_half_width, kArrowHeight); + arrow.lineTo(arrow_middle + arrow_half_width, kArrowHeight); + arrow.lineTo(arrow_middle, 0); arrow.close(); - SkPaint paint; - paint.setColor(color); - canvas->DrawPath(arrow, paint); + canvas->ClipPath(arrow); + canvas->DrawColor(color); } +typedef ui::MultiAnimation::Part Part; +typedef ui::MultiAnimation::Parts Parts; + +class OverlayView : public views::View, + public ui::AnimationDelegate { + public: + OverlayView() { + SetLayoutManager(new views::FillLayout()); + + set_background(views::Background::CreateSolidBackground(GetNativeTheme()-> + GetSystemColor(ui::NativeTheme::kColorId_DialogBackground))); + + Parts parts; + // For this part of the animation, simply show the splash image. + parts.push_back(Part(kSplashDisplayDurationMs, ui::Tween::ZERO)); + // For this part of the animation, fade out the splash image. + parts.push_back(Part(kSplashFadeOutDurationMs, ui::Tween::EASE_IN)); + // For this part of the animation, fade out |this| (fade in the dialog). + parts.push_back(Part(kSplashFadeInDialogDurationMs, ui::Tween::EASE_OUT)); + fade_out_.reset( + new ui::MultiAnimation(parts, + ui::MultiAnimation::GetDefaultTimerInterval())); + fade_out_->set_delegate(this); + fade_out_->set_continuous(false); + fade_out_->Start(); + } + + virtual ~OverlayView() {} + + // ui::AnimationDelegate implementation: + virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE { + DCHECK_EQ(animation, fade_out_.get()); + if (fade_out_->current_part_index() != 0) + SchedulePaint(); + } + + virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE { + DCHECK_EQ(animation, fade_out_.get()); + SetVisible(false); + } + + // views::View implementation: + virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE { + // BubbleFrameView doesn't mask the window, it just draws the border via + // image assets. Match that rounding here. + static const SkScalar kCornerRadius = SkIntToScalar(2); + gfx::Rect rect = + GetWidget()->non_client_view()->frame_view()->GetLocalBounds(); + rect.Inset(12, 12, 12, 12); + gfx::Path window_mask; + window_mask.addRoundRect(gfx::RectToSkRect(rect), + kCornerRadius, kCornerRadius); + canvas->ClipPath(window_mask); + + if (fade_out_->current_part_index() == 2) { + canvas->SaveLayerAlpha((1 - fade_out_->GetCurrentValue()) * 255); + views::View::OnPaint(canvas); + canvas->Restore(); + } else { + views::View::OnPaint(canvas); + } + } + + virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE { + if (fade_out_->current_part_index() == 0) { + views::View::PaintChildren(canvas); + } else if (fade_out_->current_part_index() == 1) { + canvas->SaveLayerAlpha((1 - fade_out_->GetCurrentValue()) * 255); + views::View::PaintChildren(canvas); + canvas->Restore(); + } + } + + private: + // This MultiAnimation is used to first fade out the contents of the overlay, + // then fade out the background of the overlay (revealing the dialog behind + // the overlay). This avoids cross-fade. + scoped_ptr<ui::MultiAnimation> fade_out_; + + DISALLOW_COPY_AND_ASSIGN(OverlayView); +}; + // This class handles layout for the first row of a SuggestionView. // It exists to circumvent shortcomings of GridLayout and BoxLayout (namely that // the former doesn't fully respect child visibility, and that the latter won't @@ -536,184 +609,6 @@ void AutofillDialogViews::AccountChooser::LinkClicked(views::Link* source, controller_->SignInLinkClicked(); } -// AutofillDialogViews::OverlayView -------------------------------------------- - -AutofillDialogViews::OverlayView::OverlayView(views::ButtonListener* listener) - : image_view_(new views::ImageView()), - message_stack_(new views::View()), - button_(new views::LabelButton(listener, string16())) { - set_border(views::Border::CreateEmptyBorder(12, 12, 12, 12)); - set_background(views::Background::CreateSolidBackground(GetNativeTheme()-> - GetSystemColor(ui::NativeTheme::kColorId_DialogBackground))); - - AddChildView(image_view_); - - AddChildView(message_stack_); - message_stack_->SetLayoutManager( - new views::BoxLayout(views::BoxLayout::kVertical, 0, 0, - kOverlayTextInterlineSpacing)); - message_stack_->set_border(views::Border::CreateEmptyBorder( - kOverlayTextPadding, kOverlayTextPadding, 0, kOverlayTextPadding)); - - AddChildView(button_); - button_->SetStyle(views::Button::STYLE_NATIVE_TEXTBUTTON); - button_->set_focusable(true); -} - -AutofillDialogViews::OverlayView::~OverlayView() {} - -void AutofillDialogViews::OverlayView::SetState( - const DialogOverlayState& state, - views::ButtonListener* listener) { - // Don't update anything if we're still fading out the old state. - if (fade_out_) - return; - - if (state.image.IsEmpty()) { - SetVisible(false); - return; - } - - image_view_->SetImage(state.image.ToImageSkia()); - - message_stack_->RemoveAllChildViews(true); - for (size_t i = 0; i < state.strings.size(); ++i) { - views::Label* label = new views::Label(); - label->SetMultiLine(true); - label->SetText(state.strings[i].text); - label->SetFont(state.strings[i].font); - label->SetHorizontalAlignment(state.strings[i].alignment); - message_stack_->AddChildView(label); - } - message_stack_->SetVisible(message_stack_->child_count() > 0); - - button_->SetVisible(!state.button_text.empty()); - if (!state.button_text.empty()) - button_->SetText(state.button_text); - - SetVisible(true); - if (parent()) - parent()->Layout(); -} - -void AutofillDialogViews::OverlayView::BeginFadeOut() { - Parts parts; - // For this part of the animation, simply show the splash image. - parts.push_back(Part(kSplashDisplayDurationMs, ui::Tween::ZERO)); - // For this part of the animation, fade out the splash image. - parts.push_back(Part(kSplashFadeOutDurationMs, ui::Tween::EASE_IN)); - // For this part of the animation, fade out |this| (fade in the dialog). - parts.push_back(Part(kSplashFadeInDialogDurationMs, ui::Tween::EASE_OUT)); - fade_out_.reset( - new ui::MultiAnimation(parts, - ui::MultiAnimation::GetDefaultTimerInterval())); - fade_out_->set_delegate(this); - fade_out_->set_continuous(false); - fade_out_->Start(); -} - -void AutofillDialogViews::OverlayView::AnimationProgressed( - const ui::Animation* animation) { - DCHECK_EQ(animation, fade_out_.get()); - if (fade_out_->current_part_index() != 0) - SchedulePaint(); -} - -void AutofillDialogViews::OverlayView::AnimationEnded( - const ui::Animation* animation) { - DCHECK_EQ(animation, fade_out_.get()); - SetVisible(false); - fade_out_.reset(); -} - -void AutofillDialogViews::OverlayView::Layout() { - gfx::Rect bounds = GetContentsBounds(); - if (!message_stack_->visible()) { - image_view_->SetBoundsRect(bounds); - return; - } - - int y = bounds.bottom() - views::kButtonVEdgeMarginNew; - if (button_->visible()) { - button_->SizeToPreferredSize(); - y -= button_->height(); - button_->SetPosition(gfx::Point( - bounds.width() - button_->width() - - views::kButtonHEdgeMarginNew, - y)); - y -= views::kButtonVEdgeMarginNew; - } - - int message_height = message_stack_->GetHeightForWidth(bounds.width()); - y -= message_height; - message_stack_->SetBounds(bounds.x(), y, bounds.width(), message_height); - - gfx::Size image_size = image_view_->GetPreferredSize(); - const int kImageBottomMargin = 40; - y -= image_size.height() + kImageBottomMargin; - image_view_->SetBounds(bounds.x(), y, bounds.width(), image_size.height()); -} - -const char* AutofillDialogViews::OverlayView::GetClassName() const { - return kOverlayViewClassName; -} - -void AutofillDialogViews::OverlayView::OnPaint(gfx::Canvas* canvas) { - // BubbleFrameView doesn't mask the window, it just draws the border via - // image assets. Match that rounding here. - static const SkScalar kCornerRadius = SkIntToScalar(2); - gfx::Rect rect = GetContentsBounds(); - gfx::Path window_mask; - window_mask.addRoundRect(gfx::RectToSkRect(rect), - kCornerRadius, kCornerRadius); - canvas->ClipPath(window_mask); - - // Fade out background (i.e. fade in what's behind |this|). - if (fade_out_ && fade_out_->current_part_index() == 2) - canvas->SaveLayerAlpha((1 - fade_out_->GetCurrentValue()) * 255); - - OnPaintBackground(canvas); - - // Draw the arrow, border, and fill for the bottom area. - if (message_stack_->visible()) { - const int arrow_half_width = kArrowWidth / 2.0f; - SkPath arrow; - int y = message_stack_->y() - 1; - // Note that we purposely draw slightly outside of |rect| so that the - // stroke is hidden on the sides. - arrow.moveTo(rect.x() - 1, y); - arrow.rLineTo(rect.width() / 2 - arrow_half_width, 0); - arrow.rLineTo(arrow_half_width, -kArrowHeight); - arrow.rLineTo(arrow_half_width, kArrowHeight); - arrow.lineTo(rect.right() + 1, y); - arrow.lineTo(rect.right() + 1, rect.bottom() + 1); - arrow.lineTo(rect.x() - 1, rect.bottom() + 1); - arrow.close(); - - SkPaint paint; - paint.setColor(kShadingColor); - paint.setStyle(SkPaint::kFill_Style); - canvas->DrawPath(arrow, paint); - paint.setColor(kSubtleBorderColor); - paint.setStyle(SkPaint::kStroke_Style); - canvas->DrawPath(arrow, paint); - } - - PaintChildren(canvas); -} - -void AutofillDialogViews::OverlayView::PaintChildren(gfx::Canvas* canvas) { - // Don't draw children. - if (fade_out_ && fade_out_->current_part_index() == 2) - return; - - // Fade out children. - if (fade_out_ && fade_out_->current_part_index() == 1) - canvas->SaveLayerAlpha((1 - fade_out_->GetCurrentValue()) * 255); - - views::View::PaintChildren(canvas); -} - // AutofillDialogViews::NotificationArea --------------------------------------- AutofillDialogViews::NotificationArea::NotificationArea( @@ -1123,14 +1018,6 @@ void AutofillDialogViews::Show() { views::Widget::GetTopLevelWidgetForNativeView( controller_->web_contents()->GetView()->GetNativeView()); observer_.Add(browser_widget); - - gfx::Image splash_image = controller_->SplashPageImage(); - if (!splash_image.IsEmpty()) { - DialogOverlayState state; - state.image = splash_image; - overlay_view_->SetState(state, NULL); - overlay_view_->BeginFadeOut(); - } } void AutofillDialogViews::Hide() { @@ -1182,9 +1069,6 @@ void AutofillDialogViews::UpdateButtonStrip() { autocheckout_progress_bar_view_->SetVisible( controller_->ShouldShowProgressBar()); GetDialogClientView()->UpdateDialogButtons(); - - overlay_view_->SetState(controller_->GetDialogOverlay(), this); - ContentsPreferredSizeChanged(); } @@ -1517,6 +1401,15 @@ views::View* AutofillDialogViews::CreateFootnoteView() { } views::View* AutofillDialogViews::CreateOverlayView() { + gfx::Image splash_image = controller_->SplashPageImage(); + if (splash_image.IsEmpty()) + return NULL; + + overlay_view_ = new OverlayView(); + views::ImageView* image = new views::ImageView(); + image->SetImage(splash_image.ToImageSkia()); + overlay_view_->AddChildView(image); + return overlay_view_; } @@ -1546,11 +1439,6 @@ views::NonClientFrameView* AutofillDialogViews::CreateNonClientFrameView( void AutofillDialogViews::ButtonPressed(views::Button* sender, const ui::Event& event) { - if (sender->GetAncestorWithClassName(kOverlayViewClassName)) { - controller_->OverlayButtonPressed(); - return; - } - // TODO(estade): Should the menu be shown on mouse down? DetailsGroup* group = NULL; for (DetailGroupMap::iterator iter = detail_groups_.begin(); @@ -1693,9 +1581,6 @@ void AutofillDialogViews::InitChildViews() { sign_in_delegate_.reset( new AutofillDialogSignInDelegate(this, sign_in_webview_->GetWebContents())); - - overlay_view_ = new OverlayView(this); - overlay_view_->SetVisible(false); } views::View* AutofillDialogViews::CreateDetailsContainer() { diff --git a/chrome/browser/ui/views/autofill/autofill_dialog_views.h b/chrome/browser/ui/views/autofill/autofill_dialog_views.h index b7ac208..ef7d115 100644 --- a/chrome/browser/ui/views/autofill/autofill_dialog_views.h +++ b/chrome/browser/ui/views/autofill/autofill_dialog_views.h @@ -13,7 +13,6 @@ #include "chrome/browser/ui/autofill/autofill_dialog_view.h" #include "chrome/browser/ui/autofill/testable_autofill_dialog_view.h" #include "ui/base/accelerators/accelerator.h" -#include "ui/base/animation/animation_delegate.h" #include "ui/views/controls/button/button.h" #include "ui/views/controls/button/menu_button_listener.h" #include "ui/views/controls/combobox/combobox_listener.h" @@ -43,7 +42,6 @@ class FocusManager; class ImageButton; class ImageView; class Label; -class LabelButton; class Link; class MenuRunner; class StyledLabel; @@ -54,7 +52,6 @@ class Widget; namespace ui { class ComboboxModel; class KeyEvent; -class MultiAnimation; } namespace autofill { @@ -275,48 +272,6 @@ class AutofillDialogViews : public AutofillDialogView, DISALLOW_COPY_AND_ASSIGN(AccountChooser); }; - // A view which displays an image, optionally some messages and a button. Used - // for the splash page as well as the Wallet interstitial. - class OverlayView : public views::View, - public ui::AnimationDelegate { - public: - // The listener is informed when |button_| is pressed. - explicit OverlayView(views::ButtonListener* listener); - virtual ~OverlayView(); - - // Sets properties that should be displayed. - void SetState(const DialogOverlayState& state, - views::ButtonListener* listener); - - // Fades the view out after a delay. - void BeginFadeOut(); - - // ui::AnimationDelegate implementation: - virtual void AnimationProgressed(const ui::Animation* animation) OVERRIDE; - virtual void AnimationEnded(const ui::Animation* animation) OVERRIDE; - - // views::View implementation: - virtual void Layout() OVERRIDE; - virtual const char* GetClassName() const OVERRIDE; - virtual void OnPaint(gfx::Canvas* canvas) OVERRIDE; - virtual void PaintChildren(gfx::Canvas* canvas) OVERRIDE; - - private: - // Child View. Front and center. - views::ImageView* image_view_; - // Child View. When visible, below |image_view_|. - views::View* message_stack_; - // Child View. When visible, below |message_stack_|. - views::LabelButton* button_; - - // This MultiAnimation is used to first fade out the contents of the - // overlay, then fade out the background of the overlay (revealing the - // dialog behind the overlay). This avoids cross-fade. - scoped_ptr<ui::MultiAnimation> fade_out_; - - DISALLOW_COPY_AND_ASSIGN(OverlayView); - }; - // An area for notifications. Some notifications point at the account chooser. class NotificationArea : public views::View, public views::ButtonListener { @@ -610,7 +565,7 @@ class AutofillDialogViews : public AutofillDialogView, views::Label* loading_shield_; // The view that completely overlays the dialog (used for the splash page). - OverlayView* overlay_view_; + views::View* overlay_view_; // The "Extra view" is on the same row as the dialog buttons. views::View* button_strip_extra_view_; |