OLD | NEW |
1 // Copyright 2013 The Chromium Authors. All rights reserved. | 1 // Copyright 2013 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/sync_file_system/local/local_file_sync_service.h" | 5 #include "chrome/browser/sync_file_system/local/local_file_sync_service.h" |
6 | 6 |
7 #include "base/stl_util.h" | 7 #include "base/stl_util.h" |
8 #include "chrome/browser/extensions/extension_service.h" | |
9 #include "chrome/browser/extensions/extension_util.h" | 8 #include "chrome/browser/extensions/extension_util.h" |
10 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
11 #include "chrome/browser/sync_file_system/file_change.h" | 10 #include "chrome/browser/sync_file_system/file_change.h" |
12 #include "chrome/browser/sync_file_system/local/local_file_change_tracker.h" | 11 #include "chrome/browser/sync_file_system/local/local_file_change_tracker.h" |
13 #include "chrome/browser/sync_file_system/local/local_file_sync_context.h" | 12 #include "chrome/browser/sync_file_system/local/local_file_sync_context.h" |
14 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" | 13 #include "chrome/browser/sync_file_system/local/sync_file_system_backend.h" |
15 #include "chrome/browser/sync_file_system/local_change_processor.h" | 14 #include "chrome/browser/sync_file_system/local_change_processor.h" |
16 #include "chrome/browser/sync_file_system/logger.h" | 15 #include "chrome/browser/sync_file_system/logger.h" |
17 #include "chrome/browser/sync_file_system/sync_file_metadata.h" | 16 #include "chrome/browser/sync_file_system/sync_file_metadata.h" |
18 #include "content/public/browser/browser_context.h" | 17 #include "content/public/browser/browser_context.h" |
19 #include "content/public/browser/browser_thread.h" | 18 #include "content/public/browser/browser_thread.h" |
20 #include "content/public/browser/site_instance.h" | 19 #include "content/public/browser/site_instance.h" |
21 #include "content/public/browser/storage_partition.h" | 20 #include "content/public/browser/storage_partition.h" |
22 #include "extensions/browser/extension_system.h" | 21 #include "extensions/browser/extension_registry.h" |
| 22 #include "extensions/common/extension_set.h" |
23 #include "url/gurl.h" | 23 #include "url/gurl.h" |
24 #include "webkit/browser/fileapi/file_system_context.h" | 24 #include "webkit/browser/fileapi/file_system_context.h" |
25 #include "webkit/browser/fileapi/file_system_url.h" | 25 #include "webkit/browser/fileapi/file_system_url.h" |
26 #include "webkit/common/blob/scoped_file.h" | 26 #include "webkit/common/blob/scoped_file.h" |
27 | 27 |
28 using content::BrowserThread; | 28 using content::BrowserThread; |
29 using fileapi::FileSystemURL; | 29 using fileapi::FileSystemURL; |
30 | 30 |
31 namespace sync_file_system { | 31 namespace sync_file_system { |
32 | 32 |
(...skipping 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
200 void LocalFileSyncService::PrepareForProcessRemoteChange( | 200 void LocalFileSyncService::PrepareForProcessRemoteChange( |
201 const FileSystemURL& url, | 201 const FileSystemURL& url, |
202 const PrepareChangeCallback& callback) { | 202 const PrepareChangeCallback& callback) { |
203 DVLOG(1) << "PrepareForProcessRemoteChange: " << url.DebugString(); | 203 DVLOG(1) << "PrepareForProcessRemoteChange: " << url.DebugString(); |
204 | 204 |
205 if (!ContainsKey(origin_to_contexts_, url.origin())) { | 205 if (!ContainsKey(origin_to_contexts_, url.origin())) { |
206 // This could happen if a remote sync is triggered for the app that hasn't | 206 // This could happen if a remote sync is triggered for the app that hasn't |
207 // been initialized in this service. | 207 // been initialized in this service. |
208 DCHECK(profile_); | 208 DCHECK(profile_); |
209 // The given url.origin() must be for valid installed app. | 209 // The given url.origin() must be for valid installed app. |
210 ExtensionService* extension_service = | 210 const extensions::Extension* extension = |
211 extensions::ExtensionSystem::Get(profile_)->extension_service(); | 211 extensions::ExtensionRegistry::Get(profile_) |
212 const extensions::Extension* extension = extension_service->GetInstalledApp( | 212 ->enabled_extensions().GetAppByURL(url.origin()); |
213 url.origin()); | |
214 if (!extension) { | 213 if (!extension) { |
215 util::Log( | 214 util::Log( |
216 logging::LOG_WARNING, | 215 logging::LOG_WARNING, |
217 FROM_HERE, | 216 FROM_HERE, |
218 "PrepareForProcessRemoteChange called for non-existing origin: %s", | 217 "PrepareForProcessRemoteChange called for non-existing origin: %s", |
219 url.origin().spec().c_str()); | 218 url.origin().spec().c_str()); |
220 | 219 |
221 // The extension has been uninstalled and this method is called | 220 // The extension has been uninstalled and this method is called |
222 // before the remote changes for the origin are removed. | 221 // before the remote changes for the origin are removed. |
223 callback.Run(SYNC_STATUS_NO_CHANGE_TO_SYNC, | 222 callback.Run(SYNC_STATUS_NO_CHANGE_TO_SYNC, |
(...skipping 259 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
483 | 482 |
484 LocalChangeProcessor* LocalFileSyncService::GetLocalChangeProcessor( | 483 LocalChangeProcessor* LocalFileSyncService::GetLocalChangeProcessor( |
485 const FileSystemURL& url) { | 484 const FileSystemURL& url) { |
486 if (!get_local_change_processor_.is_null()) | 485 if (!get_local_change_processor_.is_null()) |
487 return get_local_change_processor_.Run(url.origin()); | 486 return get_local_change_processor_.Run(url.origin()); |
488 DCHECK(local_change_processor_); | 487 DCHECK(local_change_processor_); |
489 return local_change_processor_; | 488 return local_change_processor_; |
490 } | 489 } |
491 | 490 |
492 } // namespace sync_file_system | 491 } // namespace sync_file_system |
OLD | NEW |