Chromium Code Reviews| Index: chrome/browser/ui/views/autofill/autofill_external_delegate_views.cc |
| diff --git a/chrome/browser/ui/views/autofill/autofill_external_delegate_views.cc b/chrome/browser/ui/views/autofill/autofill_external_delegate_views.cc |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..b121e12289fc69c5af1daa6334daca957d9c5fe0 |
| --- /dev/null |
| +++ b/chrome/browser/ui/views/autofill/autofill_external_delegate_views.cc |
| @@ -0,0 +1,69 @@ |
| +// Copyright (c) 2012 The Chromium Authors. All rights reserved. |
| +// Use of this source code is governed by a BSD-style license that can be |
| +// found in the LICENSE file. |
| + |
| +#include "chrome/browser/ui/views/autofill/autofill_external_delegate_views.h" |
| + |
| +#include "chrome/browser/ui/views/autofill/autofill_popup_view_views.h" |
| + |
| +AutofillExternalDelegate* AutofillExternalDelegate::Create( |
| + TabContents* tab_contents, |
| + AutofillManager* autofill_manager) { |
| + return new AutofillExternalDelegateViews(tab_contents, autofill_manager); |
| +} |
| + |
| +AutofillExternalDelegateViews::AutofillExternalDelegateViews( |
| + TabContents* tab_contents, |
| + AutofillManager* autofill_manager) |
| + : AutofillExternalDelegate(tab_contents, autofill_manager), |
| + view_(NULL) { |
| +} |
| + |
| +AutofillExternalDelegateViews::~AutofillExternalDelegateViews() { |
| + delete view_; |
| +} |
| + |
| +void AutofillExternalDelegateViews::InvalidateView() { |
| + view_ = NULL; |
| +} |
| + |
| +void AutofillExternalDelegateViews::HideAutofillPopupInternal() { |
| + if (!view_) |
| + return; |
| + |
| + view_->Hide(); |
|
sky
2012/08/16 23:02:01
I know I asked this before, but how come delete vi
csharp
2012/08/20 20:59:00
Hide calls a virtual function in view_, so I can't
sky
2012/08/21 15:29:41
Can't the destructor in the base class take care o
csharp
2012/08/21 20:23:57
Done.
|
| + |
| + delete view_; |
| + view_ = NULL; |
| +} |
| + |
| +void AutofillExternalDelegateViews::OnQueryPlatformSpecific( |
| + int query_id, |
| + const webkit::forms::FormData& form, |
| + const webkit::forms::FormField& field, |
| + const gfx::Rect& bounds) { |
| + CreateViewIfNeeded(); |
| + view_->set_element_bounds(bounds); |
| +} |
| + |
| +void AutofillExternalDelegateViews::ApplyAutofillSuggestions( |
| + const std::vector<string16>& autofill_values, |
| + const std::vector<string16>& autofill_labels, |
| + const std::vector<string16>& autofill_icons, |
| + const std::vector<int>& autofill_unique_ids) { |
| + CreateViewIfNeeded(); |
| + |
| + view_->Show(autofill_values, |
| + autofill_labels, |
| + autofill_icons, |
| + autofill_unique_ids); |
| +} |
| + |
| +void AutofillExternalDelegateViews::SetBounds(const gfx::Rect& bounds) { |
| + view_->SetBoundsRect(bounds); |
| +} |
| + |
| +void AutofillExternalDelegateViews::CreateViewIfNeeded() { |
| + if (!view_) |
| + view_ = new AutofillPopupViewViews(web_contents(), this); |
| +} |