OLD | NEW |
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 20 matching lines...) Expand all Loading... |
31 #include "components/autofill/core/browser/autofill_cc_infobar_delegate.h" | 31 #include "components/autofill/core/browser/autofill_cc_infobar_delegate.h" |
32 #include "components/autofill/core/browser/ui/card_unmask_prompt_view.h" | 32 #include "components/autofill/core/browser/ui/card_unmask_prompt_view.h" |
33 #include "components/autofill/core/common/autofill_pref_names.h" | 33 #include "components/autofill/core/common/autofill_pref_names.h" |
34 #include "components/password_manager/content/browser/content_password_manager_d
river.h" | 34 #include "components/password_manager/content/browser/content_password_manager_d
river.h" |
35 #include "components/signin/core/browser/profile_identity_provider.h" | 35 #include "components/signin/core/browser/profile_identity_provider.h" |
36 #include "components/user_prefs/user_prefs.h" | 36 #include "components/user_prefs/user_prefs.h" |
37 #include "content/public/browser/navigation_entry.h" | 37 #include "content/public/browser/navigation_entry.h" |
38 #include "content/public/browser/render_frame_host.h" | 38 #include "content/public/browser/render_frame_host.h" |
39 #include "ui/gfx/geometry/rect.h" | 39 #include "ui/gfx/geometry/rect.h" |
40 | 40 |
41 #if defined(OS_ANDROID) | 41 #if defined(OS_ANDROID) && !defined(USE_AURA) |
42 #include "chrome/browser/android/chrome_application.h" | 42 #include "chrome/browser/android/chrome_application.h" |
43 #include "chrome/browser/ui/android/autofill/autofill_logger_android.h" | 43 #include "chrome/browser/ui/android/autofill/autofill_logger_android.h" |
44 #else | 44 #else |
45 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 45 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
46 #include "components/ui/zoom/zoom_controller.h" | 46 #include "components/ui/zoom/zoom_controller.h" |
47 #endif | 47 #endif |
48 | 48 |
49 DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::ChromeAutofillClient); | 49 DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::ChromeAutofillClient); |
50 | 50 |
51 namespace autofill { | 51 namespace autofill { |
52 | 52 |
53 ChromeAutofillClient::ChromeAutofillClient(content::WebContents* web_contents) | 53 ChromeAutofillClient::ChromeAutofillClient(content::WebContents* web_contents) |
54 : content::WebContentsObserver(web_contents), | 54 : content::WebContentsObserver(web_contents), |
55 unmask_controller_( | 55 unmask_controller_( |
56 base::Bind(&LoadRiskData, 0, web_contents), | 56 base::Bind(&LoadRiskData, 0, web_contents), |
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(OS_ANDROID) || defined(USE_AURA) |
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 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 return Profile::FromBrowserContext(web_contents()->GetBrowserContext()) | 112 return Profile::FromBrowserContext(web_contents()->GetBrowserContext()) |
113 ->GetPrefs(); | 113 ->GetPrefs(); |
114 } | 114 } |
115 | 115 |
116 IdentityProvider* ChromeAutofillClient::GetIdentityProvider() { | 116 IdentityProvider* ChromeAutofillClient::GetIdentityProvider() { |
117 if (!identity_provider_) { | 117 if (!identity_provider_) { |
118 Profile* profile = | 118 Profile* profile = |
119 Profile::FromBrowserContext(web_contents()->GetBrowserContext()) | 119 Profile::FromBrowserContext(web_contents()->GetBrowserContext()) |
120 ->GetOriginalProfile(); | 120 ->GetOriginalProfile(); |
121 base::Closure login_callback; | 121 base::Closure login_callback; |
122 #if !defined(OS_ANDROID) | 122 #if !defined(OS_ANDROID) || defined(USE_AURA) |
123 login_callback = | 123 login_callback = |
124 LoginUIServiceFactory::GetShowLoginPopupCallbackForProfile(profile); | 124 LoginUIServiceFactory::GetShowLoginPopupCallbackForProfile(profile); |
125 #endif | 125 #endif |
126 identity_provider_.reset(new ProfileIdentityProvider( | 126 identity_provider_.reset(new ProfileIdentityProvider( |
127 SigninManagerFactory::GetForProfile(profile), | 127 SigninManagerFactory::GetForProfile(profile), |
128 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), | 128 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), |
129 login_callback)); | 129 login_callback)); |
130 } | 130 } |
131 | 131 |
132 return identity_provider_.get(); | 132 return identity_provider_.get(); |
133 } | 133 } |
134 | 134 |
135 rappor::RapporService* ChromeAutofillClient::GetRapporService() { | 135 rappor::RapporService* ChromeAutofillClient::GetRapporService() { |
136 return g_browser_process->rappor_service(); | 136 return g_browser_process->rappor_service(); |
137 } | 137 } |
138 | 138 |
139 void ChromeAutofillClient::ShowAutofillSettings() { | 139 void ChromeAutofillClient::ShowAutofillSettings() { |
140 #if defined(OS_ANDROID) | 140 #if defined(OS_ANDROID) && !defined(USE_AURA) |
141 chrome::android::ChromeApplication::ShowAutofillSettings(); | 141 chrome::android::ChromeApplication::ShowAutofillSettings(); |
142 #else | 142 #else |
143 Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); | 143 Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); |
144 if (browser) | 144 if (browser) |
145 chrome::ShowSettingsSubPage(browser, chrome::kAutofillSubPage); | 145 chrome::ShowSettingsSubPage(browser, chrome::kAutofillSubPage); |
146 #endif // #if defined(OS_ANDROID) | 146 #endif // #if defined(OS_ANDROID) && !defined(USE_AURA) |
147 } | 147 } |
148 | 148 |
149 void ChromeAutofillClient::ShowUnmaskPrompt( | 149 void ChromeAutofillClient::ShowUnmaskPrompt( |
150 const CreditCard& card, | 150 const CreditCard& card, |
151 base::WeakPtr<CardUnmaskDelegate> delegate) { | 151 base::WeakPtr<CardUnmaskDelegate> delegate) { |
152 unmask_controller_.ShowPrompt( | 152 unmask_controller_.ShowPrompt( |
153 CreateCardUnmaskPromptView(&unmask_controller_, web_contents()), | 153 CreateCardUnmaskPromptView(&unmask_controller_, web_contents()), |
154 card, delegate); | 154 card, delegate); |
155 } | 155 } |
156 | 156 |
(...skipping 128 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
285 rfh); | 285 rfh); |
286 if (driver) { | 286 if (driver) { |
287 driver->GetPasswordGenerationManager()->DetectAccountCreationForms(forms); | 287 driver->GetPasswordGenerationManager()->DetectAccountCreationForms(forms); |
288 driver->GetPasswordManager()->ProcessAutofillPredictions(driver, forms); | 288 driver->GetPasswordManager()->ProcessAutofillPredictions(driver, forms); |
289 } | 289 } |
290 } | 290 } |
291 | 291 |
292 void ChromeAutofillClient::DidFillOrPreviewField( | 292 void ChromeAutofillClient::DidFillOrPreviewField( |
293 const base::string16& autofilled_value, | 293 const base::string16& autofilled_value, |
294 const base::string16& profile_full_name) { | 294 const base::string16& profile_full_name) { |
295 #if defined(OS_ANDROID) | 295 #if defined(OS_ANDROID) && !defined(USE_AURA) |
296 AutofillLoggerAndroid::DidFillOrPreviewField(autofilled_value, | 296 AutofillLoggerAndroid::DidFillOrPreviewField(autofilled_value, |
297 profile_full_name); | 297 profile_full_name); |
298 #endif // defined(OS_ANDROID) | 298 #endif // defined(OS_ANDROID) && !defined(USE_AURA) |
299 } | 299 } |
300 | 300 |
301 void ChromeAutofillClient::OnFirstUserGestureObserved() { | 301 void ChromeAutofillClient::OnFirstUserGestureObserved() { |
302 web_contents()->SendToAllFrames( | 302 web_contents()->SendToAllFrames( |
303 new AutofillMsg_FirstUserGestureObservedInTab(routing_id())); | 303 new AutofillMsg_FirstUserGestureObservedInTab(routing_id())); |
304 } | 304 } |
305 | 305 |
306 void ChromeAutofillClient::LinkClicked(const GURL& url, | 306 void ChromeAutofillClient::LinkClicked(const GURL& url, |
307 WindowOpenDisposition disposition) { | 307 WindowOpenDisposition disposition) { |
308 web_contents()->OpenURL(content::OpenURLParams( | 308 web_contents()->OpenURL(content::OpenURLParams( |
309 url, content::Referrer(), disposition, ui::PAGE_TRANSITION_LINK, false)); | 309 url, content::Referrer(), disposition, ui::PAGE_TRANSITION_LINK, false)); |
310 } | 310 } |
311 | 311 |
312 bool ChromeAutofillClient::IsContextSecure(const GURL& form_origin) { | 312 bool ChromeAutofillClient::IsContextSecure(const GURL& form_origin) { |
313 content::SSLStatus ssl_status; | 313 content::SSLStatus ssl_status; |
314 content::NavigationEntry* navigation_entry = | 314 content::NavigationEntry* navigation_entry = |
315 web_contents()->GetController().GetLastCommittedEntry(); | 315 web_contents()->GetController().GetLastCommittedEntry(); |
316 if (!navigation_entry) | 316 if (!navigation_entry) |
317 return false; | 317 return false; |
318 | 318 |
319 ssl_status = navigation_entry->GetSSL(); | 319 ssl_status = navigation_entry->GetSSL(); |
320 // Note: If changing the implementation below, also change | 320 // Note: If changing the implementation below, also change |
321 // AwAutofillClient::IsContextSecure. See crbug.com/505388 | 321 // AwAutofillClient::IsContextSecure. See crbug.com/505388 |
322 return ssl_status.security_style == | 322 return ssl_status.security_style == |
323 content::SECURITY_STYLE_AUTHENTICATED && | 323 content::SECURITY_STYLE_AUTHENTICATED && |
324 ssl_status.content_status == content::SSLStatus::NORMAL_CONTENT; | 324 ssl_status.content_status == content::SSLStatus::NORMAL_CONTENT; |
325 } | 325 } |
326 | 326 |
327 } // namespace autofill | 327 } // namespace autofill |
OLD | NEW |