Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(325)

Side by Side Diff: chrome/browser/component_updater/supervised_user_whitelist_installer.cc

Issue 2483513002: Revert of Makes the component installers return a Result instead of a bool. (Closed)
Patch Set: Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 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 #include "chrome/browser/component_updater/supervised_user_whitelist_installer.h " 5 #include "chrome/browser/component_updater/supervised_user_whitelist_installer.h "
6 6
7 #include <stddef.h> 7 #include <stddef.h>
8 8
9 #include <map> 9 #include <map>
10 #include <utility> 10 #include <utility>
(...skipping 22 matching lines...) Expand all
33 #include "chrome/common/chrome_paths.h" 33 #include "chrome/common/chrome_paths.h"
34 #include "chrome/common/pref_names.h" 34 #include "chrome/common/pref_names.h"
35 #include "components/component_updater/component_updater_paths.h" 35 #include "components/component_updater/component_updater_paths.h"
36 #include "components/component_updater/component_updater_service.h" 36 #include "components/component_updater/component_updater_service.h"
37 #include "components/component_updater/default_component_installer.h" 37 #include "components/component_updater/default_component_installer.h"
38 #include "components/crx_file/id_util.h" 38 #include "components/crx_file/id_util.h"
39 #include "components/prefs/pref_registry_simple.h" 39 #include "components/prefs/pref_registry_simple.h"
40 #include "components/prefs/pref_service.h" 40 #include "components/prefs/pref_service.h"
41 #include "components/prefs/scoped_user_pref_update.h" 41 #include "components/prefs/scoped_user_pref_update.h"
42 #include "components/safe_json/json_sanitizer.h" 42 #include "components/safe_json/json_sanitizer.h"
43 #include "components/update_client/update_client_errors.h"
44 #include "content/public/browser/browser_thread.h" 43 #include "content/public/browser/browser_thread.h"
45 44
46 namespace component_updater { 45 namespace component_updater {
47 46
48 namespace { 47 namespace {
49 48
50 const char kSanitizedWhitelistExtension[] = ".json"; 49 const char kSanitizedWhitelistExtension[] = ".json";
51 50
52 const char kWhitelistedContent[] = "whitelisted_content"; 51 const char kWhitelistedContent[] = "whitelisted_content";
53 const char kSites[] = "sites"; 52 const char kSites[] = "sites";
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
246 const RawWhitelistReadyCallback& callback) 245 const RawWhitelistReadyCallback& callback)
247 : crx_id_(crx_id), name_(name), callback_(callback) {} 246 : crx_id_(crx_id), name_(name), callback_(callback) {}
248 ~SupervisedUserWhitelistComponentInstallerTraits() override {} 247 ~SupervisedUserWhitelistComponentInstallerTraits() override {}
249 248
250 private: 249 private:
251 // ComponentInstallerTraits overrides: 250 // ComponentInstallerTraits overrides:
252 bool VerifyInstallation(const base::DictionaryValue& manifest, 251 bool VerifyInstallation(const base::DictionaryValue& manifest,
253 const base::FilePath& install_dir) const override; 252 const base::FilePath& install_dir) const override;
254 bool SupportsGroupPolicyEnabledComponentUpdates() const override; 253 bool SupportsGroupPolicyEnabledComponentUpdates() const override;
255 bool RequiresNetworkEncryption() const override; 254 bool RequiresNetworkEncryption() const override;
256 update_client::CrxInstaller::Result OnCustomInstall( 255 bool OnCustomInstall(const base::DictionaryValue& manifest,
257 const base::DictionaryValue& manifest, 256 const base::FilePath& install_dir) override;
258 const base::FilePath& install_dir) override;
259 void ComponentReady(const base::Version& version, 257 void ComponentReady(const base::Version& version,
260 const base::FilePath& install_dir, 258 const base::FilePath& install_dir,
261 std::unique_ptr<base::DictionaryValue> manifest) override; 259 std::unique_ptr<base::DictionaryValue> manifest) override;
262 base::FilePath GetRelativeInstallDir() const override; 260 base::FilePath GetRelativeInstallDir() const override;
263 void GetHash(std::vector<uint8_t>* hash) const override; 261 void GetHash(std::vector<uint8_t>* hash) const override;
264 std::string GetName() const override; 262 std::string GetName() const override;
265 update_client::InstallerAttributes GetInstallerAttributes() const override; 263 update_client::InstallerAttributes GetInstallerAttributes() const override;
266 std::vector<std::string> GetMimeTypes() const override; 264 std::vector<std::string> GetMimeTypes() const override;
267 265
268 std::string crx_id_; 266 std::string crx_id_;
(...skipping 14 matching lines...) Expand all
283 bool SupervisedUserWhitelistComponentInstallerTraits:: 281 bool SupervisedUserWhitelistComponentInstallerTraits::
284 SupportsGroupPolicyEnabledComponentUpdates() const { 282 SupportsGroupPolicyEnabledComponentUpdates() const {
285 return false; 283 return false;
286 } 284 }
287 285
288 bool SupervisedUserWhitelistComponentInstallerTraits:: 286 bool SupervisedUserWhitelistComponentInstallerTraits::
289 RequiresNetworkEncryption() const { 287 RequiresNetworkEncryption() const {
290 return true; 288 return true;
291 } 289 }
292 290
293 update_client::CrxInstaller::Result 291 bool SupervisedUserWhitelistComponentInstallerTraits::OnCustomInstall(
294 SupervisedUserWhitelistComponentInstallerTraits::OnCustomInstall(
295 const base::DictionaryValue& manifest, 292 const base::DictionaryValue& manifest,
296 const base::FilePath& install_dir) { 293 const base::FilePath& install_dir) {
297 // Delete the existing sanitized whitelist. 294 // Delete the existing sanitized whitelist.
298 const bool success = 295 return base::DeleteFile(GetSanitizedWhitelistPath(crx_id_), false);
299 base::DeleteFile(GetSanitizedWhitelistPath(crx_id_), false);
300 return update_client::CrxInstaller::Result(
301 success ? update_client::InstallError::NONE
302 : update_client::InstallError::GENERIC_ERROR);
303 } 296 }
304 297
305 void SupervisedUserWhitelistComponentInstallerTraits::ComponentReady( 298 void SupervisedUserWhitelistComponentInstallerTraits::ComponentReady(
306 const base::Version& version, 299 const base::Version& version,
307 const base::FilePath& install_dir, 300 const base::FilePath& install_dir,
308 std::unique_ptr<base::DictionaryValue> manifest) { 301 std::unique_ptr<base::DictionaryValue> manifest) {
309 // TODO(treib): Before getting the title, we should localize the manifest 302 // TODO(treib): Before getting the title, we should localize the manifest
310 // using extension_l10n_util::LocalizeExtension, but that doesn't exist on 303 // using extension_l10n_util::LocalizeExtension, but that doesn't exist on
311 // Android. crbug.com/558387 304 // Android. crbug.com/558387
312 callback_.Run(GetWhitelistTitle(*manifest), 305 callback_.Run(GetWhitelistTitle(*manifest),
(...skipping 334 matching lines...) Expand 10 before | Expand all | Expand 10 after
647 640
648 // static 641 // static
649 void SupervisedUserWhitelistInstaller::TriggerComponentUpdate( 642 void SupervisedUserWhitelistInstaller::TriggerComponentUpdate(
650 OnDemandUpdater* updater, 643 OnDemandUpdater* updater,
651 const std::string& crx_id) { 644 const std::string& crx_id) {
652 // TODO(sorin): use a callback to check the result (crbug.com/639189). 645 // TODO(sorin): use a callback to check the result (crbug.com/639189).
653 updater->OnDemandUpdate(crx_id, component_updater::Callback()); 646 updater->OnDemandUpdate(crx_id, component_updater::Callback());
654 } 647 }
655 648
656 } // namespace component_updater 649 } // namespace component_updater
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698