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" |
(...skipping 2278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2289 service->SetBoolean(prefs::kDisableGDataHostedFiles, tmp); | 2289 service->SetBoolean(prefs::kDisableGDataHostedFiles, tmp); |
2290 } | 2290 } |
2291 | 2291 |
2292 return true; | 2292 return true; |
2293 } | 2293 } |
2294 | 2294 |
2295 bool SearchDriveFunction::RunImpl() { | 2295 bool SearchDriveFunction::RunImpl() { |
2296 if (!args_->GetString(0, &query_)) | 2296 if (!args_->GetString(0, &query_)) |
2297 return false; | 2297 return false; |
2298 | 2298 |
| 2299 if (!args_->GetString(1, &next_feed_)) |
| 2300 return false; |
| 2301 |
2299 BrowserContext::GetFileSystemContext(profile())->OpenFileSystem( | 2302 BrowserContext::GetFileSystemContext(profile())->OpenFileSystem( |
2300 source_url_.GetOrigin(), fileapi::kFileSystemTypeExternal, false, | 2303 source_url_.GetOrigin(), fileapi::kFileSystemTypeExternal, false, |
2301 base::Bind(&SearchDriveFunction::OnFileSystemOpened, this)); | 2304 base::Bind(&SearchDriveFunction::OnFileSystemOpened, this)); |
2302 return true; | 2305 return true; |
2303 } | 2306 } |
2304 | 2307 |
2305 void SearchDriveFunction::OnFileSystemOpened( | 2308 void SearchDriveFunction::OnFileSystemOpened( |
2306 base::PlatformFileError result, | 2309 base::PlatformFileError result, |
2307 const std::string& file_system_name, | 2310 const std::string& file_system_name, |
2308 const GURL& file_system_url) { | 2311 const GURL& file_system_url) { |
2309 if (result != base::PLATFORM_FILE_OK) { | 2312 if (result != base::PLATFORM_FILE_OK) { |
2310 SendResponse(false); | 2313 SendResponse(false); |
2311 return; | 2314 return; |
2312 } | 2315 } |
2313 | 2316 |
2314 file_system_name_ = file_system_name; | 2317 file_system_name_ = file_system_name; |
2315 file_system_url_ = file_system_url; | 2318 file_system_url_ = file_system_url; |
2316 | 2319 |
2317 gdata::GDataSystemService* system_service = | 2320 gdata::GDataSystemService* system_service = |
2318 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 2321 gdata::GDataSystemServiceFactory::GetForProfile(profile_); |
2319 if (!system_service || !system_service->file_system()) { | 2322 if (!system_service || !system_service->file_system()) { |
2320 SendResponse(false); | 2323 SendResponse(false); |
2321 return; | 2324 return; |
2322 } | 2325 } |
2323 | 2326 |
2324 system_service->file_system()->Search( | 2327 system_service->file_system()->Search( |
2325 query_, | 2328 query_, GURL(next_feed_), |
2326 base::Bind(&SearchDriveFunction::OnSearch, this)); | 2329 base::Bind(&SearchDriveFunction::OnSearch, this)); |
2327 } | 2330 } |
2328 | 2331 |
2329 void SearchDriveFunction::OnSearch( | 2332 void SearchDriveFunction::OnSearch( |
2330 gdata::GDataFileError error, | 2333 gdata::GDataFileError error, |
| 2334 const GURL& next_feed, |
2331 scoped_ptr<std::vector<gdata::SearchResultInfo> > results) { | 2335 scoped_ptr<std::vector<gdata::SearchResultInfo> > results) { |
2332 if (error != gdata::GDATA_FILE_OK) { | 2336 if (error != gdata::GDATA_FILE_OK) { |
2333 SendResponse(false); | 2337 SendResponse(false); |
2334 return; | 2338 return; |
2335 } | 2339 } |
2336 | 2340 |
2337 DCHECK(results.get()); | 2341 DCHECK(results.get()); |
2338 | 2342 |
2339 base::ListValue* entries = new ListValue(); | 2343 base::ListValue* entries = new ListValue(); |
2340 // Convert gdata files to something File API stack can understand. | 2344 // Convert gdata files to something File API stack can understand. |
2341 for (size_t i = 0; i < results->size(); ++i) { | 2345 for (size_t i = 0; i < results->size(); ++i) { |
2342 DictionaryValue* entry = new DictionaryValue(); | 2346 DictionaryValue* entry = new DictionaryValue(); |
2343 entry->SetString("fileSystemName", file_system_name_); | 2347 entry->SetString("fileSystemName", file_system_name_); |
2344 entry->SetString("fileSystemRoot", file_system_url_.spec()); | 2348 entry->SetString("fileSystemRoot", file_system_url_.spec()); |
2345 entry->SetString("fileFullPath", "/" + results->at(i).path.value()); | 2349 entry->SetString("fileFullPath", "/" + results->at(i).path.value()); |
2346 entry->SetBoolean("fileIsDirectory", results->at(i).is_directory); | 2350 entry->SetBoolean("fileIsDirectory", results->at(i).is_directory); |
2347 | 2351 |
2348 entries->Append(entry); | 2352 entries->Append(entry); |
2349 } | 2353 } |
2350 | 2354 |
2351 SetResult(entries); | 2355 base::DictionaryValue* result = new DictionaryValue(); |
| 2356 result->Set("entries", entries); |
| 2357 result->SetString("nextFeed", next_feed.spec()); |
| 2358 |
| 2359 SetResult(result); |
2352 SendResponse(true); | 2360 SendResponse(true); |
2353 } | 2361 } |
2354 | 2362 |
2355 bool GetNetworkConnectionStateFunction::RunImpl() { | 2363 bool GetNetworkConnectionStateFunction::RunImpl() { |
2356 chromeos::NetworkLibrary* network_library = | 2364 chromeos::NetworkLibrary* network_library = |
2357 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); | 2365 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); |
2358 if (!network_library) | 2366 if (!network_library) |
2359 return false; | 2367 return false; |
2360 | 2368 |
2361 const chromeos::Network* active_network = network_library->active_network(); | 2369 const chromeos::Network* active_network = network_library->active_network(); |
(...skipping 23 matching lines...) Expand all Loading... |
2385 gdata::GDataSystemService* system_service = | 2393 gdata::GDataSystemService* system_service = |
2386 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 2394 gdata::GDataSystemServiceFactory::GetForProfile(profile_); |
2387 if (!system_service || !system_service->file_system()) | 2395 if (!system_service || !system_service->file_system()) |
2388 return false; | 2396 return false; |
2389 | 2397 |
2390 FilePath directory_path = GetVirtualPathFromURL(GURL(file_url_as_string)); | 2398 FilePath directory_path = GetVirtualPathFromURL(GURL(file_url_as_string)); |
2391 system_service->file_system()->RequestDirectoryRefresh(directory_path); | 2399 system_service->file_system()->RequestDirectoryRefresh(directory_path); |
2392 | 2400 |
2393 return true; | 2401 return true; |
2394 } | 2402 } |
OLD | NEW |