| 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/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 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 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 extensions::ExtensionSystem::Get(profile_) | 83 extensions::ExtensionSystem::Get(profile_) |
| 84 ->extension_service() | 84 ->extension_service() |
| 85 ->UninstallExtension(existing_chrome_app_id, | 85 ->UninstallExtension(existing_chrome_app_id, false, NULL); |
| 86 ExtensionService::UNINSTALL_REASON_SYNC, | |
| 87 NULL); | |
| 88 } | 86 } |
| 89 } | 87 } |
| 90 | 88 |
| 91 void DriveAppProvider::ProcessDeferredOnExtensionInstalled( | 89 void DriveAppProvider::ProcessDeferredOnExtensionInstalled( |
| 92 const std::string drive_app_id, | 90 const std::string drive_app_id, |
| 93 const std::string chrome_app_id) { | 91 const std::string chrome_app_id) { |
| 94 const Extension* app = ExtensionRegistry::Get(profile_)->GetExtensionById( | 92 const Extension* app = ExtensionRegistry::Get(profile_)->GetExtensionById( |
| 95 chrome_app_id, ExtensionRegistry::EVERYTHING); | 93 chrome_app_id, ExtensionRegistry::EVERYTHING); |
| 96 if (!app) | 94 if (!app) |
| 97 return; | 95 return; |
| (...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 186 return; | 184 return; |
| 187 | 185 |
| 188 const Extension* existing_app = | 186 const Extension* existing_app = |
| 189 ExtensionRegistry::Get(profile_) | 187 ExtensionRegistry::Get(profile_) |
| 190 ->GetExtensionById(chrome_app_id, ExtensionRegistry::EVERYTHING); | 188 ->GetExtensionById(chrome_app_id, ExtensionRegistry::EVERYTHING); |
| 191 if (!existing_app) | 189 if (!existing_app) |
| 192 return; | 190 return; |
| 193 | 191 |
| 194 extensions::ExtensionSystem::Get(profile_) | 192 extensions::ExtensionSystem::Get(profile_) |
| 195 ->extension_service() | 193 ->extension_service() |
| 196 ->UninstallExtension( | 194 ->UninstallExtension(chrome_app_id, false, NULL); |
| 197 chrome_app_id, ExtensionService::UNINSTALL_REASON_SYNC, NULL); | |
| 198 } | 195 } |
| 199 | 196 |
| 200 void DriveAppProvider::OnDriveAppRegistryUpdated() { | 197 void DriveAppProvider::OnDriveAppRegistryUpdated() { |
| 201 service_bridge_->GetAppRegistry()->GetAppList(&drive_apps_); | 198 service_bridge_->GetAppRegistry()->GetAppList(&drive_apps_); |
| 202 | 199 |
| 203 IdSet current_ids; | 200 IdSet current_ids; |
| 204 for (size_t i = 0; i < drive_apps_.size(); ++i) | 201 for (size_t i = 0; i < drive_apps_.size(); ++i) |
| 205 current_ids.insert(drive_apps_[i].app_id); | 202 current_ids.insert(drive_apps_[i].app_id); |
| 206 | 203 |
| 207 const IdSet existing_ids = mapping_->GetDriveAppIds(); | 204 const IdSet existing_ids = mapping_->GetDriveAppIds(); |
| (...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 257 void DriveAppProvider::OnExtensionUninstalled( | 254 void DriveAppProvider::OnExtensionUninstalled( |
| 258 content::BrowserContext* browser_context, | 255 content::BrowserContext* browser_context, |
| 259 const Extension* extension) { | 256 const Extension* extension) { |
| 260 std::string drive_app_id = mapping_->GetDriveApp(extension->id()); | 257 std::string drive_app_id = mapping_->GetDriveApp(extension->id()); |
| 261 if (drive_app_id.empty()) | 258 if (drive_app_id.empty()) |
| 262 return; | 259 return; |
| 263 | 260 |
| 264 service_bridge_->GetAppRegistry()->UninstallApp( | 261 service_bridge_->GetAppRegistry()->UninstallApp( |
| 265 drive_app_id, base::Bind(&IgnoreUninstallResult)); | 262 drive_app_id, base::Bind(&IgnoreUninstallResult)); |
| 266 } | 263 } |
| OLD | NEW |