| OLD | NEW |
| 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 "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| 11 #include "components/dom_distiller/core/dom_distiller_features.h" |
| 11 #include "components/dom_distiller/core/url_constants.h" | 12 #include "components/dom_distiller/core/url_constants.h" |
| 12 #include "grit/components_resources.h" | 13 #include "grit/components_resources.h" |
| 13 #include "net/base/url_util.h" | 14 #include "net/base/url_util.h" |
| 14 #include "ui/base/resource/resource_bundle.h" | 15 #include "ui/base/resource/resource_bundle.h" |
| 15 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 16 | 17 |
| 17 namespace dom_distiller { | 18 namespace dom_distiller { |
| 18 | 19 |
| 19 namespace url_utils { | 20 namespace url_utils { |
| 20 | 21 |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 | 79 |
| 79 std::string GetValueForKeyInUrlPathQuery(const std::string& path, | 80 std::string GetValueForKeyInUrlPathQuery(const std::string& path, |
| 80 const std::string& key) { | 81 const std::string& key) { |
| 81 // Tools for retrieving a value in a query only works with full GURLs, so | 82 // Tools for retrieving a value in a query only works with full GURLs, so |
| 82 // using a dummy scheme and host to create a fake URL which can be parsed. | 83 // using a dummy scheme and host to create a fake URL which can be parsed. |
| 83 GURL dummy_url(kDummyInternalUrlPrefix + path); | 84 GURL dummy_url(kDummyInternalUrlPrefix + path); |
| 84 return GetValueForKeyInUrl(dummy_url, key); | 85 return GetValueForKeyInUrl(dummy_url, key); |
| 85 } | 86 } |
| 86 | 87 |
| 87 bool IsUrlDistillable(const GURL& url) { | 88 bool IsUrlDistillable(const GURL& url) { |
| 88 return url.is_valid() && url.SchemeIsHTTPOrHTTPS(); | 89 if (!url.is_valid()) |
| 90 return false; |
| 91 if (IsDistillabilityDevSet() && url.SchemeIsFile()) |
| 92 return true; |
| 93 return url.SchemeIsHTTPOrHTTPS(); |
| 89 } | 94 } |
| 90 | 95 |
| 91 bool IsDistilledPage(const GURL& url) { | 96 bool IsDistilledPage(const GURL& url) { |
| 92 return url.is_valid() && url.scheme() == kDomDistillerScheme; | 97 return url.is_valid() && url.scheme() == kDomDistillerScheme; |
| 93 } | 98 } |
| 94 | 99 |
| 95 std::string GetIsDistillableJs() { | 100 std::string GetIsDistillableJs() { |
| 96 return ResourceBundle::GetSharedInstance() | 101 return ResourceBundle::GetSharedInstance() |
| 97 .GetRawDataResource(IDR_IS_DISTILLABLE_JS).as_string(); | 102 .GetRawDataResource(IDR_IS_DISTILLABLE_JS).as_string(); |
| 98 } | 103 } |
| 99 | 104 |
| 100 } // namespace url_utils | 105 } // namespace url_utils |
| 101 | 106 |
| 102 } // namespace dom_distiller | 107 } // namespace dom_distiller |
| OLD | NEW |