| 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 "components/dom_distiller/core/dom_distiller_features.h" |
| 10 #include "components/dom_distiller/core/url_constants.h" | 11 #include "components/dom_distiller/core/url_constants.h" |
| 11 #include "grit/components_resources.h" | 12 #include "grit/components_resources.h" |
| 12 #include "net/base/url_util.h" | 13 #include "net/base/url_util.h" |
| 13 #include "ui/base/resource/resource_bundle.h" | 14 #include "ui/base/resource/resource_bundle.h" |
| 14 #include "url/gurl.h" | 15 #include "url/gurl.h" |
| 15 | 16 |
| 16 namespace dom_distiller { | 17 namespace dom_distiller { |
| 17 | 18 |
| 18 namespace url_utils { | 19 namespace url_utils { |
| 19 | 20 |
| (...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 57 | 58 |
| 58 std::string GetValueForKeyInUrlPathQuery(const std::string& path, | 59 std::string GetValueForKeyInUrlPathQuery(const std::string& path, |
| 59 const std::string& key) { | 60 const std::string& key) { |
| 60 // Tools for retrieving a value in a query only works with full GURLs, so | 61 // Tools for retrieving a value in a query only works with full GURLs, so |
| 61 // using a dummy scheme and host to create a fake URL which can be parsed. | 62 // using a dummy scheme and host to create a fake URL which can be parsed. |
| 62 GURL dummy_url(kDummyInternalUrlPrefix + path); | 63 GURL dummy_url(kDummyInternalUrlPrefix + path); |
| 63 return GetValueForKeyInUrl(dummy_url, key); | 64 return GetValueForKeyInUrl(dummy_url, key); |
| 64 } | 65 } |
| 65 | 66 |
| 66 bool IsUrlDistillable(const GURL& url) { | 67 bool IsUrlDistillable(const GURL& url) { |
| 67 return url.is_valid() && url.SchemeIsHTTPOrHTTPS(); | 68 if (!url.is_valid()) |
| 69 return false; |
| 70 if (IsDistillabilityDevSet() && url.SchemeIsFile()) |
| 71 return true; |
| 72 return url.SchemeIsHTTPOrHTTPS(); |
| 68 } | 73 } |
| 69 | 74 |
| 70 bool IsDistilledPage(const GURL& url) { | 75 bool IsDistilledPage(const GURL& url) { |
| 71 return url.is_valid() && url.scheme() == kDomDistillerScheme; | 76 return url.is_valid() && url.scheme() == kDomDistillerScheme; |
| 72 } | 77 } |
| 73 | 78 |
| 74 std::string GetIsDistillableJs() { | 79 std::string GetIsDistillableJs() { |
| 75 return ResourceBundle::GetSharedInstance() | 80 return ResourceBundle::GetSharedInstance() |
| 76 .GetRawDataResource(IDR_IS_DISTILLABLE_JS).as_string(); | 81 .GetRawDataResource(IDR_IS_DISTILLABLE_JS).as_string(); |
| 77 } | 82 } |
| 78 | 83 |
| 79 } // namespace url_utils | 84 } // namespace url_utils |
| 80 | 85 |
| 81 } // namespace dom_distiller | 86 } // namespace dom_distiller |
| OLD | NEW |