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/gdata/gdata_operations.h" | 5 #include "chrome/browser/chromeos/gdata/gdata_operations.h" |
6 | 6 |
7 #include "base/bind.h" | 7 #include "base/bind.h" |
8 #include "base/json/json_reader.h" | 8 #include "base/json/json_reader.h" |
9 #include "base/metrics/histogram.h" | 9 #include "base/metrics/histogram.h" |
10 #include "base/string_number_conversions.h" | 10 #include "base/string_number_conversions.h" |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
91 GURL AddStandardUrlParams(const GURL& url) { | 91 GURL AddStandardUrlParams(const GURL& url) { |
92 GURL result = | 92 GURL result = |
93 chrome_browser_net::AppendOrReplaceQueryParameter(url, "v", "3"); | 93 chrome_browser_net::AppendOrReplaceQueryParameter(url, "v", "3"); |
94 result = | 94 result = |
95 chrome_browser_net::AppendOrReplaceQueryParameter(result, "alt", "json"); | 95 chrome_browser_net::AppendOrReplaceQueryParameter(result, "alt", "json"); |
96 return result; | 96 return result; |
97 } | 97 } |
98 | 98 |
99 // Adds additional parameters for API version, output content type and to show | 99 // Adds additional parameters for API version, output content type and to show |
100 // folders in the feed are added to document feed URLs. | 100 // folders in the feed are added to document feed URLs. |
101 GURL AddFeedUrlParams(const GURL& url, int num_items_to_fetch, | 101 GURL AddFeedUrlParams(const GURL& url, |
102 int changestamp) { | 102 int num_items_to_fetch, |
| 103 int changestamp, |
| 104 const std::string& search_string) { |
103 GURL result = AddStandardUrlParams(url); | 105 GURL result = AddStandardUrlParams(url); |
104 result = chrome_browser_net::AppendOrReplaceQueryParameter( | 106 result = chrome_browser_net::AppendOrReplaceQueryParameter( |
105 result, | 107 result, |
106 "showfolders", | 108 "showfolders", |
107 "true"); | 109 "true"); |
108 result = chrome_browser_net::AppendOrReplaceQueryParameter( | 110 result = chrome_browser_net::AppendOrReplaceQueryParameter( |
109 result, | 111 result, |
110 "max-results", | 112 "max-results", |
111 base::StringPrintf("%d", num_items_to_fetch)); | 113 base::StringPrintf("%d", num_items_to_fetch)); |
112 | 114 |
113 if (changestamp) { | 115 if (changestamp) { |
114 result = chrome_browser_net::AppendQueryParameter( | 116 result = chrome_browser_net::AppendQueryParameter( |
115 result, | 117 result, |
116 "start-index", | 118 "start-index", |
117 base::StringPrintf("%d", changestamp)); | 119 base::StringPrintf("%d", changestamp)); |
118 } | 120 } |
| 121 |
| 122 if (!search_string.empty()) { |
| 123 result = chrome_browser_net::AppendOrReplaceQueryParameter( |
| 124 result, "q", search_string); |
| 125 } |
119 return result; | 126 return result; |
120 } | 127 } |
121 | 128 |
122 } // namespace | 129 } // namespace |
123 | 130 |
124 namespace gdata { | 131 namespace gdata { |
125 | 132 |
126 //================================ AuthOperation =============================== | 133 //================================ AuthOperation =============================== |
127 | 134 |
128 AuthOperation::AuthOperation(GDataOperationRegistry* registry, | 135 AuthOperation::AuthOperation(GDataOperationRegistry* registry, |
(...skipping 311 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
440 return NULL; | 447 return NULL; |
441 } | 448 } |
442 return root_value.release(); | 449 return root_value.release(); |
443 } | 450 } |
444 | 451 |
445 //============================ GetDocumentsOperation =========================== | 452 //============================ GetDocumentsOperation =========================== |
446 | 453 |
447 GetDocumentsOperation::GetDocumentsOperation(GDataOperationRegistry* registry, | 454 GetDocumentsOperation::GetDocumentsOperation(GDataOperationRegistry* registry, |
448 Profile* profile, | 455 Profile* profile, |
449 int start_changestamp, | 456 int start_changestamp, |
| 457 const std::string& search_string, |
450 const GetDataCallback& callback) | 458 const GetDataCallback& callback) |
451 : GetDataOperation(registry, profile, callback), | 459 : GetDataOperation(registry, profile, callback), |
452 start_changestamp_(start_changestamp) { | 460 start_changestamp_(start_changestamp), |
| 461 search_string_(search_string) { |
453 } | 462 } |
454 | 463 |
455 GetDocumentsOperation::~GetDocumentsOperation() {} | 464 GetDocumentsOperation::~GetDocumentsOperation() {} |
456 | 465 |
457 void GetDocumentsOperation::SetUrl(const GURL& url) { | 466 void GetDocumentsOperation::SetUrl(const GURL& url) { |
458 override_url_ = url; | 467 override_url_ = url; |
459 } | 468 } |
460 | 469 |
461 GURL GetDocumentsOperation::GetURL() const { | 470 GURL GetDocumentsOperation::GetURL() const { |
462 if (!override_url_.is_empty()) | 471 if (!override_url_.is_empty()) |
463 return AddFeedUrlParams(override_url_, kMaxDocumentsPerFeed, 0); | 472 return AddFeedUrlParams(override_url_, |
| 473 kMaxDocumentsPerFeed, |
| 474 0, |
| 475 std::string()); |
464 | 476 |
465 if (start_changestamp_ == 0) { | 477 if (start_changestamp_ == 0) { |
466 return AddFeedUrlParams(GURL(kGetDocumentListURL), | 478 return AddFeedUrlParams(GURL(kGetDocumentListURL), |
467 kMaxDocumentsPerFeed, | 479 kMaxDocumentsPerFeed, |
468 0); | 480 0, |
| 481 search_string_); |
469 } | 482 } |
470 | 483 |
471 return AddFeedUrlParams(GURL(kGetChangesListURL), | 484 return AddFeedUrlParams(GURL(kGetChangesListURL), |
472 kMaxDocumentsPerFeed, | 485 kMaxDocumentsPerFeed, |
473 start_changestamp_); | 486 start_changestamp_, |
| 487 std::string()); |
474 } | 488 } |
475 | 489 |
476 //========================= GetAccountMetadataOperation ======================== | 490 //========================= GetAccountMetadataOperation ======================== |
477 | 491 |
478 GetAccountMetadataOperation::GetAccountMetadataOperation( | 492 GetAccountMetadataOperation::GetAccountMetadataOperation( |
479 GDataOperationRegistry* registry, | 493 GDataOperationRegistry* registry, |
480 Profile* profile, | 494 Profile* profile, |
481 const GetDataCallback& callback) | 495 const GetDataCallback& callback) |
482 : GetDataOperation(registry, profile, callback) { | 496 : GetDataOperation(registry, profile, callback) { |
483 } | 497 } |
(...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1017 return true; | 1031 return true; |
1018 } | 1032 } |
1019 | 1033 |
1020 void ResumeUploadOperation::OnURLFetchUploadProgress( | 1034 void ResumeUploadOperation::OnURLFetchUploadProgress( |
1021 const content::URLFetcher* source, int64 current, int64 total) { | 1035 const content::URLFetcher* source, int64 current, int64 total) { |
1022 // Adjust the progress values according to the range currently uploaded. | 1036 // Adjust the progress values according to the range currently uploaded. |
1023 NotifyProgress(params_.start_range + current, params_.content_length); | 1037 NotifyProgress(params_.start_range + current, params_.content_length); |
1024 } | 1038 } |
1025 | 1039 |
1026 } // namespace gdata | 1040 } // namespace gdata |
OLD | NEW |