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

Side by Side Diff: chrome/browser/safe_browsing/chrome_cleaner/reporter_runner_win.cc

Issue 2973873002: Primary histograms for InBrowserCleanerUI experiment (Closed)
Patch Set: Revert changes to histogram.cc 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
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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/safe_browsing/chrome_cleaner/reporter_runner_win.h" 5 #include "chrome/browser/safe_browsing/chrome_cleaner/reporter_runner_win.h"
6 6
7 #include <stdint.h> 7 #include <stdint.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <memory> 10 #include <memory>
(...skipping 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 ChromeCleanerFetchStatus fetch_status) { 489 ChromeCleanerFetchStatus fetch_status) {
490 // As long as the fetch didn't fail due to HTTP_NOT_FOUND, show a prompt 490 // As long as the fetch didn't fail due to HTTP_NOT_FOUND, show a prompt
491 // (either offering the tool directly or pointing to the download page). 491 // (either offering the tool directly or pointing to the download page).
492 // If the fetch failed to find the file, don't prompt the user since the 492 // If the fetch failed to find the file, don't prompt the user since the
493 // tool is not currently available. 493 // tool is not currently available.
494 // TODO(csharp): In the event the browser is closed before the prompt 494 // TODO(csharp): In the event the browser is closed before the prompt
495 // displays, we will wait until the next scanner run to 495 // displays, we will wait until the next scanner run to
496 // re-display it. Improve this. http://crbug.com/460295 496 // re-display it. Improve this. http://crbug.com/460295
497 if (fetch_status == ChromeCleanerFetchStatus::kNotFoundOnServer) { 497 if (fetch_status == ChromeCleanerFetchStatus::kNotFoundOnServer) {
498 RecordSRTPromptHistogram(SRT_PROMPT_DOWNLOAD_UNAVAILABLE); 498 RecordSRTPromptHistogram(SRT_PROMPT_DOWNLOAD_UNAVAILABLE);
499 RecordPromptNotShownWithReasonHistogram(
500 NO_PROMPT_REASON_CLEANER_DOWNLOAD_FAILED);
499 return; 501 return;
500 } 502 }
501 503
502 // Find the last active browser, which may be NULL, in which case we won't 504 // Find the last active browser, which may be NULL, in which case we won't
503 // show the prompt this time and will wait until the next run of the 505 // show the prompt this time and will wait until the next run of the
504 // reporter. We can't use other ways of finding a browser because we don't 506 // reporter. We can't use other ways of finding a browser because we don't
505 // have a profile. 507 // have a profile.
506 Browser* browser = chrome::FindLastActive(); 508 Browser* browser = chrome::FindLastActive();
507 if (!browser) 509 if (!browser) {
510 RecordPromptNotShownWithReasonHistogram(
511 NO_PROMPT_REASON_BROWSER_NOT_AVAILABLE);
508 return; 512 return;
513 }
509 514
510 Profile* profile = browser->profile(); 515 Profile* profile = browser->profile();
511 DCHECK(profile); 516 DCHECK(profile);
512 517
513 // Make sure we have a tabbed browser since we need to anchor the bubble to 518 // Make sure we have a tabbed browser since we need to anchor the bubble to
514 // the toolbar's wrench menu. Create one if none exist already. 519 // the toolbar's wrench menu. Create one if none exist already.
515 if (browser->type() != Browser::TYPE_TABBED) { 520 if (browser->type() != Browser::TYPE_TABBED) {
516 browser = chrome::FindTabbedBrowser(profile, false); 521 browser = chrome::FindTabbedBrowser(profile, false);
517 if (!browser) 522 if (!browser)
518 browser = new Browser(Browser::CreateParams(profile, false)); 523 browser = new Browser(Browser::CreateParams(profile, false));
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
581 586
582 void ScanAndPrompt(const SwReporterInvocation& reporter_invocation) { 587 void ScanAndPrompt(const SwReporterInvocation& reporter_invocation) {
583 if (g_testing_delegate_) { 588 if (g_testing_delegate_) {
584 g_testing_delegate_->TriggerPrompt(); 589 g_testing_delegate_->TriggerPrompt();
585 return; 590 return;
586 } 591 }
587 592
588 ChromeCleanerController* cleaner_controller = 593 ChromeCleanerController* cleaner_controller =
589 ChromeCleanerController::GetInstance(); 594 ChromeCleanerController::GetInstance();
590 595
591 if (cleaner_controller->state() != ChromeCleanerController::State::kIdle) 596 if (cleaner_controller->state() != ChromeCleanerController::State::kIdle) {
597 RecordPromptNotShownWithReasonHistogram(NO_PROMPT_REASON_NOT_ON_IDLE_STATE);
592 return; 598 return;
599 }
593 600
594 cleaner_controller->Scan(reporter_invocation); 601 cleaner_controller->Scan(reporter_invocation);
595 DCHECK_EQ(ChromeCleanerController::State::kScanning, 602 DCHECK_EQ(ChromeCleanerController::State::kScanning,
596 cleaner_controller->state()); 603 cleaner_controller->state());
597 604
598 // The dialog controller manages its own lifetime. If the controller enters 605 // The dialog controller manages its own lifetime. If the controller enters
599 // the kInfected state, the dialog controller will show the chrome cleaner 606 // the kInfected state, the dialog controller will show the chrome cleaner
600 // dialog to the user. 607 // dialog to the user.
601 new ChromeCleanerDialogControllerImpl(cleaner_controller); 608 new ChromeCleanerDialogControllerImpl(cleaner_controller);
602 } 609 }
(...skipping 14 matching lines...) Expand all
617 // Don't show the prompt again if it's been shown before for this profile 624 // Don't show the prompt again if it's been shown before for this profile
618 // and for the current variations seed, unless there's a pending prompt to 625 // and for the current variations seed, unless there's a pending prompt to
619 // show in the Chrome menu. 626 // show in the Chrome menu.
620 std::string incoming_seed = GetIncomingSRTSeed(); 627 std::string incoming_seed = GetIncomingSRTSeed();
621 std::string old_seed = prefs->GetString(prefs::kSwReporterPromptSeed); 628 std::string old_seed = prefs->GetString(prefs::kSwReporterPromptSeed);
622 PrefService* local_state = g_browser_process->local_state(); 629 PrefService* local_state = g_browser_process->local_state();
623 bool pending_prompt = 630 bool pending_prompt =
624 local_state && local_state->GetBoolean(prefs::kSwReporterPendingPrompt); 631 local_state && local_state->GetBoolean(prefs::kSwReporterPendingPrompt);
625 if (!incoming_seed.empty() && incoming_seed == old_seed && !pending_prompt) { 632 if (!incoming_seed.empty() && incoming_seed == old_seed && !pending_prompt) {
626 RecordReporterStepHistogram(SW_REPORTER_ALREADY_PROMPTED); 633 RecordReporterStepHistogram(SW_REPORTER_ALREADY_PROMPTED);
634 RecordPromptNotShownWithReasonHistogram(NO_PROMPT_REASON_ALREADY_PROMPTED);
627 return; 635 return;
628 } 636 }
629 637
630 if (!incoming_seed.empty() && incoming_seed != old_seed) { 638 if (!incoming_seed.empty() && incoming_seed != old_seed) {
631 prefs->SetString(prefs::kSwReporterPromptSeed, incoming_seed); 639 prefs->SetString(prefs::kSwReporterPromptSeed, incoming_seed);
632 // Forget about pending prompts if prompt seed has changed. 640 // Forget about pending prompts if prompt seed has changed.
633 if (local_state) 641 if (local_state)
634 local_state->SetBoolean(prefs::kSwReporterPendingPrompt, false); 642 local_state->SetBoolean(prefs::kSwReporterPendingPrompt, false);
635 } 643 }
636 prefs->SetString(prefs::kSwReporterPromptVersion, 644 prefs->SetString(prefs::kSwReporterPromptVersion,
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
764 now.ToInternalValue()); 772 now.ToInternalValue());
765 } 773 }
766 uma.ReportRuntime(reporter_running_time); 774 uma.ReportRuntime(reporter_running_time);
767 uma.ReportScanTimes(); 775 uma.ReportScanTimes();
768 uma.ReportMemoryUsage(); 776 uma.ReportMemoryUsage();
769 if (finished_invocation.logs_upload_enabled) 777 if (finished_invocation.logs_upload_enabled)
770 uma.RecordLogsUploadResult(); 778 uma.RecordLogsUploadResult();
771 779
772 if (!finished_invocation.BehaviourIsSupported( 780 if (!finished_invocation.BehaviourIsSupported(
773 SwReporterInvocation::BEHAVIOUR_TRIGGER_PROMPT)) { 781 SwReporterInvocation::BEHAVIOUR_TRIGGER_PROMPT)) {
782 RecordPromptNotShownWithReasonHistogram(
783 NO_PROMPT_REASON_BEHAVIOUR_NOT_SUPPORTED);
774 return; 784 return;
775 } 785 }
776 786
777 if (!base::FeatureList::IsEnabled(kInBrowserCleanerUIFeature) && 787 if (!base::FeatureList::IsEnabled(kInBrowserCleanerUIFeature) &&
778 !IsInSRTPromptFieldTrialGroups()) { 788 !IsInSRTPromptFieldTrialGroups()) {
779 // Knowing about disabled field trial is more important than reporter not 789 // Knowing about disabled field trial is more important than reporter not
780 // finding anything to remove, so check this case first. 790 // finding anything to remove, so check this case first.
781 RecordReporterStepHistogram(SW_REPORTER_NO_PROMPT_FIELD_TRIAL); 791 RecordReporterStepHistogram(SW_REPORTER_NO_PROMPT_FIELD_TRIAL);
792 RecordPromptNotShownWithReasonHistogram(
793 NO_PROMPT_REASON_FEATURE_NOT_ENABLED);
782 return; 794 return;
783 } 795 }
784 796
785 if (exit_code != chrome_cleaner::kSwReporterPostRebootCleanupNeeded && 797 if (exit_code != chrome_cleaner::kSwReporterPostRebootCleanupNeeded &&
786 exit_code != chrome_cleaner::kSwReporterCleanupNeeded) { 798 exit_code != chrome_cleaner::kSwReporterCleanupNeeded) {
787 RecordReporterStepHistogram(SW_REPORTER_NO_PROMPT_NEEDED); 799 RecordReporterStepHistogram(SW_REPORTER_NO_PROMPT_NEEDED);
800 RecordPromptNotShownWithReasonHistogram(NO_PROMPT_REASON_NOTHING_FOUND);
788 return; 801 return;
789 } 802 }
790 803
791 // The kInBrowserCleanerUI feature takes precedence over the 804 // The kInBrowserCleanerUI feature takes precedence over the
792 // SRTPromptFieldTrial. If it is enabled, no attempt will be made to show 805 // SRTPromptFieldTrial. If it is enabled, no attempt will be made to show
793 // the old SRT prompt. 806 // the old SRT prompt.
794 if (base::FeatureList::IsEnabled(kInBrowserCleanerUIFeature)) { 807 if (base::FeatureList::IsEnabled(kInBrowserCleanerUIFeature)) {
795 ScanAndPrompt(finished_invocation); 808 ScanAndPrompt(finished_invocation);
796 return; 809 return;
797 } 810 }
(...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after
1021 return srt_cleaner_key.Open(HKEY_CURRENT_USER, cleaner_key_path.c_str(), 1034 return srt_cleaner_key.Open(HKEY_CURRENT_USER, cleaner_key_path.c_str(),
1022 KEY_QUERY_VALUE) == ERROR_SUCCESS && 1035 KEY_QUERY_VALUE) == ERROR_SUCCESS &&
1023 srt_cleaner_key.GetValueCount() > 0; 1036 srt_cleaner_key.GetValueCount() > 0;
1024 } 1037 }
1025 1038
1026 void SetSwReporterTestingDelegate(SwReporterTestingDelegate* delegate) { 1039 void SetSwReporterTestingDelegate(SwReporterTestingDelegate* delegate) {
1027 g_testing_delegate_ = delegate; 1040 g_testing_delegate_ = delegate;
1028 } 1041 }
1029 1042
1030 } // namespace safe_browsing 1043 } // namespace safe_browsing
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698