| 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 // URL utility functions for Google Documents List API (aka WAPI). | 5 // URL utility functions for Google Documents List API (aka WAPI). |
| 6 | 6 |
| 7 #ifndef CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_URL_UTIL_H_ | 7 #ifndef CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_URL_UTIL_H_ |
| 8 #define CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_URL_UTIL_H_ | 8 #define CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_URL_UTIL_H_ |
| 9 | 9 |
| 10 #include <string> | 10 #include <string> |
| 11 | 11 |
| 12 class GURL; | 12 #include "googleurl/src/gurl.h" |
| 13 | 13 |
| 14 namespace google_apis { | 14 namespace google_apis { |
| 15 namespace gdata_wapi_url_util { | 15 namespace gdata_wapi_url_util { |
| 16 | 16 |
| 17 // The base URL for communicating with the WAPI server for production. |
| 18 extern const char kBaseUrlForProduction[]; |
| 19 |
| 20 // The base URL for communicating with the local test server for testing. |
| 21 extern const char kBaseUrlForTesting[]; |
| 22 |
| 17 // Adds additional parameters for API version, output content type and to show | 23 // Adds additional parameters for API version, output content type and to show |
| 18 // folders in the feed are added to document feed URLs. | 24 // folders in the feed are added to document feed URLs. |
| 19 GURL AddStandardUrlParams(const GURL& url); | 25 GURL AddStandardUrlParams(const GURL& url); |
| 20 | 26 |
| 21 // Adds additional parameters to metadata feed to include installed 3rd party | 27 // Adds additional parameters to metadata feed to include installed 3rd party |
| 22 // applications. | 28 // applications. |
| 23 GURL AddMetadataUrlParams(const GURL& url); | 29 GURL AddMetadataUrlParams(const GURL& url); |
| 24 | 30 |
| 25 // Adds additional parameters for API version, output content type and to show | 31 // Adds additional parameters for API version, output content type and to show |
| 26 // folders in the feed are added to document feed URLs. | 32 // folders in the feed are added to document feed URLs. |
| 27 // Optionally, adds start-index=... parameter if |changestamp| is non-zero, | 33 // Optionally, adds start-index=... parameter if |changestamp| is non-zero, |
| 28 // and adds q=... parameter if |search_string| is non-empty. | 34 // and adds q=... parameter if |search_string| is non-empty. |
| 29 GURL AddFeedUrlParams(const GURL& url, | 35 GURL AddFeedUrlParams(const GURL& url, |
| 30 int num_items_to_fetch, | 36 int num_items_to_fetch, |
| 31 int changestamp, | 37 int changestamp, |
| 32 const std::string& search_string); | 38 const std::string& search_string); |
| 33 | 39 |
| 34 // Generates a URL for getting the documents list feed. | 40 } // namespace gdata_wapi_url_util |
| 41 |
| 42 // TODO(satorux): Move the class to a separate file gdata_wapi_url_generator.h. |
| 35 // | 43 // |
| 36 // override_url: | 44 // The class is used to generate URLs for communicating with the WAPI server. |
| 37 // By default, a hard-coded base URL of the WAPI server is used. | 45 // for production, and the local server for testing. |
| 38 // The base URL can be overridden by |override_url|. | 46 class GDataWapiUrlGenerator { |
| 39 // This is used for handling continuation of feeds (2nd page and onward). | 47 public: |
| 40 // | 48 explicit GDataWapiUrlGenerator(const GURL& base_url); |
| 41 // start_changestamp | 49 ~GDataWapiUrlGenerator(); |
| 42 // If |start_changestamp| is 0, URL for a full feed is generated. | |
| 43 // If |start_changestamp| is non-zero, URL for a delta feed is generated. | |
| 44 // | |
| 45 // search_string | |
| 46 // If |search_string| is non-empty, q=... parameter is added, and | |
| 47 // max-results=... parameter is adjusted for a search. | |
| 48 // | |
| 49 // shared_with_me | |
| 50 // If |shared_with_me| is true, the base URL is changed to fetch the | |
| 51 // shared-with-me documents. | |
| 52 // | |
| 53 // directory_resource_id: | |
| 54 // If |directory_resource_id| is non-empty, a URL for fetching documents in | |
| 55 // a particular directory is generated. | |
| 56 // | |
| 57 GURL GenerateDocumentListUrl( | |
| 58 const GURL& override_url, | |
| 59 int start_changestamp, | |
| 60 const std::string& search_string, | |
| 61 bool shared_with_me, | |
| 62 const std::string& directory_resource_id); | |
| 63 | 50 |
| 64 // Generates a URL for getting the document entry of the given resource ID. | 51 // Generates a URL for getting the documents list feed. |
| 65 GURL GenerateDocumentEntryUrl(const std::string& resource_id); | 52 // |
| 53 // override_url: |
| 54 // By default, a hard-coded base URL of the WAPI server is used. |
| 55 // The base URL can be overridden by |override_url|. |
| 56 // This is used for handling continuation of feeds (2nd page and onward). |
| 57 // |
| 58 // start_changestamp |
| 59 // If |start_changestamp| is 0, URL for a full feed is generated. |
| 60 // If |start_changestamp| is non-zero, URL for a delta feed is generated. |
| 61 // |
| 62 // search_string |
| 63 // If |search_string| is non-empty, q=... parameter is added, and |
| 64 // max-results=... parameter is adjusted for a search. |
| 65 // |
| 66 // shared_with_me |
| 67 // If |shared_with_me| is true, the base URL is changed to fetch the |
| 68 // shared-with-me documents. |
| 69 // |
| 70 // directory_resource_id: |
| 71 // If |directory_resource_id| is non-empty, a URL for fetching documents in |
| 72 // a particular directory is generated. |
| 73 // |
| 74 GURL GenerateDocumentListUrl( |
| 75 const GURL& override_url, |
| 76 int start_changestamp, |
| 77 const std::string& search_string, |
| 78 bool shared_with_me, |
| 79 const std::string& directory_resource_id) const; |
| 66 | 80 |
| 67 // Generates a URL for getting the root document list feed. | 81 // Generates a URL for getting the document entry of the given resource ID. |
| 68 // Used to make changes in the root directory (ex. create a directory in the | 82 GURL GenerateDocumentEntryUrl(const std::string& resource_id) const; |
| 69 // root directory) | |
| 70 GURL GenerateDocumentListRootUrl(); | |
| 71 | 83 |
| 72 // Generates a URL for getting the account metadata feed. | 84 // Generates a URL for getting the root document list feed. |
| 73 GURL GenerateAccountMetadataUrl(); | 85 // Used to make changes in the root directory (ex. create a directory in the |
| 86 // root directory) |
| 87 GURL GenerateDocumentListRootUrl() const; |
| 74 | 88 |
| 75 } // namespace gdata_wapi_url_util | 89 // Generates a URL for getting the account metadata feed. |
| 90 GURL GenerateAccountMetadataUrl() const; |
| 91 |
| 92 private: |
| 93 const GURL base_url_; |
| 94 }; |
| 95 |
| 76 } // namespace google_apis | 96 } // namespace google_apis |
| 77 | 97 |
| 78 #endif // CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_URL_UTIL_H_ | 98 #endif // CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_URL_UTIL_H_ |
| OLD | NEW |