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

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

Issue 879993005: Add support for uninstalling components and use it in SupervisedUserWhitelistInstaller. (Closed) Base URL: https://chromium.googlesource.com/chromium/src@master
Patch Set: x Created 5 years, 10 months 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 <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
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 DefaultComponentInstaller* installer = 143 scoped_refptr<DefaultComponentInstaller> installer(
143 new DefaultComponentInstaller(traits.Pass()); 144 new DefaultComponentInstaller(traits.Pass()));
144 145
145 // Takes ownership of |installer|.
146 installer->Register(cus_); 146 installer->Register(cus_);
147 147
148 installers_[crx_id] = installer;
149
148 if (newly_added) 150 if (newly_added)
149 TriggerComponentUpdate(&cus_->GetOnDemandUpdater(), crx_id); 151 TriggerComponentUpdate(&cus_->GetOnDemandUpdater(), crx_id);
150 } 152 }
151 153
152 void SupervisedUserWhitelistInstallerImpl::UnregisterWhitelist( 154 void SupervisedUserWhitelistInstallerImpl::UninstallWhitelist(
153 const std::string& id) { 155 const std::string& crx_id) {
154 // TODO(bauerb): Implement! 156 auto it = installers_.find(crx_id);
Marc Treib 2015/02/04 09:55:46 nit: DCHECK_NE(it, installers_.end()) ?
Bernhard Bauer 2015/02/04 11:28:40 Done. Not using DCHECK_NE, because AFAICR that did
155 NOTIMPLEMENTED(); 157 it->second->Unregister(cus_);
158 installers_.erase(it);
156 } 159 }
157 160
158 } // namespace 161 } // namespace
159 162
160 // static 163 // static
161 scoped_ptr<SupervisedUserWhitelistInstaller> 164 scoped_ptr<SupervisedUserWhitelistInstaller>
162 SupervisedUserWhitelistInstaller::Create(ComponentUpdateService* cus) { 165 SupervisedUserWhitelistInstaller::Create(ComponentUpdateService* cus) {
163 return make_scoped_ptr(new SupervisedUserWhitelistInstallerImpl(cus)); 166 return make_scoped_ptr(new SupervisedUserWhitelistInstallerImpl(cus));
164 } 167 }
165 168
(...skipping 20 matching lines...) Expand all
186 } 189 }
187 190
188 // static 191 // static
189 void SupervisedUserWhitelistInstaller::TriggerComponentUpdate( 192 void SupervisedUserWhitelistInstaller::TriggerComponentUpdate(
190 OnDemandUpdater* updater, 193 OnDemandUpdater* updater,
191 const std::string& crx_id) { 194 const std::string& crx_id) {
192 updater->OnDemandUpdate(crx_id); 195 updater->OnDemandUpdate(crx_id);
193 } 196 }
194 197
195 } // namespace component_updater 198 } // namespace component_updater
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698