| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 // | |
| 5 // URL utility functions for Google Documents List API (aka WAPI). | |
| 6 | |
| 7 #ifndef CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_URL_GENERATOR_H_ | |
| 8 #define CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_URL_GENERATOR_H_ | |
| 9 | |
| 10 #include <string> | |
| 11 | |
| 12 #include "url/gurl.h" | |
| 13 | |
| 14 namespace google_apis { | |
| 15 | |
| 16 // The class is used to generate URLs for communicating with the WAPI server. | |
| 17 // for production, and the local server for testing. | |
| 18 class GDataWapiUrlGenerator { | |
| 19 public: | |
| 20 // The | |
| 21 GDataWapiUrlGenerator(const GURL& base_url, const GURL& base_download_url); | |
| 22 ~GDataWapiUrlGenerator(); | |
| 23 | |
| 24 // The base URL for communicating with the WAPI server for production. | |
| 25 static const char kBaseUrlForProduction[]; | |
| 26 | |
| 27 // The base URL for the file download server for production. | |
| 28 static const char kBaseDownloadUrlForProduction[]; | |
| 29 | |
| 30 // Adds additional parameters for API version, output content type and to | |
| 31 // show folders in the feed are added to document feed URLs. | |
| 32 static GURL AddStandardUrlParams(const GURL& url); | |
| 33 | |
| 34 // Adds additional parameters for initiate uploading as well as standard | |
| 35 // url params (as AddStandardUrlParams above does). | |
| 36 static GURL AddInitiateUploadUrlParams(const GURL& url); | |
| 37 | |
| 38 // Adds additional parameters for API version, output content type and to | |
| 39 // show folders in the feed are added to document feed URLs. | |
| 40 static GURL AddFeedUrlParams(const GURL& url, | |
| 41 int num_items_to_fetch); | |
| 42 | |
| 43 // Generates a URL for getting the resource list feed. | |
| 44 // | |
| 45 // The parameters other than |search_string| are mutually exclusive. | |
| 46 // If |override_url| is non-empty, other parameters are ignored. Or if | |
| 47 // |override_url| is empty, others are not used. Besides, |search_string| | |
| 48 // cannot be set together with |start_changestamp|. | |
| 49 // | |
| 50 // override_url: | |
| 51 // By default, a hard-coded base URL of the WAPI server is used. | |
| 52 // The base URL can be overridden by |override_url|. | |
| 53 // This is used for handling continuation of feeds (2nd page and onward). | |
| 54 // | |
| 55 // start_changestamp | |
| 56 // If |start_changestamp| is 0, URL for a full feed is generated. | |
| 57 // If |start_changestamp| is non-zero, URL for a delta feed is generated. | |
| 58 // | |
| 59 // search_string | |
| 60 // If |search_string| is non-empty, q=... parameter is added, and | |
| 61 // max-results=... parameter is adjusted for a search. | |
| 62 // | |
| 63 // directory_resource_id: | |
| 64 // If |directory_resource_id| is non-empty, a URL for fetching documents in | |
| 65 // a particular directory is generated. | |
| 66 // | |
| 67 GURL GenerateResourceListUrl( | |
| 68 const GURL& override_url, | |
| 69 int64 start_changestamp, | |
| 70 const std::string& search_string, | |
| 71 const std::string& directory_resource_id) const; | |
| 72 | |
| 73 // Generates a URL for searching resources by title (exact-match). | |
| 74 // |directory_resource_id| is optional parameter. When it is empty | |
| 75 // all the existing resources are target of the search. Otherwise, | |
| 76 // the search target is just under the directory with it. | |
| 77 GURL GenerateSearchByTitleUrl( | |
| 78 const std::string& title, | |
| 79 const std::string& directory_resource_id) const; | |
| 80 | |
| 81 // Generates a URL for getting or editing the resource entry of | |
| 82 // the given resource ID. | |
| 83 GURL GenerateEditUrl(const std::string& resource_id) const; | |
| 84 | |
| 85 // Generates a URL for getting or editing the resource entry of the | |
| 86 // given resource ID without query params. | |
| 87 // Note that, in order to access to the WAPI server, it is necessary to | |
| 88 // append some query parameters to the URL. GenerateEditUrl declared above | |
| 89 // should be used in such cases. This method is designed for constructing | |
| 90 // the data, such as xml element/attributes in request body containing | |
| 91 // edit urls. | |
| 92 GURL GenerateEditUrlWithoutParams(const std::string& resource_id) const; | |
| 93 | |
| 94 // Generates a URL for getting or editing the resource entry of the given | |
| 95 // resource ID with additionally passed embed origin. This is used to fetch | |
| 96 // share urls for the sharing dialog to be embedded with the |embed_origin| | |
| 97 // origin. | |
| 98 GURL GenerateEditUrlWithEmbedOrigin(const std::string& resource_id, | |
| 99 const GURL& embed_origin) const; | |
| 100 | |
| 101 // Generates a URL for editing the contents in the directory specified | |
| 102 // by the given resource ID. | |
| 103 GURL GenerateContentUrl(const std::string& resource_id) const; | |
| 104 | |
| 105 // Generates a URL to remove an entry specified by |resource_id| from | |
| 106 // the directory specified by the given |parent_resource_id|. | |
| 107 GURL GenerateResourceUrlForRemoval(const std::string& parent_resource_id, | |
| 108 const std::string& resource_id) const; | |
| 109 | |
| 110 // Generates a URL to initiate uploading a new file to a directory | |
| 111 // specified by |parent_resource_id|. | |
| 112 GURL GenerateInitiateUploadNewFileUrl( | |
| 113 const std::string& parent_resource_id) const; | |
| 114 | |
| 115 // Generates a URL to initiate uploading file content to overwrite a | |
| 116 // file specified by |resource_id|. | |
| 117 GURL GenerateInitiateUploadExistingFileUrl( | |
| 118 const std::string& resource_id) const; | |
| 119 | |
| 120 // Generates a URL for getting the root resource list feed. | |
| 121 // Used to make changes in the root directory (ex. create a directory in the | |
| 122 // root directory) | |
| 123 GURL GenerateResourceListRootUrl() const; | |
| 124 | |
| 125 // Generates a URL for getting the account metadata feed. | |
| 126 // If |include_installed_apps| is set to true, the response will include the | |
| 127 // list of installed third party applications. | |
| 128 GURL GenerateAccountMetadataUrl(bool include_installed_apps) const; | |
| 129 | |
| 130 // Generates a URL for downloading a file. | |
| 131 GURL GenerateDownloadFileUrl(const std::string& resource_id) const; | |
| 132 | |
| 133 private: | |
| 134 const GURL base_url_; | |
| 135 const GURL base_download_url_; | |
| 136 }; | |
| 137 | |
| 138 } // namespace google_apis | |
| 139 | |
| 140 #endif // CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_URL_GENERATOR_H_ | |
| OLD | NEW |