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

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

Issue 151003006: Add support for distilling arbitrary URLs in DOM Distiller Viewer. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Added new strings to iOS whitelist Created 6 years, 9 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
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "components/dom_distiller/core/url_utils.h"
6
7 #include <string>
8
9 #include "base/guid.h"
10 #include "components/dom_distiller/core/url_constants.h"
11 #include "net/base/url_util.h"
12 #include "url/gurl.h"
13
14 namespace dom_distiller {
15
16 namespace url_utils {
17
18 namespace {
19
20 const char kDummyInternalUrlPrefix[] = "chrome-distiller-internal://dummy/";
21
22 } // namespace
23
24 const GURL GetDistillerViewUrlFromEntryId(const std::string& scheme,
25 const std::string& entry_id) {
26 GURL url(scheme + "://" + base::GenerateGUID());
27 return net::AppendOrReplaceQueryParameter(url, kEntryIdKey, entry_id);
28 }
29
30 const GURL GetDistillerViewUrlFromUrl(const std::string& scheme,
31 const GURL& view_url) {
32 GURL url(scheme + "://" + base::GenerateGUID());
33 return net::AppendOrReplaceQueryParameter(url, kUrlKey, view_url.spec());
34 }
35
36 std::string GetValueForKeyInUrlPathQuery(const std::string& path,
37 const std::string& key) {
38 // 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.
40 GURL dummy_url(kDummyInternalUrlPrefix + path);
41 std::string value;
42 net::GetValueForKeyInQuery(dummy_url, key, &value);
43 return value;
44 }
45
46 bool IsUrlDistillable(const GURL& url) {
47 return url.is_valid() && url.SchemeIsHTTPOrHTTPS();
48 }
49
50 } // namespace url_utils
51
52 } // namespace dom_distiller
OLDNEW
« no previous file with comments | « components/dom_distiller/core/url_utils.h ('k') | components/dom_distiller/core/url_utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698