| 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/autofill/autofill_popup_controller_impl.h" | 5 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/logging.h" | 10 #include "base/logging.h" |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 66 }; | 66 }; |
| 67 | 67 |
| 68 } // namespace | 68 } // namespace |
| 69 | 69 |
| 70 // static | 70 // static |
| 71 WeakPtr<AutofillPopupControllerImpl> AutofillPopupControllerImpl::GetOrCreate( | 71 WeakPtr<AutofillPopupControllerImpl> AutofillPopupControllerImpl::GetOrCreate( |
| 72 WeakPtr<AutofillPopupControllerImpl> previous, | 72 WeakPtr<AutofillPopupControllerImpl> previous, |
| 73 WeakPtr<AutofillPopupDelegate> delegate, | 73 WeakPtr<AutofillPopupDelegate> delegate, |
| 74 gfx::NativeView container_view, | 74 gfx::NativeView container_view, |
| 75 const gfx::RectF& element_bounds) { | 75 const gfx::RectF& element_bounds) { |
| 76 DCHECK(!previous || previous->delegate_ == delegate); | 76 DCHECK(!previous.get() || previous->delegate_.get() == delegate.get()); |
| 77 | 77 |
| 78 if (previous && | 78 if (previous.get() && previous->container_view() == container_view && |
| 79 previous->container_view() == container_view && | |
| 80 previous->element_bounds() == element_bounds) { | 79 previous->element_bounds() == element_bounds) { |
| 81 previous->ClearState(); | 80 previous->ClearState(); |
| 82 return previous; | 81 return previous; |
| 83 } | 82 } |
| 84 | 83 |
| 85 if (previous) | 84 if (previous.get()) |
| 86 previous->Hide(); | 85 previous->Hide(); |
| 87 | 86 |
| 88 AutofillPopupControllerImpl* controller = | 87 AutofillPopupControllerImpl* controller = |
| 89 new AutofillPopupControllerImpl(delegate, container_view, element_bounds); | 88 new AutofillPopupControllerImpl(delegate, container_view, element_bounds); |
| 90 return controller->GetWeakPtr(); | 89 return controller->GetWeakPtr(); |
| 91 } | 90 } |
| 92 | 91 |
| 93 AutofillPopupControllerImpl::AutofillPopupControllerImpl( | 92 AutofillPopupControllerImpl::AutofillPopupControllerImpl( |
| 94 base::WeakPtr<AutofillPopupDelegate> delegate, | 93 base::WeakPtr<AutofillPopupDelegate> delegate, |
| 95 gfx::NativeView container_view, | 94 gfx::NativeView container_view, |
| (...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 162 | 161 |
| 163 ShowView(); | 162 ShowView(); |
| 164 } else { | 163 } else { |
| 165 UpdateBoundsAndRedrawPopup(); | 164 UpdateBoundsAndRedrawPopup(); |
| 166 } | 165 } |
| 167 | 166 |
| 168 delegate_->OnPopupShown(this); | 167 delegate_->OnPopupShown(this); |
| 169 } | 168 } |
| 170 | 169 |
| 171 void AutofillPopupControllerImpl::Hide() { | 170 void AutofillPopupControllerImpl::Hide() { |
| 172 if (delegate_) | 171 if (delegate_.get()) |
| 173 delegate_->OnPopupHidden(this); | 172 delegate_->OnPopupHidden(this); |
| 174 | 173 |
| 175 if (view_) | 174 if (view_) |
| 176 view_->Hide(); | 175 view_->Hide(); |
| 177 | 176 |
| 178 delete this; | 177 delete this; |
| 179 } | 178 } |
| 180 | 179 |
| 181 void AutofillPopupControllerImpl::ViewDestroyed() { | 180 void AutofillPopupControllerImpl::ViewDestroyed() { |
| 182 // The view has already been destroyed so clear the reference to it. | 181 // The view has already been destroyed so clear the reference to it. |
| (...skipping 469 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 652 // The popup can appear below the field. | 651 // The popup can appear below the field. |
| 653 return std::make_pair(bottom_growth_start, popup_required_height); | 652 return std::make_pair(bottom_growth_start, popup_required_height); |
| 654 } else { | 653 } else { |
| 655 // The popup must appear above the field. | 654 // The popup must appear above the field. |
| 656 return std::make_pair(top_growth_end - popup_required_height, | 655 return std::make_pair(top_growth_end - popup_required_height, |
| 657 popup_required_height); | 656 popup_required_height); |
| 658 } | 657 } |
| 659 } | 658 } |
| 660 | 659 |
| 661 } // namespace autofill | 660 } // namespace autofill |
| OLD | NEW |