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

Side by Side Diff: chrome/browser/password_manager/chrome_password_manager_client.cc

Issue 2958533003: Disable Credential management API dialog in VR mode (Closed)
Patch Set: cr feedback Created 3 years, 5 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
« no previous file with comments | « chrome/browser/password_manager/chrome_password_manager_client.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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/password_manager/chrome_password_manager_client.h" 5 #include "chrome/browser/password_manager/chrome_password_manager_client.h"
6 6
7 #include <string> 7 #include <string>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/bind.h" 10 #include "base/bind.h"
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after
81 #include "chrome/browser/password_manager/generated_password_saved_infobar_deleg ate_android.h" 81 #include "chrome/browser/password_manager/generated_password_saved_infobar_deleg ate_android.h"
82 #include "chrome/browser/password_manager/save_password_infobar_delegate_android .h" 82 #include "chrome/browser/password_manager/save_password_infobar_delegate_android .h"
83 #include "chrome/browser/password_manager/update_password_infobar_delegate_andro id.h" 83 #include "chrome/browser/password_manager/update_password_infobar_delegate_andro id.h"
84 #include "chrome/browser/ui/android/snackbars/auto_signin_prompt_controller.h" 84 #include "chrome/browser/ui/android/snackbars/auto_signin_prompt_controller.h"
85 #endif 85 #endif
86 86
87 #if BUILDFLAG(ENABLE_EXTENSIONS) 87 #if BUILDFLAG(ENABLE_EXTENSIONS)
88 #include "extensions/common/constants.h" 88 #include "extensions/common/constants.h"
89 #endif 89 #endif
90 90
91 #include "device/vr/features/features.h"
92 #if BUILDFLAG(ENABLE_VR)
93 #include "chrome/browser/android/vr_shell/vr_tab_helper.h"
94 #endif // BUILDFLAG(ENABLE_VR)
95
91 using password_manager::ContentPasswordManagerDriverFactory; 96 using password_manager::ContentPasswordManagerDriverFactory;
92 using password_manager::PasswordManagerInternalsService; 97 using password_manager::PasswordManagerInternalsService;
93 using sessions::SerializedNavigationEntry; 98 using sessions::SerializedNavigationEntry;
94 99
95 // Shorten the name to spare line breaks. The code provides enough context 100 // Shorten the name to spare line breaks. The code provides enough context
96 // already. 101 // already.
97 typedef autofill::SavePasswordProgressLogger Logger; 102 typedef autofill::SavePasswordProgressLogger Logger;
98 103
99 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ChromePasswordManagerClient); 104 DEFINE_WEB_CONTENTS_USER_DATA_KEY(ChromePasswordManagerClient);
100 105
(...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after
209 is_enabled = 214 is_enabled =
210 entry->GetURL().host_piece() != chrome::kChromeUIChromeSigninHost; 215 entry->GetURL().host_piece() != chrome::kChromeUIChromeSigninHost;
211 } 216 }
212 if (log_manager_->IsLoggingActive()) { 217 if (log_manager_->IsLoggingActive()) {
213 password_manager::BrowserSavePasswordProgressLogger logger( 218 password_manager::BrowserSavePasswordProgressLogger logger(
214 log_manager_.get()); 219 log_manager_.get());
215 logger.LogBoolean( 220 logger.LogBoolean(
216 Logger::STRING_PASSWORD_MANAGEMENT_ENABLED_FOR_CURRENT_PAGE, 221 Logger::STRING_PASSWORD_MANAGEMENT_ENABLED_FOR_CURRENT_PAGE,
217 is_enabled); 222 is_enabled);
218 } 223 }
224 if (IsInVr()) {
225 is_enabled = false;
226 }
billorr 2017/06/29 22:26:02 moving above the logging...
billorr 2017/06/30 17:54:18 Done.
219 return is_enabled; 227 return is_enabled;
220 } 228 }
221 229
222 bool ChromePasswordManagerClient::IsSavingAndFillingEnabledForCurrentPage() 230 bool ChromePasswordManagerClient::IsSavingAndFillingEnabledForCurrentPage()
223 const { 231 const {
224 if (base::CommandLine::ForCurrentProcess()->HasSwitch( 232 if (base::CommandLine::ForCurrentProcess()->HasSwitch(
225 switches::kEnableAutomation)) { 233 switches::kEnableAutomation)) {
226 // Disable the password saving UI for automated tests. It obscures the 234 // Disable the password saving UI for automated tests. It obscures the
227 // page, and there is no API to access (or dismiss) UI bubbles/infobars. 235 // page, and there is no API to access (or dismiss) UI bubbles/infobars.
228 return false; 236 return false;
(...skipping 16 matching lines...) Expand all
245 origin, make_scoped_refptr(profile_->GetRequestContext()), callback); 253 origin, make_scoped_refptr(profile_->GetRequestContext()), callback);
246 } 254 }
247 255
248 bool ChromePasswordManagerClient::OnCredentialManagerUsed() { 256 bool ChromePasswordManagerClient::OnCredentialManagerUsed() {
249 prerender::PrerenderContents* prerender_contents = 257 prerender::PrerenderContents* prerender_contents =
250 prerender::PrerenderContents::FromWebContents(web_contents()); 258 prerender::PrerenderContents::FromWebContents(web_contents());
251 if (prerender_contents) { 259 if (prerender_contents) {
252 prerender_contents->Destroy(prerender::FINAL_STATUS_CREDENTIAL_MANAGER_API); 260 prerender_contents->Destroy(prerender::FINAL_STATUS_CREDENTIAL_MANAGER_API);
253 return false; 261 return false;
254 } 262 }
255 return true; 263
264 // The credential manager is not used while in VR.
265 return !IsInVr();
256 } 266 }
257 267
258 bool ChromePasswordManagerClient::PromptUserToSaveOrUpdatePassword( 268 bool ChromePasswordManagerClient::PromptUserToSaveOrUpdatePassword(
259 std::unique_ptr<password_manager::PasswordFormManager> form_to_save, 269 std::unique_ptr<password_manager::PasswordFormManager> form_to_save,
260 bool update_password) { 270 bool update_password) {
261 // Save password infobar and the password bubble prompts in case of 271 // Save password infobar and the password bubble prompts in case of
262 // "webby" URLs and do not prompt in case of "non-webby" URLS (e.g. file://). 272 // "webby" URLs and do not prompt in case of "non-webby" URLS (e.g. file://).
263 if (!CanShowBubbleOnURL(web_contents()->GetLastCommittedURL())) 273 if (!CanShowBubbleOnURL(web_contents()->GetLastCommittedURL()))
264 return false; 274 return false;
265 275
(...skipping 19 matching lines...) Expand all
285 SavePasswordInfoBarDelegate::Create(web_contents(), 295 SavePasswordInfoBarDelegate::Create(web_contents(),
286 std::move(form_to_save)); 296 std::move(form_to_save));
287 #endif // !defined(OS_ANDROID) 297 #endif // !defined(OS_ANDROID)
288 return true; 298 return true;
289 } 299 }
290 300
291 bool ChromePasswordManagerClient::PromptUserToChooseCredentials( 301 bool ChromePasswordManagerClient::PromptUserToChooseCredentials(
292 std::vector<std::unique_ptr<autofill::PasswordForm>> local_forms, 302 std::vector<std::unique_ptr<autofill::PasswordForm>> local_forms,
293 const GURL& origin, 303 const GURL& origin,
294 const CredentialsCallback& callback) { 304 const CredentialsCallback& callback) {
305 // Do not show popup dialogs while in VR
billorr 2017/06/29 22:26:02 nit: period.
billorr 2017/06/30 17:54:18 Done.
306 if (IsInVr())
307 return false;
308
295 // Set up an intercept callback if the prompt is zero-clickable (e.g. just one 309 // Set up an intercept callback if the prompt is zero-clickable (e.g. just one
296 // form provided). 310 // form provided).
297 CredentialsCallback intercept = 311 CredentialsCallback intercept =
298 base::Bind(&ChromePasswordManagerClient::OnCredentialsChosen, 312 base::Bind(&ChromePasswordManagerClient::OnCredentialsChosen,
299 base::Unretained(this), callback, local_forms.size() == 1); 313 base::Unretained(this), callback, local_forms.size() == 1);
300 #if defined(OS_ANDROID) 314 #if defined(OS_ANDROID)
301 // Deletes itself on the event from Java counterpart, when user interacts with 315 // Deletes itself on the event from Java counterpart, when user interacts with
302 // dialog. 316 // dialog.
303 AccountChooserDialogAndroid* acccount_chooser_dialog = 317 AccountChooserDialogAndroid* acccount_chooser_dialog =
304 new AccountChooserDialogAndroid(web_contents(), std::move(local_forms), 318 new AccountChooserDialogAndroid(web_contents(), std::move(local_forms),
(...skipping 239 matching lines...) Expand 10 before | Expand all | Expand 10 after
544 log_manager_.get()); 558 log_manager_.get());
545 logger.LogBoolean(Logger::STRING_SSL_ERRORS_PRESENT, ssl_errors); 559 logger.LogBoolean(Logger::STRING_SSL_ERRORS_PRESENT, ssl_errors);
546 } 560 }
547 return ssl_errors; 561 return ssl_errors;
548 } 562 }
549 563
550 bool ChromePasswordManagerClient::IsIncognito() const { 564 bool ChromePasswordManagerClient::IsIncognito() const {
551 return web_contents()->GetBrowserContext()->IsOffTheRecord(); 565 return web_contents()->GetBrowserContext()->IsOffTheRecord();
552 } 566 }
553 567
568 bool ChromePasswordManagerClient::IsInVr() const {
569 #if BUILDFLAG(ENABLE_VR)
570 return vr_shell::VrTabHelper::IsInVr(web_contents());
571 #else
572 return false;
573 #endif // BUILDFLAG(ENABLE_VR)
574 }
575
554 const password_manager::PasswordManager* 576 const password_manager::PasswordManager*
555 ChromePasswordManagerClient::GetPasswordManager() const { 577 ChromePasswordManagerClient::GetPasswordManager() const {
556 return &password_manager_; 578 return &password_manager_;
557 } 579 }
558 580
559 autofill::AutofillManager* 581 autofill::AutofillManager*
560 ChromePasswordManagerClient::GetAutofillManagerForMainFrame() { 582 ChromePasswordManagerClient::GetAutofillManagerForMainFrame() {
561 autofill::ContentAutofillDriverFactory* factory = 583 autofill::ContentAutofillDriverFactory* factory =
562 autofill::ContentAutofillDriverFactory::FromWebContents(web_contents()); 584 autofill::ContentAutofillDriverFactory::FromWebContents(web_contents());
563 return factory 585 return factory
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
618 password_manager_client_bindings_.GetCurrentTargetFrame()), 640 password_manager_client_bindings_.GetCurrentTargetFrame()),
619 observer_, web_contents(), web_contents()->GetNativeView()); 641 observer_, web_contents(), web_contents()->GetNativeView());
620 popup_controller_->Show(false /* display_password */); 642 popup_controller_->Show(false /* display_password */);
621 } 643 }
622 644
623 void ChromePasswordManagerClient::PromptUserToEnableAutosigninIfNecessary() { 645 void ChromePasswordManagerClient::PromptUserToEnableAutosigninIfNecessary() {
624 if (!password_bubble_experiment::ShouldShowAutoSignInPromptFirstRunExperience( 646 if (!password_bubble_experiment::ShouldShowAutoSignInPromptFirstRunExperience(
625 GetPrefs()) || 647 GetPrefs()) ||
626 !GetPrefs()->GetBoolean( 648 !GetPrefs()->GetBoolean(
627 password_manager::prefs::kCredentialsEnableAutosignin) || 649 password_manager::prefs::kCredentialsEnableAutosignin) ||
628 IsIncognito()) 650 IsIncognito() || IsInVr())
629 return; 651 return;
630 652
631 #if defined(OS_ANDROID) 653 #if defined(OS_ANDROID)
632 // Dialog is deleted by the Java counterpart after user interacts with it. 654 // Dialog is deleted by the Java counterpart after user interacts with it.
633 AutoSigninFirstRunDialogAndroid* auto_signin_first_run_dialog = 655 AutoSigninFirstRunDialogAndroid* auto_signin_first_run_dialog =
634 new AutoSigninFirstRunDialogAndroid(web_contents()); 656 new AutoSigninFirstRunDialogAndroid(web_contents());
635 auto_signin_first_run_dialog->ShowDialog(); 657 auto_signin_first_run_dialog->ShowDialog();
636 #else 658 #else
637 PasswordsClientUIDelegateFromWebContents(web_contents()) 659 PasswordsClientUIDelegateFromWebContents(web_contents())
638 ->OnPromptEnableAutoSignin(); 660 ->OnPromptEnableAutoSignin();
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after
740 // static 762 // static
741 bool ChromePasswordManagerClient::CanShowBubbleOnURL(const GURL& url) { 763 bool ChromePasswordManagerClient::CanShowBubbleOnURL(const GURL& url) {
742 std::string scheme = url.scheme(); 764 std::string scheme = url.scheme();
743 return (content::ChildProcessSecurityPolicy::GetInstance()->IsWebSafeScheme( 765 return (content::ChildProcessSecurityPolicy::GetInstance()->IsWebSafeScheme(
744 scheme) && 766 scheme) &&
745 #if BUILDFLAG(ENABLE_EXTENSIONS) 767 #if BUILDFLAG(ENABLE_EXTENSIONS)
746 scheme != extensions::kExtensionScheme && 768 scheme != extensions::kExtensionScheme &&
747 #endif 769 #endif
748 scheme != content::kChromeDevToolsScheme); 770 scheme != content::kChromeDevToolsScheme);
749 } 771 }
OLDNEW
« no previous file with comments | « chrome/browser/password_manager/chrome_password_manager_client.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698