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

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

Issue 2302823003: Only report PasswordState in Sync for UMA+non-custom passphrase users. (Closed)
Patch Set: Split apart state-transition test Created 4 years, 3 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
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"
11 #include "base/bind_helpers.h" 11 #include "base/bind_helpers.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/memory/singleton.h" 13 #include "base/memory/singleton.h"
14 #include "base/metrics/field_trial.h" 14 #include "base/metrics/field_trial.h"
15 #include "base/metrics/histogram.h" 15 #include "base/metrics/histogram.h"
16 #include "build/build_config.h" 16 #include "build/build_config.h"
17 #include "chrome/browser/browsing_data/browsing_data_helper.h" 17 #include "chrome/browser/browsing_data/browsing_data_helper.h"
18 #include "chrome/browser/metrics/chrome_metrics_service_accessor.h"
18 #include "chrome/browser/password_manager/password_store_factory.h" 19 #include "chrome/browser/password_manager/password_store_factory.h"
19 #include "chrome/browser/profiles/profile.h" 20 #include "chrome/browser/profiles/profile.h"
20 #include "chrome/browser/signin/signin_manager_factory.h" 21 #include "chrome/browser/signin/signin_manager_factory.h"
21 #include "chrome/browser/sync/profile_sync_service_factory.h" 22 #include "chrome/browser/sync/profile_sync_service_factory.h"
22 #include "chrome/browser/ui/autofill/password_generation_popup_controller_impl.h " 23 #include "chrome/browser/ui/autofill/password_generation_popup_controller_impl.h "
23 #include "chrome/browser/ui/passwords/passwords_client_ui_delegate.h" 24 #include "chrome/browser/ui/passwords/passwords_client_ui_delegate.h"
24 #include "chrome/common/channel_info.h" 25 #include "chrome/common/channel_info.h"
25 #include "chrome/common/chrome_switches.h" 26 #include "chrome/common/chrome_switches.h"
26 #include "chrome/common/features.h" 27 #include "chrome/common/features.h"
27 #include "chrome/common/url_constants.h" 28 #include "chrome/common/url_constants.h"
(...skipping 539 matching lines...) Expand 10 before | Expand all | Expand 10 after
567 const GURL& ChromePasswordManagerClient::GetLastCommittedEntryURL() const { 568 const GURL& ChromePasswordManagerClient::GetLastCommittedEntryURL() const {
568 DCHECK(web_contents()); 569 DCHECK(web_contents());
569 content::NavigationEntry* entry = 570 content::NavigationEntry* entry =
570 web_contents()->GetController().GetLastCommittedEntry(); 571 web_contents()->GetController().GetLastCommittedEntry();
571 if (!entry) 572 if (!entry)
572 return GURL::EmptyGURL(); 573 return GURL::EmptyGURL();
573 574
574 return entry->GetURL(); 575 return entry->GetURL();
575 } 576 }
576 577
578 // static
579 bool ChromePasswordManagerClient::ShouldAnnotateNavigationEntries(
580 Profile* profile) {
581 // Only annotate PasswordState onto the navigation entry if user is
582 // opted into UMA and they're not syncing w/ a custom passphrase.
583 if (!ChromeMetricsServiceAccessor::IsMetricsAndCrashReportingEnabled())
584 return false;
585
586 ProfileSyncService* profile_sync_service =
587 ProfileSyncServiceFactory::GetForProfile(profile);
588 if (!profile_sync_service || !profile_sync_service->IsSyncActive() ||
589 profile_sync_service->IsUsingSecondaryPassphrase()) {
590 return false;
591 }
592
593 return true;
594 }
595
577 void ChromePasswordManagerClient::AnnotateNavigationEntry( 596 void ChromePasswordManagerClient::AnnotateNavigationEntry(
578 bool has_password_field) { 597 bool has_password_field) {
598 if (!ShouldAnnotateNavigationEntries(profile_))
599 return;
600
579 content::NavigationEntry* entry = 601 content::NavigationEntry* entry =
580 web_contents()->GetController().GetLastCommittedEntry(); 602 web_contents()->GetController().GetLastCommittedEntry();
581 if (!entry) 603 if (!entry)
582 return; 604 return;
583 605
584 SerializedNavigationEntry::PasswordState old_state = 606 SerializedNavigationEntry::PasswordState old_state =
585 sessions::GetPasswordStateFromNavigation(*entry); 607 sessions::GetPasswordStateFromNavigation(*entry);
586 608
587 SerializedNavigationEntry::PasswordState new_state = 609 SerializedNavigationEntry::PasswordState new_state =
588 (has_password_field ? SerializedNavigationEntry::HAS_PASSWORD_FIELD 610 (has_password_field ? SerializedNavigationEntry::HAS_PASSWORD_FIELD
(...skipping 20 matching lines...) Expand all
609 password_manager::mojom::CredentialManagerRequest request) { 631 password_manager::mojom::CredentialManagerRequest request) {
610 content::WebContents* web_contents = 632 content::WebContents* web_contents =
611 content::WebContents::FromRenderFrameHost(render_frame_host); 633 content::WebContents::FromRenderFrameHost(render_frame_host);
612 DCHECK(web_contents); 634 DCHECK(web_contents);
613 635
614 ChromePasswordManagerClient* instance = 636 ChromePasswordManagerClient* instance =
615 ChromePasswordManagerClient::FromWebContents(web_contents); 637 ChromePasswordManagerClient::FromWebContents(web_contents);
616 DCHECK(instance); 638 DCHECK(instance);
617 instance->credential_manager_impl_.BindRequest(std::move(request)); 639 instance->credential_manager_impl_.BindRequest(std::move(request));
618 } 640 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698