OLD | NEW |
1 // Copyright (c) 2014 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2014 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_COMPONENT_UPDATER_SW_REPORTER_INSTALLER_WIN_H_ | 5 #ifndef CHROME_BROWSER_COMPONENT_UPDATER_SW_REPORTER_INSTALLER_WIN_H_ |
6 #define CHROME_BROWSER_COMPONENT_UPDATER_SW_REPORTER_INSTALLER_WIN_H_ | 6 #define CHROME_BROWSER_COMPONENT_UPDATER_SW_REPORTER_INSTALLER_WIN_H_ |
7 | 7 |
8 #include <stdint.h> | 8 #include <stdint.h> |
9 #include <memory> | 9 #include <memory> |
10 #include <string> | 10 #include <string> |
(...skipping 17 matching lines...) Expand all Loading... |
28 } | 28 } |
29 | 29 |
30 namespace user_prefs { | 30 namespace user_prefs { |
31 class PrefRegistrySyncable; | 31 class PrefRegistrySyncable; |
32 } | 32 } |
33 | 33 |
34 namespace component_updater { | 34 namespace component_updater { |
35 | 35 |
36 class ComponentUpdateService; | 36 class ComponentUpdateService; |
37 | 37 |
| 38 // These MUST match the values for SwReporterExperimentError in histograms.xml. |
| 39 // Exposed for testing. |
| 40 enum SwReporterExperimentError { |
| 41 SW_REPORTER_EXPERIMENT_ERROR_BAD_TAG = 0, |
| 42 SW_REPORTER_EXPERIMENT_ERROR_BAD_PARAMS = 1, |
| 43 SW_REPORTER_EXPERIMENT_ERROR_MAX, |
| 44 }; |
| 45 |
38 // Callback for running the software reporter after it is downloaded. | 46 // Callback for running the software reporter after it is downloaded. |
39 using SwReporterRunner = | 47 using SwReporterRunner = |
40 base::Callback<void(const safe_browsing::SwReporterInvocation& invocation, | 48 base::Callback<void(const safe_browsing::SwReporterInvocation& invocation, |
41 const base::Version& version)>; | 49 const base::Version& version)>; |
42 | 50 |
43 class SwReporterInstallerTraits : public ComponentInstallerTraits { | 51 class SwReporterInstallerTraits : public ComponentInstallerTraits { |
44 public: | 52 public: |
45 explicit SwReporterInstallerTraits(const SwReporterRunner& reporter_runner); | 53 SwReporterInstallerTraits(const SwReporterRunner& reporter_runner, |
| 54 bool is_experimental_engine_supported); |
46 ~SwReporterInstallerTraits() override; | 55 ~SwReporterInstallerTraits() override; |
47 | 56 |
48 private: | |
49 friend class SwReporterInstallerTest; | |
50 | |
51 // ComponentInstallerTraits implementation. | 57 // ComponentInstallerTraits implementation. |
52 bool VerifyInstallation(const base::DictionaryValue& manifest, | 58 bool VerifyInstallation(const base::DictionaryValue& manifest, |
53 const base::FilePath& dir) const override; | 59 const base::FilePath& dir) const override; |
54 bool SupportsGroupPolicyEnabledComponentUpdates() const override; | 60 bool SupportsGroupPolicyEnabledComponentUpdates() const override; |
55 bool RequiresNetworkEncryption() const override; | 61 bool RequiresNetworkEncryption() const override; |
56 bool OnCustomInstall(const base::DictionaryValue& manifest, | 62 bool OnCustomInstall(const base::DictionaryValue& manifest, |
57 const base::FilePath& install_dir) override; | 63 const base::FilePath& install_dir) override; |
58 void ComponentReady(const base::Version& version, | 64 void ComponentReady(const base::Version& version, |
59 const base::FilePath& install_dir, | 65 const base::FilePath& install_dir, |
60 std::unique_ptr<base::DictionaryValue> manifest) override; | 66 std::unique_ptr<base::DictionaryValue> manifest) override; |
61 base::FilePath GetRelativeInstallDir() const override; | 67 base::FilePath GetRelativeInstallDir() const override; |
62 void GetHash(std::vector<uint8_t>* hash) const override; | 68 void GetHash(std::vector<uint8_t>* hash) const override; |
63 std::string GetName() const override; | 69 std::string GetName() const override; |
64 update_client::InstallerAttributes GetInstallerAttributes() const override; | 70 update_client::InstallerAttributes GetInstallerAttributes() const override; |
65 std::vector<std::string> GetMimeTypes() const override; | 71 std::vector<std::string> GetMimeTypes() const override; |
66 | 72 |
| 73 private: |
| 74 friend class SwReporterInstallerTest; |
| 75 |
| 76 // Returns true if the experimental engine is supported and the Feature is |
| 77 // enabled. |
| 78 bool IsExperimentalEngineEnabled() const; |
| 79 |
67 SwReporterRunner reporter_runner_; | 80 SwReporterRunner reporter_runner_; |
| 81 const bool is_experimental_engine_supported_; |
68 | 82 |
69 DISALLOW_COPY_AND_ASSIGN(SwReporterInstallerTraits); | 83 DISALLOW_COPY_AND_ASSIGN(SwReporterInstallerTraits); |
70 }; | 84 }; |
71 | 85 |
72 // Call once during startup to make the component update service aware of the | 86 // Call once during startup to make the component update service aware of the |
73 // SwReporter. | 87 // SwReporter. |
74 void RegisterSwReporterComponent(ComponentUpdateService* cus); | 88 void RegisterSwReporterComponent(ComponentUpdateService* cus); |
75 | 89 |
76 // Register local state preferences related to the SwReporter. | 90 // Register local state preferences related to the SwReporter. |
77 void RegisterPrefsForSwReporter(PrefRegistrySimple* registry); | 91 void RegisterPrefsForSwReporter(PrefRegistrySimple* registry); |
78 | 92 |
79 // Register profile preferences related to the SwReporter. | 93 // Register profile preferences related to the SwReporter. |
80 void RegisterProfilePrefsForSwReporter( | 94 void RegisterProfilePrefsForSwReporter( |
81 user_prefs::PrefRegistrySyncable* registry); | 95 user_prefs::PrefRegistrySyncable* registry); |
82 | 96 |
83 } // namespace component_updater | 97 } // namespace component_updater |
84 | 98 |
85 #endif // CHROME_BROWSER_COMPONENT_UPDATER_SW_REPORTER_INSTALLER_WIN_H_ | 99 #endif // CHROME_BROWSER_COMPONENT_UPDATER_SW_REPORTER_INSTALLER_WIN_H_ |
OLD | NEW |