| 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/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
| 11 #include "base/strings/string_util.h" | 11 #include "base/strings/string_util.h" |
| 12 #include "base/threading/thread_task_runner_handle.h" | 12 #include "base/threading/thread_task_runner_handle.h" |
| 13 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h" | 13 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h" |
| 14 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" | 14 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" |
| 15 #include "chrome/browser/android/offline_pages/offline_page_tab_helper.h" |
| 15 #include "components/offline_pages/offline_page_feature.h" | 16 #include "components/offline_pages/offline_page_feature.h" |
| 16 #include "components/offline_pages/offline_page_item.h" | 17 #include "components/offline_pages/offline_page_item.h" |
| 17 #include "components/offline_pages/offline_page_model.h" | 18 #include "components/offline_pages/offline_page_model.h" |
| 18 #include "content/public/browser/browser_context.h" | 19 #include "content/public/browser/browser_context.h" |
| 20 #include "content/public/browser/web_contents.h" |
| 19 #include "url/gurl.h" | 21 #include "url/gurl.h" |
| 20 | 22 |
| 21 namespace offline_pages { | 23 namespace offline_pages { |
| 22 namespace { | 24 namespace { |
| 23 | 25 |
| 24 // Returns an offline page originated from the |online_url|. | 26 // Returns an offline page originated from the |online_url|. |
| 25 const OfflinePageItem* MaybeGetBestOfflinePageForOnlineURL( | 27 const OfflinePageItem* MaybeGetBestOfflinePageForOnlineURL( |
| 26 content::BrowserContext* browser_context, | 28 content::BrowserContext* browser_context, |
| 27 const GURL& online_url) { | 29 const GURL& online_url) { |
| 28 DCHECK(browser_context); | 30 DCHECK(browser_context); |
| (...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 160 GetOfflinePageForOfflineURL(browser_context, offline_url); | 162 GetOfflinePageForOfflineURL(browser_context, offline_url); |
| 161 if (!offline_page) | 163 if (!offline_page) |
| 162 return; | 164 return; |
| 163 | 165 |
| 164 OfflinePageModel* offline_page_model = | 166 OfflinePageModel* offline_page_model = |
| 165 OfflinePageModelFactory::GetForBrowserContext(browser_context); | 167 OfflinePageModelFactory::GetForBrowserContext(browser_context); |
| 166 DCHECK(offline_page_model); | 168 DCHECK(offline_page_model); |
| 167 offline_page_model->MarkPageAccessed(offline_page->offline_id); | 169 offline_page_model->MarkPageAccessed(offline_page->offline_id); |
| 168 } | 170 } |
| 169 | 171 |
| 172 const OfflinePageItem* OfflinePageUtils::GetOfflinePageFromWebContents( |
| 173 content::WebContents* web_contents) { |
| 174 OfflinePageTabHelper* tab_helper = |
| 175 OfflinePageTabHelper::FromWebContents(web_contents); |
| 176 return tab_helper ? tab_helper->offline_page() : nullptr; |
| 177 } |
| 178 |
| 170 } // namespace offline_pages | 179 } // namespace offline_pages |
| OLD | NEW |