| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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/offline_page_utils.h" | 5 #include "chrome/browser/android/offline_pages/offline_page_utils.h" |
| 6 | 6 |
| 7 #include "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/metrics/histogram_macros.h" | 9 #include "base/metrics/histogram_macros.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 11 matching lines...) Expand all Loading... |
| 22 #include "components/offline_pages/core/background/save_page_request.h" | 22 #include "components/offline_pages/core/background/save_page_request.h" |
| 23 #include "components/offline_pages/core/client_namespace_constants.h" | 23 #include "components/offline_pages/core/client_namespace_constants.h" |
| 24 #include "components/offline_pages/core/client_policy_controller.h" | 24 #include "components/offline_pages/core/client_policy_controller.h" |
| 25 #include "components/offline_pages/core/offline_page_feature.h" | 25 #include "components/offline_pages/core/offline_page_feature.h" |
| 26 #include "components/offline_pages/core/offline_page_item.h" | 26 #include "components/offline_pages/core/offline_page_item.h" |
| 27 #include "components/offline_pages/core/offline_page_model.h" | 27 #include "components/offline_pages/core/offline_page_model.h" |
| 28 #include "components/offline_pages/core/request_header/offline_page_header.h" | 28 #include "components/offline_pages/core/request_header/offline_page_header.h" |
| 29 #include "content/public/browser/browser_context.h" | 29 #include "content/public/browser/browser_context.h" |
| 30 #include "content/public/browser/navigation_entry.h" | 30 #include "content/public/browser/navigation_entry.h" |
| 31 #include "content/public/browser/web_contents.h" | 31 #include "content/public/browser/web_contents.h" |
| 32 #include "net/base/mime_util.h" |
| 32 | 33 |
| 33 namespace offline_pages { | 34 namespace offline_pages { |
| 34 namespace { | 35 namespace { |
| 35 | 36 |
| 36 void OnGetPagesByURLDone( | 37 void OnGetPagesByURLDone( |
| 37 const GURL& url, | 38 const GURL& url, |
| 38 int tab_id, | 39 int tab_id, |
| 39 const std::vector<std::string>& namespaces_to_show_in_original_tab, | 40 const std::vector<std::string>& namespaces_to_show_in_original_tab, |
| 40 const base::Callback<void(const OfflinePageItem*)>& callback, | 41 const base::Callback<void(const OfflinePageItem*)>& callback, |
| 41 const MultipleOfflinePageItemResult& pages) { | 42 const MultipleOfflinePageItemResult& pages) { |
| (...skipping 249 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 291 DownloadUIActionFlags ui_action) { | 292 DownloadUIActionFlags ui_action) { |
| 292 DCHECK(web_contents); | 293 DCHECK(web_contents); |
| 293 | 294 |
| 294 OfflinePageTabHelper* tab_helper = | 295 OfflinePageTabHelper* tab_helper = |
| 295 OfflinePageTabHelper::FromWebContents(web_contents); | 296 OfflinePageTabHelper::FromWebContents(web_contents); |
| 296 if (!tab_helper) | 297 if (!tab_helper) |
| 297 return; | 298 return; |
| 298 tab_helper->ScheduleDownloadHelper(web_contents, name_space, url, ui_action); | 299 tab_helper->ScheduleDownloadHelper(web_contents, name_space, url, ui_action); |
| 299 } | 300 } |
| 300 | 301 |
| 302 // static |
| 303 bool OfflinePageUtils::CanDownloadAsOfflinePage( |
| 304 const GURL& url, |
| 305 const std::string& contents_mime_type) { |
| 306 return url.SchemeIsHTTPOrHTTPS() && |
| 307 (net::MatchesMimeType(contents_mime_type, "text/html") || |
| 308 net::MatchesMimeType(contents_mime_type, "application/xhtml+xml")); |
| 309 } |
| 310 |
| 301 } // namespace offline_pages | 311 } // namespace offline_pages |
| OLD | NEW |