| OLD | NEW |
| (Empty) | |
| 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 |
| 3 // found in the LICENSE file. |
| 4 |
| 5 #include "chrome/browser/ui/views/autofill/autofill_external_delegate_views.h" |
| 6 |
| 7 #include "chrome/browser/ui/views/autofill/autofill_popup_view_views.h" |
| 8 |
| 9 AutofillExternalDelegate* AutofillExternalDelegate::Create( |
| 10 TabContents* tab_contents, |
| 11 AutofillManager* autofill_manager) { |
| 12 return new AutofillExternalDelegateViews(tab_contents, autofill_manager); |
| 13 } |
| 14 |
| 15 AutofillExternalDelegateViews::AutofillExternalDelegateViews( |
| 16 TabContents* tab_contents, |
| 17 AutofillManager* autofill_manager) |
| 18 : AutofillExternalDelegate(tab_contents, autofill_manager), |
| 19 view_(NULL) { |
| 20 } |
| 21 |
| 22 AutofillExternalDelegateViews::~AutofillExternalDelegateViews() { |
| 23 if (view_) |
| 24 delete view_; |
| 25 } |
| 26 |
| 27 void AutofillExternalDelegateViews::InvalidateView() { |
| 28 view_ = NULL; |
| 29 HideAutofillPopup(); |
| 30 } |
| 31 |
| 32 void AutofillExternalDelegateViews::HideAutofillPopupInternal() { |
| 33 if (!view_) |
| 34 return; |
| 35 |
| 36 view_->Hide(); |
| 37 |
| 38 delete view_; |
| 39 view_ = NULL; |
| 40 } |
| 41 |
| 42 void AutofillExternalDelegateViews::OnQueryPlatformSpecific( |
| 43 int query_id, |
| 44 const webkit::forms::FormData& form, |
| 45 const webkit::forms::FormField& field, |
| 46 const gfx::Rect& bounds) { |
| 47 CreateViewIfNeeded(); |
| 48 view_->set_element_bounds(bounds); |
| 49 } |
| 50 |
| 51 void AutofillExternalDelegateViews::ApplyAutofillSuggestions( |
| 52 const std::vector<string16>& autofill_values, |
| 53 const std::vector<string16>& autofill_labels, |
| 54 const std::vector<string16>& autofill_icons, |
| 55 const std::vector<int>& autofill_unique_ids) { |
| 56 CreateViewIfNeeded(); |
| 57 |
| 58 view_->Show(autofill_values, |
| 59 autofill_labels, |
| 60 autofill_icons, |
| 61 autofill_unique_ids); |
| 62 } |
| 63 |
| 64 void AutofillExternalDelegateViews::SetBounds(const gfx::Rect& bounds) { |
| 65 view_->SetBoundsRect(bounds); |
| 66 } |
| 67 |
| 68 void AutofillExternalDelegateViews::CreateViewIfNeeded() { |
| 69 if (!view_) |
| 70 view_ = new AutofillPopupViewViews(web_contents(), this); |
| 71 } |
| OLD | NEW |