Chromium Code Reviews| 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 <utility> | 7 #include <utility> |
| 8 | 8 |
| 9 #include "base/bind.h" | 9 #include "base/bind.h" |
| 10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
| 11 #include "base/logging.h" | 11 #include "base/logging.h" |
| 12 #include "base/memory/ptr_util.h" | 12 #include "base/memory/ptr_util.h" |
| 13 #include "build/build_config.h" | 13 #include "build/build_config.h" |
| 14 #include "chrome/browser/autofill/personal_data_manager_factory.h" | 14 #include "chrome/browser/autofill/personal_data_manager_factory.h" |
| 15 #include "chrome/browser/autofill/risk_util.h" | 15 #include "chrome/browser/autofill/risk_util.h" |
| 16 #include "chrome/browser/browser_process.h" | 16 #include "chrome/browser/browser_process.h" |
| 17 #include "chrome/browser/password_manager/chrome_password_manager_client.h" | 17 #include "chrome/browser/password_manager/chrome_password_manager_client.h" |
| 18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
| 19 #include "chrome/browser/profiles/profile_manager.h" | 19 #include "chrome/browser/profiles/profile_manager.h" |
| 20 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" | 20 #include "chrome/browser/signin/profile_oauth2_token_service_factory.h" |
| 21 #include "chrome/browser/signin/signin_manager_factory.h" | 21 #include "chrome/browser/signin/signin_manager_factory.h" |
| 22 #include "chrome/browser/signin/signin_promo_util.h" | 22 #include "chrome/browser/signin/signin_promo_util.h" |
| 23 #include "chrome/browser/ssl/security_state_tab_helper.h" | |
| 23 #include "chrome/browser/sync/profile_sync_service_factory.h" | 24 #include "chrome/browser/sync/profile_sync_service_factory.h" |
| 24 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" | 25 #include "chrome/browser/ui/autofill/autofill_popup_controller_impl.h" |
| 25 #include "chrome/browser/ui/autofill/create_card_unmask_prompt_view.h" | 26 #include "chrome/browser/ui/autofill/create_card_unmask_prompt_view.h" |
| 26 #include "chrome/browser/ui/autofill/credit_card_scanner_controller.h" | 27 #include "chrome/browser/ui/autofill/credit_card_scanner_controller.h" |
| 27 #include "chrome/browser/ui/autofill/save_card_bubble_controller_impl.h" | 28 #include "chrome/browser/ui/autofill/save_card_bubble_controller_impl.h" |
| 29 #include "chrome/browser/ui/browser_commands.h" | |
| 28 #include "chrome/browser/ui/browser_finder.h" | 30 #include "chrome/browser/ui/browser_finder.h" |
| 29 #include "chrome/browser/ui/browser_window.h" | 31 #include "chrome/browser/ui/browser_window.h" |
| 30 #include "chrome/browser/ui/chrome_pages.h" | 32 #include "chrome/browser/ui/chrome_pages.h" |
| 31 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" | 33 #include "chrome/browser/ui/tabs/tab_strip_model_observer.h" |
| 32 #include "chrome/browser/web_data_service_factory.h" | 34 #include "chrome/browser/web_data_service_factory.h" |
| 33 #include "chrome/common/url_constants.h" | 35 #include "chrome/common/url_constants.h" |
| 34 #include "components/autofill/content/browser/content_autofill_driver.h" | 36 #include "components/autofill/content/browser/content_autofill_driver.h" |
| 35 #include "components/autofill/content/browser/content_autofill_driver_factory.h" | 37 #include "components/autofill/content/browser/content_autofill_driver_factory.h" |
| 36 #include "components/autofill/core/browser/ui/card_unmask_prompt_view.h" | 38 #include "components/autofill/core/browser/ui/card_unmask_prompt_view.h" |
| 37 #include "components/autofill/core/common/autofill_pref_names.h" | 39 #include "components/autofill/core/common/autofill_pref_names.h" |
| 38 #include "components/autofill/core/common/autofill_switches.h" | 40 #include "components/autofill/core/common/autofill_switches.h" |
| 39 #include "components/browser_sync/profile_sync_service.h" | 41 #include "components/browser_sync/profile_sync_service.h" |
| 40 #include "components/password_manager/content/browser/content_password_manager_d river.h" | 42 #include "components/password_manager/content/browser/content_password_manager_d river.h" |
| 41 #include "components/prefs/pref_service.h" | 43 #include "components/prefs/pref_service.h" |
| 44 #include "components/security_state/core/security_state.h" | |
|
elawrence
2017/01/25 15:50:48
Should/can the new #includes live inside the #else
estark
2017/01/25 16:50:01
Moved into the !OS_ANDROID block on line 54.
| |
| 42 #include "components/signin/core/browser/profile_identity_provider.h" | 45 #include "components/signin/core/browser/profile_identity_provider.h" |
| 43 #include "components/signin/core/browser/signin_header_helper.h" | 46 #include "components/signin/core/browser/signin_header_helper.h" |
| 44 #include "components/signin/core/browser/signin_metrics.h" | 47 #include "components/signin/core/browser/signin_metrics.h" |
| 45 #include "components/user_prefs/user_prefs.h" | 48 #include "components/user_prefs/user_prefs.h" |
| 46 #include "content/public/browser/navigation_entry.h" | 49 #include "content/public/browser/navigation_entry.h" |
| 47 #include "content/public/browser/render_frame_host.h" | 50 #include "content/public/browser/render_frame_host.h" |
| 48 #include "content/public/browser/ssl_status.h" | 51 #include "content/public/browser/ssl_status.h" |
| 49 #include "ui/gfx/geometry/rect.h" | 52 #include "ui/gfx/geometry/rect.h" |
| 50 | 53 |
| 51 #if defined(OS_ANDROID) | 54 #if defined(OS_ANDROID) |
| (...skipping 11 matching lines...) Expand all Loading... | |
| 63 #else // !OS_ANDROID | 66 #else // !OS_ANDROID |
| 64 #include "chrome/browser/ui/browser.h" | 67 #include "chrome/browser/ui/browser.h" |
| 65 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" | 68 #include "chrome/browser/ui/webui/signin/login_ui_service_factory.h" |
| 66 #include "components/zoom/zoom_controller.h" | 69 #include "components/zoom/zoom_controller.h" |
| 67 #endif | 70 #endif |
| 68 | 71 |
| 69 DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::ChromeAutofillClient); | 72 DEFINE_WEB_CONTENTS_USER_DATA_KEY(autofill::ChromeAutofillClient); |
| 70 | 73 |
| 71 namespace autofill { | 74 namespace autofill { |
| 72 | 75 |
| 73 namespace { | |
| 74 | |
| 75 const char kSecurityIndicatorHelpCenterUrl[] = | |
| 76 "https://support.google.com/chrome/answer/95617"; | |
| 77 | |
| 78 } // anonymous namespace | |
| 79 | |
| 80 ChromeAutofillClient::ChromeAutofillClient(content::WebContents* web_contents) | 76 ChromeAutofillClient::ChromeAutofillClient(content::WebContents* web_contents) |
| 81 : content::WebContentsObserver(web_contents), | 77 : content::WebContentsObserver(web_contents), |
| 82 unmask_controller_( | 78 unmask_controller_( |
| 83 user_prefs::UserPrefs::Get(web_contents->GetBrowserContext()), | 79 user_prefs::UserPrefs::Get(web_contents->GetBrowserContext()), |
| 84 Profile::FromBrowserContext(web_contents->GetBrowserContext()) | 80 Profile::FromBrowserContext(web_contents->GetBrowserContext()) |
| 85 ->IsOffTheRecord()) { | 81 ->IsOffTheRecord()) { |
| 86 DCHECK(web_contents); | 82 DCHECK(web_contents); |
| 87 | 83 |
| 88 #if !defined(OS_ANDROID) | 84 #if !defined(OS_ANDROID) |
| 89 // Since ZoomController is also a WebContentsObserver, we need to be careful | 85 // Since ZoomController is also a WebContentsObserver, we need to be careful |
| (...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 388 chrome::FindBrowserWithWebContents(web_contents()) | 384 chrome::FindBrowserWithWebContents(web_contents()) |
| 389 ->window() | 385 ->window() |
| 390 ->ShowAvatarBubbleFromAvatarButton( | 386 ->ShowAvatarBubbleFromAvatarButton( |
| 391 BrowserWindow::AVATAR_BUBBLE_MODE_SIGNIN, | 387 BrowserWindow::AVATAR_BUBBLE_MODE_SIGNIN, |
| 392 signin::ManageAccountsParams(), | 388 signin::ManageAccountsParams(), |
| 393 signin_metrics::AccessPoint::ACCESS_POINT_AUTOFILL_DROPDOWN); | 389 signin_metrics::AccessPoint::ACCESS_POINT_AUTOFILL_DROPDOWN); |
| 394 #endif | 390 #endif |
| 395 } | 391 } |
| 396 | 392 |
| 397 void ChromeAutofillClient::ShowHttpNotSecureExplanation() { | 393 void ChromeAutofillClient::ShowHttpNotSecureExplanation() { |
| 394 // On Android, open a Help Center URL in a new tab, since Page Info does not | |
| 395 // (yet) contain a link to the Help Center. See https://crbug.com/679532. On | |
| 396 // other platforms, open Page Info which briefly explains the HTTP warning | |
| 397 // message and provides a link to the Help Center for more details. | |
| 398 | |
| 399 #if defined(OS_ANDROID) | |
| 400 const char kSecurityIndicatorHelpCenterUrl[] = | |
| 401 "https://support.google.com/chrome/answer/95617"; | |
|
elawrence
2017/01/25 15:50:48
Per https://bugs.chromium.org/p/chromium/issues/de
Mathieu
2017/01/25 15:55:56
Would you like to verify with meggynwatkins@ about
estark
2017/01/25 16:50:01
Done per elawrence's similar comment.
estark
2017/01/25 16:50:01
Done.
| |
| 398 web_contents()->OpenURL(content::OpenURLParams( | 402 web_contents()->OpenURL(content::OpenURLParams( |
| 399 GURL(kSecurityIndicatorHelpCenterUrl), content::Referrer(), | 403 GURL(kSecurityIndicatorHelpCenterUrl), content::Referrer(), |
| 400 WindowOpenDisposition::NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, | 404 WindowOpenDisposition::NEW_FOREGROUND_TAB, ui::PAGE_TRANSITION_LINK, |
| 401 false /* is_renderer_initiated */)); | 405 false /* is_renderer_initiated */)); |
| 406 #else | |
| 407 // Important to use GetVisibleEntry to match what's showing in the omnibox. | |
| 408 content::NavigationEntry* entry = | |
| 409 web_contents()->GetController().GetVisibleEntry(); | |
|
Mathieu
2017/01/25 15:55:56
Ideally there would be a function that shows the w
estark
2017/01/25 16:50:01
I pushed the shared code into chrome::ShowWebsiteS
| |
| 410 // The visible entry can be nullptr in the case of window.open(""). | |
| 411 if (!entry) | |
| 412 return; | |
| 413 | |
| 414 SecurityStateTabHelper* helper = | |
| 415 SecurityStateTabHelper::FromWebContents(web_contents()); | |
| 416 DCHECK(helper); | |
| 417 security_state::SecurityInfo security_info; | |
| 418 helper->GetSecurityInfo(&security_info); | |
| 419 | |
| 420 chrome::ShowWebsiteSettings( | |
| 421 chrome::FindBrowserWithWebContents(web_contents()), web_contents(), | |
| 422 entry->GetURL(), security_info); | |
| 423 #endif | |
|
elawrence
2017/01/25 15:50:48
Could it be written like this, so that we fall bac
estark
2017/01/25 16:50:01
Done. (With some modification because of mathp's c
| |
| 402 } | 424 } |
| 403 | 425 |
| 404 } // namespace autofill | 426 } // namespace autofill |
| OLD | NEW |