Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(191)

Side by Side Diff: chrome/browser/ui/autofill/tab_autofill_manager_delegate.cc

Issue 22623002: Extract AutofillDialogController interface and common utilities. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
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_pref_names.h" 25 #include "components/autofill/core/common/autofill_pref_names.h"
26 #include "content/public/browser/navigation_details.h" 26 #include "content/public/browser/navigation_details.h"
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
114 NOTIMPLEMENTED(); 114 NOTIMPLEMENTED();
115 #else 115 #else
116 HideAutocheckoutBubble(); 116 HideAutocheckoutBubble();
117 117
118 // Convert |bounding_box| to be in screen space. 118 // Convert |bounding_box| to be in screen space.
119 gfx::Rect container_rect; 119 gfx::Rect container_rect;
120 web_contents_->GetView()->GetContainerBounds(&container_rect); 120 web_contents_->GetView()->GetContainerBounds(&container_rect);
121 gfx::RectF anchor = bounding_box + container_rect.OffsetFromOrigin(); 121 gfx::RectF anchor = bounding_box + container_rect.OffsetFromOrigin();
122 122
123 autocheckout_bubble_ = 123 autocheckout_bubble_ =
124 AutocheckoutBubble::Create(scoped_ptr<AutocheckoutBubbleController>( 124 AutocheckoutBubble::Create(
125 new AutocheckoutBubbleController( 125 web_contents_,
126 anchor, 126 scoped_ptr<AutocheckoutBubbleController>(
127 web_contents_->GetView()->GetTopLevelNativeWindow(), 127 new AutocheckoutBubbleController(
128 is_google_user, 128 anchor,
129 callback))); 129 web_contents_->GetView()->GetTopLevelNativeWindow(),
130 is_google_user,
131 callback)));
130 autocheckout_bubble_->ShowBubble(); 132 autocheckout_bubble_->ShowBubble();
131 #endif // #if !defined(TOOLKIT_VIEWS) 133 #endif // #if !defined(TOOLKIT_VIEWS)
132 } 134 }
133 135
134 void TabAutofillManagerDelegate::HideAutocheckoutBubble() { 136 void TabAutofillManagerDelegate::HideAutocheckoutBubble() {
135 if (autocheckout_bubble_.get()) 137 if (autocheckout_bubble_.get())
136 autocheckout_bubble_->HideBubble(); 138 autocheckout_bubble_->HideBubble();
137 } 139 }
138 140
139 void TabAutofillManagerDelegate::ShowRequestAutocompleteDialog( 141 void TabAutofillManagerDelegate::ShowRequestAutocompleteDialog(
140 const FormData& form, 142 const FormData& form,
141 const GURL& source_url, 143 const GURL& source_url,
142 DialogType dialog_type, 144 DialogType dialog_type,
143 const base::Callback<void(const FormStructure*, 145 const base::Callback<void(const FormStructure*,
144 const std::string&)>& callback) { 146 const std::string&)>& callback) {
145 #if defined(ENABLE_AUTOFILL_DIALOG)
146 HideRequestAutocompleteDialog(); 147 HideRequestAutocompleteDialog();
147 148
148 dialog_controller_ = AutofillDialogControllerImpl::Create(web_contents_, 149 dialog_controller_ = AutofillDialogController::Create(web_contents_,
149 form, 150 form,
aruslan 2013/08/07 21:07:00 Indent.
aruslan 2013/08/07 21:21:23 Done.
150 source_url, 151 source_url,
151 dialog_type, 152 dialog_type,
152 callback); 153 callback);
153 dialog_controller_->Show(); 154 if (dialog_controller_) {
154 #else 155 dialog_controller_->Show();
155 callback.Run(NULL, std::string()); 156 } else {
156 NOTIMPLEMENTED(); 157 callback.Run(NULL, std::string());
157 #endif // #if !defined(ENABLE_AUTOFILL_DIALOG) 158 NOTIMPLEMENTED();
159 }
158 } 160 }
159 161
160 void TabAutofillManagerDelegate::ShowAutofillPopup( 162 void TabAutofillManagerDelegate::ShowAutofillPopup(
161 const gfx::RectF& element_bounds, 163 const gfx::RectF& element_bounds,
162 base::i18n::TextDirection text_direction, 164 base::i18n::TextDirection text_direction,
163 const std::vector<string16>& values, 165 const std::vector<string16>& values,
164 const std::vector<string16>& labels, 166 const std::vector<string16>& labels,
165 const std::vector<string16>& icons, 167 const std::vector<string16>& icons,
166 const std::vector<int>& identifiers, 168 const std::vector<int>& identifiers,
167 base::WeakPtr<AutofillPopupDelegate> delegate) { 169 base::WeakPtr<AutofillPopupDelegate> delegate) {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
224 if (!dialog_controller_.get()) 226 if (!dialog_controller_.get())
225 return; 227 return;
226 228
227 // A redirect immediately after a successful Autocheckout flow shouldn't hide 229 // A redirect immediately after a successful Autocheckout flow shouldn't hide
228 // the dialog. 230 // the dialog.
229 bool preserve_dialog = AutofillDriverImpl::FromWebContents(web_contents())-> 231 bool preserve_dialog = AutofillDriverImpl::FromWebContents(web_contents())->
230 autofill_manager()->autocheckout_manager()->should_preserve_dialog(); 232 autofill_manager()->autocheckout_manager()->should_preserve_dialog();
231 bool was_redirect = details.entry && 233 bool was_redirect = details.entry &&
232 content::PageTransitionIsRedirect(details.entry->GetTransitionType()); 234 content::PageTransitionIsRedirect(details.entry->GetTransitionType());
233 235
234 if (dialog_controller_->dialog_type() == DIALOG_TYPE_REQUEST_AUTOCOMPLETE || 236 if (dialog_controller_->GetDialogType() == DIALOG_TYPE_REQUEST_AUTOCOMPLETE ||
235 (!was_redirect && !preserve_dialog)) { 237 (!was_redirect && !preserve_dialog)) {
236 HideRequestAutocompleteDialog(); 238 HideRequestAutocompleteDialog();
237 } 239 }
238 } 240 }
239 241
240 void TabAutofillManagerDelegate::WebContentsDestroyed( 242 void TabAutofillManagerDelegate::WebContentsDestroyed(
241 content::WebContents* web_contents) { 243 content::WebContents* web_contents) {
242 HideAutofillPopup(); 244 HideAutofillPopup();
243 } 245 }
244 246
245 } // namespace autofill 247 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698