Index: ios/chrome/browser/reading_list/offline_url_utils.cc |
diff --git a/ios/chrome/browser/reading_list/offline_url_utils.cc b/ios/chrome/browser/reading_list/offline_url_utils.cc |
index e2ceb6c0c1b448ce785d8e2e9175a1f81e98db1e..5ce022c7fb2f04cab833a075a904406df8ea0836 100644 |
--- a/ios/chrome/browser/reading_list/offline_url_utils.cc |
+++ b/ios/chrome/browser/reading_list/offline_url_utils.cc |
@@ -4,8 +4,11 @@ |
#include "ios/chrome/browser/reading_list/offline_url_utils.h" |
+#include "base/logging.h" |
#include "base/md5.h" |
+#include "base/strings/string_util.h" |
#include "base/strings/stringprintf.h" |
+#include "base/strings/utf_string_conversions.h" |
#include "components/reading_list/ios/offline_url_utils.h" |
#include "ios/chrome/browser/chrome_url_constants.h" |
#include "net/base/url_util.h" |
@@ -63,4 +66,27 @@ GURL FileURLForDistilledURL(const GURL& distilled_url, |
bool IsOfflineURL(const GURL& url) { |
return url.SchemeIs(kChromeUIScheme) && url.host() == kChromeUIOfflineHost; |
} |
+ |
+base::string16 StripSchemeFromOnlineURL(const base::string16& online_url, |
+ size_t* removed_chars) { |
+ base::string16 https_scheme = base::UTF8ToUTF16(base::StringPrintf( |
+ "%s%s", url::kHttpsScheme, url::kStandardSchemeSeparator)); |
+ if (base::StartsWith(online_url, https_scheme, |
+ base::CompareCase::SENSITIVE)) { |
+ if (removed_chars) { |
+ *removed_chars = https_scheme.length(); |
+ } |
+ return online_url.substr(https_scheme.length()); |
+ } |
+ // http:// scheme should already have been trimmed at this point. |
+ // DCHECK to detect formatting changes in omnibox. |
+ DCHECK(!base::StartsWith( |
+ online_url, base::UTF8ToUTF16(base::StringPrintf( |
+ "%s%s", url::kHttpScheme, url::kStandardSchemeSeparator)), |
+ base::CompareCase::SENSITIVE)); |
+ if (removed_chars) { |
+ *removed_chars = 0; |
+ } |
+ return online_url; |
+} |
} |