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

Side by Side Diff: chrome/browser/apps/drive/drive_app_provider.cc

Issue 405433003: Apps&Extensions for supervised users: Allow the custodian to remotely uninstall extensions. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: other UNINSTALL_REASON_SYNC occurrences Created 6 years, 5 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 | Annotate | Revision Log
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/apps/drive/drive_app_provider.h" 5 #include "chrome/browser/apps/drive/drive_app_provider.h"
6 6
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
73 return; 73 return;
74 74
75 const bool is_existing_app_generated = 75 const bool is_existing_app_generated =
76 mapping_->IsChromeAppGenerated(existing_chrome_app_id); 76 mapping_->IsChromeAppGenerated(existing_chrome_app_id);
77 mapping_->Add(drive_app_id, new_chrome_app_id, is_new_app_generated); 77 mapping_->Add(drive_app_id, new_chrome_app_id, is_new_app_generated);
78 78
79 const Extension* existing_app = 79 const Extension* existing_app =
80 ExtensionRegistry::Get(profile_)->GetExtensionById( 80 ExtensionRegistry::Get(profile_)->GetExtensionById(
81 existing_chrome_app_id, ExtensionRegistry::EVERYTHING); 81 existing_chrome_app_id, ExtensionRegistry::EVERYTHING);
82 if (existing_app && is_existing_app_generated) { 82 if (existing_app && is_existing_app_generated) {
83 // If the new app was installed by the custodian, also use custodian
84 // privileges for removing the old one.
85 ExtensionService::UninstallReason reason =
86 new_app->was_installed_by_custodian() ?
87 ExtensionService::UNINSTALL_REASON_SYNC_BY_CUSTODIAN :
88 ExtensionService::UNINSTALL_REASON_SYNC;
89
83 extensions::ExtensionSystem::Get(profile_) 90 extensions::ExtensionSystem::Get(profile_)
84 ->extension_service() 91 ->extension_service()
85 ->UninstallExtension(existing_chrome_app_id, 92 ->UninstallExtension(existing_chrome_app_id, reason, NULL);
86 ExtensionService::UNINSTALL_REASON_SYNC,
87 NULL);
88 } 93 }
89 } 94 }
90 95
91 void DriveAppProvider::ProcessDeferredOnExtensionInstalled( 96 void DriveAppProvider::ProcessDeferredOnExtensionInstalled(
92 const std::string drive_app_id, 97 const std::string drive_app_id,
93 const std::string chrome_app_id) { 98 const std::string chrome_app_id) {
94 const Extension* app = ExtensionRegistry::Get(profile_)->GetExtensionById( 99 const Extension* app = ExtensionRegistry::Get(profile_)->GetExtensionById(
95 chrome_app_id, ExtensionRegistry::EVERYTHING); 100 chrome_app_id, ExtensionRegistry::EVERYTHING);
96 if (!app) 101 if (!app)
97 return; 102 return;
(...skipping 86 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 189
185 if (chrome_app_id.empty() || !is_generated) 190 if (chrome_app_id.empty() || !is_generated)
186 return; 191 return;
187 192
188 const Extension* existing_app = 193 const Extension* existing_app =
189 ExtensionRegistry::Get(profile_) 194 ExtensionRegistry::Get(profile_)
190 ->GetExtensionById(chrome_app_id, ExtensionRegistry::EVERYTHING); 195 ->GetExtensionById(chrome_app_id, ExtensionRegistry::EVERYTHING);
191 if (!existing_app) 196 if (!existing_app)
192 return; 197 return;
193 198
199 ExtensionService::UninstallReason reason =
200 existing_app->was_installed_by_custodian() ?
201 ExtensionService::UNINSTALL_REASON_SYNC_BY_CUSTODIAN :
202 ExtensionService::UNINSTALL_REASON_SYNC;
194 extensions::ExtensionSystem::Get(profile_) 203 extensions::ExtensionSystem::Get(profile_)
195 ->extension_service() 204 ->extension_service()
196 ->UninstallExtension( 205 ->UninstallExtension(chrome_app_id, reason, NULL);
197 chrome_app_id, ExtensionService::UNINSTALL_REASON_SYNC, NULL);
198 } 206 }
199 207
200 void DriveAppProvider::OnDriveAppRegistryUpdated() { 208 void DriveAppProvider::OnDriveAppRegistryUpdated() {
201 service_bridge_->GetAppRegistry()->GetAppList(&drive_apps_); 209 service_bridge_->GetAppRegistry()->GetAppList(&drive_apps_);
202 210
203 IdSet current_ids; 211 IdSet current_ids;
204 for (size_t i = 0; i < drive_apps_.size(); ++i) 212 for (size_t i = 0; i < drive_apps_.size(); ++i)
205 current_ids.insert(drive_apps_[i].app_id); 213 current_ids.insert(drive_apps_[i].app_id);
206 214
207 const IdSet existing_ids = mapping_->GetDriveAppIds(); 215 const IdSet existing_ids = mapping_->GetDriveAppIds();
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
258 void DriveAppProvider::OnExtensionUninstalled( 266 void DriveAppProvider::OnExtensionUninstalled(
259 content::BrowserContext* browser_context, 267 content::BrowserContext* browser_context,
260 const Extension* extension) { 268 const Extension* extension) {
261 std::string drive_app_id = mapping_->GetDriveApp(extension->id()); 269 std::string drive_app_id = mapping_->GetDriveApp(extension->id());
262 if (drive_app_id.empty()) 270 if (drive_app_id.empty())
263 return; 271 return;
264 272
265 service_bridge_->GetAppRegistry()->UninstallApp( 273 service_bridge_->GetAppRegistry()->UninstallApp(
266 drive_app_id, base::Bind(&IgnoreUninstallResult)); 274 drive_app_id, base::Bind(&IgnoreUninstallResult));
267 } 275 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_service.h » ('j') | chrome/browser/extensions/extension_service.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698