| 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/strings/string_number_conversions.h" | 7 #include "base/strings/string_number_conversions.h" |
| 8 #include "base/strings/string_piece.h" | 8 #include "base/strings/string_piece.h" |
| 9 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 10 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h" | 10 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h" |
| (...skipping 43 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 54 OfflinePageModelFactory::GetForBrowserContext(browser_context); | 54 OfflinePageModelFactory::GetForBrowserContext(browser_context); |
| 55 if (!offline_page_model) | 55 if (!offline_page_model) |
| 56 return nullptr; | 56 return nullptr; |
| 57 | 57 |
| 58 return offline_page_model->MaybeGetPageByOfflineURL(offline_url); | 58 return offline_page_model->MaybeGetPageByOfflineURL(offline_url); |
| 59 } | 59 } |
| 60 | 60 |
| 61 } // namespace | 61 } // namespace |
| 62 | 62 |
| 63 // static | 63 // static |
| 64 bool OfflinePageUtils::CanSaveURL(const GURL& url) { |
| 65 return url.is_valid() && url.SchemeIsHTTPOrHTTPS(); |
| 66 } |
| 67 |
| 68 // static |
| 64 bool OfflinePageUtils::MightBeOfflineURL(const GURL& url) { | 69 bool OfflinePageUtils::MightBeOfflineURL(const GURL& url) { |
| 65 // It has to be a file URL ending with .mhtml extension. | 70 // It has to be a file URL ending with .mhtml extension. |
| 66 return url.is_valid() && url.SchemeIsFile() && | 71 return url.is_valid() && url.SchemeIsFile() && |
| 67 base::EndsWith(url.spec(), | 72 base::EndsWith(url.spec(), |
| 68 OfflinePageMHTMLArchiver::GetFileNameExtension(), | 73 OfflinePageMHTMLArchiver::GetFileNameExtension(), |
| 69 base::CompareCase::INSENSITIVE_ASCII); | 74 base::CompareCase::INSENSITIVE_ASCII); |
| 70 } | 75 } |
| 71 | 76 |
| 72 // static | 77 // static |
| 73 GURL OfflinePageUtils::GetOfflineURLForOnlineURL( | 78 GURL OfflinePageUtils::GetOfflineURLForOnlineURL( |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 118 if (!offline_page) | 123 if (!offline_page) |
| 119 return; | 124 return; |
| 120 | 125 |
| 121 OfflinePageModel* offline_page_model = | 126 OfflinePageModel* offline_page_model = |
| 122 OfflinePageModelFactory::GetForBrowserContext(browser_context); | 127 OfflinePageModelFactory::GetForBrowserContext(browser_context); |
| 123 DCHECK(offline_page_model); | 128 DCHECK(offline_page_model); |
| 124 offline_page_model->MarkPageAccessed(offline_page->offline_id); | 129 offline_page_model->MarkPageAccessed(offline_page->offline_id); |
| 125 } | 130 } |
| 126 | 131 |
| 127 } // namespace offline_pages | 132 } // namespace offline_pages |
| OLD | NEW |