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 <sys/statvfs.h> | 7 #include <sys/statvfs.h> |
8 #include <utility> | 8 #include <utility> |
9 | 9 |
10 #include "base/base64.h" | 10 #include "base/base64.h" |
(...skipping 16 matching lines...) Expand all Loading... |
27 #include "chrome/browser/chromeos/gdata/drive_system_service.h" | 27 #include "chrome/browser/chromeos/gdata/drive_system_service.h" |
28 #include "chrome/browser/chromeos/gdata/drive_webapps_registry.h" | 28 #include "chrome/browser/chromeos/gdata/drive_webapps_registry.h" |
29 #include "chrome/browser/chromeos/system/statistics_provider.h" | 29 #include "chrome/browser/chromeos/system/statistics_provider.h" |
30 #include "chrome/browser/extensions/extension_function_dispatcher.h" | 30 #include "chrome/browser/extensions/extension_function_dispatcher.h" |
31 #include "chrome/browser/extensions/extension_process_manager.h" | 31 #include "chrome/browser/extensions/extension_process_manager.h" |
32 #include "chrome/browser/extensions/extension_service.h" | 32 #include "chrome/browser/extensions/extension_service.h" |
33 #include "chrome/browser/extensions/extension_tab_util.h" | 33 #include "chrome/browser/extensions/extension_tab_util.h" |
34 #include "chrome/browser/extensions/process_map.h" | 34 #include "chrome/browser/extensions/process_map.h" |
35 #include "chrome/browser/google_apis/gdata_util.h" | 35 #include "chrome/browser/google_apis/gdata_util.h" |
36 #include "chrome/browser/google_apis/gdata_wapi_parser.h" | 36 #include "chrome/browser/google_apis/gdata_wapi_parser.h" |
37 #include "chrome/browser/google_apis/operation_registry.h" | |
38 #include "chrome/browser/profiles/profile.h" | 37 #include "chrome/browser/profiles/profile.h" |
39 #include "chrome/browser/ui/browser.h" | 38 #include "chrome/browser/ui/browser.h" |
40 #include "chrome/browser/ui/browser_window.h" | 39 #include "chrome/browser/ui/browser_window.h" |
41 #include "chrome/browser/ui/views/select_file_dialog_extension.h" | 40 #include "chrome/browser/ui/views/select_file_dialog_extension.h" |
42 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" | 41 #include "chrome/browser/ui/webui/extensions/extension_icon_source.h" |
43 #include "chrome/common/extensions/extension.h" | 42 #include "chrome/common/extensions/extension.h" |
44 #include "chrome/common/extensions/extension_constants.h" | 43 #include "chrome/common/extensions/extension_constants.h" |
45 #include "chrome/common/extensions/extension_icon_set.h" | 44 #include "chrome/common/extensions/extension_icon_set.h" |
46 #include "chrome/common/extensions/file_browser_handler.h" | 45 #include "chrome/common/extensions/file_browser_handler.h" |
47 #include "chrome/common/pref_names.h" | 46 #include "chrome/common/pref_names.h" |
(...skipping 17 matching lines...) Expand all Loading... |
65 | 64 |
66 using chromeos::disks::DiskMountManager; | 65 using chromeos::disks::DiskMountManager; |
67 using content::BrowserContext; | 66 using content::BrowserContext; |
68 using content::BrowserThread; | 67 using content::BrowserThread; |
69 using content::ChildProcessSecurityPolicy; | 68 using content::ChildProcessSecurityPolicy; |
70 using content::SiteInstance; | 69 using content::SiteInstance; |
71 using content::WebContents; | 70 using content::WebContents; |
72 using extensions::Extension; | 71 using extensions::Extension; |
73 using file_handler_util::FileTaskExecutor; | 72 using file_handler_util::FileTaskExecutor; |
74 using gdata::InstalledApp; | 73 using gdata::InstalledApp; |
75 using gdata::OperationRegistry; | |
76 | 74 |
77 namespace { | 75 namespace { |
78 | 76 |
79 // Default icon path for drive docs. | 77 // Default icon path for drive docs. |
80 const char kDefaultDriveIcon[] = "images/filetype_generic.png"; | 78 const char kDefaultDriveIcon[] = "images/filetype_generic.png"; |
81 const int kPreferredIconSize = 16; | 79 const int kPreferredIconSize = 16; |
82 | 80 |
83 // Error messages. | 81 // Error messages. |
84 const char kFileError[] = "File error %d"; | 82 const char kFileError[] = "File error %d"; |
85 const char kInvalidFileUrl[] = "Invalid file URL"; | 83 const char kInvalidFileUrl[] = "Invalid file URL"; |
(...skipping 2193 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2279 GetFileTransfersFunction::GetFileTransfersFunction() {} | 2277 GetFileTransfersFunction::GetFileTransfersFunction() {} |
2280 | 2278 |
2281 GetFileTransfersFunction::~GetFileTransfersFunction() {} | 2279 GetFileTransfersFunction::~GetFileTransfersFunction() {} |
2282 | 2280 |
2283 ListValue* GetFileTransfersFunction::GetFileTransfersList() { | 2281 ListValue* GetFileTransfersFunction::GetFileTransfersList() { |
2284 gdata::DriveSystemService* system_service = | 2282 gdata::DriveSystemService* system_service = |
2285 gdata::DriveSystemServiceFactory::GetForProfile(profile_); | 2283 gdata::DriveSystemServiceFactory::GetForProfile(profile_); |
2286 if (!system_service) | 2284 if (!system_service) |
2287 return NULL; | 2285 return NULL; |
2288 | 2286 |
2289 std::vector<gdata::OperationRegistry::ProgressStatus> | 2287 gdata::OperationProgressStatusList list = |
2290 list = system_service->drive_service()->operation_registry()-> | 2288 system_service->drive_service()->GetProgressStatusList(); |
2291 GetProgressStatusList(); | |
2292 return file_manager_util::ProgressStatusVectorToListValue( | 2289 return file_manager_util::ProgressStatusVectorToListValue( |
2293 profile_, source_url_.GetOrigin(), list); | 2290 profile_, source_url_.GetOrigin(), list); |
2294 } | 2291 } |
2295 | 2292 |
2296 bool GetFileTransfersFunction::RunImpl() { | 2293 bool GetFileTransfersFunction::RunImpl() { |
2297 scoped_ptr<ListValue> progress_status_list(GetFileTransfersList()); | 2294 scoped_ptr<ListValue> progress_status_list(GetFileTransfersList()); |
2298 if (!progress_status_list.get()) { | 2295 if (!progress_status_list.get()) { |
2299 SendResponse(false); | 2296 SendResponse(false); |
2300 return false; | 2297 return false; |
2301 } | 2298 } |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2336 void CancelFileTransfersFunction::GetLocalPathsResponseOnUIThread( | 2333 void CancelFileTransfersFunction::GetLocalPathsResponseOnUIThread( |
2337 const SelectedFileInfoList& files) { | 2334 const SelectedFileInfoList& files) { |
2338 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 2335 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
2339 gdata::DriveSystemService* system_service = | 2336 gdata::DriveSystemService* system_service = |
2340 gdata::DriveSystemServiceFactory::GetForProfile(profile_); | 2337 gdata::DriveSystemServiceFactory::GetForProfile(profile_); |
2341 if (!system_service) { | 2338 if (!system_service) { |
2342 SendResponse(false); | 2339 SendResponse(false); |
2343 return; | 2340 return; |
2344 } | 2341 } |
2345 | 2342 |
2346 gdata::OperationRegistry* operation_registry = | |
2347 system_service->drive_service()->operation_registry(); | |
2348 | |
2349 scoped_ptr<ListValue> responses(new ListValue()); | 2343 scoped_ptr<ListValue> responses(new ListValue()); |
2350 for (size_t i = 0; i < files.size(); ++i) { | 2344 for (size_t i = 0; i < files.size(); ++i) { |
2351 DCHECK(gdata::util::IsUnderDriveMountPoint(files[i].file_path)); | 2345 DCHECK(gdata::util::IsUnderDriveMountPoint(files[i].file_path)); |
2352 FilePath file_path = gdata::util::ExtractDrivePath(files[i].file_path); | 2346 FilePath file_path = gdata::util::ExtractDrivePath(files[i].file_path); |
2353 scoped_ptr<DictionaryValue> result(new DictionaryValue()); | 2347 scoped_ptr<DictionaryValue> result(new DictionaryValue()); |
2354 result->SetBoolean( | 2348 result->SetBoolean( |
2355 "canceled", | 2349 "canceled", |
2356 operation_registry->CancelForFilePath(file_path)); | 2350 system_service->drive_service()->CancelForFilePath(file_path)); |
2357 GURL file_url; | 2351 GURL file_url; |
2358 if (file_manager_util::ConvertFileToFileSystemUrl(profile_, | 2352 if (file_manager_util::ConvertFileToFileSystemUrl(profile_, |
2359 gdata::util::GetSpecialRemoteRootPath().Append(file_path), | 2353 gdata::util::GetSpecialRemoteRootPath().Append(file_path), |
2360 source_url_.GetOrigin(), | 2354 source_url_.GetOrigin(), |
2361 &file_url)) { | 2355 &file_url)) { |
2362 result->SetString("fileUrl", file_url.spec()); | 2356 result->SetString("fileUrl", file_url.spec()); |
2363 } | 2357 } |
2364 | 2358 |
2365 responses->Append(result.release()); | 2359 responses->Append(result.release()); |
2366 } | 2360 } |
(...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2612 gdata::DriveSystemService* system_service = | 2606 gdata::DriveSystemService* system_service = |
2613 gdata::DriveSystemServiceFactory::GetForProfile(profile_); | 2607 gdata::DriveSystemServiceFactory::GetForProfile(profile_); |
2614 if (!system_service || !system_service->file_system()) | 2608 if (!system_service || !system_service->file_system()) |
2615 return false; | 2609 return false; |
2616 | 2610 |
2617 FilePath directory_path = GetVirtualPathFromURL(GURL(file_url_as_string)); | 2611 FilePath directory_path = GetVirtualPathFromURL(GURL(file_url_as_string)); |
2618 system_service->file_system()->RequestDirectoryRefresh(directory_path); | 2612 system_service->file_system()->RequestDirectoryRefresh(directory_path); |
2619 | 2613 |
2620 return true; | 2614 return true; |
2621 } | 2615 } |
OLD | NEW |