1 // Copyright 2019 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4 
5 #include "chrome/browser/safe_browsing/chrome_cleaner/sw_reporter_invocation_win.h"
6 
7 #include <utility>
8 
9 namespace safe_browsing {
10 
SwReporterInvocation(const base::CommandLine & command_line)11 SwReporterInvocation::SwReporterInvocation(
12     const base::CommandLine& command_line)
13     : command_line_(command_line) {}
14 
SwReporterInvocation(const SwReporterInvocation & other)15 SwReporterInvocation::SwReporterInvocation(const SwReporterInvocation& other)
16     : command_line_(other.command_line_),
17       supported_behaviours_(other.supported_behaviours_),
18       suffix_(other.suffix_),
19       reporter_logs_upload_enabled_(other.reporter_logs_upload_enabled_),
20       cleaner_logs_upload_enabled_(other.cleaner_logs_upload_enabled_),
21       chrome_prompt_(other.chrome_prompt_) {}
22 
operator =(const SwReporterInvocation & invocation)23 void SwReporterInvocation::operator=(const SwReporterInvocation& invocation) {
24   command_line_ = invocation.command_line_;
25   supported_behaviours_ = invocation.supported_behaviours_;
26   suffix_ = invocation.suffix_;
27   reporter_logs_upload_enabled_ = invocation.reporter_logs_upload_enabled_;
28   cleaner_logs_upload_enabled_ = invocation.cleaner_logs_upload_enabled_;
29   chrome_prompt_ = invocation.chrome_prompt_;
30 }
31 
WithSuffix(const std::string & suffix)32 SwReporterInvocation& SwReporterInvocation::WithSuffix(
33     const std::string& suffix) {
34   suffix_ = suffix;
35   return *this;
36 }
37 
WithSupportedBehaviours(Behaviours supported_behaviours)38 SwReporterInvocation& SwReporterInvocation::WithSupportedBehaviours(
39     Behaviours supported_behaviours) {
40   supported_behaviours_ = supported_behaviours;
41   return *this;
42 }
43 
operator ==(const SwReporterInvocation & other) const44 bool SwReporterInvocation::operator==(const SwReporterInvocation& other) const {
45   return command_line_.argv() == other.command_line_.argv() &&
46          supported_behaviours_ == other.supported_behaviours_ &&
47          suffix_ == other.suffix_ &&
48          reporter_logs_upload_enabled_ == other.reporter_logs_upload_enabled_ &&
49          cleaner_logs_upload_enabled_ == other.cleaner_logs_upload_enabled_ &&
50          chrome_prompt_ == other.chrome_prompt_;
51 }
52 
command_line() const53 const base::CommandLine& SwReporterInvocation::command_line() const {
54   return command_line_;
55 }
56 
mutable_command_line()57 base::CommandLine& SwReporterInvocation::mutable_command_line() {
58   return command_line_;
59 }
60 
supported_behaviours() const61 SwReporterInvocation::Behaviours SwReporterInvocation::supported_behaviours()
62     const {
63   return supported_behaviours_;
64 }
65 
BehaviourIsSupported(SwReporterInvocation::Behaviours intended_behaviour) const66 bool SwReporterInvocation::BehaviourIsSupported(
67     SwReporterInvocation::Behaviours intended_behaviour) const {
68   return (supported_behaviours_ & intended_behaviour) != 0;
69 }
70 
suffix() const71 std::string SwReporterInvocation::suffix() const {
72   return suffix_;
73 }
74 
reporter_logs_upload_enabled() const75 bool SwReporterInvocation::reporter_logs_upload_enabled() const {
76   return reporter_logs_upload_enabled_;
77 }
78 
set_reporter_logs_upload_enabled(bool reporter_logs_upload_enabled)79 void SwReporterInvocation::set_reporter_logs_upload_enabled(
80     bool reporter_logs_upload_enabled) {
81   reporter_logs_upload_enabled_ = reporter_logs_upload_enabled;
82 }
83 
cleaner_logs_upload_enabled() const84 bool SwReporterInvocation::cleaner_logs_upload_enabled() const {
85   return cleaner_logs_upload_enabled_;
86 }
87 
set_cleaner_logs_upload_enabled(bool cleaner_logs_upload_enabled)88 void SwReporterInvocation::set_cleaner_logs_upload_enabled(
89     bool cleaner_logs_upload_enabled) {
90   cleaner_logs_upload_enabled_ = cleaner_logs_upload_enabled;
91 }
92 
chrome_prompt() const93 chrome_cleaner::ChromePromptValue SwReporterInvocation::chrome_prompt() const {
94   return chrome_prompt_;
95 }
96 
set_chrome_prompt(chrome_cleaner::ChromePromptValue chrome_prompt)97 void SwReporterInvocation::set_chrome_prompt(
98     chrome_cleaner::ChromePromptValue chrome_prompt) {
99   chrome_prompt_ = chrome_prompt;
100 }
101 
SwReporterInvocationSequence(const base::Version & version)102 SwReporterInvocationSequence::SwReporterInvocationSequence(
103     const base::Version& version)
104     : version_(version) {}
105 
SwReporterInvocationSequence(SwReporterInvocationSequence && invocations_sequence)106 SwReporterInvocationSequence::SwReporterInvocationSequence(
107     SwReporterInvocationSequence&& invocations_sequence)
108     : version_(std::move(invocations_sequence.version_)),
109       container_(std::move(invocations_sequence.container_)) {}
110 
SwReporterInvocationSequence(const SwReporterInvocationSequence & invocations_sequence)111 SwReporterInvocationSequence::SwReporterInvocationSequence(
112     const SwReporterInvocationSequence& invocations_sequence)
113     : version_(invocations_sequence.version_),
114       container_(invocations_sequence.container_) {}
115 
116 SwReporterInvocationSequence::~SwReporterInvocationSequence() = default;
117 
operator =(SwReporterInvocationSequence && invocations_sequence)118 void SwReporterInvocationSequence::operator=(
119     SwReporterInvocationSequence&& invocations_sequence) {
120   version_ = std::move(invocations_sequence.version_);
121   container_ = std::move(invocations_sequence.container_);
122 }
123 
PushInvocation(const SwReporterInvocation & invocation)124 void SwReporterInvocationSequence::PushInvocation(
125     const SwReporterInvocation& invocation) {
126   container_.push(invocation);
127 }
128 
version() const129 base::Version SwReporterInvocationSequence::version() const {
130   return version_;
131 }
132 
133 const SwReporterInvocationSequence::Queue&
container() const134 SwReporterInvocationSequence::container() const {
135   return container_;
136 }
137 
138 SwReporterInvocationSequence::Queue&
mutable_container()139 SwReporterInvocationSequence::mutable_container() {
140   return container_;
141 }
142 
143 }  // namespace safe_browsing
144