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 2287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2298 service->SetBoolean(prefs::kDisableGDataOverCellular, tmp); | 2298 service->SetBoolean(prefs::kDisableGDataOverCellular, tmp); |
2299 } | 2299 } |
2300 | 2300 |
2301 if (value->GetBoolean("hostedFilesDisabled", &tmp)) { | 2301 if (value->GetBoolean("hostedFilesDisabled", &tmp)) { |
2302 service->SetBoolean(prefs::kDisableGDataHostedFiles, tmp); | 2302 service->SetBoolean(prefs::kDisableGDataHostedFiles, tmp); |
2303 } | 2303 } |
2304 | 2304 |
2305 return true; | 2305 return true; |
2306 } | 2306 } |
2307 | 2307 |
| 2308 SearchDriveFunction::SearchDriveFunction() {} |
| 2309 |
| 2310 SearchDriveFunction::~SearchDriveFunction() {} |
| 2311 |
2308 bool SearchDriveFunction::RunImpl() { | 2312 bool SearchDriveFunction::RunImpl() { |
2309 if (!args_->GetString(0, &query_)) | 2313 if (!args_->GetString(0, &query_)) |
2310 return false; | 2314 return false; |
2311 | 2315 |
| 2316 if (!args_->GetString(1, &next_feed_)) |
| 2317 return false; |
| 2318 |
2312 BrowserContext::GetFileSystemContext(profile())->OpenFileSystem( | 2319 BrowserContext::GetFileSystemContext(profile())->OpenFileSystem( |
2313 source_url_.GetOrigin(), fileapi::kFileSystemTypeExternal, false, | 2320 source_url_.GetOrigin(), fileapi::kFileSystemTypeExternal, false, |
2314 base::Bind(&SearchDriveFunction::OnFileSystemOpened, this)); | 2321 base::Bind(&SearchDriveFunction::OnFileSystemOpened, this)); |
2315 return true; | 2322 return true; |
2316 } | 2323 } |
2317 | 2324 |
2318 void SearchDriveFunction::OnFileSystemOpened( | 2325 void SearchDriveFunction::OnFileSystemOpened( |
2319 base::PlatformFileError result, | 2326 base::PlatformFileError result, |
2320 const std::string& file_system_name, | 2327 const std::string& file_system_name, |
2321 const GURL& file_system_url) { | 2328 const GURL& file_system_url) { |
2322 if (result != base::PLATFORM_FILE_OK) { | 2329 if (result != base::PLATFORM_FILE_OK) { |
2323 SendResponse(false); | 2330 SendResponse(false); |
2324 return; | 2331 return; |
2325 } | 2332 } |
2326 | 2333 |
2327 file_system_name_ = file_system_name; | 2334 file_system_name_ = file_system_name; |
2328 file_system_url_ = file_system_url; | 2335 file_system_url_ = file_system_url; |
2329 | 2336 |
2330 gdata::GDataSystemService* system_service = | 2337 gdata::GDataSystemService* system_service = |
2331 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 2338 gdata::GDataSystemServiceFactory::GetForProfile(profile_); |
2332 if (!system_service || !system_service->file_system()) { | 2339 if (!system_service || !system_service->file_system()) { |
2333 SendResponse(false); | 2340 SendResponse(false); |
2334 return; | 2341 return; |
2335 } | 2342 } |
2336 | 2343 |
2337 system_service->file_system()->Search( | 2344 system_service->file_system()->Search( |
2338 query_, | 2345 query_, GURL(next_feed_), |
2339 base::Bind(&SearchDriveFunction::OnSearch, this)); | 2346 base::Bind(&SearchDriveFunction::OnSearch, this)); |
2340 } | 2347 } |
2341 | 2348 |
2342 void SearchDriveFunction::OnSearch( | 2349 void SearchDriveFunction::OnSearch( |
2343 gdata::GDataFileError error, | 2350 gdata::GDataFileError error, |
| 2351 const GURL& next_feed, |
2344 scoped_ptr<std::vector<gdata::SearchResultInfo> > results) { | 2352 scoped_ptr<std::vector<gdata::SearchResultInfo> > results) { |
2345 if (error != gdata::GDATA_FILE_OK) { | 2353 if (error != gdata::GDATA_FILE_OK) { |
2346 SendResponse(false); | 2354 SendResponse(false); |
2347 return; | 2355 return; |
2348 } | 2356 } |
2349 | 2357 |
2350 DCHECK(results.get()); | 2358 DCHECK(results.get()); |
2351 | 2359 |
2352 base::ListValue* entries = new ListValue(); | 2360 base::ListValue* entries = new ListValue(); |
2353 // Convert gdata files to something File API stack can understand. | 2361 // Convert gdata files to something File API stack can understand. |
2354 for (size_t i = 0; i < results->size(); ++i) { | 2362 for (size_t i = 0; i < results->size(); ++i) { |
2355 DictionaryValue* entry = new DictionaryValue(); | 2363 DictionaryValue* entry = new DictionaryValue(); |
2356 entry->SetString("fileSystemName", file_system_name_); | 2364 entry->SetString("fileSystemName", file_system_name_); |
2357 entry->SetString("fileSystemRoot", file_system_url_.spec()); | 2365 entry->SetString("fileSystemRoot", file_system_url_.spec()); |
2358 entry->SetString("fileFullPath", "/" + results->at(i).path.value()); | 2366 entry->SetString("fileFullPath", "/" + results->at(i).path.value()); |
2359 entry->SetBoolean("fileIsDirectory", results->at(i).is_directory); | 2367 entry->SetBoolean("fileIsDirectory", results->at(i).is_directory); |
2360 | 2368 |
2361 entries->Append(entry); | 2369 entries->Append(entry); |
2362 } | 2370 } |
2363 | 2371 |
2364 SetResult(entries); | 2372 base::DictionaryValue* result = new DictionaryValue(); |
| 2373 result->Set("entries", entries); |
| 2374 result->SetString("nextFeed", next_feed.spec()); |
| 2375 |
| 2376 SetResult(result); |
2365 SendResponse(true); | 2377 SendResponse(true); |
2366 } | 2378 } |
2367 | 2379 |
2368 bool ClearDriveCacheFunction::RunImpl() { | 2380 bool ClearDriveCacheFunction::RunImpl() { |
2369 gdata::GDataSystemService* system_service = | 2381 gdata::GDataSystemService* system_service = |
2370 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 2382 gdata::GDataSystemServiceFactory::GetForProfile(profile_); |
2371 // |system_service| is NULL if incognito window / guest login. | 2383 // |system_service| is NULL if incognito window / guest login. |
2372 if (!system_service || !system_service->file_system()) | 2384 if (!system_service || !system_service->file_system()) |
2373 return false; | 2385 return false; |
2374 | 2386 |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2413 gdata::GDataSystemService* system_service = | 2425 gdata::GDataSystemService* system_service = |
2414 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 2426 gdata::GDataSystemServiceFactory::GetForProfile(profile_); |
2415 if (!system_service || !system_service->file_system()) | 2427 if (!system_service || !system_service->file_system()) |
2416 return false; | 2428 return false; |
2417 | 2429 |
2418 FilePath directory_path = GetVirtualPathFromURL(GURL(file_url_as_string)); | 2430 FilePath directory_path = GetVirtualPathFromURL(GURL(file_url_as_string)); |
2419 system_service->file_system()->RequestDirectoryRefresh(directory_path); | 2431 system_service->file_system()->RequestDirectoryRefresh(directory_path); |
2420 | 2432 |
2421 return true; | 2433 return true; |
2422 } | 2434 } |
OLD | NEW |