| 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 2307 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2318 service->SetBoolean(prefs::kDisableGDataHostedFiles, tmp); | 2318 service->SetBoolean(prefs::kDisableGDataHostedFiles, tmp); |
| 2319 } | 2319 } |
| 2320 | 2320 |
| 2321 return true; | 2321 return true; |
| 2322 } | 2322 } |
| 2323 | 2323 |
| 2324 bool SearchDriveFunction::RunImpl() { | 2324 bool SearchDriveFunction::RunImpl() { |
| 2325 if (!args_->GetString(0, &query_)) | 2325 if (!args_->GetString(0, &query_)) |
| 2326 return false; | 2326 return false; |
| 2327 | 2327 |
| 2328 if (!args_->GetString(1, &next_feed_)) |
| 2329 return false; |
| 2330 |
| 2328 BrowserContext::GetFileSystemContext(profile())->OpenFileSystem( | 2331 BrowserContext::GetFileSystemContext(profile())->OpenFileSystem( |
| 2329 source_url_.GetOrigin(), fileapi::kFileSystemTypeExternal, false, | 2332 source_url_.GetOrigin(), fileapi::kFileSystemTypeExternal, false, |
| 2330 base::Bind(&SearchDriveFunction::OnFileSystemOpened, this)); | 2333 base::Bind(&SearchDriveFunction::OnFileSystemOpened, this)); |
| 2331 return true; | 2334 return true; |
| 2332 } | 2335 } |
| 2333 | 2336 |
| 2334 void SearchDriveFunction::OnFileSystemOpened( | 2337 void SearchDriveFunction::OnFileSystemOpened( |
| 2335 base::PlatformFileError result, | 2338 base::PlatformFileError result, |
| 2336 const std::string& file_system_name, | 2339 const std::string& file_system_name, |
| 2337 const GURL& file_system_url) { | 2340 const GURL& file_system_url) { |
| 2338 if (result != base::PLATFORM_FILE_OK) { | 2341 if (result != base::PLATFORM_FILE_OK) { |
| 2339 SendResponse(false); | 2342 SendResponse(false); |
| 2340 return; | 2343 return; |
| 2341 } | 2344 } |
| 2342 | 2345 |
| 2343 file_system_name_ = file_system_name; | 2346 file_system_name_ = file_system_name; |
| 2344 file_system_url_ = file_system_url; | 2347 file_system_url_ = file_system_url; |
| 2345 | 2348 |
| 2346 gdata::GDataSystemService* system_service = | 2349 gdata::GDataSystemService* system_service = |
| 2347 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 2350 gdata::GDataSystemServiceFactory::GetForProfile(profile_); |
| 2348 if (!system_service || !system_service->file_system()) { | 2351 if (!system_service || !system_service->file_system()) { |
| 2349 SendResponse(false); | 2352 SendResponse(false); |
| 2350 return; | 2353 return; |
| 2351 } | 2354 } |
| 2352 | 2355 |
| 2353 system_service->file_system()->Search( | 2356 system_service->file_system()->Search( |
| 2354 query_, | 2357 query_, GURL(next_feed_), |
| 2355 base::Bind(&SearchDriveFunction::OnSearch, this)); | 2358 base::Bind(&SearchDriveFunction::OnSearch, this)); |
| 2356 } | 2359 } |
| 2357 | 2360 |
| 2358 void SearchDriveFunction::OnSearch( | 2361 void SearchDriveFunction::OnSearch( |
| 2359 gdata::GDataFileError error, | 2362 gdata::GDataFileError error, |
| 2363 const GURL& next_feed, |
| 2360 scoped_ptr<std::vector<gdata::SearchResultInfo> > results) { | 2364 scoped_ptr<std::vector<gdata::SearchResultInfo> > results) { |
| 2361 if (error != gdata::GDATA_FILE_OK) { | 2365 if (error != gdata::GDATA_FILE_OK) { |
| 2362 SendResponse(false); | 2366 SendResponse(false); |
| 2363 return; | 2367 return; |
| 2364 } | 2368 } |
| 2365 | 2369 |
| 2366 DCHECK(results.get()); | 2370 DCHECK(results.get()); |
| 2367 | 2371 |
| 2368 base::ListValue* entries = new ListValue(); | 2372 base::ListValue* entries = new ListValue(); |
| 2369 // Convert gdata files to something File API stack can understand. | 2373 // Convert gdata files to something File API stack can understand. |
| 2370 for (size_t i = 0; i < results->size(); ++i) { | 2374 for (size_t i = 0; i < results->size(); ++i) { |
| 2371 DictionaryValue* entry = new DictionaryValue(); | 2375 DictionaryValue* entry = new DictionaryValue(); |
| 2372 entry->SetString("fileSystemName", file_system_name_); | 2376 entry->SetString("fileSystemName", file_system_name_); |
| 2373 entry->SetString("fileSystemRoot", file_system_url_.spec()); | 2377 entry->SetString("fileSystemRoot", file_system_url_.spec()); |
| 2374 entry->SetString("fileFullPath", "/" + results->at(i).path.value()); | 2378 entry->SetString("fileFullPath", "/" + results->at(i).path.value()); |
| 2375 entry->SetBoolean("fileIsDirectory", results->at(i).is_directory); | 2379 entry->SetBoolean("fileIsDirectory", results->at(i).is_directory); |
| 2376 | 2380 |
| 2377 entries->Append(entry); | 2381 entries->Append(entry); |
| 2378 } | 2382 } |
| 2379 | 2383 |
| 2380 SetResult(entries); | 2384 base::DictionaryValue* result = new DictionaryValue(); |
| 2385 result->Set("entries", entries); |
| 2386 result->SetString("nextFeed", next_feed.spec()); |
| 2387 |
| 2388 SetResult(result); |
| 2381 SendResponse(true); | 2389 SendResponse(true); |
| 2382 } | 2390 } |
| 2383 | 2391 |
| 2384 bool GetNetworkConnectionStateFunction::RunImpl() { | 2392 bool GetNetworkConnectionStateFunction::RunImpl() { |
| 2385 chromeos::NetworkLibrary* network_library = | 2393 chromeos::NetworkLibrary* network_library = |
| 2386 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); | 2394 chromeos::CrosLibrary::Get()->GetNetworkLibrary(); |
| 2387 if (!network_library) | 2395 if (!network_library) |
| 2388 return false; | 2396 return false; |
| 2389 | 2397 |
| 2390 const chromeos::Network* active_network = network_library->active_network(); | 2398 const chromeos::Network* active_network = network_library->active_network(); |
| (...skipping 23 matching lines...) Expand all Loading... |
| 2414 gdata::GDataSystemService* system_service = | 2422 gdata::GDataSystemService* system_service = |
| 2415 gdata::GDataSystemServiceFactory::GetForProfile(profile_); | 2423 gdata::GDataSystemServiceFactory::GetForProfile(profile_); |
| 2416 if (!system_service || !system_service->file_system()) | 2424 if (!system_service || !system_service->file_system()) |
| 2417 return false; | 2425 return false; |
| 2418 | 2426 |
| 2419 FilePath directory_path = GetVirtualPathFromURL(GURL(file_url_as_string)); | 2427 FilePath directory_path = GetVirtualPathFromURL(GURL(file_url_as_string)); |
| 2420 system_service->file_system()->RequestDirectoryRefresh(directory_path); | 2428 system_service->file_system()->RequestDirectoryRefresh(directory_path); |
| 2421 | 2429 |
| 2422 return true; | 2430 return true; |
| 2423 } | 2431 } |
| OLD | NEW |