Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(47)

Unified Diff: ios/chrome/browser/reading_list/offline_url_utils.cc

Issue 2606873002: Move the offline URL trimming to GetFormattedURL. (Closed)
Patch Set: clean Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
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..a31130a51b21b9cc579bef7cea04ab543cec0161 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,20 @@ GURL FileURLForDistilledURL(const GURL& distilled_url,
bool IsOfflineURL(const GURL& url) {
return url.SchemeIs(kChromeUIScheme) && url.host() == kChromeUIOfflineHost;
}
+
+base::string16 StripSchemeFromOnlineUrl(base::string16 online_url) {
+ base::string16 https_scheme = base::UTF8ToUTF16(base::StringPrintf(
+ "%s%s", url::kHttpsScheme, url::kStandardSchemeSeparator));
+ if (base::StartsWith(online_url, https_scheme,
+ base::CompareCase::SENSITIVE)) {
+ 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(
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
+ "%s%s", url::kHttpScheme, url::kStandardSchemeSeparator)),
+ base::CompareCase::SENSITIVE));
+ return online_url;
+}
}

Powered by Google App Engine
This is Rietveld 408576698