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/drive/drive_task_executor.h" | 5 #include "chrome/browser/chromeos/drive/drive_task_executor.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/json/json_writer.h" | 10 #include "base/json/json_writer.h" |
11 #include "base/string_util.h" | 11 #include "base/string_util.h" |
12 #include "chrome/browser/chromeos/drive/drive.pb.h" | 12 #include "chrome/browser/chromeos/drive/drive.pb.h" |
13 #include "chrome/browser/chromeos/drive/drive_file_system_interface.h" | 13 #include "chrome/browser/chromeos/drive/drive_file_system_interface.h" |
14 #include "chrome/browser/chromeos/drive/drive_system_service.h" | 14 #include "chrome/browser/chromeos/drive/drive_system_service.h" |
15 #include "chrome/browser/chromeos/extensions/file_browser_private_api.h" | 15 #include "chrome/browser/chromeos/extensions/file_browser_private_api.h" |
16 #include "chrome/browser/google_apis/drive_service_interface.h" | 16 #include "chrome/browser/google_apis/drive_service_interface.h" |
17 #include "chrome/browser/google_apis/gdata_wapi_parser.h" | 17 #include "chrome/browser/google_apis/gdata_wapi_parser.h" |
18 #include "chrome/browser/profiles/profile.h" | 18 #include "chrome/browser/profiles/profile.h" |
19 #include "chrome/browser/profiles/profile_manager.h" | 19 #include "chrome/browser/profiles/profile_manager.h" |
20 #include "chrome/browser/ui/browser.h" | 20 #include "chrome/browser/ui/browser.h" |
21 #include "chrome/browser/ui/browser_finder.h" | 21 #include "chrome/browser/ui/browser_finder.h" |
22 #include "chrome/browser/ui/browser_tabstrip.h" | 22 #include "chrome/browser/ui/browser_tabstrip.h" |
23 #include "chrome/browser/ui/browser_window.h" | 23 #include "chrome/browser/ui/browser_window.h" |
24 #include "content/public/browser/browser_thread.h" | 24 #include "content/public/browser/browser_thread.h" |
25 #include "webkit/fileapi/file_system_types.h" | 25 #include "webkit/fileapi/file_system_types.h" |
26 #include "webkit/fileapi/file_system_url.h" | 26 #include "webkit/fileapi/file_system_url.h" |
27 #include "webkit/fileapi/file_system_util.h" | 27 #include "webkit/fileapi/file_system_util.h" |
28 | 28 |
| 29 using file_handler_util::FileTaskExecutor; |
| 30 using fileapi::FileSystemURL; |
| 31 |
29 namespace drive { | 32 namespace drive { |
30 | 33 |
31 using file_handler_util::FileTaskExecutor; | |
32 | |
33 DriveTaskExecutor::DriveTaskExecutor(Profile* profile, | 34 DriveTaskExecutor::DriveTaskExecutor(Profile* profile, |
34 const std::string& app_id, | 35 const std::string& app_id, |
35 const std::string& action_id) | 36 const std::string& action_id) |
36 : file_handler_util::FileTaskExecutor(profile, GURL(), "", app_id), | 37 : file_handler_util::FileTaskExecutor(profile, GURL(), "", app_id), |
37 action_id_(action_id), | 38 action_id_(action_id), |
38 current_index_(0) { | 39 current_index_(0) { |
39 DCHECK("open-with" == action_id_); | 40 DCHECK("open-with" == action_id_); |
40 } | 41 } |
41 | 42 |
42 DriveTaskExecutor::~DriveTaskExecutor() { | 43 DriveTaskExecutor::~DriveTaskExecutor() { |
43 } | 44 } |
44 | 45 |
45 bool DriveTaskExecutor::ExecuteAndNotify( | 46 bool DriveTaskExecutor::ExecuteAndNotify( |
46 const std::vector<GURL>& file_urls, | 47 const std::vector<FileSystemURL>& file_urls, |
47 const file_handler_util::FileTaskFinishedCallback& done) { | 48 const file_handler_util::FileTaskFinishedCallback& done) { |
48 std::vector<FilePath> raw_paths; | 49 std::vector<FilePath> raw_paths; |
49 for (std::vector<GURL>::const_iterator iter = file_urls.begin(); | 50 for (std::vector<FileSystemURL>::const_iterator url = file_urls.begin(); |
50 iter != file_urls.end(); ++iter) { | 51 url != file_urls.end(); ++url) { |
51 fileapi::FileSystemURL url(*iter); | 52 if (!url->is_valid() || url->type() != fileapi::kFileSystemTypeDrive) |
52 if (!url.is_valid() || url.type() != fileapi::kFileSystemTypeDrive) | |
53 return false; | 53 return false; |
54 raw_paths.push_back(url.virtual_path()); | 54 raw_paths.push_back(url->virtual_path()); |
55 } | 55 } |
56 | 56 |
57 DriveSystemService* system_service = | 57 DriveSystemService* system_service = |
58 DriveSystemServiceFactory::GetForProfile(profile()); | 58 DriveSystemServiceFactory::GetForProfile(profile()); |
59 DCHECK(current_index_ == 0); | 59 DCHECK(current_index_ == 0); |
60 if (!system_service || !system_service->file_system()) | 60 if (!system_service || !system_service->file_system()) |
61 return false; | 61 return false; |
62 DriveFileSystemInterface* file_system = system_service->file_system(); | 62 DriveFileSystemInterface* file_system = system_service->file_system(); |
63 | 63 |
64 // Reset the index, so we know when we're done. | 64 // Reset the index, so we know when we're done. |
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
152 | 152 |
153 void DriveTaskExecutor::Done(bool success) { | 153 void DriveTaskExecutor::Done(bool success) { |
154 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 154 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
155 current_index_ = 0; | 155 current_index_ = 0; |
156 if (!done_.is_null()) | 156 if (!done_.is_null()) |
157 done_.Run(success); | 157 done_.Run(success); |
158 done_.Reset(); | 158 done_.Reset(); |
159 } | 159 } |
160 | 160 |
161 } // namespace drive | 161 } // namespace drive |
OLD | NEW |