| 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 "apps/saved_files_service.h" | 5 #include "apps/saved_files_service.h" |
| 6 | 6 |
| 7 #include <algorithm> | 7 #include <algorithm> |
| 8 | 8 |
| 9 #include "apps/saved_files_service_factory.h" | 9 #include "apps/saved_files_service_factory.h" |
| 10 #include "base/basictypes.h" | 10 #include "base/basictypes.h" |
| 11 #include "base/containers/hash_tables.h" | 11 #include "base/containers/hash_tables.h" |
| 12 #include "base/value_conversions.h" | 12 #include "base/value_conversions.h" |
| 13 #include "chrome/browser/chrome_notification_types.h" | 13 #include "chrome/browser/chrome_notification_types.h" |
| 14 #include "chrome/browser/profiles/profile.h" | 14 #include "chrome/browser/profiles/profile.h" |
| 15 #include "content/public/browser/notification_service.h" | 15 #include "content/public/browser/notification_service.h" |
| 16 #include "extensions/browser/extension_host.h" | 16 #include "extensions/browser/extension_host.h" |
| 17 #include "extensions/browser/extension_prefs.h" | 17 #include "extensions/browser/extension_prefs.h" |
| 18 #include "extensions/browser/extension_system.h" | 18 #include "extensions/browser/extension_system.h" |
| 19 #include "extensions/browser/extension_util.h" | 19 #include "extensions/browser/extension_util.h" |
| 20 #include "extensions/browser/notification_types.h" |
| 20 #include "extensions/common/permissions/api_permission.h" | 21 #include "extensions/common/permissions/api_permission.h" |
| 21 #include "extensions/common/permissions/permission_set.h" | 22 #include "extensions/common/permissions/permission_set.h" |
| 22 #include "extensions/common/permissions/permissions_data.h" | 23 #include "extensions/common/permissions/permissions_data.h" |
| 23 | 24 |
| 24 namespace apps { | 25 namespace apps { |
| 25 | 26 |
| 26 using extensions::APIPermission; | 27 using extensions::APIPermission; |
| 27 using extensions::Extension; | 28 using extensions::Extension; |
| 28 using extensions::ExtensionHost; | 29 using extensions::ExtensionHost; |
| 29 using extensions::ExtensionPrefs; | 30 using extensions::ExtensionPrefs; |
| (...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 190 | 191 |
| 191 // static | 192 // static |
| 192 SavedFilesService* SavedFilesService::Get(Profile* profile) { | 193 SavedFilesService* SavedFilesService::Get(Profile* profile) { |
| 193 return SavedFilesServiceFactory::GetForProfile(profile); | 194 return SavedFilesServiceFactory::GetForProfile(profile); |
| 194 } | 195 } |
| 195 | 196 |
| 196 SavedFilesService::SavedFilesService(Profile* profile) | 197 SavedFilesService::SavedFilesService(Profile* profile) |
| 197 : extension_id_to_saved_files_deleter_(&extension_id_to_saved_files_), | 198 : extension_id_to_saved_files_deleter_(&extension_id_to_saved_files_), |
| 198 profile_(profile) { | 199 profile_(profile) { |
| 199 registrar_.Add(this, | 200 registrar_.Add(this, |
| 200 chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED, | 201 extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED, |
| 201 content::NotificationService::AllSources()); | 202 content::NotificationService::AllSources()); |
| 202 registrar_.Add(this, | 203 registrar_.Add(this, |
| 203 chrome::NOTIFICATION_APP_TERMINATING, | 204 chrome::NOTIFICATION_APP_TERMINATING, |
| 204 content::NotificationService::AllSources()); | 205 content::NotificationService::AllSources()); |
| 205 } | 206 } |
| 206 | 207 |
| 207 SavedFilesService::~SavedFilesService() {} | 208 SavedFilesService::~SavedFilesService() {} |
| 208 | 209 |
| 209 void SavedFilesService::Observe(int type, | 210 void SavedFilesService::Observe(int type, |
| 210 const content::NotificationSource& source, | 211 const content::NotificationSource& source, |
| 211 const content::NotificationDetails& details) { | 212 const content::NotificationDetails& details) { |
| 212 switch (type) { | 213 switch (type) { |
| 213 case chrome::NOTIFICATION_EXTENSION_HOST_DESTROYED: { | 214 case extensions::NOTIFICATION_EXTENSION_HOST_DESTROYED: { |
| 214 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr(); | 215 ExtensionHost* host = content::Details<ExtensionHost>(details).ptr(); |
| 215 const Extension* extension = host->extension(); | 216 const Extension* extension = host->extension(); |
| 216 if (extension) { | 217 if (extension) { |
| 217 ClearQueueIfNoRetainPermission(extension); | 218 ClearQueueIfNoRetainPermission(extension); |
| 218 Clear(extension->id()); | 219 Clear(extension->id()); |
| 219 } | 220 } |
| 220 break; | 221 break; |
| 221 } | 222 } |
| 222 | 223 |
| 223 case chrome::NOTIFICATION_APP_TERMINATING: { | 224 case chrome::NOTIFICATION_APP_TERMINATING: { |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 452 void SavedFilesService::SetLruSizeForTest(int size) { | 453 void SavedFilesService::SetLruSizeForTest(int size) { |
| 453 g_max_saved_file_entries = size; | 454 g_max_saved_file_entries = size; |
| 454 } | 455 } |
| 455 | 456 |
| 456 // static | 457 // static |
| 457 void SavedFilesService::ClearLruSizeForTest() { | 458 void SavedFilesService::ClearLruSizeForTest() { |
| 458 g_max_saved_file_entries = kMaxSavedFileEntries; | 459 g_max_saved_file_entries = kMaxSavedFileEntries; |
| 459 } | 460 } |
| 460 | 461 |
| 461 } // namespace apps | 462 } // namespace apps |
| OLD | NEW |