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

Side by Side Diff: google_apis/drive/gdata_wapi_url_generator.cc

Issue 861133002: Remove WAPI-related code, except the type definition of ResourceEntry. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Respond to review comments. Created 5 years, 11 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 unified diff | Download patch
OLDNEW
(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 #include "google_apis/drive/gdata_wapi_url_generator.h"
6
7 #include "base/logging.h"
8 #include "base/strings/string_number_conversions.h"
9 #include "base/strings/stringprintf.h"
10 #include "net/base/escape.h"
11 #include "net/base/url_util.h"
12 #include "url/gurl.h"
13
14 namespace google_apis {
15 namespace {
16
17 // URL requesting single resource entry whose resource id is followed by this
18 // prefix.
19 const char kGetEditURLPrefix[] = "/feeds/default/private/full/";
20
21 } // namespace
22
23 const char GDataWapiUrlGenerator::kBaseUrlForProduction[] =
24 "https://docs.google.com/";
25
26 // static
27 GURL GDataWapiUrlGenerator::AddStandardUrlParams(const GURL& url) {
28 GURL result = net::AppendOrReplaceQueryParameter(url, "v", "3");
29 result = net::AppendOrReplaceQueryParameter(result, "alt", "json");
30 result = net::AppendOrReplaceQueryParameter(result, "showroot", "true");
31 return result;
32 }
33
34 GDataWapiUrlGenerator::GDataWapiUrlGenerator(const GURL& base_url)
35 : base_url_(base_url) {
36 }
37
38 GDataWapiUrlGenerator::~GDataWapiUrlGenerator() {
39 }
40
41 GURL GDataWapiUrlGenerator::GenerateEditUrl(
42 const std::string& resource_id) const {
43 return AddStandardUrlParams(GenerateEditUrlWithoutParams(resource_id));
44 }
45
46 GURL GDataWapiUrlGenerator::GenerateEditUrlWithoutParams(
47 const std::string& resource_id) const {
48 return base_url_.Resolve(kGetEditURLPrefix + net::EscapePath(resource_id));
49 }
50
51 GURL GDataWapiUrlGenerator::GenerateEditUrlWithEmbedOrigin(
52 const std::string& resource_id, const GURL& embed_origin) const {
53 GURL url = GenerateEditUrl(resource_id);
54 if (!embed_origin.is_empty()) {
55 // Construct a valid serialized embed origin from an url, according to
56 // WD-html5-20110525. Such string has to be built manually, since
57 // GURL::spec() always adds the trailing slash. Moreover, ports are
58 // currently not supported.
59 DCHECK(!embed_origin.has_port());
60 DCHECK(!embed_origin.has_path() || embed_origin.path() == "/");
61 const std::string serialized_embed_origin =
62 embed_origin.scheme() + "://" + embed_origin.host();
63 url = net::AppendOrReplaceQueryParameter(
64 url, "embedOrigin", serialized_embed_origin);
65 }
66 return url;
67 }
68
69 } // namespace google_apis
OLDNEW
« no previous file with comments | « google_apis/drive/gdata_wapi_url_generator.h ('k') | google_apis/drive/gdata_wapi_url_generator_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698