Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 <vector> | 7 #include <vector> |
| 8 | 8 |
| 9 #include "base/callback.h" | 9 #include "base/callback.h" |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| (...skipping 103 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 114 public: | 114 public: |
| 115 explicit SupervisedUserWhitelistInstallerImpl(ComponentUpdateService* cus); | 115 explicit SupervisedUserWhitelistInstallerImpl(ComponentUpdateService* cus); |
| 116 ~SupervisedUserWhitelistInstallerImpl() override {} | 116 ~SupervisedUserWhitelistInstallerImpl() override {} |
| 117 | 117 |
| 118 private: | 118 private: |
| 119 // SupervisedUserWhitelistInstaller overrides: | 119 // SupervisedUserWhitelistInstaller overrides: |
| 120 void RegisterWhitelist(const std::string& crx_id, | 120 void RegisterWhitelist(const std::string& crx_id, |
| 121 const std::string& name, | 121 const std::string& name, |
| 122 bool newly_added, | 122 bool newly_added, |
| 123 const WhitelistReadyCallback& callback) override; | 123 const WhitelistReadyCallback& callback) override; |
| 124 void UnregisterWhitelist(const std::string& crx_id) override; | 124 void UninstallWhitelist(const std::string& crx_id) override; |
| 125 | 125 |
| 126 ComponentUpdateService* cus_; | 126 ComponentUpdateService* cus_; |
| 127 std::map<std::string, scoped_refptr<DefaultComponentInstaller>> installers_; | |
| 127 }; | 128 }; |
| 128 | 129 |
| 129 SupervisedUserWhitelistInstallerImpl::SupervisedUserWhitelistInstallerImpl( | 130 SupervisedUserWhitelistInstallerImpl::SupervisedUserWhitelistInstallerImpl( |
| 130 ComponentUpdateService* cus) | 131 ComponentUpdateService* cus) |
| 131 : cus_(cus) { | 132 : cus_(cus) { |
| 132 } | 133 } |
| 133 | 134 |
| 134 void SupervisedUserWhitelistInstallerImpl::RegisterWhitelist( | 135 void SupervisedUserWhitelistInstallerImpl::RegisterWhitelist( |
| 135 const std::string& crx_id, | 136 const std::string& crx_id, |
| 136 const std::string& name, | 137 const std::string& name, |
| 137 bool newly_added, | 138 bool newly_added, |
| 138 const WhitelistReadyCallback& callback) { | 139 const WhitelistReadyCallback& callback) { |
| 139 scoped_ptr<ComponentInstallerTraits> traits( | 140 scoped_ptr<ComponentInstallerTraits> traits( |
| 140 new SupervisedUserWhitelistComponentInstallerTraits(crx_id, name, | 141 new SupervisedUserWhitelistComponentInstallerTraits(crx_id, name, |
| 141 callback)); | 142 callback)); |
| 142 scoped_refptr<DefaultComponentInstaller> installer( | 143 scoped_refptr<DefaultComponentInstaller> installer( |
| 143 new DefaultComponentInstaller(traits.Pass())); | 144 new DefaultComponentInstaller(traits.Pass())); |
| 144 | 145 |
| 145 installer->Register(cus_); | 146 installer->Register(cus_); |
| 146 | 147 |
| 148 installers_[crx_id] = installer; | |
|
Sorin Jianu
2015/02/05 22:55:35
Do we have many crx ids associated with this produ
Bernhard Bauer
2015/02/05 23:57:34
Yeah, there can be multiple whitelists, each with
Sorin Jianu
2015/02/06 00:22:04
Do we have an idea about how many whitelists are w
Bernhard Bauer
2015/02/06 16:05:05
The design doc is at go/unichrome-whitelists-clank
| |
| 149 | |
| 147 if (newly_added) | 150 if (newly_added) |
| 148 TriggerComponentUpdate(&cus_->GetOnDemandUpdater(), crx_id); | 151 TriggerComponentUpdate(&cus_->GetOnDemandUpdater(), crx_id); |
| 149 } | 152 } |
| 150 | 153 |
| 151 void SupervisedUserWhitelistInstallerImpl::UnregisterWhitelist( | 154 void SupervisedUserWhitelistInstallerImpl::UninstallWhitelist( |
| 152 const std::string& id) { | 155 const std::string& crx_id) { |
| 153 // TODO(bauerb): Implement! | 156 auto it = installers_.find(crx_id); |
| 154 NOTIMPLEMENTED(); | 157 DCHECK(it != installers_.end()); |
| 158 it->second->Unregister(cus_); | |
| 159 installers_.erase(it); | |
| 155 } | 160 } |
| 156 | 161 |
| 157 } // namespace | 162 } // namespace |
| 158 | 163 |
| 159 // static | 164 // static |
| 160 scoped_ptr<SupervisedUserWhitelistInstaller> | 165 scoped_ptr<SupervisedUserWhitelistInstaller> |
| 161 SupervisedUserWhitelistInstaller::Create(ComponentUpdateService* cus) { | 166 SupervisedUserWhitelistInstaller::Create(ComponentUpdateService* cus) { |
| 162 return make_scoped_ptr(new SupervisedUserWhitelistInstallerImpl(cus)); | 167 return make_scoped_ptr(new SupervisedUserWhitelistInstallerImpl(cus)); |
| 163 } | 168 } |
| 164 | 169 |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 185 } | 190 } |
| 186 | 191 |
| 187 // static | 192 // static |
| 188 void SupervisedUserWhitelistInstaller::TriggerComponentUpdate( | 193 void SupervisedUserWhitelistInstaller::TriggerComponentUpdate( |
| 189 OnDemandUpdater* updater, | 194 OnDemandUpdater* updater, |
| 190 const std::string& crx_id) { | 195 const std::string& crx_id) { |
| 191 updater->OnDemandUpdate(crx_id); | 196 updater->OnDemandUpdate(crx_id); |
| 192 } | 197 } |
| 193 | 198 |
| 194 } // namespace component_updater | 199 } // namespace component_updater |
| OLD | NEW |