Fix build break
[chromium-blink-merge.git] / chrome / browser / google_apis / gdata_wapi_url_generator.h
blob16667da149f475bc44c6cc6056a2b14f834d6a29
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).
7 #ifndef CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_URL_GENERATOR_H_
8 #define CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_URL_GENERATOR_H_
10 #include <string>
12 #include "googleurl/src/gurl.h"
14 namespace google_apis {
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 explicit GDataWapiUrlGenerator(const GURL& base_url);
21 ~GDataWapiUrlGenerator();
23 // The base URL for communicating with the WAPI server for production.
24 static const char kBaseUrlForProduction[];
26 // Adds additional parameters for API version, output content type and to
27 // show folders in the feed are added to document feed URLs.
28 static GURL AddStandardUrlParams(const GURL& url);
30 // Adds additional parameters for initiate uploading as well as standard
31 // url params (as AddStandardUrlParams above does).
32 static GURL AddInitiateUploadUrlParams(const GURL& url);
34 // Adds additional parameters for API version, output content type and to
35 // show folders in the feed are added to document feed URLs.
36 // Optionally, adds start-index=... parameter if |changestamp| is non-zero,
37 // and adds q=... parameter if |search_string| is non-empty.
38 static GURL AddFeedUrlParams(const GURL& url,
39 int num_items_to_fetch,
40 int changestamp,
41 const std::string& search_string);
43 // Generates a URL for getting the resource list feed.
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|.
50 // TODO(kinaba,haruki): http://crbug.com/160932
51 // This is really hard to follow. We should split to multiple functions.
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).
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.
62 // search_string
63 // If |search_string| is non-empty, q=... parameter is added, and
64 // max-results=... parameter is adjusted for a search.
66 // directory_resource_id:
67 // If |directory_resource_id| is non-empty, a URL for fetching documents in
68 // a particular directory is generated.
70 GURL GenerateResourceListUrl(
71 const GURL& override_url,
72 int start_changestamp,
73 const std::string& search_string,
74 const std::string& directory_resource_id) const;
76 // Generates a URL for getting or editing the resource entry of
77 // the given resource ID.
78 GURL GenerateEditUrl(const std::string& resource_id) const;
80 // Generates a URL for getting or editing the resource entry of the
81 // given resource ID without query params.
82 // Note that, in order to access to the WAPI server, it is necessary to
83 // append some query parameters to the URL. GenerateEditUrl declared above
84 // should be used in such cases. This method is designed for constructing
85 // the data, such as xml element/attributes in request body containing
86 // edit urls.
87 GURL GenerateEditUrlWithoutParams(const std::string& resource_id) const;
89 // Generates a URL for editing the contents in the directory specified
90 // by the given resource ID.
91 GURL GenerateContentUrl(const std::string& resource_id) const;
93 // Generates a URL to remove an entry specified by |resource_id| from
94 // the directory specified by the given |parent_resource_id|.
95 GURL GenerateResourceUrlForRemoval(const std::string& parent_resource_id,
96 const std::string& resource_id) const;
98 // Generates a URL to initiate uploading a new file to a directory
99 // specified by |parent_resource_id|.
100 GURL GenerateInitiateUploadNewFileUrl(
101 const std::string& parent_resource_id) const;
103 // Generates a URL to initiate uploading file content to overwrite a
104 // file specified by |resource_id|.
105 GURL GenerateInitiateUploadExistingFileUrl(
106 const std::string& resource_id) const;
108 // Generates a URL for getting the root resource list feed.
109 // Used to make changes in the root directory (ex. create a directory in the
110 // root directory)
111 GURL GenerateResourceListRootUrl() const;
113 // Generates a URL for getting the account metadata feed.
114 // If |include_installed_apps| is set to true, the response will include the
115 // list of installed third party applications.
116 GURL GenerateAccountMetadataUrl(bool include_installed_apps) const;
118 private:
119 const GURL base_url_;
122 } // namespace google_apis
124 #endif // CHROME_BROWSER_GOOGLE_APIS_GDATA_WAPI_URL_GENERATOR_H_