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

Side by Side Diff: ios/chrome/browser/reading_list/offline_url_utils.cc

Issue 2606873002: Move the offline URL trimming to GetFormattedURL. (Closed)
Patch Set: fix DEPS Created 3 years, 11 months 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 unified diff | Download patch
OLDNEW
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
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(const base::string16& online_url,
71 size_t* removed_chars) {
72 base::string16 https_scheme = base::UTF8ToUTF16(base::StringPrintf(
73 "%s%s", url::kHttpsScheme, url::kStandardSchemeSeparator));
74 if (base::StartsWith(online_url, https_scheme,
75 base::CompareCase::SENSITIVE)) {
76 if (removed_chars) {
77 *removed_chars = https_scheme.length();
78 }
79 return online_url.substr(https_scheme.length());
80 }
81 // http:// scheme should already have been trimmed at this point.
82 // DCHECK to detect formatting changes in omnibox.
83 DCHECK(!base::StartsWith(
84 online_url, base::UTF8ToUTF16(base::StringPrintf(
85 "%s%s", url::kHttpScheme, url::kStandardSchemeSeparator)),
86 base::CompareCase::SENSITIVE));
87 if (removed_chars) {
88 *removed_chars = 0;
89 }
90 return online_url;
66 } 91 }
92 }
OLDNEW
« no previous file with comments | « ios/chrome/browser/reading_list/offline_url_utils.h ('k') | ios/chrome/browser/reading_list/offline_url_utils_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698