| 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/tab_autofill_manager_delegate.h" | 5 #include "chrome/browser/ui/autofill/tab_autofill_manager_delegate.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "base/prefs/pref_service.h" | 8 #include "base/prefs/pref_service.h" |
| 9 #include "chrome/browser/autofill/autocheckout_whitelist_manager_factory.h" | 9 #include "chrome/browser/autofill/autocheckout_whitelist_manager_factory.h" |
| 10 #include "chrome/browser/autofill/autofill_cc_infobar_delegate.h" | 10 #include "chrome/browser/autofill/autofill_cc_infobar_delegate.h" |
| 11 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 11 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
| 12 #include "chrome/browser/infobars/infobar_service.h" | 12 #include "chrome/browser/infobars/infobar_service.h" |
| 13 #include "chrome/browser/profiles/profile.h" | 13 #include "chrome/browser/profiles/profile.h" |
| 14 #include "chrome/browser/ui/autofill/autocheckout_bubble.h" | 14 #include "chrome/browser/ui/autofill/autocheckout_bubble.h" |
| 15 #include "chrome/browser/ui/autofill/autocheckout_bubble_controller.h" | 15 #include "chrome/browser/ui/autofill/autocheckout_bubble_controller.h" |
| 16 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" | 16 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h" |
| 17 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" | 17 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" |
| 18 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
| 19 #include "chrome/browser/ui/browser_finder.h" | 19 #include "chrome/browser/ui/browser_finder.h" |
| 20 #include "chrome/browser/ui/browser_window.h" | 20 #include "chrome/browser/ui/browser_window.h" |
| 21 #include "chrome/browser/ui/chrome_pages.h" | 21 #include "chrome/browser/ui/chrome_pages.h" |
| 22 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" | 22 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" |
| 23 #include "chrome/common/url_constants.h" | 23 #include "chrome/common/url_constants.h" |
| 24 #include "components/autofill/content/browser/autofill_driver_impl.h" | 24 #include "components/autofill/content/browser/autofill_driver_impl.h" |
| 25 #include "components/autofill/core/common/autofill_messages.h" | 25 #include "components/autofill/core/common/autofill_messages.h" |
| 26 #include "components/autofill/core/common/autofill_pref_names.h" | 26 #include "components/autofill/core/common/autofill_pref_names.h" |
| (...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 143 if (autocheckout_bubble_.get()) | 143 if (autocheckout_bubble_.get()) |
| 144 autocheckout_bubble_->HideBubble(); | 144 autocheckout_bubble_->HideBubble(); |
| 145 } | 145 } |
| 146 | 146 |
| 147 void TabAutofillManagerDelegate::ShowRequestAutocompleteDialog( | 147 void TabAutofillManagerDelegate::ShowRequestAutocompleteDialog( |
| 148 const FormData& form, | 148 const FormData& form, |
| 149 const GURL& source_url, | 149 const GURL& source_url, |
| 150 DialogType dialog_type, | 150 DialogType dialog_type, |
| 151 const base::Callback<void(const FormStructure*, | 151 const base::Callback<void(const FormStructure*, |
| 152 const std::string&)>& callback) { | 152 const std::string&)>& callback) { |
| 153 #if defined(ENABLE_AUTOFILL_DIALOG) | |
| 154 HideRequestAutocompleteDialog(); | 153 HideRequestAutocompleteDialog(); |
| 155 | 154 |
| 156 dialog_controller_ = AutofillDialogControllerImpl::Create(web_contents_, | 155 dialog_controller_ = AutofillDialogController::Create(web_contents_, |
| 157 form, | 156 form, |
| 158 source_url, | 157 source_url, |
| 159 dialog_type, | 158 dialog_type, |
| 160 callback); | 159 callback); |
| 161 dialog_controller_->Show(); | 160 if (dialog_controller_) { |
| 162 #else | 161 dialog_controller_->Show(); |
| 163 callback.Run(NULL, std::string()); | 162 } else { |
| 164 NOTIMPLEMENTED(); | 163 callback.Run(NULL, std::string()); |
| 165 #endif // #if !defined(ENABLE_AUTOFILL_DIALOG) | 164 NOTIMPLEMENTED(); |
| 165 } |
| 166 } | 166 } |
| 167 | 167 |
| 168 void TabAutofillManagerDelegate::ShowAutofillPopup( | 168 void TabAutofillManagerDelegate::ShowAutofillPopup( |
| 169 const gfx::RectF& element_bounds, | 169 const gfx::RectF& element_bounds, |
| 170 base::i18n::TextDirection text_direction, | 170 base::i18n::TextDirection text_direction, |
| 171 const std::vector<string16>& values, | 171 const std::vector<string16>& values, |
| 172 const std::vector<string16>& labels, | 172 const std::vector<string16>& labels, |
| 173 const std::vector<string16>& icons, | 173 const std::vector<string16>& icons, |
| 174 const std::vector<int>& identifiers, | 174 const std::vector<int>& identifiers, |
| 175 base::WeakPtr<AutofillPopupDelegate> delegate) { | 175 base::WeakPtr<AutofillPopupDelegate> delegate) { |
| (...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 239 if (!dialog_controller_.get()) | 239 if (!dialog_controller_.get()) |
| 240 return; | 240 return; |
| 241 | 241 |
| 242 // A redirect immediately after a successful Autocheckout flow shouldn't hide | 242 // A redirect immediately after a successful Autocheckout flow shouldn't hide |
| 243 // the dialog. | 243 // the dialog. |
| 244 bool preserve_dialog = AutofillDriverImpl::FromWebContents(web_contents())-> | 244 bool preserve_dialog = AutofillDriverImpl::FromWebContents(web_contents())-> |
| 245 autofill_manager()->autocheckout_manager()->should_preserve_dialog(); | 245 autofill_manager()->autocheckout_manager()->should_preserve_dialog(); |
| 246 bool was_redirect = details.entry && | 246 bool was_redirect = details.entry && |
| 247 content::PageTransitionIsRedirect(details.entry->GetTransitionType()); | 247 content::PageTransitionIsRedirect(details.entry->GetTransitionType()); |
| 248 | 248 |
| 249 if (dialog_controller_->dialog_type() == DIALOG_TYPE_REQUEST_AUTOCOMPLETE || | 249 if (dialog_controller_->GetDialogType() == DIALOG_TYPE_REQUEST_AUTOCOMPLETE || |
| 250 (!was_redirect && !preserve_dialog)) { | 250 (!was_redirect && !preserve_dialog)) { |
| 251 HideRequestAutocompleteDialog(); | 251 HideRequestAutocompleteDialog(); |
| 252 } | 252 } |
| 253 } | 253 } |
| 254 | 254 |
| 255 void TabAutofillManagerDelegate::WebContentsDestroyed( | 255 void TabAutofillManagerDelegate::WebContentsDestroyed( |
| 256 content::WebContents* web_contents) { | 256 content::WebContents* web_contents) { |
| 257 HideAutofillPopup(); | 257 HideAutofillPopup(); |
| 258 } | 258 } |
| 259 | 259 |
| 260 } // namespace autofill | 260 } // namespace autofill |
| OLD | NEW |