12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Copyright (c) 2012 The Chromium Authors. All rights reserved.
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// Use of this source code is governed by a BSD-style license that can be
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// found in the LICENSE file.
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)//
52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// URL utility functions for Google Documents List API (aka WAPI).
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
7a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#ifndef GOOGLE_APIS_DRIVE_GDATA_WAPI_URL_GENERATOR_H_
8a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#define GOOGLE_APIS_DRIVE_GDATA_WAPI_URL_GENERATOR_H_
92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include <string>
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
12eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch#include "url/gurl.h"
132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)namespace google_apis {
152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
162a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// The class is used to generate URLs for communicating with the WAPI server.
172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)// for production, and the local server for testing.
182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)class GDataWapiUrlGenerator {
192a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) public:
200529e5d033099cbfc42635f6f6183833b09dff6eBen Murdoch  GDataWapiUrlGenerator(const GURL& base_url);
212a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  ~GDataWapiUrlGenerator();
222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // The base URL for communicating with the WAPI server for production.
242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  static const char kBaseUrlForProduction[];
252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
26eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  // The base URL for the file download server for production.
27eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch  static const char kBaseDownloadUrlForProduction[];
28eb525c5499e34cc9c4b825d6d9e75bb07cc06aceBen Murdoch
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Adds additional parameters for API version, output content type and to
302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // show folders in the feed are added to document feed URLs.
312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  static GURL AddStandardUrlParams(const GURL& url);
322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Generates a URL for getting or editing the resource entry of
342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // the given resource ID.
352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GURL GenerateEditUrl(const std::string& resource_id) const;
362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Generates a URL for getting or editing the resource entry of the
382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // given resource ID without query params.
392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // Note that, in order to access to the WAPI server, it is necessary to
402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // append some query parameters to the URL. GenerateEditUrl declared above
412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // should be used in such cases. This method is designed for constructing
422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // the data, such as xml element/attributes in request body containing
432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  // edit urls.
442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  GURL GenerateEditUrlWithoutParams(const std::string& resource_id) const;
452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
46bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch  // Generates a URL for getting or editing the resource entry of the given
47bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch  // resource ID with additionally passed embed origin. This is used to fetch
48bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch  // share urls for the sharing dialog to be embedded with the |embed_origin|
49bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch  // origin.
50bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch  GURL GenerateEditUrlWithEmbedOrigin(const std::string& resource_id,
51bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch                                      const GURL& embed_origin) const;
52bbcdd45c55eb7c4641ab97aef9889b0fc828e7d3Ben Murdoch
532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) private:
542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)  const GURL base_url_;
552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)};
562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)}  // namespace google_apis
582a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
59a3f6a49ab37290eeeb8db0f41ec0f1cb74a68be7Torne (Richard Coles)#endif  // GOOGLE_APIS_DRIVE_GDATA_WAPI_URL_GENERATOR_H_
60