| OLD | NEW |
| 1 // Copyright 2017 The Chromium Authors. All rights reserved. | 1 // Copyright 2017 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 #ifndef CHROME_BROWSER_SAFE_BROWSING_CHROME_CLEANER_MOCK_CHROME_CLEANER_PROCESS_
WIN_H_ | 5 #ifndef CHROME_BROWSER_SAFE_BROWSING_CHROME_CLEANER_MOCK_CHROME_CLEANER_PROCESS_
WIN_H_ |
| 6 #define CHROME_BROWSER_SAFE_BROWSING_CHROME_CLEANER_MOCK_CHROME_CLEANER_PROCESS_
WIN_H_ | 6 #define CHROME_BROWSER_SAFE_BROWSING_CHROME_CLEANER_MOCK_CHROME_CLEANER_PROCESS_
WIN_H_ |
| 7 | 7 |
| 8 #include <set> | 8 #include <set> |
| 9 #include <string> | 9 #include <string> |
| 10 | 10 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 36 public: | 36 public: |
| 37 enum class CrashPoint { | 37 enum class CrashPoint { |
| 38 kNone, | 38 kNone, |
| 39 kOnStartup, | 39 kOnStartup, |
| 40 kAfterConnection, | 40 kAfterConnection, |
| 41 kAfterRequestSent, | 41 kAfterRequestSent, |
| 42 kAfterResponseReceived, | 42 kAfterResponseReceived, |
| 43 kNumCrashPoints, | 43 kNumCrashPoints, |
| 44 }; | 44 }; |
| 45 | 45 |
| 46 static constexpr int kInternalTestFailureExitCode = -1; | 46 static constexpr int kInternalTestFailureExitCode = 100001; |
| 47 static constexpr int kDeliberateCrashExitCode = -2; | 47 static constexpr int kDeliberateCrashExitCode = 100002; |
| 48 static constexpr int kNothingFoundExitCode = 2; | 48 static constexpr int kNothingFoundExitCode = 2; |
| 49 static constexpr int kDeclinedExitCode = 44; | 49 static constexpr int kDeclinedExitCode = 44; |
| 50 static constexpr int kRebootRequiredExitCode = 15; | 50 static constexpr int kRebootRequiredExitCode = 15; |
| 51 static constexpr int kRebootNotRequiredExitCode = 0; | 51 static constexpr int kRebootNotRequiredExitCode = 0; |
| 52 | 52 |
| 53 class Options { | 53 class Options { |
| 54 public: | 54 public: |
| 55 static bool FromCommandLine(const base::CommandLine& command_line, | 55 static bool FromCommandLine(const base::CommandLine& command_line, |
| 56 Options* options); | 56 Options* options); |
| 57 | 57 |
| (...skipping 10 matching lines...) Expand all Loading... |
| 68 } | 68 } |
| 69 | 69 |
| 70 void set_reboot_required(bool reboot_required) { | 70 void set_reboot_required(bool reboot_required) { |
| 71 reboot_required_ = reboot_required; | 71 reboot_required_ = reboot_required; |
| 72 } | 72 } |
| 73 bool reboot_required() const { return reboot_required_; } | 73 bool reboot_required() const { return reboot_required_; } |
| 74 | 74 |
| 75 void set_crash_point(CrashPoint crash_point) { crash_point_ = crash_point; } | 75 void set_crash_point(CrashPoint crash_point) { crash_point_ = crash_point; } |
| 76 CrashPoint crash_point() const { return crash_point_; } | 76 CrashPoint crash_point() const { return crash_point_; } |
| 77 | 77 |
| 78 void set_expected_user_response( |
| 79 chrome_cleaner::mojom::PromptAcceptance expected_user_response) { |
| 80 expected_user_response_ = expected_user_response; |
| 81 } |
| 82 |
| 83 chrome_cleaner::mojom::PromptAcceptance expected_user_response() const { |
| 84 return expected_user_response_; |
| 85 } |
| 86 |
| 78 int ExpectedExitCode(chrome_cleaner::mojom::PromptAcceptance | 87 int ExpectedExitCode(chrome_cleaner::mojom::PromptAcceptance |
| 79 received_prompt_acceptance) const; | 88 received_prompt_acceptance) const; |
| 80 | 89 |
| 81 private: | 90 private: |
| 82 std::set<base::FilePath> files_to_delete_; | 91 std::set<base::FilePath> files_to_delete_; |
| 83 bool reboot_required_ = false; | 92 bool reboot_required_ = false; |
| 84 CrashPoint crash_point_ = CrashPoint::kNone; | 93 CrashPoint crash_point_ = CrashPoint::kNone; |
| 94 chrome_cleaner::mojom::PromptAcceptance expected_user_response_ = |
| 95 chrome_cleaner::mojom::PromptAcceptance::UNSPECIFIED; |
| 85 }; | 96 }; |
| 86 | 97 |
| 87 MockChromeCleanerProcess(const Options& options, | 98 MockChromeCleanerProcess(const Options& options, |
| 88 const std::string& chrome_mojo_pipe_token); | 99 const std::string& chrome_mojo_pipe_token); |
| 89 | 100 |
| 90 // Call this in the main function of the mock Chrome Cleaner process. Returns | 101 // Call this in the main function of the mock Chrome Cleaner process. Returns |
| 91 // the exit code that should be used when the process exits. | 102 // the exit code that should be used when the process exits. |
| 92 // | 103 // |
| 93 // If a crash point has been specified in the options passed to the | 104 // If a crash point has been specified in the options passed to the |
| 94 // constructor, the process will exit with a kDeliberateCrashExitCode exit | 105 // constructor, the process will exit with a kDeliberateCrashExitCode exit |
| (...skipping 13 matching lines...) Expand all Loading... |
| 108 std::string chrome_mojo_pipe_token_; | 119 std::string chrome_mojo_pipe_token_; |
| 109 // The PromptAcceptance received in PromptUserCallback(). | 120 // The PromptAcceptance received in PromptUserCallback(). |
| 110 chrome_cleaner::mojom::PromptAcceptance received_prompt_acceptance_ = | 121 chrome_cleaner::mojom::PromptAcceptance received_prompt_acceptance_ = |
| 111 chrome_cleaner::mojom::PromptAcceptance::UNSPECIFIED; | 122 chrome_cleaner::mojom::PromptAcceptance::UNSPECIFIED; |
| 112 chrome_cleaner::mojom::ChromePromptPtr* chrome_prompt_ptr_ = nullptr; | 123 chrome_cleaner::mojom::ChromePromptPtr* chrome_prompt_ptr_ = nullptr; |
| 113 }; | 124 }; |
| 114 | 125 |
| 115 } // namespace safe_browsing | 126 } // namespace safe_browsing |
| 116 | 127 |
| 117 #endif // CHROME_BROWSER_SAFE_BROWSING_CHROME_CLEANER_MOCK_CHROME_CLEANER_PROCE
SS_WIN_H_ | 128 #endif // CHROME_BROWSER_SAFE_BROWSING_CHROME_CLEANER_MOCK_CHROME_CLEANER_PROCE
SS_WIN_H_ |
| OLD | NEW |