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

Side by Side Diff: components/dom_distiller/core/url_utils.cc

Issue 442503002: Retrieve article original URL from entryID (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added comments Created 6 years, 4 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 | Annotate | Revision Log
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 #include "components/dom_distiller/core/url_utils.h" 5 #include "components/dom_distiller/core/url_utils.h"
6 6
7 #include <string> 7 #include <string>
8 8
9 #include "base/guid.h" 9 #include "base/guid.h"
10 #include "components/dom_distiller/core/url_constants.h" 10 #include "components/dom_distiller/core/url_constants.h"
(...skipping 15 matching lines...) Expand all
26 GURL url(scheme + "://" + base::GenerateGUID()); 26 GURL url(scheme + "://" + base::GenerateGUID());
27 return net::AppendOrReplaceQueryParameter(url, kEntryIdKey, entry_id); 27 return net::AppendOrReplaceQueryParameter(url, kEntryIdKey, entry_id);
28 } 28 }
29 29
30 const GURL GetDistillerViewUrlFromUrl(const std::string& scheme, 30 const GURL GetDistillerViewUrlFromUrl(const std::string& scheme,
31 const GURL& view_url) { 31 const GURL& view_url) {
32 GURL url(scheme + "://" + base::GenerateGUID()); 32 GURL url(scheme + "://" + base::GenerateGUID());
33 return net::AppendOrReplaceQueryParameter(url, kUrlKey, view_url.spec()); 33 return net::AppendOrReplaceQueryParameter(url, kUrlKey, view_url.spec());
34 } 34 }
35 35
36 std::string GetValueForKeyInUrl(const GURL& url, const std::string& key) {
37 std::string value;
robliao 2014/08/13 23:43:15 Move declaration to after return "" (Minimal scope
sunangel 2014/08/13 23:47:15 Done.
38 if (!url.is_valid())
39 return "";
40 if (net::GetValueForKeyInQuery(url, key, &value)) {
41 return value;
42 }
43 return "";
44 }
45
36 std::string GetValueForKeyInUrlPathQuery(const std::string& path, 46 std::string GetValueForKeyInUrlPathQuery(const std::string& path,
37 const std::string& key) { 47 const std::string& key) {
38 // Tools for retrieving a value in a query only works with full GURLs, so 48 // Tools for retrieving a value in a query only works with full GURLs, so
39 // using a dummy scheme and host to create a fake URL which can be parsed. 49 // using a dummy scheme and host to create a fake URL which can be parsed.
40 GURL dummy_url(kDummyInternalUrlPrefix + path); 50 GURL dummy_url(kDummyInternalUrlPrefix + path);
41 std::string value; 51 return GetValueForKeyInUrl(dummy_url, key);
42 net::GetValueForKeyInQuery(dummy_url, key, &value);
43 return value;
44 } 52 }
45 53
46 bool IsUrlDistillable(const GURL& url) { 54 bool IsUrlDistillable(const GURL& url) {
47 return url.is_valid() && url.SchemeIsHTTPOrHTTPS(); 55 return url.is_valid() && url.SchemeIsHTTPOrHTTPS();
48 } 56 }
49 57
50 bool IsDistilledPage(const GURL& url) { 58 bool IsDistilledPage(const GURL& url) {
51 return url.is_valid() && url.scheme() == kDomDistillerScheme; 59 return url.is_valid() && url.scheme() == kDomDistillerScheme;
52 } 60 }
53 61
54 } // namespace url_utils 62 } // namespace url_utils
55 63
56 } // namespace dom_distiller 64 } // namespace dom_distiller
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698