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/extensions/file_browser_private_api.h" | 12 #include "chrome/browser/chromeos/extensions/file_browser_private_api.h" |
13 #include "chrome/browser/chromeos/drive/drive.pb.h" | 13 #include "chrome/browser/chromeos/drive/drive.pb.h" |
14 #include "chrome/browser/chromeos/drive/drive_file_system_interface.h" | 14 #include "chrome/browser/chromeos/drive/drive_file_system_interface.h" |
15 #include "chrome/browser/chromeos/drive/drive_service_interface.h" | 15 #include "chrome/browser/chromeos/drive/drive_service_interface.h" |
16 #include "chrome/browser/chromeos/drive/drive_system_service.h" | 16 #include "chrome/browser/chromeos/drive/drive_system_service.h" |
17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
18 #include "chrome/browser/profiles/profile_manager.h" | 18 #include "chrome/browser/profiles/profile_manager.h" |
19 #include "chrome/browser/ui/browser.h" | 19 #include "chrome/browser/ui/browser.h" |
20 #include "chrome/browser/ui/browser_finder.h" | 20 #include "chrome/browser/ui/browser_finder.h" |
21 #include "chrome/browser/ui/browser_tabstrip.h" | 21 #include "chrome/browser/ui/browser_tabstrip.h" |
22 #include "chrome/browser/ui/browser_window.h" | 22 #include "chrome/browser/ui/browser_window.h" |
23 #include "content/public/browser/browser_thread.h" | 23 #include "content/public/browser/browser_thread.h" |
24 #include "webkit/fileapi/file_system_types.h" | 24 #include "webkit/fileapi/file_system_types.h" |
25 #include "webkit/fileapi/file_system_url.h" | 25 #include "webkit/fileapi/file_system_url.h" |
26 #include "webkit/fileapi/file_system_util.h" | 26 #include "webkit/fileapi/file_system_util.h" |
27 | 27 |
28 namespace gdata { | 28 namespace drive { |
29 | 29 |
30 using file_handler_util::FileTaskExecutor; | 30 using file_handler_util::FileTaskExecutor; |
31 | 31 |
32 DriveTaskExecutor::DriveTaskExecutor(Profile* profile, | 32 DriveTaskExecutor::DriveTaskExecutor(Profile* profile, |
33 const std::string& app_id, | 33 const std::string& app_id, |
34 const std::string& action_id) | 34 const std::string& action_id) |
35 : file_handler_util::FileTaskExecutor(profile, app_id), | 35 : file_handler_util::FileTaskExecutor(profile, app_id), |
36 action_id_(action_id), | 36 action_id_(action_id), |
37 current_index_(0) { | 37 current_index_(0) { |
38 DCHECK("open-with" == action_id_); | 38 DCHECK("open-with" == action_id_); |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
100 drive_service->AuthorizeApp( | 100 drive_service->AuthorizeApp( |
101 GURL(entry_proto->edit_url()), | 101 GURL(entry_proto->edit_url()), |
102 extension_id(), // really app_id | 102 extension_id(), // really app_id |
103 base::Bind(&DriveTaskExecutor::OnAppAuthorized, | 103 base::Bind(&DriveTaskExecutor::OnAppAuthorized, |
104 this, | 104 this, |
105 entry_proto->resource_id())); | 105 entry_proto->resource_id())); |
106 } | 106 } |
107 | 107 |
108 void DriveTaskExecutor::OnAppAuthorized( | 108 void DriveTaskExecutor::OnAppAuthorized( |
109 const std::string& resource_id, | 109 const std::string& resource_id, |
110 GDataErrorCode error, | 110 gdata::GDataErrorCode error, |
111 scoped_ptr<base::Value> feed_data) { | 111 scoped_ptr<base::Value> feed_data) { |
112 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 112 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
113 | 113 |
114 // If we aborted, then this will be zero. | 114 // If we aborted, then this will be zero. |
115 if (!current_index_) | 115 if (!current_index_) |
116 return; | 116 return; |
117 | 117 |
118 DriveSystemService* system_service = | 118 DriveSystemService* system_service = |
119 DriveSystemServiceFactory::GetForProfile(profile()); | 119 DriveSystemServiceFactory::GetForProfile(profile()); |
120 | 120 |
121 if (!system_service || error != HTTP_SUCCESS) { | 121 if (!system_service || error != gdata::HTTP_SUCCESS) { |
122 Done(false); | 122 Done(false); |
123 return; | 123 return; |
124 } | 124 } |
125 | 125 |
126 // Yay! We've got the feed data finally, and we can get the open-with URL. | 126 // Yay! We've got the feed data finally, and we can get the open-with URL. |
127 GURL open_with_url; | 127 GURL open_with_url; |
128 base::ListValue* link_list = NULL; | 128 base::ListValue* link_list = NULL; |
129 feed_data->GetAsList(&link_list); | 129 feed_data->GetAsList(&link_list); |
130 for (size_t i = 0; i < link_list->GetSize(); ++i) { | 130 for (size_t i = 0; i < link_list->GetSize(); ++i) { |
131 DictionaryValue* entry = NULL; | 131 DictionaryValue* entry = NULL; |
(...skipping 28 matching lines...) Expand all Loading... |
160 } | 160 } |
161 | 161 |
162 void DriveTaskExecutor::Done(bool success) { | 162 void DriveTaskExecutor::Done(bool success) { |
163 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); | 163 DCHECK(content::BrowserThread::CurrentlyOn(content::BrowserThread::UI)); |
164 current_index_ = 0; | 164 current_index_ = 0; |
165 if (!done_.is_null()) | 165 if (!done_.is_null()) |
166 done_.Run(success); | 166 done_.Run(success); |
167 done_.Reset(); | 167 done_.Reset(); |
168 } | 168 } |
169 | 169 |
170 } // namespace gdata | 170 } // namespace drive |
OLD | NEW |