OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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_browser_private_api.h" | 5 #include "chrome/browser/chromeos/extensions/file_browser_private_api.h" |
6 | 6 |
7 #include <utility> | 7 #include <utility> |
8 | 8 |
9 #include "base/base64.h" | 9 #include "base/base64.h" |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
11 #include "base/logging.h" | 11 #include "base/logging.h" |
12 #include "base/memory/scoped_vector.h" | 12 #include "base/memory/scoped_vector.h" |
13 #include "base/memory/singleton.h" | 13 #include "base/memory/singleton.h" |
14 #include "base/string_split.h" | 14 #include "base/string_split.h" |
15 #include "base/stringprintf.h" | 15 #include "base/stringprintf.h" |
16 #include "base/time.h" | 16 #include "base/time.h" |
17 #include "base/values.h" | 17 #include "base/values.h" |
18 #include "chrome/browser/chromeos/cros/cros_library.h" | 18 #include "chrome/browser/chromeos/cros/cros_library.h" |
19 #include "chrome/browser/chromeos/cros/network_library.h" | 19 #include "chrome/browser/chromeos/cros/network_library.h" |
20 #include "chrome/browser/chromeos/disks/disk_mount_manager.h" | 20 #include "chrome/browser/chromeos/disks/disk_mount_manager.h" |
21 #include "chrome/browser/chromeos/extensions/file_handler_util.h" | 21 #include "chrome/browser/chromeos/extensions/file_handler_util.h" |
22 #include "chrome/browser/chromeos/extensions/file_manager_util.h" | 22 #include "chrome/browser/chromeos/extensions/file_manager_util.h" |
23 #include "chrome/browser/chromeos/gdata/drive_service_interface.h" | 23 #include "chrome/browser/chromeos/gdata/drive_service_interface.h" |
24 #include "chrome/browser/chromeos/gdata/drive_webapps_registry.h" | 24 #include "chrome/browser/chromeos/gdata/drive_webapps_registry.h" |
25 #include "chrome/browser/chromeos/gdata/gdata.pb.h" | 25 #include "chrome/browser/chromeos/gdata/gdata.pb.h" |
26 #include "chrome/browser/chromeos/gdata/gdata_operation_registry.h" | |
27 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" | 26 #include "chrome/browser/chromeos/gdata/gdata_system_service.h" |
28 #include "chrome/browser/chromeos/gdata/gdata_util.h" | 27 #include "chrome/browser/chromeos/gdata/gdata_util.h" |
29 #include "chrome/browser/chromeos/gdata/gdata_wapi_parser.h" | 28 #include "chrome/browser/chromeos/gdata/gdata_wapi_parser.h" |
| 29 #include "chrome/browser/chromeos/gdata/operation_registry.h" |
30 #include "chrome/browser/chromeos/system/statistics_provider.h" | 30 #include "chrome/browser/chromeos/system/statistics_provider.h" |
31 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 31 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
32 #include "chrome/browser/extensions/extension_process_manager.h" | 32 #include "chrome/browser/extensions/extension_process_manager.h" |
33 #include "chrome/browser/extensions/extension_service.h" | 33 #include "chrome/browser/extensions/extension_service.h" |
34 #include "chrome/browser/extensions/extension_tab_util.h" | 34 #include "chrome/browser/extensions/extension_tab_util.h" |
35 #include "chrome/browser/extensions/process_map.h" | 35 #include "chrome/browser/extensions/process_map.h" |
36 #include "chrome/browser/profiles/profile.h" | 36 #include "chrome/browser/profiles/profile.h" |
37 #include "chrome/browser/ui/browser.h" | 37 #include "chrome/browser/ui/browser.h" |
38 #include "chrome/browser/ui/browser_window.h" | 38 #include "chrome/browser/ui/browser_window.h" |
39 #include "chrome/browser/ui/views/select_file_dialog_extension.h" | 39 #include "chrome/browser/ui/views/select_file_dialog_extension.h" |
(...skipping 21 matching lines...) Expand all Loading... |
61 #include "webkit/fileapi/file_system_util.h" | 61 #include "webkit/fileapi/file_system_util.h" |
62 | 62 |
63 using chromeos::disks::DiskMountManager; | 63 using chromeos::disks::DiskMountManager; |
64 using content::BrowserContext; | 64 using content::BrowserContext; |
65 using content::BrowserThread; | 65 using content::BrowserThread; |
66 using content::ChildProcessSecurityPolicy; | 66 using content::ChildProcessSecurityPolicy; |
67 using content::SiteInstance; | 67 using content::SiteInstance; |
68 using content::WebContents; | 68 using content::WebContents; |
69 using extensions::Extension; | 69 using extensions::Extension; |
70 using file_handler_util::FileTaskExecutor; | 70 using file_handler_util::FileTaskExecutor; |
71 using gdata::GDataOperationRegistry; | |
72 using gdata::InstalledApp; | 71 using gdata::InstalledApp; |
| 72 using gdata::OperationRegistry; |
73 | 73 |
74 namespace { | 74 namespace { |
75 | 75 |
76 // Default icon path for drive docs. | 76 // Default icon path for drive docs. |
77 const char kDefaultDriveIcon[] = "images/filetype_generic.png"; | 77 const char kDefaultDriveIcon[] = "images/filetype_generic.png"; |
78 const int kPreferredIconSize = 16; | 78 const int kPreferredIconSize = 16; |
79 | 79 |
80 // Error messages. | 80 // Error messages. |
81 const char kFileError[] = "File error %d"; | 81 const char kFileError[] = "File error %d"; |
82 const char kInvalidFileUrl[] = "Invalid file URL"; | 82 const char kInvalidFileUrl[] = "Invalid file URL"; |
(...skipping 2016 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2099 GetFileTransfersFunction::GetFileTransfersFunction() {} | 2099 GetFileTransfersFunction::GetFileTransfersFunction() {} |
2100 | 2100 |
2101 GetFileTransfersFunction::~GetFileTransfersFunction() {} | 2101 GetFileTransfersFunction::~GetFileTransfersFunction() {} |
2102 | 2102 |
2103 ListValue* GetFileTransfersFunction::GetFileTransfersList() { | 2103 ListValue* GetFileTransfersFunction::GetFileTransfersList() { |
2104 gdata::GDataSystemService* system_service = | 2104 gdata::GDataSystemService* system_service = |
2105 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 2105 gdata::GDataSystemServiceFactory::GetForProfile(profile_); |
2106 if (!system_service) | 2106 if (!system_service) |
2107 return NULL; | 2107 return NULL; |
2108 | 2108 |
2109 std::vector<gdata::GDataOperationRegistry::ProgressStatus> | 2109 std::vector<gdata::OperationRegistry::ProgressStatus> |
2110 list = system_service->drive_service()->operation_registry()-> | 2110 list = system_service->drive_service()->operation_registry()-> |
2111 GetProgressStatusList(); | 2111 GetProgressStatusList(); |
2112 return file_manager_util::ProgressStatusVectorToListValue( | 2112 return file_manager_util::ProgressStatusVectorToListValue( |
2113 profile_, source_url_.GetOrigin(), list); | 2113 profile_, source_url_.GetOrigin(), list); |
2114 } | 2114 } |
2115 | 2115 |
2116 bool GetFileTransfersFunction::RunImpl() { | 2116 bool GetFileTransfersFunction::RunImpl() { |
2117 scoped_ptr<ListValue> progress_status_list(GetFileTransfersList()); | 2117 scoped_ptr<ListValue> progress_status_list(GetFileTransfersList()); |
2118 if (!progress_status_list.get()) { | 2118 if (!progress_status_list.get()) { |
2119 SendResponse(false); | 2119 SendResponse(false); |
(...skipping 36 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2156 void CancelFileTransfersFunction::GetLocalPathsResponseOnUIThread( | 2156 void CancelFileTransfersFunction::GetLocalPathsResponseOnUIThread( |
2157 const SelectedFileInfoList& files) { | 2157 const SelectedFileInfoList& files) { |
2158 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2158 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
2159 gdata::GDataSystemService* system_service = | 2159 gdata::GDataSystemService* system_service = |
2160 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 2160 gdata::GDataSystemServiceFactory::GetForProfile(profile_); |
2161 if (!system_service) { | 2161 if (!system_service) { |
2162 SendResponse(false); | 2162 SendResponse(false); |
2163 return; | 2163 return; |
2164 } | 2164 } |
2165 | 2165 |
2166 gdata::GDataOperationRegistry* operation_registry = | 2166 gdata::OperationRegistry* operation_registry = |
2167 system_service->drive_service()->operation_registry(); | 2167 system_service->drive_service()->operation_registry(); |
2168 | 2168 |
2169 scoped_ptr<ListValue> responses(new ListValue()); | 2169 scoped_ptr<ListValue> responses(new ListValue()); |
2170 for (size_t i = 0; i < files.size(); ++i) { | 2170 for (size_t i = 0; i < files.size(); ++i) { |
2171 DCHECK(gdata::util::IsUnderGDataMountPoint(files[i].file_path)); | 2171 DCHECK(gdata::util::IsUnderGDataMountPoint(files[i].file_path)); |
2172 FilePath file_path = gdata::util::ExtractGDataPath(files[i].file_path); | 2172 FilePath file_path = gdata::util::ExtractGDataPath(files[i].file_path); |
2173 scoped_ptr<DictionaryValue> result(new DictionaryValue()); | 2173 scoped_ptr<DictionaryValue> result(new DictionaryValue()); |
2174 result->SetBoolean( | 2174 result->SetBoolean( |
2175 "canceled", | 2175 "canceled", |
2176 operation_registry->CancelForFilePath(file_path)); | 2176 operation_registry->CancelForFilePath(file_path)); |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2432 gdata::GDataSystemService* system_service = | 2432 gdata::GDataSystemService* system_service = |
2433 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 2433 gdata::GDataSystemServiceFactory::GetForProfile(profile_); |
2434 if (!system_service || !system_service->file_system()) | 2434 if (!system_service || !system_service->file_system()) |
2435 return false; | 2435 return false; |
2436 | 2436 |
2437 FilePath directory_path = GetVirtualPathFromURL(GURL(file_url_as_string)); | 2437 FilePath directory_path = GetVirtualPathFromURL(GURL(file_url_as_string)); |
2438 system_service->file_system()->RequestDirectoryRefresh(directory_path); | 2438 system_service->file_system()->RequestDirectoryRefresh(directory_path); |
2439 | 2439 |
2440 return true; | 2440 return true; |
2441 } | 2441 } |
OLD | NEW |