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