Make sure webrtc::VideoSource is released when WebRtcVideoTrackAdapter is destroyed.
[chromium-blink-merge.git] / components / dom_distiller / core / url_utils.cc
blobe1d9b3d7606f0f346d8ad2c2e17179ccadbaf859
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.
5 #include "components/dom_distiller/core/url_utils.h"
7 #include <string>
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"
14 namespace dom_distiller {
16 namespace url_utils {
18 namespace {
20 const char kDummyInternalUrlPrefix[] = "chrome-distiller-internal://dummy/";
22 } // namespace
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);
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());
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;
46 bool IsUrlDistillable(const GURL& url) {
47 return url.is_valid() && url.SchemeIsHTTPOrHTTPS();
50 bool IsUrlReportable(const std::string& scheme, const GURL& url) {
51 return url.is_valid() && url.scheme() == scheme;
54 } // namespace url_utils
56 } // namespace dom_distiller