Chromium Code Reviews| 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 "chrome/browser/android/offline_pages/downloads/resource_throttle.h" | 5 #include "chrome/browser/android/offline_pages/downloads/resource_throttle.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "chrome/browser/android/offline_pages/offline_page_utils.h" | 8 #include "chrome/browser/android/offline_pages/offline_page_utils.h" |
| 9 #include "components/offline_pages/core/client_namespace_constants.h" | 9 #include "components/offline_pages/core/client_namespace_constants.h" |
| 10 #include "content/public/browser/browser_thread.h" | 10 #include "content/public/browser/browser_thread.h" |
| (...skipping 29 matching lines...) Expand all Loading... | |
| 40 : request_(request) { | 40 : request_(request) { |
| 41 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 41 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 42 } | 42 } |
| 43 | 43 |
| 44 ResourceThrottle::~ResourceThrottle() { | 44 ResourceThrottle::~ResourceThrottle() { |
| 45 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 45 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 46 } | 46 } |
| 47 | 47 |
| 48 void ResourceThrottle::WillProcessResponse(bool* defer) { | 48 void ResourceThrottle::WillProcessResponse(bool* defer) { |
| 49 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); | 49 DCHECK_CURRENTLY_ON(content::BrowserThread::IO); |
| 50 | |
| 51 if (request_->url_chain().empty()) | |
|
Dmitry Titov
2017/04/25 07:03:01
URLRequest is constructed with at least one URL, t
qinmin
2017/04/25 18:52:45
Done.
| |
| 52 return; | |
| 53 GURL url = request_->url_chain().back(); | |
| 54 if (!url.SchemeIsHTTPOrHTTPS()) | |
| 55 return; | |
| 56 | |
| 50 std::string mime_type; | 57 std::string mime_type; |
| 51 request_->GetMimeType(&mime_type); | 58 request_->GetMimeType(&mime_type); |
| 59 | |
| 52 if (CanDownloadAsOfflinePage(mime_type)) { | 60 if (CanDownloadAsOfflinePage(mime_type)) { |
|
David Trainor- moved to gerrit
2017/04/25 03:31:16
Would it be cleaner to bake that into CanDownloadA
Dmitry Titov
2017/04/25 07:03:01
+1, good suggestion.
qinmin
2017/04/25 18:52:45
Done.
| |
| 53 const content::ResourceRequestInfo* info = | 61 const content::ResourceRequestInfo* info = |
| 54 content::ResourceRequestInfo::ForRequest(request_); | 62 content::ResourceRequestInfo::ForRequest(request_); |
| 55 if (!info) | 63 if (!info) |
| 56 return; | 64 return; |
| 57 content::BrowserThread::PostTask( | 65 content::BrowserThread::PostTask( |
| 58 content::BrowserThread::UI, FROM_HERE, | 66 content::BrowserThread::UI, FROM_HERE, |
| 59 base::Bind(&WillStartOfflineRequestOnUIThread, request_->url(), | 67 base::Bind(&WillStartOfflineRequestOnUIThread, request_->url(), |
| 60 info->GetWebContentsGetterForRequest())); | 68 info->GetWebContentsGetterForRequest())); |
| 61 Cancel(); | 69 Cancel(); |
| 62 } | 70 } |
| 63 } | 71 } |
| 64 | 72 |
| 65 const char* ResourceThrottle::GetNameForLogging() const { | 73 const char* ResourceThrottle::GetNameForLogging() const { |
| 66 return "offline_pages::downloads::ResourceThrottle"; | 74 return "offline_pages::downloads::ResourceThrottle"; |
| 67 } | 75 } |
| 68 | 76 |
| 69 } // namespace downloads | 77 } // namespace downloads |
| 70 } // namespace offline_pages | 78 } // namespace offline_pages |
| OLD | NEW |