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

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: Try to fix AutofillTest.DisableAutocompleteWhileFilling Created 7 years, 9 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 dialog_controller_(NULL) {
35 DCHECK(web_contents); 36 DCHECK(web_contents);
36 } 37 }
37 38
39 TabAutofillManagerDelegate::~TabAutofillManagerDelegate() {
40 HideAutofillPopup();
41 }
42
38 InfoBarService* TabAutofillManagerDelegate::GetInfoBarService() { 43 InfoBarService* TabAutofillManagerDelegate::GetInfoBarService() {
39 return InfoBarService::FromWebContents(web_contents_); 44 return InfoBarService::FromWebContents(web_contents_);
40 } 45 }
41 46
42 PersonalDataManager* TabAutofillManagerDelegate::GetPersonalDataManager() { 47 PersonalDataManager* TabAutofillManagerDelegate::GetPersonalDataManager() {
43 Profile* profile = 48 Profile* profile =
44 Profile::FromBrowserContext(web_contents_->GetBrowserContext()); 49 Profile::FromBrowserContext(web_contents_->GetBrowserContext());
45 return PersonalDataManagerFactory::GetForProfile( 50 return PersonalDataManagerFactory::GetForProfile(
46 profile->GetOriginalProfile()); 51 profile->GetOriginalProfile());
47 } 52 }
48 53
49 PrefService* TabAutofillManagerDelegate::GetPrefs() { 54 PrefService* TabAutofillManagerDelegate::GetPrefs() {
50 return Profile::FromBrowserContext(web_contents_->GetBrowserContext())-> 55 return Profile::FromBrowserContext(web_contents_->GetBrowserContext())->
51 GetPrefs(); 56 GetPrefs();
52 } 57 }
53 58
54 ProfileSyncServiceBase* TabAutofillManagerDelegate::GetProfileSyncService() { 59 ProfileSyncServiceBase* TabAutofillManagerDelegate::GetProfileSyncService() {
55 return ProfileSyncServiceFactory::GetForProfile( 60 return ProfileSyncServiceFactory::GetForProfile(
56 Profile::FromBrowserContext(web_contents_->GetBrowserContext())); 61 Profile::FromBrowserContext(web_contents_->GetBrowserContext()));
57 } 62 }
58 63
59 bool TabAutofillManagerDelegate::IsSavingPasswordsEnabled() const { 64 bool TabAutofillManagerDelegate::IsSavingPasswordsEnabled() const {
60 return PasswordManager::FromWebContents(web_contents_)->IsSavingEnabled(); 65 return PasswordManager::FromWebContents(web_contents_)->IsSavingEnabled();
61 } 66 }
62 67
63 void TabAutofillManagerDelegate::OnAutocheckoutError() { 68 void TabAutofillManagerDelegate::OnAutocheckoutError() {
64 // TODO(ahutter): Notify |autofill_dialog_controller_| of the error once it 69 // TODO(ahutter): Notify |dialog_controller_| of the error once it stays open
65 // stays open for Autocheckout. 70 // for Autocheckout.
66 } 71 }
67 72
68 void TabAutofillManagerDelegate::ShowAutofillSettings() { 73 void TabAutofillManagerDelegate::ShowAutofillSettings() {
69 #if defined(OS_ANDROID) 74 #if defined(OS_ANDROID)
70 NOTIMPLEMENTED(); 75 NOTIMPLEMENTED();
71 #else 76 #else
72 Browser* browser = chrome::FindBrowserWithWebContents(web_contents_); 77 Browser* browser = chrome::FindBrowserWithWebContents(web_contents_);
73 if (browser) 78 if (browser)
74 chrome::ShowSettingsSubPage(browser, chrome::kAutofillSubPage); 79 chrome::ShowSettingsSubPage(browser, chrome::kAutofillSubPage);
75 #endif // #if defined(OS_ANDROID) 80 #endif // #if defined(OS_ANDROID)
(...skipping 20 matching lines...) Expand all
96 101
97 void TabAutofillManagerDelegate::ShowRequestAutocompleteDialog( 102 void TabAutofillManagerDelegate::ShowRequestAutocompleteDialog(
98 const FormData& form, 103 const FormData& form,
99 const GURL& source_url, 104 const GURL& source_url,
100 const content::SSLStatus& ssl_status, 105 const content::SSLStatus& ssl_status,
101 const AutofillMetrics& metric_logger, 106 const AutofillMetrics& metric_logger,
102 DialogType dialog_type, 107 DialogType dialog_type,
103 const base::Callback<void(const FormStructure*)>& callback) { 108 const base::Callback<void(const FormStructure*)>& callback) {
104 HideRequestAutocompleteDialog(); 109 HideRequestAutocompleteDialog();
105 110
106 autofill_dialog_controller_ = 111 dialog_controller_ =
107 new autofill::AutofillDialogControllerImpl(web_contents_, 112 new autofill::AutofillDialogControllerImpl(web_contents_,
108 form, 113 form,
109 source_url, 114 source_url,
110 ssl_status, 115 ssl_status,
111 metric_logger, 116 metric_logger,
112 dialog_type, 117 dialog_type,
113 callback); 118 callback);
114 autofill_dialog_controller_->Show(); 119 dialog_controller_->Show();
115 } 120 }
116 121
117 void TabAutofillManagerDelegate::RequestAutocompleteDialogClosed() { 122 void TabAutofillManagerDelegate::RequestAutocompleteDialogClosed() {
118 autofill_dialog_controller_ = NULL; 123 dialog_controller_ = NULL;
124 }
125
126 void TabAutofillManagerDelegate::ShowAutofillPopup(
127 const gfx::RectF& element_bounds,
128 const std::vector<string16>& values,
129 const std::vector<string16>& labels,
130 const std::vector<string16>& icons,
131 const std::vector<int>& identifiers,
132 AutofillPopupDelegate* delegate) {
133 // Convert element_bounds to be in screen space.
134 gfx::Rect client_area;
135 web_contents_->GetView()->GetContainerBounds(&client_area);
136 gfx::RectF element_bounds_in_screen_space =
137 element_bounds + client_area.OffsetFromOrigin();
138
139 // Will delete or reuse the old |popup_controller_|.
140 popup_controller_ = AutofillPopupControllerImpl::GetOrCreate(
141 popup_controller_,
142 delegate,
143 web_contents()->GetView()->GetContentNativeView(),
144 element_bounds_in_screen_space);
145
146 popup_controller_->Show(values, labels, icons, identifiers);
147 }
148
149 void TabAutofillManagerDelegate::HideAutofillPopup() {
150 if (popup_controller_)
151 popup_controller_->Hide();
119 } 152 }
120 153
121 void TabAutofillManagerDelegate::UpdateProgressBar(double value) { 154 void TabAutofillManagerDelegate::UpdateProgressBar(double value) {
122 // TODO(ahutter): Notify |autofill_dialog_controller_| of the change once it 155 // TODO(ahutter): Notify |dialog_controller_| of the change once it stays open
123 // stays open for Autocheckout. 156 // for Autocheckout.
124 } 157 }
125 158
126 void TabAutofillManagerDelegate::HideRequestAutocompleteDialog() { 159 void TabAutofillManagerDelegate::HideRequestAutocompleteDialog() {
127 if (autofill_dialog_controller_) { 160 if (dialog_controller_) {
128 autofill_dialog_controller_->Hide(); 161 dialog_controller_->Hide();
129 RequestAutocompleteDialogClosed(); 162 RequestAutocompleteDialogClosed();
130 } 163 }
131 } 164 }
132 165
133 void TabAutofillManagerDelegate::DidNavigateMainFrame( 166 void TabAutofillManagerDelegate::DidNavigateMainFrame(
134 const content::LoadCommittedDetails& details, 167 const content::LoadCommittedDetails& details,
135 const content::FrameNavigateParams& params) { 168 const content::FrameNavigateParams& params) {
136 if (autofill_dialog_controller_ && 169 if (dialog_controller_ &&
137 autofill_dialog_controller_->dialog_type() == 170 dialog_controller_->dialog_type() ==
138 autofill::DIALOG_TYPE_REQUEST_AUTOCOMPLETE) { 171 autofill::DIALOG_TYPE_REQUEST_AUTOCOMPLETE) {
139 HideRequestAutocompleteDialog(); 172 HideRequestAutocompleteDialog();
140 } 173 }
141 } 174 }
142 175
143 } // namespace autofill 176 } // namespace autofill
OLDNEW
« no previous file with comments | « chrome/browser/ui/autofill/tab_autofill_manager_delegate.h ('k') | chrome/chrome_tests_unit.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698