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 <stddef.h> | 7 #include <stddef.h> |
8 #include <utility> | 8 #include <utility> |
9 #include <vector> | 9 #include <vector> |
10 | 10 |
11 #include "base/bind.h" | 11 #include "base/bind.h" |
12 #include "base/bind_helpers.h" | 12 #include "base/bind_helpers.h" |
13 #include "base/location.h" | 13 #include "base/location.h" |
14 #include "base/logging.h" | 14 #include "base/logging.h" |
| 15 #include "base/memory/ptr_util.h" |
15 #include "base/single_thread_task_runner.h" | 16 #include "base/single_thread_task_runner.h" |
16 #include "base/stl_util.h" | 17 #include "base/stl_util.h" |
17 #include "base/threading/thread_task_runner_handle.h" | 18 #include "base/threading/thread_task_runner_handle.h" |
18 #include "chrome/browser/apps/drive/drive_app_converter.h" | 19 #include "chrome/browser/apps/drive/drive_app_converter.h" |
19 #include "chrome/browser/apps/drive/drive_app_mapping.h" | 20 #include "chrome/browser/apps/drive/drive_app_mapping.h" |
20 #include "chrome/browser/apps/drive/drive_app_uninstall_sync_service.h" | 21 #include "chrome/browser/apps/drive/drive_app_uninstall_sync_service.h" |
21 #include "chrome/browser/apps/drive/drive_service_bridge.h" | 22 #include "chrome/browser/apps/drive/drive_service_bridge.h" |
22 #include "chrome/browser/extensions/extension_service.h" | 23 #include "chrome/browser/extensions/extension_service.h" |
23 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
24 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" | 25 #include "chrome/common/extensions/manifest_handlers/app_launch_info.h" |
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
141 void DriveAppProvider::SchedulePendingConverters() { | 142 void DriveAppProvider::SchedulePendingConverters() { |
142 if (pending_converters_.empty()) | 143 if (pending_converters_.empty()) |
143 return; | 144 return; |
144 | 145 |
145 if (!pending_converters_.front()->IsStarted()) | 146 if (!pending_converters_.front()->IsStarted()) |
146 pending_converters_.front()->Start(); | 147 pending_converters_.front()->Start(); |
147 } | 148 } |
148 | 149 |
149 void DriveAppProvider::OnLocalAppConverted(const DriveAppConverter* converter, | 150 void DriveAppProvider::OnLocalAppConverted(const DriveAppConverter* converter, |
150 bool success) { | 151 bool success) { |
151 DCHECK_EQ(pending_converters_.front(), converter); | 152 DCHECK_EQ(pending_converters_.front().get(), converter); |
152 | 153 |
153 if (success) { | 154 if (success) { |
154 const bool was_generated = | 155 const bool was_generated = |
155 mapping_->GetDriveApp(converter->extension()->id()) == | 156 mapping_->GetDriveApp(converter->extension()->id()) == |
156 converter->drive_app_info().app_id && | 157 converter->drive_app_info().app_id && |
157 mapping_->IsChromeAppGenerated(converter->extension()->id()); | 158 mapping_->IsChromeAppGenerated(converter->extension()->id()); |
158 UpdateMappingAndExtensionSystem( | 159 UpdateMappingAndExtensionSystem( |
159 converter->drive_app_info().app_id, | 160 converter->drive_app_info().app_id, |
160 converter->extension(), | 161 converter->extension(), |
161 converter->is_new_install() || was_generated); | 162 converter->is_new_install() || was_generated); |
(...skipping 30 matching lines...) Expand all Loading... |
192 ExtensionRegistry::Get(profile_)->GetExtensionById( | 193 ExtensionRegistry::Get(profile_)->GetExtensionById( |
193 drive_app.product_id, ExtensionRegistry::EVERYTHING); | 194 drive_app.product_id, ExtensionRegistry::EVERYTHING); |
194 if (chrome_app) { | 195 if (chrome_app) { |
195 UpdateMappingAndExtensionSystem(drive_app.app_id, chrome_app, false); | 196 UpdateMappingAndExtensionSystem(drive_app.app_id, chrome_app, false); |
196 return; | 197 return; |
197 } | 198 } |
198 | 199 |
199 if (IsMappedUrlAppUpToDate(drive_app)) | 200 if (IsMappedUrlAppUpToDate(drive_app)) |
200 return; | 201 return; |
201 | 202 |
202 ScopedVector<DriveAppConverter>::iterator it = pending_converters_.begin(); | 203 auto it = pending_converters_.begin(); |
203 while (it != pending_converters_.end()) { | 204 while (it != pending_converters_.end()) { |
204 if (!(*it)->IsStarted() && | 205 if (!(*it)->IsStarted() && |
205 (*it)->drive_app_info().app_id == drive_app.app_id) { | 206 (*it)->drive_app_info().app_id == drive_app.app_id) { |
206 it = pending_converters_.erase(it); | 207 it = pending_converters_.erase(it); |
207 } else { | 208 } else { |
208 ++it; | 209 ++it; |
209 } | 210 } |
210 } | 211 } |
211 | 212 |
212 pending_converters_.push_back( | 213 pending_converters_.push_back(base::MakeUnique<DriveAppConverter>( |
213 new DriveAppConverter(profile_, | 214 profile_, drive_app, |
214 drive_app, | 215 base::Bind(&DriveAppProvider::OnLocalAppConverted, |
215 base::Bind(&DriveAppProvider::OnLocalAppConverted, | 216 base::Unretained(this)))); |
216 base::Unretained(this)))); | |
217 } | 217 } |
218 | 218 |
219 void DriveAppProvider::ProcessRemovedDriveApp(const std::string& drive_app_id) { | 219 void DriveAppProvider::ProcessRemovedDriveApp(const std::string& drive_app_id) { |
220 const std::string chrome_app_id = mapping_->GetChromeApp(drive_app_id); | 220 const std::string chrome_app_id = mapping_->GetChromeApp(drive_app_id); |
221 const bool is_generated = mapping_->IsChromeAppGenerated(chrome_app_id); | 221 const bool is_generated = mapping_->IsChromeAppGenerated(chrome_app_id); |
222 mapping_->Remove(drive_app_id); | 222 mapping_->Remove(drive_app_id); |
223 | 223 |
224 if (chrome_app_id.empty() || !is_generated) | 224 if (chrome_app_id.empty() || !is_generated) |
225 return; | 225 return; |
226 | 226 |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
327 service_bridge_->GetAppRegistry()->UninstallApp( | 327 service_bridge_->GetAppRegistry()->UninstallApp( |
328 drive_app_id, base::Bind(&IgnoreUninstallResult)); | 328 drive_app_id, base::Bind(&IgnoreUninstallResult)); |
329 } else { | 329 } else { |
330 mapping_->AddUninstalledDriveApp(drive_app_id); | 330 mapping_->AddUninstalledDriveApp(drive_app_id); |
331 uninstall_sync_service_->TrackUninstalledDriveApp(drive_app_id); | 331 uninstall_sync_service_->TrackUninstalledDriveApp(drive_app_id); |
332 } | 332 } |
333 | 333 |
334 return; | 334 return; |
335 } | 335 } |
336 } | 336 } |
OLD | NEW |