OLD | NEW |
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/srt_fetcher_win.h" | 5 #include "chrome/browser/safe_browsing/srt_fetcher_win.h" |
6 | 6 |
7 #include <stdint.h> | 7 #include <stdint.h> |
8 | 8 |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 "SoftwareReporter.FoundUwSReadError"; | 89 "SoftwareReporter.FoundUwSReadError"; |
90 const char kScanTimesMetricName[] = "SoftwareReporter.UwSScanTimes"; | 90 const char kScanTimesMetricName[] = "SoftwareReporter.UwSScanTimes"; |
91 const char kMemoryUsedMetricName[] = "SoftwareReporter.MemoryUsed"; | 91 const char kMemoryUsedMetricName[] = "SoftwareReporter.MemoryUsed"; |
92 | 92 |
93 void DisplaySRTPrompt(const base::FilePath& download_path) { | 93 void DisplaySRTPrompt(const base::FilePath& download_path) { |
94 // Find the last active browser, which may be NULL, in which case we won't | 94 // Find the last active browser, which may be NULL, in which case we won't |
95 // show the prompt this time and will wait until the next run of the | 95 // show the prompt this time and will wait until the next run of the |
96 // reporter. We can't use other ways of finding a browser because we don't | 96 // reporter. We can't use other ways of finding a browser because we don't |
97 // have a profile. | 97 // have a profile. |
98 chrome::HostDesktopType desktop_type = chrome::GetActiveDesktop(); | 98 chrome::HostDesktopType desktop_type = chrome::GetActiveDesktop(); |
99 Browser* browser = chrome::FindLastActiveWithHostDesktopType(desktop_type); | 99 Browser* browser = chrome::FindLastActive(); |
100 if (!browser) | 100 if (!browser) |
101 return; | 101 return; |
102 | 102 |
103 Profile* profile = browser->profile(); | 103 Profile* profile = browser->profile(); |
104 DCHECK(profile); | 104 DCHECK(profile); |
105 | 105 |
106 // Make sure we have a tabbed browser since we need to anchor the bubble to | 106 // Make sure we have a tabbed browser since we need to anchor the bubble to |
107 // the toolbar's wrench menu. Create one if none exist already. | 107 // the toolbar's wrench menu. Create one if none exist already. |
108 if (browser->type() != Browser::TYPE_TABBED) { | 108 if (browser->type() != Browser::TYPE_TABBED) { |
109 browser = chrome::FindTabbedBrowser(profile, false, desktop_type); | 109 browser = chrome::FindTabbedBrowser(profile, false, desktop_type); |
(...skipping 409 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
519 RecordReporterStepHistogram(SW_REPORTER_NO_PROMPT_NEEDED); | 519 RecordReporterStepHistogram(SW_REPORTER_NO_PROMPT_NEEDED); |
520 return; | 520 return; |
521 } | 521 } |
522 | 522 |
523 // Find the last active browser, which may be NULL, in which case we need | 523 // Find the last active browser, which may be NULL, in which case we need |
524 // to wait for one to be available. We can't use other ways of finding a | 524 // to wait for one to be available. We can't use other ways of finding a |
525 // browser because we don't have a profile. And we need a browser to get to | 525 // browser because we don't have a profile. And we need a browser to get to |
526 // a profile, which we need, to tell whether we should prompt or not. | 526 // a profile, which we need, to tell whether we should prompt or not. |
527 // TODO(mad): crbug.com/503269, investigate whether we should change how we | 527 // TODO(mad): crbug.com/503269, investigate whether we should change how we |
528 // decide when it's time to download the SRT and when to display the prompt. | 528 // decide when it's time to download the SRT and when to display the prompt. |
529 chrome::HostDesktopType desktop_type = chrome::GetActiveDesktop(); | 529 Browser* browser = chrome::FindLastActive(); |
530 Browser* browser = chrome::FindLastActiveWithHostDesktopType(desktop_type); | |
531 if (!browser) { | 530 if (!browser) { |
532 RecordReporterStepHistogram(SW_REPORTER_NO_BROWSER); | 531 RecordReporterStepHistogram(SW_REPORTER_NO_BROWSER); |
533 BrowserList::AddObserver(this); | 532 BrowserList::AddObserver(this); |
534 } else { | 533 } else { |
535 MaybeFetchSRT(browser, version_); | 534 MaybeFetchSRT(browser, version_); |
536 } | 535 } |
537 } | 536 } |
538 | 537 |
539 void TryToRun() { | 538 void TryToRun() { |
540 DCHECK(thread_checker_.CalledOnValidThread()); | 539 DCHECK(thread_checker_.CalledOnValidThread()); |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
631 | 630 |
632 void SetReporterLauncherForTesting(const ReporterLauncher& reporter_launcher) { | 631 void SetReporterLauncherForTesting(const ReporterLauncher& reporter_launcher) { |
633 g_reporter_launcher_ = reporter_launcher; | 632 g_reporter_launcher_ = reporter_launcher; |
634 } | 633 } |
635 | 634 |
636 void SetPromptTriggerForTesting(const PromptTrigger& prompt_trigger) { | 635 void SetPromptTriggerForTesting(const PromptTrigger& prompt_trigger) { |
637 g_prompt_trigger_ = prompt_trigger; | 636 g_prompt_trigger_ = prompt_trigger; |
638 } | 637 } |
639 | 638 |
640 } // namespace safe_browsing | 639 } // namespace safe_browsing |
OLD | NEW |