OLD | NEW |
---|---|
1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 "ios/chrome/browser/reading_list/offline_url_utils.h" | 5 #include "ios/chrome/browser/reading_list/offline_url_utils.h" |
6 | 6 |
7 #include "base/logging.h" | |
7 #include "base/md5.h" | 8 #include "base/md5.h" |
9 #include "base/strings/string_util.h" | |
8 #include "base/strings/stringprintf.h" | 10 #include "base/strings/stringprintf.h" |
11 #include "base/strings/utf_string_conversions.h" | |
9 #include "components/reading_list/ios/offline_url_utils.h" | 12 #include "components/reading_list/ios/offline_url_utils.h" |
10 #include "ios/chrome/browser/chrome_url_constants.h" | 13 #include "ios/chrome/browser/chrome_url_constants.h" |
11 #include "net/base/url_util.h" | 14 #include "net/base/url_util.h" |
12 | 15 |
13 namespace { | 16 namespace { |
14 const char kVirtualURLQueryParam[] = "virtualURL"; | 17 const char kVirtualURLQueryParam[] = "virtualURL"; |
15 } | 18 } |
16 | 19 |
17 namespace reading_list { | 20 namespace reading_list { |
18 | 21 |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
56 offline_path.value() + distilled_url.path()); | 59 offline_path.value() + distilled_url.path()); |
57 if (resources_root_url) { | 60 if (resources_root_url) { |
58 *resources_root_url = file_url.Resolve("."); | 61 *resources_root_url = file_url.Resolve("."); |
59 } | 62 } |
60 return file_url; | 63 return file_url; |
61 } | 64 } |
62 | 65 |
63 bool IsOfflineURL(const GURL& url) { | 66 bool IsOfflineURL(const GURL& url) { |
64 return url.SchemeIs(kChromeUIScheme) && url.host() == kChromeUIOfflineHost; | 67 return url.SchemeIs(kChromeUIScheme) && url.host() == kChromeUIOfflineHost; |
65 } | 68 } |
69 | |
70 base::string16 StripSchemeFromOnlineUrl(base::string16 online_url) { | |
71 base::string16 https_scheme = base::UTF8ToUTF16(base::StringPrintf( | |
72 "%s%s", url::kHttpsScheme, url::kStandardSchemeSeparator)); | |
73 if (base::StartsWith(online_url, https_scheme, | |
74 base::CompareCase::SENSITIVE)) { | |
75 return online_url.substr(https_scheme.length()); | |
76 } | |
77 // http:// scheme should already have been trimmed at this point. | |
78 // DCHECK to detect formatting changes in omnibox. | |
79 DCHECK(!base::StartsWith( | |
80 online_url, base::UTF8ToUTF16(base::StringPrintf( | |
Eugene But (OOO till 7-30)
2016/12/28 17:02:59
Optional nit: For the purpose of your DCHECK this
Olivier
2016/12/29 12:37:20
This would DCHECK on http://http.com.
I will keep
| |
81 "%s%s", url::kHttpScheme, url::kStandardSchemeSeparator)), | |
82 base::CompareCase::SENSITIVE)); | |
83 return online_url; | |
66 } | 84 } |
85 } | |
OLD | NEW |