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

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

Issue 1459793002: Android: Allow compiling browser without Java UI (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 5 years 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
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/chrome_autofill_client.h" 5 #include "chrome/browser/ui/autofill/chrome_autofill_client.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/logging.h" 8 #include "base/logging.h"
9 #include "base/prefs/pref_service.h" 9 #include "base/prefs/pref_service.h"
10 #include "chrome/browser/autofill/personal_data_manager_factory.h" 10 #include "chrome/browser/autofill/personal_data_manager_factory.h"
(...skipping 21 matching lines...) Expand all
32 #include "components/autofill/core/browser/autofill_cc_infobar_delegate.h" 32 #include "components/autofill/core/browser/autofill_cc_infobar_delegate.h"
33 #include "components/autofill/core/browser/ui/card_unmask_prompt_view.h" 33 #include "components/autofill/core/browser/ui/card_unmask_prompt_view.h"
34 #include "components/autofill/core/common/autofill_pref_names.h" 34 #include "components/autofill/core/common/autofill_pref_names.h"
35 #include "components/password_manager/content/browser/content_password_manager_d river.h" 35 #include "components/password_manager/content/browser/content_password_manager_d river.h"
36 #include "components/signin/core/browser/profile_identity_provider.h" 36 #include "components/signin/core/browser/profile_identity_provider.h"
37 #include "components/user_prefs/user_prefs.h" 37 #include "components/user_prefs/user_prefs.h"
38 #include "content/public/browser/navigation_entry.h" 38 #include "content/public/browser/navigation_entry.h"
39 #include "content/public/browser/render_frame_host.h" 39 #include "content/public/browser/render_frame_host.h"
40 #include "ui/gfx/geometry/rect.h" 40 #include "ui/gfx/geometry/rect.h"
41 41
42 #if defined(OS_ANDROID) 42 #if defined(ANDROID_JAVA_UI)
43 #include "chrome/browser/android/chrome_application.h" 43 #include "chrome/browser/android/chrome_application.h"
44 #include "chrome/browser/ui/android/autofill/autofill_logger_android.h" 44 #include "chrome/browser/ui/android/autofill/autofill_logger_android.h"
45 #else 45 #else
46 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" 46 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h"
47 #include "components/ui/zoom/zoom_controller.h" 47 #include "components/ui/zoom/zoom_controller.h"
48 #endif 48 #endif
49 49
50 DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::ChromeAutofillClient); 50 DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::ChromeAutofillClient);
51 51
52 namespace autofill { 52 namespace autofill {
53 53
54 ChromeAutofillClient::ChromeAutofillClient(content::WebContents* web_contents) 54 ChromeAutofillClient::ChromeAutofillClient(content::WebContents* web_contents)
55 : content::WebContentsObserver(web_contents), 55 : content::WebContentsObserver(web_contents),
56 unmask_controller_( 56 unmask_controller_(
57 user_prefs::UserPrefs::Get(web_contents->GetBrowserContext()), 57 user_prefs::UserPrefs::Get(web_contents->GetBrowserContext()),
58 Profile::FromBrowserContext(web_contents->GetBrowserContext()) 58 Profile::FromBrowserContext(web_contents->GetBrowserContext())
59 ->IsOffTheRecord()), 59 ->IsOffTheRecord()),
60 last_rfh_to_rac_(nullptr) { 60 last_rfh_to_rac_(nullptr) {
61 DCHECK(web_contents); 61 DCHECK(web_contents);
62 62
63 #if !defined(OS_ANDROID) 63 #if !defined(ANDROID_JAVA_UI)
64 // Since ZoomController is also a WebContentsObserver, we need to be careful 64 // Since ZoomController is also a WebContentsObserver, we need to be careful
65 // about disconnecting from it since the relative order of destruction of 65 // about disconnecting from it since the relative order of destruction of
66 // WebContentsObservers is not guaranteed. ZoomController silently clears 66 // WebContentsObservers is not guaranteed. ZoomController silently clears
67 // its ZoomObserver list during WebContentsDestroyed() so there's no need 67 // its ZoomObserver list during WebContentsDestroyed() so there's no need
68 // to explicitly remove ourselves on destruction. 68 // to explicitly remove ourselves on destruction.
69 ui_zoom::ZoomController* zoom_controller = 69 ui_zoom::ZoomController* zoom_controller =
70 ui_zoom::ZoomController::FromWebContents(web_contents); 70 ui_zoom::ZoomController::FromWebContents(web_contents);
71 // There may not always be a ZoomController, e.g. in tests. 71 // There may not always be a ZoomController, e.g. in tests.
72 if (zoom_controller) 72 if (zoom_controller)
73 zoom_controller->AddObserver(this); 73 zoom_controller->AddObserver(this);
(...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after
105 return Profile::FromBrowserContext(web_contents()->GetBrowserContext()) 105 return Profile::FromBrowserContext(web_contents()->GetBrowserContext())
106 ->GetPrefs(); 106 ->GetPrefs();
107 } 107 }
108 108
109 IdentityProvider* ChromeAutofillClient::GetIdentityProvider() { 109 IdentityProvider* ChromeAutofillClient::GetIdentityProvider() {
110 if (!identity_provider_) { 110 if (!identity_provider_) {
111 Profile* profile = 111 Profile* profile =
112 Profile::FromBrowserContext(web_contents()->GetBrowserContext()) 112 Profile::FromBrowserContext(web_contents()->GetBrowserContext())
113 ->GetOriginalProfile(); 113 ->GetOriginalProfile();
114 base::Closure login_callback; 114 base::Closure login_callback;
115 #if !defined(OS_ANDROID) 115 #if !defined(ANDROID_JAVA_UI)
116 login_callback = 116 login_callback =
117 LoginUIServiceFactory::GetShowLoginPopupCallbackForProfile(profile); 117 LoginUIServiceFactory::GetShowLoginPopupCallbackForProfile(profile);
118 #endif 118 #endif
119 identity_provider_.reset(new ProfileIdentityProvider( 119 identity_provider_.reset(new ProfileIdentityProvider(
120 SigninManagerFactory::GetForProfile(profile), 120 SigninManagerFactory::GetForProfile(profile),
121 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), 121 ProfileOAuth2TokenServiceFactory::GetForProfile(profile),
122 login_callback)); 122 login_callback));
123 } 123 }
124 124
125 return identity_provider_.get(); 125 return identity_provider_.get();
126 } 126 }
127 127
128 rappor::RapporService* ChromeAutofillClient::GetRapporService() { 128 rappor::RapporService* ChromeAutofillClient::GetRapporService() {
129 return g_browser_process->rappor_service(); 129 return g_browser_process->rappor_service();
130 } 130 }
131 131
132 void ChromeAutofillClient::ShowAutofillSettings() { 132 void ChromeAutofillClient::ShowAutofillSettings() {
133 #if defined(OS_ANDROID) 133 #if defined(ANDROID_JAVA_UI)
134 chrome::android::ChromeApplication::ShowAutofillSettings(); 134 chrome::android::ChromeApplication::ShowAutofillSettings();
135 #else 135 #else
136 Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); 136 Browser* browser = chrome::FindBrowserWithWebContents(web_contents());
137 if (browser) 137 if (browser)
138 chrome::ShowSettingsSubPage(browser, chrome::kAutofillSubPage); 138 chrome::ShowSettingsSubPage(browser, chrome::kAutofillSubPage);
139 #endif // #if defined(OS_ANDROID) 139 #endif // #if defined(ANDROID_JAVA_UI)
140 } 140 }
141 141
142 void ChromeAutofillClient::ShowUnmaskPrompt( 142 void ChromeAutofillClient::ShowUnmaskPrompt(
143 const CreditCard& card, 143 const CreditCard& card,
144 base::WeakPtr<CardUnmaskDelegate> delegate) { 144 base::WeakPtr<CardUnmaskDelegate> delegate) {
145 unmask_controller_.ShowPrompt( 145 unmask_controller_.ShowPrompt(
146 CreateCardUnmaskPromptView(&unmask_controller_, web_contents()), 146 CreateCardUnmaskPromptView(&unmask_controller_, web_contents()),
147 card, delegate); 147 card, delegate);
148 } 148 }
149 149
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
274 274
275 void ChromeAutofillClient::DidNavigateAnyFrame( 275 void ChromeAutofillClient::DidNavigateAnyFrame(
276 content::RenderFrameHost* render_frame_host, 276 content::RenderFrameHost* render_frame_host,
277 const content::LoadCommittedDetails& details, 277 const content::LoadCommittedDetails& details,
278 const content::FrameNavigateParams& params) { 278 const content::FrameNavigateParams& params) {
279 if (dialog_controller_ && render_frame_host == last_rfh_to_rac_) 279 if (dialog_controller_ && render_frame_host == last_rfh_to_rac_)
280 HideRequestAutocompleteDialog(); 280 HideRequestAutocompleteDialog();
281 } 281 }
282 282
283 void ChromeAutofillClient::MainFrameWasResized(bool width_changed) { 283 void ChromeAutofillClient::MainFrameWasResized(bool width_changed) {
284 #if defined(OS_ANDROID) 284 #if defined(ANDROID_JAVA_UI)
285 // Ignore virtual keyboard showing and hiding a strip of suggestions. 285 // Ignore virtual keyboard showing and hiding a strip of suggestions.
286 if (!width_changed) 286 if (!width_changed)
287 return; 287 return;
288 #endif 288 #endif
289 289
290 HideAutofillPopup(); 290 HideAutofillPopup();
291 } 291 }
292 292
293 void ChromeAutofillClient::WebContentsDestroyed() { 293 void ChromeAutofillClient::WebContentsDestroyed() {
294 HideAutofillPopup(); 294 HideAutofillPopup();
(...skipping 12 matching lines...) Expand all
307 rfh); 307 rfh);
308 if (driver) { 308 if (driver) {
309 driver->GetPasswordGenerationManager()->DetectAccountCreationForms(forms); 309 driver->GetPasswordGenerationManager()->DetectAccountCreationForms(forms);
310 driver->GetPasswordManager()->ProcessAutofillPredictions(driver, forms); 310 driver->GetPasswordManager()->ProcessAutofillPredictions(driver, forms);
311 } 311 }
312 } 312 }
313 313
314 void ChromeAutofillClient::DidFillOrPreviewField( 314 void ChromeAutofillClient::DidFillOrPreviewField(
315 const base::string16& autofilled_value, 315 const base::string16& autofilled_value,
316 const base::string16& profile_full_name) { 316 const base::string16& profile_full_name) {
317 #if defined(OS_ANDROID) 317 #if defined(ANDROID_JAVA_UI)
318 AutofillLoggerAndroid::DidFillOrPreviewField(autofilled_value, 318 AutofillLoggerAndroid::DidFillOrPreviewField(autofilled_value,
319 profile_full_name); 319 profile_full_name);
320 #endif // defined(OS_ANDROID) 320 #endif // defined(ANDROID_JAVA_UI)
321 } 321 }
322 322
323 void ChromeAutofillClient::OnFirstUserGestureObserved() { 323 void ChromeAutofillClient::OnFirstUserGestureObserved() {
324 web_contents()->SendToAllFrames( 324 web_contents()->SendToAllFrames(
325 new AutofillMsg_FirstUserGestureObservedInTab(routing_id())); 325 new AutofillMsg_FirstUserGestureObservedInTab(routing_id()));
326 } 326 }
327 327
328 bool ChromeAutofillClient::IsContextSecure(const GURL& form_origin) { 328 bool ChromeAutofillClient::IsContextSecure(const GURL& form_origin) {
329 content::SSLStatus ssl_status; 329 content::SSLStatus ssl_status;
330 content::NavigationEntry* navigation_entry = 330 content::NavigationEntry* navigation_entry =
331 web_contents()->GetController().GetLastCommittedEntry(); 331 web_contents()->GetController().GetLastCommittedEntry();
332 if (!navigation_entry) 332 if (!navigation_entry)
333 return false; 333 return false;
334 334
335 ssl_status = navigation_entry->GetSSL(); 335 ssl_status = navigation_entry->GetSSL();
336 // Note: If changing the implementation below, also change 336 // Note: If changing the implementation below, also change
337 // AwAutofillClient::IsContextSecure. See crbug.com/505388 337 // AwAutofillClient::IsContextSecure. See crbug.com/505388
338 return ssl_status.security_style == 338 return ssl_status.security_style ==
339 content::SECURITY_STYLE_AUTHENTICATED && 339 content::SECURITY_STYLE_AUTHENTICATED &&
340 ssl_status.content_status == content::SSLStatus::NORMAL_CONTENT; 340 ssl_status.content_status == content::SSLStatus::NORMAL_CONTENT;
341 } 341 }
342 342
343 } // namespace autofill 343 } // namespace autofill
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698