| 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 <stdint.h> | 7 #include <stdint.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <map> | 10 #include <map> |
| 11 #include <unordered_map> | 11 #include <unordered_map> |
| 12 #include <utility> | 12 #include <utility> |
| 13 | 13 |
| 14 #include "apps/saved_files_service_factory.h" | 14 #include "apps/saved_files_service_factory.h" |
| 15 #include "base/memory/ptr_util.h" | 15 #include "base/memory/ptr_util.h" |
| 16 #include "base/value_conversions.h" | 16 #include "base/value_conversions.h" |
| 17 #include "content/public/browser/browser_context.h" | 17 #include "content/public/browser/browser_context.h" |
| 18 #include "content/public/browser/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
| 19 #include "extensions/browser/api/file_system/saved_file_entry.h" |
| 19 #include "extensions/browser/extension_host.h" | 20 #include "extensions/browser/extension_host.h" |
| 20 #include "extensions/browser/extension_prefs.h" | 21 #include "extensions/browser/extension_prefs.h" |
| 21 #include "extensions/browser/extension_system.h" | 22 #include "extensions/browser/extension_system.h" |
| 22 #include "extensions/browser/notification_types.h" | 23 #include "extensions/browser/notification_types.h" |
| 23 #include "extensions/common/permissions/api_permission.h" | 24 #include "extensions/common/permissions/api_permission.h" |
| 24 #include "extensions/common/permissions/permission_set.h" | 25 #include "extensions/common/permissions/permission_set.h" |
| 25 #include "extensions/common/permissions/permissions_data.h" | 26 #include "extensions/common/permissions/permissions_data.h" |
| 26 | 27 |
| 27 namespace apps { | 28 namespace apps { |
| 28 | 29 |
| 29 using extensions::APIPermission; | 30 using extensions::APIPermission; |
| 30 using extensions::Extension; | 31 using extensions::Extension; |
| 31 using extensions::ExtensionHost; | 32 using extensions::ExtensionHost; |
| 32 using extensions::ExtensionPrefs; | 33 using extensions::ExtensionPrefs; |
| 34 using extensions::SavedFileEntry; |
| 33 | 35 |
| 34 namespace { | 36 namespace { |
| 35 | 37 |
| 36 // Preference keys | 38 // Preference keys |
| 37 | 39 |
| 38 // The file entries that the app has permission to access. | 40 // The file entries that the app has permission to access. |
| 39 const char kFileEntries[] = "file_entries"; | 41 const char kFileEntries[] = "file_entries"; |
| 40 | 42 |
| 41 // The path to a file entry that the app had permission to access. | 43 // The path to a file entry that the app had permission to access. |
| 42 const char kFileEntryPath[] = "path"; | 44 const char kFileEntryPath[] = "path"; |
| (...skipping 90 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 if (!sequence_number) | 135 if (!sequence_number) |
| 134 continue; | 136 continue; |
| 135 result.push_back( | 137 result.push_back( |
| 136 SavedFileEntry(it.key(), file_path, is_directory, sequence_number)); | 138 SavedFileEntry(it.key(), file_path, is_directory, sequence_number)); |
| 137 } | 139 } |
| 138 return result; | 140 return result; |
| 139 } | 141 } |
| 140 | 142 |
| 141 } // namespace | 143 } // namespace |
| 142 | 144 |
| 143 SavedFileEntry::SavedFileEntry() : is_directory(false), sequence_number(0) {} | |
| 144 | |
| 145 SavedFileEntry::SavedFileEntry(const std::string& id, | |
| 146 const base::FilePath& path, | |
| 147 bool is_directory, | |
| 148 int sequence_number) | |
| 149 : id(id), | |
| 150 path(path), | |
| 151 is_directory(is_directory), | |
| 152 sequence_number(sequence_number) {} | |
| 153 | |
| 154 class SavedFilesService::SavedFiles { | 145 class SavedFilesService::SavedFiles { |
| 155 public: | 146 public: |
| 156 SavedFiles(content::BrowserContext* context, const std::string& extension_id); | 147 SavedFiles(content::BrowserContext* context, const std::string& extension_id); |
| 157 ~SavedFiles(); | 148 ~SavedFiles(); |
| 158 | 149 |
| 159 void RegisterFileEntry(const std::string& id, | 150 void RegisterFileEntry(const std::string& id, |
| 160 const base::FilePath& file_path, | 151 const base::FilePath& file_path, |
| 161 bool is_directory); | 152 bool is_directory); |
| 162 void EnqueueFileEntry(const std::string& id); | 153 void EnqueueFileEntry(const std::string& id); |
| 163 bool IsRegistered(const std::string& id) const; | 154 bool IsRegistered(const std::string& id) const; |
| (...skipping 270 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 434 void SavedFilesService::SetLruSizeForTest(int size) { | 425 void SavedFilesService::SetLruSizeForTest(int size) { |
| 435 g_max_saved_file_entries = size; | 426 g_max_saved_file_entries = size; |
| 436 } | 427 } |
| 437 | 428 |
| 438 // static | 429 // static |
| 439 void SavedFilesService::ClearLruSizeForTest() { | 430 void SavedFilesService::ClearLruSizeForTest() { |
| 440 g_max_saved_file_entries = kMaxSavedFileEntries; | 431 g_max_saved_file_entries = kMaxSavedFileEntries; |
| 441 } | 432 } |
| 442 | 433 |
| 443 } // namespace apps | 434 } // namespace apps |
| OLD | NEW |