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/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/personal_data_manager_factory.h" | 9 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
10 #include "chrome/browser/infobars/infobar_service.h" | 10 #include "chrome/browser/infobars/infobar_service.h" |
11 #include "chrome/browser/password_manager/chrome_password_manager_client.h" | 11 #include "chrome/browser/password_manager/chrome_password_manager_client.h" |
12 #include "chrome/browser/profiles/profile.h" | 12 #include "chrome/browser/profiles/profile.h" |
| 13 #include "chrome/browser/signin/profile_identity_provider.h" |
| 14 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 15 #include "chrome/browser/signin/signin_manager_factory.h" |
13 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h" | 16 #include "chrome/browser/ui/autofill/autofill_dialog_controller.h" |
14 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" | 17 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" |
15 #include "chrome/browser/ui/autofill/card_unmask_prompt_view.h" | 18 #include "chrome/browser/ui/autofill/card_unmask_prompt_view.h" |
16 #include "chrome/browser/ui/autofill/credit_card_scanner_controller.h" | 19 #include "chrome/browser/ui/autofill/credit_card_scanner_controller.h" |
17 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
18 #include "chrome/browser/ui/browser_finder.h" | 21 #include "chrome/browser/ui/browser_finder.h" |
19 #include "chrome/browser/ui/browser_window.h" | 22 #include "chrome/browser/ui/browser_window.h" |
20 #include "chrome/browser/ui/chrome_pages.h" | 23 #include "chrome/browser/ui/chrome_pages.h" |
21 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" | 24 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" |
22 #include "chrome/browser/webdata/web_data_service_factory.h" | 25 #include "chrome/browser/webdata/web_data_service_factory.h" |
23 #include "chrome/common/url_constants.h" | 26 #include "chrome/common/url_constants.h" |
24 #include "components/autofill/content/browser/content_autofill_driver.h" | 27 #include "components/autofill/content/browser/content_autofill_driver.h" |
25 #include "components/autofill/content/common/autofill_messages.h" | 28 #include "components/autofill/content/common/autofill_messages.h" |
26 #include "components/autofill/core/browser/autofill_cc_infobar_delegate.h" | 29 #include "components/autofill/core/browser/autofill_cc_infobar_delegate.h" |
27 #include "components/autofill/core/common/autofill_pref_names.h" | 30 #include "components/autofill/core/common/autofill_pref_names.h" |
28 #include "components/password_manager/content/browser/content_password_manager_d
river.h" | 31 #include "components/password_manager/content/browser/content_password_manager_d
river.h" |
29 #include "content/public/browser/render_frame_host.h" | 32 #include "content/public/browser/render_frame_host.h" |
30 #include "ui/gfx/geometry/rect.h" | 33 #include "ui/gfx/geometry/rect.h" |
31 | 34 |
32 #if defined(OS_ANDROID) | 35 #if defined(OS_ANDROID) |
33 #include "chrome/browser/android/chromium_application.h" | 36 #include "chrome/browser/android/chromium_application.h" |
34 #include "chrome/browser/ui/android/autofill/autofill_logger_android.h" | 37 #include "chrome/browser/ui/android/autofill/autofill_logger_android.h" |
35 #else | 38 #else |
| 39 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
36 #include "components/ui/zoom/zoom_controller.h" | 40 #include "components/ui/zoom/zoom_controller.h" |
37 #endif | 41 #endif |
38 | 42 |
39 DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::ChromeAutofillClient); | 43 DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::ChromeAutofillClient); |
40 | 44 |
41 namespace autofill { | 45 namespace autofill { |
42 | 46 |
43 ChromeAutofillClient::ChromeAutofillClient(content::WebContents* web_contents) | 47 ChromeAutofillClient::ChromeAutofillClient(content::WebContents* web_contents) |
44 : content::WebContentsObserver(web_contents), | 48 : content::WebContentsObserver(web_contents), |
45 unmask_controller_(web_contents), | 49 unmask_controller_(web_contents), |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
92 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); | 96 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
93 return WebDataServiceFactory::GetAutofillWebDataForProfile( | 97 return WebDataServiceFactory::GetAutofillWebDataForProfile( |
94 profile, ServiceAccessType::EXPLICIT_ACCESS); | 98 profile, ServiceAccessType::EXPLICIT_ACCESS); |
95 } | 99 } |
96 | 100 |
97 PrefService* ChromeAutofillClient::GetPrefs() { | 101 PrefService* ChromeAutofillClient::GetPrefs() { |
98 return Profile::FromBrowserContext(web_contents()->GetBrowserContext()) | 102 return Profile::FromBrowserContext(web_contents()->GetBrowserContext()) |
99 ->GetPrefs(); | 103 ->GetPrefs(); |
100 } | 104 } |
101 | 105 |
| 106 IdentityProvider* ChromeAutofillClient::GetIdentityProvider() { |
| 107 if (!identity_provider_) { |
| 108 Profile* profile = |
| 109 Profile::FromBrowserContext(web_contents()->GetBrowserContext()); |
| 110 LoginUIService* login_service = nullptr; |
| 111 #if !defined(OS_ANDROID) |
| 112 login_service = LoginUIServiceFactory::GetForProfile(profile); |
| 113 #endif |
| 114 identity_provider_.reset(new ProfileIdentityProvider( |
| 115 SigninManagerFactory::GetForProfile(profile), |
| 116 ProfileOAuth2TokenServiceFactory::GetForProfile(profile), |
| 117 login_service)); |
| 118 } |
| 119 |
| 120 return identity_provider_.get(); |
| 121 } |
| 122 |
102 void ChromeAutofillClient::ShowAutofillSettings() { | 123 void ChromeAutofillClient::ShowAutofillSettings() { |
103 #if defined(OS_ANDROID) | 124 #if defined(OS_ANDROID) |
104 chrome::android::ChromiumApplication::ShowAutofillSettings(); | 125 chrome::android::ChromiumApplication::ShowAutofillSettings(); |
105 #else | 126 #else |
106 Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); | 127 Browser* browser = chrome::FindBrowserWithWebContents(web_contents()); |
107 if (browser) | 128 if (browser) |
108 chrome::ShowSettingsSubPage(browser, chrome::kAutofillSubPage); | 129 chrome::ShowSettingsSubPage(browser, chrome::kAutofillSubPage); |
109 #endif // #if defined(OS_ANDROID) | 130 #endif // #if defined(OS_ANDROID) |
110 } | 131 } |
111 | 132 |
(...skipping 144 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
256 new AutofillMsg_FirstUserGestureObservedInTab(routing_id())); | 277 new AutofillMsg_FirstUserGestureObservedInTab(routing_id())); |
257 } | 278 } |
258 | 279 |
259 void ChromeAutofillClient::LinkClicked(const GURL& url, | 280 void ChromeAutofillClient::LinkClicked(const GURL& url, |
260 WindowOpenDisposition disposition) { | 281 WindowOpenDisposition disposition) { |
261 web_contents()->OpenURL(content::OpenURLParams( | 282 web_contents()->OpenURL(content::OpenURLParams( |
262 url, content::Referrer(), disposition, ui::PAGE_TRANSITION_LINK, false)); | 283 url, content::Referrer(), disposition, ui::PAGE_TRANSITION_LINK, false)); |
263 } | 284 } |
264 | 285 |
265 } // namespace autofill | 286 } // namespace autofill |
OLD | NEW |