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/google_apis/drive_api_service.h" | 5 #include "chrome/browser/google_apis/drive_api_service.h" |
6 | 6 |
7 #include <string> | 7 #include <string> |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/bind.h" | 10 #include "base/bind.h" |
(...skipping 331 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
342 runner_->StartOperationWithRetry( | 342 runner_->StartOperationWithRetry( |
343 new GetFilelistOperation( | 343 new GetFilelistOperation( |
344 operation_registry(), | 344 operation_registry(), |
345 url_request_context_getter_, | 345 url_request_context_getter_, |
346 url_generator_, | 346 url_generator_, |
347 drive::util::TranslateQuery(search_query), | 347 drive::util::TranslateQuery(search_query), |
348 kMaxNumFilesResourcePerRequestForSearch, | 348 kMaxNumFilesResourcePerRequestForSearch, |
349 base::Bind(&ParseResourceListOnBlockingPoolAndRun, callback))); | 349 base::Bind(&ParseResourceListOnBlockingPoolAndRun, callback))); |
350 } | 350 } |
351 | 351 |
352 void DriveAPIService::SearchInDirectory( | 352 void DriveAPIService::SearchByTitle( |
353 const std::string& search_query, | 353 const std::string& title, |
354 const std::string& directory_resource_id, | 354 const std::string& directory_resource_id, |
355 const GetResourceListCallback& callback) { | 355 const GetResourceListCallback& callback) { |
356 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 356 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
357 DCHECK(!search_query.empty()); | 357 DCHECK(!title.empty()); |
358 DCHECK(!directory_resource_id.empty()); | |
359 DCHECK(!callback.is_null()); | 358 DCHECK(!callback.is_null()); |
360 | 359 |
| 360 std::string query; |
| 361 base::StringAppendF(&query, "title contains '%s'", |
| 362 drive::util::EscapeQueryStringValue(title).c_str()); |
| 363 if (!directory_resource_id.empty()) { |
| 364 base::StringAppendF( |
| 365 &query, " and '%s' in parents", |
| 366 drive::util::EscapeQueryStringValue(directory_resource_id).c_str()); |
| 367 } |
| 368 query += " and trashed = false"; |
| 369 |
361 runner_->StartOperationWithRetry( | 370 runner_->StartOperationWithRetry( |
362 new GetFilelistOperation( | 371 new GetFilelistOperation( |
363 operation_registry(), | 372 operation_registry(), |
364 url_request_context_getter_, | 373 url_request_context_getter_, |
365 url_generator_, | 374 url_generator_, |
366 base::StringPrintf( | 375 query, |
367 "%s and '%s' in parents and trashed = false", | |
368 search_query.c_str(), | |
369 drive::util::EscapeQueryStringValue( | |
370 directory_resource_id).c_str()), | |
371 kMaxNumFilesResourcePerRequest, | 376 kMaxNumFilesResourcePerRequest, |
372 base::Bind(&ParseResourceListOnBlockingPoolAndRun, callback))); | 377 base::Bind(&ParseResourceListOnBlockingPoolAndRun, callback))); |
373 } | 378 } |
374 | 379 |
375 void DriveAPIService::GetChangeList(int64 start_changestamp, | 380 void DriveAPIService::GetChangeList(int64 start_changestamp, |
376 const GetResourceListCallback& callback) { | 381 const GetResourceListCallback& callback) { |
377 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 382 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
378 DCHECK(!callback.is_null()); | 383 DCHECK(!callback.is_null()); |
379 | 384 |
380 runner_->StartOperationWithRetry( | 385 runner_->StartOperationWithRetry( |
(...skipping 343 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
724 } | 729 } |
725 | 730 |
726 void DriveAPIService::OnProgressUpdate( | 731 void DriveAPIService::OnProgressUpdate( |
727 const OperationProgressStatusList& list) { | 732 const OperationProgressStatusList& list) { |
728 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); | 733 DCHECK(BrowserThread::CurrentlyOn(BrowserThread::UI)); |
729 FOR_EACH_OBSERVER( | 734 FOR_EACH_OBSERVER( |
730 DriveServiceObserver, observers_, OnProgressUpdate(list)); | 735 DriveServiceObserver, observers_, OnProgressUpdate(list)); |
731 } | 736 } |
732 | 737 |
733 } // namespace google_apis | 738 } // namespace google_apis |
OLD | NEW |