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

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

Issue 398083002: Add "UninstallReason" parameter to ExtensionRegistryObserver::OnExtensionUninstalled. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix header file. 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
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"
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/browser/uninstall_reason.h"
24 #include "extensions/common/extension.h" 25 #include "extensions/common/extension.h"
25 26
26 using extensions::Extension; 27 using extensions::Extension;
27 using extensions::ExtensionRegistry; 28 using extensions::ExtensionRegistry;
28 29
29 namespace { 30 namespace {
30 31
31 void IgnoreUninstallResult(google_apis::GDataErrorCode) { 32 void IgnoreUninstallResult(google_apis::GDataErrorCode) {
32 } 33 }
33 34
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
75 const bool is_existing_app_generated = 76 const bool is_existing_app_generated =
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(
86 ExtensionService::UNINSTALL_REASON_SYNC, 87 existing_chrome_app_id, extensions::UNINSTALL_REASON_SYNC, NULL);
87 NULL);
88 } 88 }
89 } 89 }
90 90
91 void DriveAppProvider::ProcessDeferredOnExtensionInstalled( 91 void DriveAppProvider::ProcessDeferredOnExtensionInstalled(
92 const std::string drive_app_id, 92 const std::string drive_app_id,
93 const std::string chrome_app_id) { 93 const std::string chrome_app_id) {
94 const Extension* app = ExtensionRegistry::Get(profile_)->GetExtensionById( 94 const Extension* app = ExtensionRegistry::Get(profile_)->GetExtensionById(
95 chrome_app_id, ExtensionRegistry::EVERYTHING); 95 chrome_app_id, ExtensionRegistry::EVERYTHING);
96 if (!app) 96 if (!app)
97 return; 97 return;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
187 187
188 const Extension* existing_app = 188 const Extension* existing_app =
189 ExtensionRegistry::Get(profile_) 189 ExtensionRegistry::Get(profile_)
190 ->GetExtensionById(chrome_app_id, ExtensionRegistry::EVERYTHING); 190 ->GetExtensionById(chrome_app_id, ExtensionRegistry::EVERYTHING);
191 if (!existing_app) 191 if (!existing_app)
192 return; 192 return;
193 193
194 extensions::ExtensionSystem::Get(profile_) 194 extensions::ExtensionSystem::Get(profile_)
195 ->extension_service() 195 ->extension_service()
196 ->UninstallExtension( 196 ->UninstallExtension(
197 chrome_app_id, ExtensionService::UNINSTALL_REASON_SYNC, NULL); 197 chrome_app_id, extensions::UNINSTALL_REASON_SYNC, NULL);
198 } 198 }
199 199
200 void DriveAppProvider::OnDriveAppRegistryUpdated() { 200 void DriveAppProvider::OnDriveAppRegistryUpdated() {
201 service_bridge_->GetAppRegistry()->GetAppList(&drive_apps_); 201 service_bridge_->GetAppRegistry()->GetAppList(&drive_apps_);
202 202
203 IdSet current_ids; 203 IdSet current_ids;
204 for (size_t i = 0; i < drive_apps_.size(); ++i) 204 for (size_t i = 0; i < drive_apps_.size(); ++i)
205 current_ids.insert(drive_apps_[i].app_id); 205 current_ids.insert(drive_apps_[i].app_id);
206 206
207 const IdSet existing_ids = mapping_->GetDriveAppIds(); 207 const IdSet existing_ids = mapping_->GetDriveAppIds();
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 weak_ptr_factory_.GetWeakPtr(), 250 weak_ptr_factory_.GetWeakPtr(),
251 drive_apps_[i].app_id, 251 drive_apps_[i].app_id,
252 extension->id())); 252 extension->id()));
253 return; 253 return;
254 } 254 }
255 } 255 }
256 } 256 }
257 257
258 void DriveAppProvider::OnExtensionUninstalled( 258 void DriveAppProvider::OnExtensionUninstalled(
259 content::BrowserContext* browser_context, 259 content::BrowserContext* browser_context,
260 const Extension* extension) { 260 const Extension* extension,
261 extensions::UninstallReason reason) {
261 std::string drive_app_id = mapping_->GetDriveApp(extension->id()); 262 std::string drive_app_id = mapping_->GetDriveApp(extension->id());
262 if (drive_app_id.empty()) 263 if (drive_app_id.empty())
263 return; 264 return;
264 265
265 service_bridge_->GetAppRegistry()->UninstallApp( 266 service_bridge_->GetAppRegistry()->UninstallApp(
266 drive_app_id, base::Bind(&IgnoreUninstallResult)); 267 drive_app_id, base::Bind(&IgnoreUninstallResult));
267 } 268 }
OLDNEW
« no previous file with comments | « chrome/browser/apps/drive/drive_app_provider.h ('k') | chrome/browser/apps/ephemeral_app_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698