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

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

Issue 344033008: [Password Manager] Disable saving and filling on sync signup (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 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 | Annotate | Revision Log
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 "base/bind_helpers.h" 7 #include "base/bind_helpers.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/memory/singleton.h" 9 #include "base/memory/singleton.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "chrome/browser/password_manager/password_manager_util.h" 11 #include "chrome/browser/password_manager/password_manager_util.h"
12 #include "chrome/browser/password_manager/password_store_factory.h" 12 #include "chrome/browser/password_manager/password_store_factory.h"
13 #include "chrome/browser/password_manager/save_password_infobar_delegate.h" 13 #include "chrome/browser/password_manager/save_password_infobar_delegate.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/sync/profile_sync_service.h" 15 #include "chrome/browser/sync/profile_sync_service.h"
16 #include "chrome/browser/sync/profile_sync_service_factory.h" 16 #include "chrome/browser/sync/profile_sync_service_factory.h"
17 #include "chrome/browser/ui/autofill/password_generation_popup_controller_impl.h " 17 #include "chrome/browser/ui/autofill/password_generation_popup_controller_impl.h "
18 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h" 18 #include "chrome/browser/ui/passwords/manage_passwords_ui_controller.h"
19 #include "chrome/common/chrome_switches.h" 19 #include "chrome/common/chrome_switches.h"
20 #include "chrome/common/chrome_version_info.h" 20 #include "chrome/common/chrome_version_info.h"
21 #include "chrome/common/url_constants.h"
21 #include "components/autofill/content/common/autofill_messages.h" 22 #include "components/autofill/content/common/autofill_messages.h"
22 #include "components/autofill/core/browser/password_generator.h" 23 #include "components/autofill/core/browser/password_generator.h"
23 #include "components/autofill/core/common/password_form.h" 24 #include "components/autofill/core/common/password_form.h"
24 #include "components/password_manager/content/browser/password_manager_internals _service_factory.h" 25 #include "components/password_manager/content/browser/password_manager_internals _service_factory.h"
25 #include "components/password_manager/core/browser/log_receiver.h" 26 #include "components/password_manager/core/browser/log_receiver.h"
26 #include "components/password_manager/core/browser/password_form_manager.h" 27 #include "components/password_manager/core/browser/password_form_manager.h"
27 #include "components/password_manager/core/browser/password_manager.h" 28 #include "components/password_manager/core/browser/password_manager.h"
28 #include "components/password_manager/core/browser/password_manager_internals_se rvice.h" 29 #include "components/password_manager/core/browser/password_manager_internals_se rvice.h"
29 #include "components/password_manager/core/browser/password_manager_metrics_util .h" 30 #include "components/password_manager/core/browser/password_manager_metrics_util .h"
30 #include "components/password_manager/core/common/password_manager_switches.h" 31 #include "components/password_manager/core/common/password_manager_switches.h"
32 #include "content/public/browser/navigation_entry.h"
31 #include "content/public/browser/render_view_host.h" 33 #include "content/public/browser/render_view_host.h"
32 #include "content/public/browser/web_contents.h" 34 #include "content/public/browser/web_contents.h"
33 35
34 #if defined(OS_ANDROID) 36 #if defined(OS_ANDROID)
35 #include "chrome/browser/android/password_authentication_manager.h" 37 #include "chrome/browser/android/password_authentication_manager.h"
36 #endif // OS_ANDROID 38 #endif // OS_ANDROID
37 39
38 using password_manager::PasswordManagerInternalsService; 40 using password_manager::PasswordManagerInternalsService;
39 using password_manager::PasswordManagerInternalsServiceFactory; 41 using password_manager::PasswordManagerInternalsServiceFactory;
40 42
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
74 service->UnregisterClient(this); 76 service->UnregisterClient(this);
75 } 77 }
76 78
77 bool ChromePasswordManagerClient::IsAutomaticPasswordSavingEnabled() const { 79 bool ChromePasswordManagerClient::IsAutomaticPasswordSavingEnabled() const {
78 return CommandLine::ForCurrentProcess()->HasSwitch( 80 return CommandLine::ForCurrentProcess()->HasSwitch(
79 password_manager::switches::kEnableAutomaticPasswordSaving) && 81 password_manager::switches::kEnableAutomaticPasswordSaving) &&
80 chrome::VersionInfo::GetChannel() == 82 chrome::VersionInfo::GetChannel() ==
81 chrome::VersionInfo::CHANNEL_UNKNOWN; 83 chrome::VersionInfo::CHANNEL_UNKNOWN;
82 } 84 }
83 85
86 bool ChromePasswordManagerClient::IsPasswordManagerEnabledForCurrentPage()
87 const {
88 if (EnabledForSyncSignin())
89 return true;
90
91 DCHECK(web_contents());
92 content::NavigationEntry* entry =
93 web_contents()->GetController().GetLastCommittedEntry();
94 if (!entry) {
95 // TODO(gcasto): Determine if fix for crbug.com/388246 is relevant here.
96 return true;
97 }
98 // Do not fill nor save password when a user is signing in for sync. This
99 // is because users need to remember their password if they are syncing as
100 // this is effectively their master password.
101 return entry->GetURL().host() != chrome::kChromeUIChromeSigninHost;
102 }
103
84 void ChromePasswordManagerClient::PromptUserToSavePassword( 104 void ChromePasswordManagerClient::PromptUserToSavePassword(
85 password_manager::PasswordFormManager* form_to_save) { 105 password_manager::PasswordFormManager* form_to_save) {
86 if (IsTheHotNewBubbleUIEnabled()) { 106 if (IsTheHotNewBubbleUIEnabled()) {
87 ManagePasswordsUIController* manage_passwords_ui_controller = 107 ManagePasswordsUIController* manage_passwords_ui_controller =
88 ManagePasswordsUIController::FromWebContents(web_contents()); 108 ManagePasswordsUIController::FromWebContents(web_contents());
89 manage_passwords_ui_controller->OnPasswordSubmitted(form_to_save); 109 manage_passwords_ui_controller->OnPasswordSubmitted(form_to_save);
90 } else { 110 } else {
91 std::string uma_histogram_suffix( 111 std::string uma_histogram_suffix(
92 password_manager::metrics_util::GroupIdToString( 112 password_manager::metrics_util::GroupIdToString(
93 password_manager::metrics_util::MonitoredDomainGroupId( 113 password_manager::metrics_util::MonitoredDomainGroupId(
(...skipping 232 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 346
327 if (command_line->HasSwitch(switches::kEnableSavePasswordBubble)) 347 if (command_line->HasSwitch(switches::kEnableSavePasswordBubble))
328 return true; 348 return true;
329 349
330 std::string group_name = 350 std::string group_name =
331 base::FieldTrialList::FindFullName("PasswordManagerUI"); 351 base::FieldTrialList::FindFullName("PasswordManagerUI");
332 352
333 // The bubble should be the default case that runs on the bots. 353 // The bubble should be the default case that runs on the bots.
334 return group_name != "Infobar"; 354 return group_name != "Infobar";
335 } 355 }
356
357 bool ChromePasswordManagerClient::EnabledForSyncSignin() {
358 CommandLine* command_line = CommandLine::ForCurrentProcess();
359 if (command_line->HasSwitch(
360 password_manager::switches::kDisableManagerForSyncSignin))
361 return false;
362
363 if (command_line->HasSwitch(
364 password_manager::switches::kEnableManagerForSyncSignin))
365 return true;
366
367 // Default is enabled.
368 std::string group_name =
369 base::FieldTrialList::FindFullName("PasswordManagerStateForSyncSignin");
370 return group_name != "Disabled";
371 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698