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 "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/callback_helpers.h" | 9 #include "base/callback_helpers.h" |
10 #include "base/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 // Overrides for the reporter launcher and prompt triggers free function, used | 44 // Overrides for the reporter launcher and prompt triggers free function, used |
45 // by tests. | 45 // by tests. |
46 ReporterLauncher g_reporter_launcher_; | 46 ReporterLauncher g_reporter_launcher_; |
47 PromptTrigger g_prompt_trigger_; | 47 PromptTrigger g_prompt_trigger_; |
48 | 48 |
49 void DisplaySRTPrompt(const base::FilePath& download_path) { | 49 void DisplaySRTPrompt(const base::FilePath& download_path) { |
50 // Find the last active browser, which may be NULL, in which case we won't | 50 // Find the last active browser, which may be NULL, in which case we won't |
51 // show the prompt this time and will wait until the next run of the | 51 // show the prompt this time and will wait until the next run of the |
52 // reporter. We can't use other ways of finding a browser because we don't | 52 // reporter. We can't use other ways of finding a browser because we don't |
53 // have a profile. | 53 // have a profile. |
54 chrome::HostDesktopType desktop_type = chrome::GetActiveDesktop(); | 54 ui::HostDesktopType desktop_type = chrome::GetActiveDesktop(); |
55 Browser* browser = chrome::FindLastActiveWithHostDesktopType(desktop_type); | 55 Browser* browser = chrome::FindLastActiveWithHostDesktopType(desktop_type); |
56 if (!browser) | 56 if (!browser) |
57 return; | 57 return; |
58 | 58 |
59 Profile* profile = browser->profile(); | 59 Profile* profile = browser->profile(); |
60 DCHECK(profile); | 60 DCHECK(profile); |
61 | 61 |
62 // Make sure we have a tabbed browser since we need to anchor the bubble to | 62 // Make sure we have a tabbed browser since we need to anchor the bubble to |
63 // the toolbar's wrench menu. Create one if none exist already. | 63 // the toolbar's wrench menu. Create one if none exist already. |
64 if (browser->type() != Browser::TYPE_TABBED) { | 64 if (browser->type() != Browser::TYPE_TABBED) { |
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
316 RecordReporterStepHistogram(SW_REPORTER_NO_PROMPT_NEEDED); | 316 RecordReporterStepHistogram(SW_REPORTER_NO_PROMPT_NEEDED); |
317 return; | 317 return; |
318 } | 318 } |
319 | 319 |
320 // Find the last active browser, which may be NULL, in which case we need | 320 // Find the last active browser, which may be NULL, in which case we need |
321 // to wait for one to be available. We can't use other ways of finding a | 321 // to wait for one to be available. We can't use other ways of finding a |
322 // browser because we don't have a profile. And we need a browser to get to | 322 // browser because we don't have a profile. And we need a browser to get to |
323 // a profile, which we need, to tell whether we should prompt or not. | 323 // a profile, which we need, to tell whether we should prompt or not. |
324 // TODO(mad): crbug.com/503269, investigate whether we should change how we | 324 // TODO(mad): crbug.com/503269, investigate whether we should change how we |
325 // decide when it's time to download the SRT and when to display the prompt. | 325 // decide when it's time to download the SRT and when to display the prompt. |
326 chrome::HostDesktopType desktop_type = chrome::GetActiveDesktop(); | 326 ui::HostDesktopType desktop_type = chrome::GetActiveDesktop(); |
327 Browser* browser = chrome::FindLastActiveWithHostDesktopType(desktop_type); | 327 Browser* browser = chrome::FindLastActiveWithHostDesktopType(desktop_type); |
328 if (!browser) { | 328 if (!browser) { |
329 RecordReporterStepHistogram(SW_REPORTER_NO_BROWSER); | 329 RecordReporterStepHistogram(SW_REPORTER_NO_BROWSER); |
330 BrowserList::AddObserver(this); | 330 BrowserList::AddObserver(this); |
331 } else { | 331 } else { |
332 MaybeFetchSRT(browser, version_); | 332 MaybeFetchSRT(browser, version_); |
333 } | 333 } |
334 } | 334 } |
335 | 335 |
336 void TryToRun() { | 336 void TryToRun() { |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
410 | 410 |
411 void SetReporterLauncherForTesting(const ReporterLauncher& reporter_launcher) { | 411 void SetReporterLauncherForTesting(const ReporterLauncher& reporter_launcher) { |
412 g_reporter_launcher_ = reporter_launcher; | 412 g_reporter_launcher_ = reporter_launcher; |
413 } | 413 } |
414 | 414 |
415 void SetPromptTriggerForTesting(const PromptTrigger& prompt_trigger) { | 415 void SetPromptTriggerForTesting(const PromptTrigger& prompt_trigger) { |
416 g_prompt_trigger_ = prompt_trigger; | 416 g_prompt_trigger_ = prompt_trigger; |
417 } | 417 } |
418 | 418 |
419 } // namespace safe_browsing | 419 } // namespace safe_browsing |
OLD | NEW |