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/chromeos/extensions/file_manager/private_api_file_syste
m.h" | 5 #include "chrome/browser/chromeos/extensions/file_manager/private_api_file_syste
m.h" |
6 | 6 |
7 #include <sys/statvfs.h> | 7 #include <sys/statvfs.h> |
8 | 8 |
9 #include "base/posix/eintr_wrapper.h" | 9 #include "base/posix/eintr_wrapper.h" |
10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
11 #include "base/strings/stringprintf.h" | 11 #include "base/strings/stringprintf.h" |
12 #include "base/task_runner_util.h" | 12 #include "base/task_runner_util.h" |
13 #include "base/threading/sequenced_worker_pool.h" | 13 #include "base/threading/sequenced_worker_pool.h" |
14 #include "chrome/browser/browser_process.h" | 14 #include "chrome/browser/browser_process.h" |
15 #include "chrome/browser/chromeos/drive/drive.pb.h" | 15 #include "chrome/browser/chromeos/drive/drive.pb.h" |
16 #include "chrome/browser/chromeos/drive/file_system_interface.h" | 16 #include "chrome/browser/chromeos/drive/file_system_interface.h" |
17 #include "chrome/browser/chromeos/drive/file_system_util.h" | 17 #include "chrome/browser/chromeos/drive/file_system_util.h" |
18 #include "chrome/browser/chromeos/extensions/file_manager/event_router.h" | 18 #include "chrome/browser/chromeos/extensions/file_manager/event_router.h" |
19 #include "chrome/browser/chromeos/extensions/file_manager/file_manager_private_a
pi.h" | 19 #include "chrome/browser/chromeos/extensions/file_manager/event_router_factory.h
" |
20 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" | 20 #include "chrome/browser/chromeos/extensions/file_manager/private_api_util.h" |
21 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" | 21 #include "chrome/browser/chromeos/file_manager/fileapi_util.h" |
22 #include "chrome/browser/chromeos/file_manager/volume_manager.h" | 22 #include "chrome/browser/chromeos/file_manager/volume_manager.h" |
23 #include "chrome/browser/chromeos/fileapi/file_system_backend.h" | 23 #include "chrome/browser/chromeos/fileapi/file_system_backend.h" |
24 #include "chrome/browser/profiles/profile.h" | 24 #include "chrome/browser/profiles/profile.h" |
25 #include "chrome/browser/profiles/profile_manager.h" | 25 #include "chrome/browser/profiles/profile_manager.h" |
26 #include "chrome/common/extensions/api/file_manager_private.h" | 26 #include "chrome/common/extensions/api/file_manager_private.h" |
27 #include "chrome/common/extensions/api/file_manager_private_internal.h" | 27 #include "chrome/common/extensions/api/file_manager_private_internal.h" |
28 #include "chromeos/disks/disk_mount_manager.h" | 28 #include "chromeos/disks/disk_mount_manager.h" |
29 #include "content/public/browser/child_process_security_policy.h" | 29 #include "content/public/browser/child_process_security_policy.h" |
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
76 // Returns EventRouter for the |profile_id| if available. | 76 // Returns EventRouter for the |profile_id| if available. |
77 file_manager::EventRouter* GetEventRouterByProfileId(void* profile_id) { | 77 file_manager::EventRouter* GetEventRouterByProfileId(void* profile_id) { |
78 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 78 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
79 | 79 |
80 // |profile_id| needs to be checked with ProfileManager::IsValidProfile | 80 // |profile_id| needs to be checked with ProfileManager::IsValidProfile |
81 // before using it. | 81 // before using it. |
82 Profile* profile = reinterpret_cast<Profile*>(profile_id); | 82 Profile* profile = reinterpret_cast<Profile*>(profile_id); |
83 if (!g_browser_process->profile_manager()->IsValidProfile(profile)) | 83 if (!g_browser_process->profile_manager()->IsValidProfile(profile)) |
84 return NULL; | 84 return NULL; |
85 | 85 |
86 return file_manager::FileManagerPrivateAPI::Get(profile)->event_router(); | 86 return file_manager::EventRouterFactory::GetForProfile(profile); |
87 } | 87 } |
88 | 88 |
89 // Notifies the copy progress to extensions via event router. | 89 // Notifies the copy progress to extensions via event router. |
90 void NotifyCopyProgress( | 90 void NotifyCopyProgress( |
91 void* profile_id, | 91 void* profile_id, |
92 storage::FileSystemOperationRunner::OperationID operation_id, | 92 storage::FileSystemOperationRunner::OperationID operation_id, |
93 storage::FileSystemOperation::CopyProgressType type, | 93 storage::FileSystemOperation::CopyProgressType type, |
94 const FileSystemURL& source_url, | 94 const FileSystemURL& source_url, |
95 const FileSystemURL& destination_url, | 95 const FileSystemURL& destination_url, |
96 int64 size) { | 96 int64 size) { |
(...skipping 277 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 return true; | 374 return true; |
375 } | 375 } |
376 | 376 |
377 void FileManagerPrivateAddFileWatchFunction::PerformFileWatchOperation( | 377 void FileManagerPrivateAddFileWatchFunction::PerformFileWatchOperation( |
378 const base::FilePath& local_path, | 378 const base::FilePath& local_path, |
379 const base::FilePath& virtual_path, | 379 const base::FilePath& virtual_path, |
380 const std::string& extension_id) { | 380 const std::string& extension_id) { |
381 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 381 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
382 | 382 |
383 file_manager::EventRouter* event_router = | 383 file_manager::EventRouter* event_router = |
384 file_manager::FileManagerPrivateAPI::Get(GetProfile())->event_router(); | 384 file_manager::EventRouterFactory::GetForProfile(GetProfile()); |
385 event_router->AddFileWatch( | 385 event_router->AddFileWatch( |
386 local_path, | 386 local_path, |
387 virtual_path, | 387 virtual_path, |
388 extension_id, | 388 extension_id, |
389 base::Bind(&FileManagerPrivateAddFileWatchFunction::Respond, this)); | 389 base::Bind(&FileManagerPrivateAddFileWatchFunction::Respond, this)); |
390 } | 390 } |
391 | 391 |
392 void FileManagerPrivateRemoveFileWatchFunction::PerformFileWatchOperation( | 392 void FileManagerPrivateRemoveFileWatchFunction::PerformFileWatchOperation( |
393 const base::FilePath& local_path, | 393 const base::FilePath& local_path, |
394 const base::FilePath& unused, | 394 const base::FilePath& unused, |
395 const std::string& extension_id) { | 395 const std::string& extension_id) { |
396 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 396 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
397 | 397 |
398 file_manager::EventRouter* event_router = | 398 file_manager::EventRouter* event_router = |
399 file_manager::FileManagerPrivateAPI::Get(GetProfile())->event_router(); | 399 file_manager::EventRouterFactory::GetForProfile(GetProfile()); |
400 event_router->RemoveFileWatch(local_path, extension_id); | 400 event_router->RemoveFileWatch(local_path, extension_id); |
401 Respond(true); | 401 Respond(true); |
402 } | 402 } |
403 | 403 |
404 bool FileManagerPrivateGetSizeStatsFunction::RunAsync() { | 404 bool FileManagerPrivateGetSizeStatsFunction::RunAsync() { |
405 using extensions::api::file_manager_private::GetSizeStats::Params; | 405 using extensions::api::file_manager_private::GetSizeStats::Params; |
406 const scoped_ptr<Params> params(Params::Create(*args_)); | 406 const scoped_ptr<Params> params(Params::Create(*args_)); |
407 EXTENSION_FUNCTION_VALIDATE(params); | 407 EXTENSION_FUNCTION_VALIDATE(params); |
408 | 408 |
409 using file_manager::VolumeManager; | 409 using file_manager::VolumeManager; |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
673 "/" + entry_definition_list->at(i).full_path.AsUTF8Unsafe(); | 673 "/" + entry_definition_list->at(i).full_path.AsUTF8Unsafe(); |
674 entry->file_is_directory = entry_definition_list->at(i).is_directory; | 674 entry->file_is_directory = entry_definition_list->at(i).is_directory; |
675 entries.push_back(entry); | 675 entries.push_back(entry); |
676 } | 676 } |
677 | 677 |
678 results_ = extensions::api::file_manager_private_internal:: | 678 results_ = extensions::api::file_manager_private_internal:: |
679 ResolveIsolatedEntries::Results::Create(entries); | 679 ResolveIsolatedEntries::Results::Create(entries); |
680 SendResponse(true); | 680 SendResponse(true); |
681 } | 681 } |
682 } // namespace extensions | 682 } // namespace extensions |
OLD | NEW |