Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(322)

Unified Diff: chrome/browser/chromeos/gdata/gdata_operations.cc

Issue 10383248: gdata: Add ability to fetch documents in a particular directory (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: fix the build Created 8 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/chromeos/gdata/gdata_operations.cc
diff --git a/chrome/browser/chromeos/gdata/gdata_operations.cc b/chrome/browser/chromeos/gdata/gdata_operations.cc
index 2217dd75b306f5f739dc905a542be2528d26b940..9275315534342368fa55906d812b856f27071303 100644
--- a/chrome/browser/chromeos/gdata/gdata_operations.cc
+++ b/chrome/browser/chromeos/gdata/gdata_operations.cc
@@ -41,9 +41,13 @@ const char kIfMatchAllHeader[] = "If-Match: *";
const char kIfMatchHeaderFormat[] = "If-Match: %s";
// URL requesting documents list that belong to the authenticated user only
-// (handled with '-/mine' part).
-const char kGetDocumentListURL[] =
+// (handled with '/mine' part).
+const char kGetDocumentListURLForAllDocuments[] =
"https://docs.google.com/feeds/default/private/full/-/mine";
+// URL requesting documents list in a particular directory specified by "%s"
+// that belong to the authenticated user only (handled with '/mine' part).
+const char kGetDocumentListURLForDirectoryFormat[] =
+ "https://docs.google.com/feeds/default/private/full/%s/contents/mine";
// URL requesting documents list of changes to documents collections.
const char kGetChangesListURL[] =
@@ -137,6 +141,18 @@ GURL AddFeedUrlParams(const GURL& url,
return result;
}
+// Formats a URL for getting document list. If |directory_resource_id| is
+// empty, returns a URL for fetching all documents. If it's given, returns a
+// URL for fetching documents in a particular directory.
+GURL FormatDocumentListURL(const std::string& directory_resource_id) {
+ if (directory_resource_id.empty())
+ return GURL(kGetDocumentListURLForAllDocuments);
+
+ return GURL(base::StringPrintf(kGetDocumentListURLForDirectoryFormat,
+ net::EscapePath(
+ directory_resource_id).c_str()));
+}
+
} // namespace
namespace gdata {
@@ -466,14 +482,18 @@ base::Value* GetDataOperation::ParseResponse(const std::string& data) {
//============================ GetDocumentsOperation ===========================
-GetDocumentsOperation::GetDocumentsOperation(GDataOperationRegistry* registry,
- Profile* profile,
- int start_changestamp,
- const std::string& search_string,
- const GetDataCallback& callback)
+GetDocumentsOperation::GetDocumentsOperation(
+ GDataOperationRegistry* registry,
+ Profile* profile,
+ int start_changestamp,
+ const std::string& search_string,
+ const std::string& directory_resource_id,
+
+ const GetDataCallback& callback)
: GetDataOperation(registry, profile, callback),
start_changestamp_(start_changestamp),
- search_string_(search_string) {
+ search_string_(search_string),
+ directory_resource_id_(directory_resource_id) {
}
GetDocumentsOperation::~GetDocumentsOperation() {}
@@ -490,7 +510,7 @@ GURL GetDocumentsOperation::GetURL() const {
std::string());
if (start_changestamp_ == 0) {
- return AddFeedUrlParams(GURL(kGetDocumentListURL),
+ return AddFeedUrlParams(FormatDocumentListURL(directory_resource_id_),
kMaxDocumentsPerFeed,
0,
search_string_);
« no previous file with comments | « chrome/browser/chromeos/gdata/gdata_operations.h ('k') | chrome/browser/chromeos/gdata/mock_gdata_documents_service.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698