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

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

Issue 12340065: Move the UI related code from AutofillExternalDelegate to AutofillManagerDelegate (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 7 years, 10 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/api/infobars/infobar_service.h" 9 #include "chrome/browser/api/infobars/infobar_service.h"
10 #include "chrome/browser/autofill/password_generator.h" 10 #include "chrome/browser/autofill/password_generator.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/password_manager/password_manager.h" 12 #include "chrome/browser/password_manager/password_manager.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/sync/profile_sync_service.h" 14 #include "chrome/browser/sync/profile_sync_service.h"
15 #include "chrome/browser/sync/profile_sync_service_factory.h" 15 #include "chrome/browser/sync/profile_sync_service_factory.h"
16 #include "chrome/browser/ui/autofill/autocheckout_bubble.h" 16 #include "chrome/browser/ui/autofill/autocheckout_bubble.h"
17 #include "chrome/browser/ui/autofill/autofill_dialog_controller_impl.h" 17 #include "chrome/browser/ui/autofill/autofill_dialog_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 "content/public/browser/web_contents_view.h"
23 #include "content/public/common/password_form.h" 24 #include "content/public/common/password_form.h"
24 #include "ui/gfx/rect.h" 25 #include "ui/gfx/rect.h"
25 26
26 DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::TabAutofillManagerDelegate); 27 DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::TabAutofillManagerDelegate);
27 28
28 namespace autofill { 29 namespace autofill {
29 30
30 TabAutofillManagerDelegate::TabAutofillManagerDelegate( 31 TabAutofillManagerDelegate::TabAutofillManagerDelegate(
31 content::WebContents* web_contents) 32 content::WebContents* web_contents)
32 : content::WebContentsObserver(web_contents), 33 : content::WebContentsObserver(web_contents),
33 web_contents_(web_contents), 34 web_contents_(web_contents),
34 autofill_dialog_controller_(NULL) { 35 autofill_dialog_controller_(NULL) {
35 DCHECK(web_contents); 36 DCHECK(web_contents);
36 } 37 }
37 38
39 TabAutofillManagerDelegate::~TabAutofillManagerDelegate() {
40 if (autofill_popup_controller_)
41 autofill_popup_controller_->Hide();
Ilya Sherman 2013/02/26 02:12:15 Optional nit: Might be slightly cleaner to call Hi
kaiwang 2013/02/26 05:24:12 Done.
42 }
43
38 InfoBarService* TabAutofillManagerDelegate::GetInfoBarService() { 44 InfoBarService* TabAutofillManagerDelegate::GetInfoBarService() {
39 return InfoBarService::FromWebContents(web_contents_); 45 return InfoBarService::FromWebContents(web_contents_);
40 } 46 }
41 47
42 PersonalDataManager* TabAutofillManagerDelegate::GetPersonalDataManager() { 48 PersonalDataManager* TabAutofillManagerDelegate::GetPersonalDataManager() {
43 Profile* profile = 49 Profile* profile =
44 Profile::FromBrowserContext(web_contents_->GetBrowserContext()); 50 Profile::FromBrowserContext(web_contents_->GetBrowserContext());
45 return PersonalDataManagerFactory::GetForProfile( 51 return PersonalDataManagerFactory::GetForProfile(
46 profile->GetOriginalProfile()); 52 profile->GetOriginalProfile());
47 } 53 }
(...skipping 63 matching lines...) Expand 10 before | Expand all | Expand 10 after
111 metric_logger, 117 metric_logger,
112 dialog_type, 118 dialog_type,
113 callback); 119 callback);
114 autofill_dialog_controller_->Show(); 120 autofill_dialog_controller_->Show();
115 } 121 }
116 122
117 void TabAutofillManagerDelegate::RequestAutocompleteDialogClosed() { 123 void TabAutofillManagerDelegate::RequestAutocompleteDialogClosed() {
118 autofill_dialog_controller_ = NULL; 124 autofill_dialog_controller_ = NULL;
119 } 125 }
120 126
127 void TabAutofillManagerDelegate::ShowAutofillPopup(
128 const gfx::RectF& element_bounds,
129 const std::vector<string16>& values,
130 const std::vector<string16>& labels,
131 const std::vector<string16>& icons,
132 const std::vector<int>& identifiers,
133 AutofillPopupDelegate* delegate) {
134 // Convert element_bounds to be in screen space.
135 gfx::Rect client_area;
136 web_contents_->GetContainerBounds(&client_area);
137 gfx::RectF element_bounds_in_screen_space =
138 element_bounds + client_area.OffsetFromOrigin();
139
140 // Will delete or reuse the old |autofill_popup_controller_|.
141 autofill_popup_controller_ = AutofillPopupControllerImpl::GetOrCreate(
142 autofill_popup_controller_,
143 delegate,
144 web_contents()->GetView()->GetContentNativeView(),
145 element_bounds_in_screen_space);
146
147 autofill_popup_controller_->Show(values, labels, icons, identifiers);
148 }
149
150 void TabAutofillManagerDelegate::HideAutofillPopup() {
151 if (autofill_popup_controller_)
152 autofill_popup_controller_->Hide();
153 }
154
121 void TabAutofillManagerDelegate::UpdateProgressBar(double value) { 155 void TabAutofillManagerDelegate::UpdateProgressBar(double value) {
122 // TODO(ahutter): Notify |autofill_dialog_controller_| of the change once it 156 // TODO(ahutter): Notify |autofill_dialog_controller_| of the change once it
123 // stays open for Autocheckout. 157 // stays open for Autocheckout.
124 } 158 }
125 159
126 void TabAutofillManagerDelegate::HideRequestAutocompleteDialog() { 160 void TabAutofillManagerDelegate::HideRequestAutocompleteDialog() {
127 if (autofill_dialog_controller_) { 161 if (autofill_dialog_controller_) {
128 autofill_dialog_controller_->Hide(); 162 autofill_dialog_controller_->Hide();
129 RequestAutocompleteDialogClosed(); 163 RequestAutocompleteDialogClosed();
130 } 164 }
131 } 165 }
132 166
133 void TabAutofillManagerDelegate::DidNavigateMainFrame( 167 void TabAutofillManagerDelegate::DidNavigateMainFrame(
134 const content::LoadCommittedDetails& details, 168 const content::LoadCommittedDetails& details,
135 const content::FrameNavigateParams& params) { 169 const content::FrameNavigateParams& params) {
136 if (autofill_dialog_controller_ && 170 if (autofill_dialog_controller_ &&
137 autofill_dialog_controller_->dialog_type() == 171 autofill_dialog_controller_->dialog_type() ==
138 autofill::DIALOG_TYPE_REQUEST_AUTOCOMPLETE) { 172 autofill::DIALOG_TYPE_REQUEST_AUTOCOMPLETE) {
139 HideRequestAutocompleteDialog(); 173 HideRequestAutocompleteDialog();
140 } 174 }
141 } 175 }
142 176
143 } // namespace autofill 177 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698