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" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/message_loop/message_loop.h" | 12 #include "base/message_loop/message_loop.h" |
13 #include "base/stl_util.h" | 13 #include "base/stl_util.h" |
14 #include "chrome/browser/apps/drive/drive_app_converter.h" | 14 #include "chrome/browser/apps/drive/drive_app_converter.h" |
15 #include "chrome/browser/apps/drive/drive_app_mapping.h" | 15 #include "chrome/browser/apps/drive/drive_app_mapping.h" |
16 #include "chrome/browser/apps/drive/drive_service_bridge.h" | 16 #include "chrome/browser/apps/drive/drive_service_bridge.h" |
17 #include "chrome/browser/drive/drive_app_registry.h" | 17 #include "chrome/browser/drive/drive_app_registry.h" |
18 #include "chrome/browser/extensions/extension_service.h" | 18 #include "chrome/browser/extensions/extension_service.h" |
19 #include "chrome/browser/profiles/profile.h" | 19 #include "chrome/browser/profiles/profile.h" |
20 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 20 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
21 #include "extensions/browser/extension_registry.h" | 21 #include "extensions/browser/extension_registry.h" |
22 #include "extensions/browser/extension_registry_factory.h" | 22 #include "extensions/browser/extension_registry_factory.h" |
23 #include "extensions/browser/extension_system.h" | 23 #include "extensions/browser/extension_system.h" |
24 #include "extensions/common/extension.h" | 24 #include "extensions/common/extension.h" |
25 | 25 |
26 using extensions::Extension; | 26 using extensions::Extension; |
27 using extensions::ExtensionRegistry; | 27 using extensions::ExtensionRegistry; |
| 28 using extensions::UninstalledExtensionInfo; |
28 | 29 |
29 namespace { | 30 namespace { |
30 | 31 |
31 void IgnoreUninstallResult(google_apis::GDataErrorCode) { | 32 void IgnoreUninstallResult(google_apis::GDataErrorCode) { |
32 } | 33 } |
33 | 34 |
34 } // namespace | 35 } // namespace |
35 | 36 |
36 DriveAppProvider::DriveAppProvider(Profile* profile) | 37 DriveAppProvider::DriveAppProvider(Profile* profile) |
37 : profile_(profile), | 38 : profile_(profile), |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 mapping_->IsChromeAppGenerated(existing_chrome_app_id); | 77 mapping_->IsChromeAppGenerated(existing_chrome_app_id); |
77 mapping_->Add(drive_app_id, new_chrome_app_id, is_new_app_generated); | 78 mapping_->Add(drive_app_id, new_chrome_app_id, is_new_app_generated); |
78 | 79 |
79 const Extension* existing_app = | 80 const Extension* existing_app = |
80 ExtensionRegistry::Get(profile_)->GetExtensionById( | 81 ExtensionRegistry::Get(profile_)->GetExtensionById( |
81 existing_chrome_app_id, ExtensionRegistry::EVERYTHING); | 82 existing_chrome_app_id, ExtensionRegistry::EVERYTHING); |
82 if (existing_app && is_existing_app_generated) { | 83 if (existing_app && is_existing_app_generated) { |
83 extensions::ExtensionSystem::Get(profile_) | 84 extensions::ExtensionSystem::Get(profile_) |
84 ->extension_service() | 85 ->extension_service() |
85 ->UninstallExtension(existing_chrome_app_id, | 86 ->UninstallExtension(existing_chrome_app_id, |
86 ExtensionService::UNINSTALL_REASON_SYNC, | 87 UninstalledExtensionInfo::REASON_SYNC, |
87 NULL); | 88 NULL); |
88 } | 89 } |
89 } | 90 } |
90 | 91 |
91 void DriveAppProvider::ProcessDeferredOnExtensionInstalled( | 92 void DriveAppProvider::ProcessDeferredOnExtensionInstalled( |
92 const std::string drive_app_id, | 93 const std::string drive_app_id, |
93 const std::string chrome_app_id) { | 94 const std::string chrome_app_id) { |
94 const Extension* app = ExtensionRegistry::Get(profile_)->GetExtensionById( | 95 const Extension* app = ExtensionRegistry::Get(profile_)->GetExtensionById( |
95 chrome_app_id, ExtensionRegistry::EVERYTHING); | 96 chrome_app_id, ExtensionRegistry::EVERYTHING); |
96 if (!app) | 97 if (!app) |
(...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
187 | 188 |
188 const Extension* existing_app = | 189 const Extension* existing_app = |
189 ExtensionRegistry::Get(profile_) | 190 ExtensionRegistry::Get(profile_) |
190 ->GetExtensionById(chrome_app_id, ExtensionRegistry::EVERYTHING); | 191 ->GetExtensionById(chrome_app_id, ExtensionRegistry::EVERYTHING); |
191 if (!existing_app) | 192 if (!existing_app) |
192 return; | 193 return; |
193 | 194 |
194 extensions::ExtensionSystem::Get(profile_) | 195 extensions::ExtensionSystem::Get(profile_) |
195 ->extension_service() | 196 ->extension_service() |
196 ->UninstallExtension( | 197 ->UninstallExtension( |
197 chrome_app_id, ExtensionService::UNINSTALL_REASON_SYNC, NULL); | 198 chrome_app_id, UninstalledExtensionInfo::REASON_SYNC, NULL); |
198 } | 199 } |
199 | 200 |
200 void DriveAppProvider::OnDriveAppRegistryUpdated() { | 201 void DriveAppProvider::OnDriveAppRegistryUpdated() { |
201 service_bridge_->GetAppRegistry()->GetAppList(&drive_apps_); | 202 service_bridge_->GetAppRegistry()->GetAppList(&drive_apps_); |
202 | 203 |
203 IdSet current_ids; | 204 IdSet current_ids; |
204 for (size_t i = 0; i < drive_apps_.size(); ++i) | 205 for (size_t i = 0; i < drive_apps_.size(); ++i) |
205 current_ids.insert(drive_apps_[i].app_id); | 206 current_ids.insert(drive_apps_[i].app_id); |
206 | 207 |
207 const IdSet existing_ids = mapping_->GetDriveAppIds(); | 208 const IdSet existing_ids = mapping_->GetDriveAppIds(); |
(...skipping 49 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
257 void DriveAppProvider::OnExtensionUninstalled( | 258 void DriveAppProvider::OnExtensionUninstalled( |
258 content::BrowserContext* browser_context, | 259 content::BrowserContext* browser_context, |
259 const Extension* extension) { | 260 const Extension* extension) { |
260 std::string drive_app_id = mapping_->GetDriveApp(extension->id()); | 261 std::string drive_app_id = mapping_->GetDriveApp(extension->id()); |
261 if (drive_app_id.empty()) | 262 if (drive_app_id.empty()) |
262 return; | 263 return; |
263 | 264 |
264 service_bridge_->GetAppRegistry()->UninstallApp( | 265 service_bridge_->GetAppRegistry()->UninstallApp( |
265 drive_app_id, base::Bind(&IgnoreUninstallResult)); | 266 drive_app_id, base::Bind(&IgnoreUninstallResult)); |
266 } | 267 } |
OLD | NEW |