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

Unified Diff: chrome/browser/android/offline_pages/downloads/resource_throttle.cc

Issue 2836163003: Stop offline page resource throttle from intercepting non http(s) urls (Closed)
Patch Set: nit Created 3 years, 8 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/android/offline_pages/downloads/resource_throttle.cc
diff --git a/chrome/browser/android/offline_pages/downloads/resource_throttle.cc b/chrome/browser/android/offline_pages/downloads/resource_throttle.cc
index a09b33c4abf26c70f13b2834710a8b659e385148..ee6aec8c702f1dfd0ea6a899ba3b019f13d9023f 100644
--- a/chrome/browser/android/offline_pages/downloads/resource_throttle.cc
+++ b/chrome/browser/android/offline_pages/downloads/resource_throttle.cc
@@ -13,11 +13,13 @@
#include "net/base/mime_util.h"
namespace {
-// Mime type of download resource that should trigger handoff to OfflinePages
-// backend for full page load and snapshot.
-bool CanDownloadAsOfflinePage(const std::string& contents_mime_type) {
- return net::MatchesMimeType(contents_mime_type, "text/html") ||
- net::MatchesMimeType(contents_mime_type, "application/xhtml+xml");
+// Check if the url and mime type of a download resource should trigger handoff
+// to OfflinePages backend for full page load and snapshot.
+bool CanDownloadAsOfflinePage(
+ const GURL& url, const std::string& contents_mime_type) {
+ return url.SchemeIsHTTPOrHTTPS() &&
+ (net::MatchesMimeType(contents_mime_type, "text/html") ||
+ net::MatchesMimeType(contents_mime_type, "application/xhtml+xml"));
}
void WillStartOfflineRequestOnUIThread(
@@ -49,7 +51,8 @@ void ResourceThrottle::WillProcessResponse(bool* defer) {
DCHECK_CURRENTLY_ON(content::BrowserThread::IO);
std::string mime_type;
request_->GetMimeType(&mime_type);
- if (CanDownloadAsOfflinePage(mime_type)) {
+
+ if (CanDownloadAsOfflinePage(request_->url(), mime_type)) {
const content::ResourceRequestInfo* info =
content::ResourceRequestInfo::ForRequest(request_);
if (!info)
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698