| 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_impl.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/common/url_constants.h" | 22 #include "chrome/common/url_constants.h" |
| 23 #include "components/autofill/core/common/autofill_pref_names.h" |
| 23 #include "content/public/browser/navigation_details.h" | 24 #include "content/public/browser/navigation_details.h" |
| 24 #include "content/public/browser/navigation_entry.h" | 25 #include "content/public/browser/navigation_entry.h" |
| 25 #include "content/public/browser/web_contents_view.h" | 26 #include "content/public/browser/web_contents_view.h" |
| 26 #include "ui/gfx/rect.h" | 27 #include "ui/gfx/rect.h" |
| 27 | 28 |
| 28 DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::TabAutofillManagerDelegate); | 29 DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::TabAutofillManagerDelegate); |
| 29 | 30 |
| 30 namespace autofill { | 31 namespace autofill { |
| 31 | 32 |
| 32 TabAutofillManagerDelegate::TabAutofillManagerDelegate( | 33 TabAutofillManagerDelegate::TabAutofillManagerDelegate( |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 if (popup_controller_.get()) | 167 if (popup_controller_.get()) |
| 167 popup_controller_->Hide(); | 168 popup_controller_->Hide(); |
| 168 } | 169 } |
| 169 | 170 |
| 170 void TabAutofillManagerDelegate::UpdateProgressBar(double value) { | 171 void TabAutofillManagerDelegate::UpdateProgressBar(double value) { |
| 171 // |dialog_controller_| is a WeakPtr, but we require it to be present when | 172 // |dialog_controller_| is a WeakPtr, but we require it to be present when |
| 172 // |UpdateProgressBar| is called, so we intentionally do not do NULL check. | 173 // |UpdateProgressBar| is called, so we intentionally do not do NULL check. |
| 173 dialog_controller_->UpdateProgressBar(value); | 174 dialog_controller_->UpdateProgressBar(value); |
| 174 } | 175 } |
| 175 | 176 |
| 177 bool TabAutofillManagerDelegate::IsAutocompleteEnabled() { |
| 178 // For browser, Autocomplete is always enabled as part of Autofill. |
| 179 return GetPrefs()->GetBoolean(prefs::kAutofillEnabled); |
| 180 } |
| 181 |
| 176 void TabAutofillManagerDelegate::HideRequestAutocompleteDialog() { | 182 void TabAutofillManagerDelegate::HideRequestAutocompleteDialog() { |
| 177 if (dialog_controller_.get()) | 183 if (dialog_controller_.get()) |
| 178 dialog_controller_->Hide(); | 184 dialog_controller_->Hide(); |
| 179 } | 185 } |
| 180 | 186 |
| 181 void TabAutofillManagerDelegate::DidNavigateMainFrame( | 187 void TabAutofillManagerDelegate::DidNavigateMainFrame( |
| 182 const content::LoadCommittedDetails& details, | 188 const content::LoadCommittedDetails& details, |
| 183 const content::FrameNavigateParams& params) { | 189 const content::FrameNavigateParams& params) { |
| 184 // A redirect immediately after a successful Autocheckout flow shouldn't hide | 190 // A redirect immediately after a successful Autocheckout flow shouldn't hide |
| 185 // the dialog. | 191 // the dialog. |
| 186 bool was_redirect = details.entry && | 192 bool was_redirect = details.entry && |
| 187 content::PageTransitionIsRedirect(details.entry->GetTransitionType()); | 193 content::PageTransitionIsRedirect(details.entry->GetTransitionType()); |
| 188 if (dialog_controller_.get() && | 194 if (dialog_controller_.get() && |
| 189 (dialog_controller_->dialog_type() == DIALOG_TYPE_REQUEST_AUTOCOMPLETE || | 195 (dialog_controller_->dialog_type() == DIALOG_TYPE_REQUEST_AUTOCOMPLETE || |
| 190 (!dialog_controller_->AutocheckoutIsRunning() && !was_redirect))) { | 196 (!dialog_controller_->AutocheckoutIsRunning() && !was_redirect))) { |
| 191 HideRequestAutocompleteDialog(); | 197 HideRequestAutocompleteDialog(); |
| 192 } | 198 } |
| 193 | 199 |
| 194 HideAutocheckoutBubble(); | 200 HideAutocheckoutBubble(); |
| 195 } | 201 } |
| 196 | 202 |
| 197 } // namespace autofill | 203 } // namespace autofill |
| OLD | NEW |