| 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 "chrome/browser/android/offline_pages/offline_page_tab_helper.h" |
| 16 #include "chrome/browser/android/tab_android.h" |
| 16 #include "components/offline_pages/offline_page_feature.h" | 17 #include "components/offline_pages/offline_page_feature.h" |
| 17 #include "components/offline_pages/offline_page_item.h" | 18 #include "components/offline_pages/offline_page_item.h" |
| 18 #include "components/offline_pages/offline_page_model.h" | 19 #include "components/offline_pages/offline_page_model.h" |
| 19 #include "content/public/browser/browser_context.h" | 20 #include "content/public/browser/browser_context.h" |
| 20 #include "content/public/browser/web_contents.h" | 21 #include "content/public/browser/web_contents.h" |
| 21 #include "url/gurl.h" | 22 #include "url/gurl.h" |
| 22 | 23 |
| 23 namespace offline_pages { | 24 namespace offline_pages { |
| 24 namespace { | 25 namespace { |
| 25 | 26 |
| (...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 169 offline_page_model->MarkPageAccessed(offline_page->offline_id); | 170 offline_page_model->MarkPageAccessed(offline_page->offline_id); |
| 170 } | 171 } |
| 171 | 172 |
| 172 const OfflinePageItem* OfflinePageUtils::GetOfflinePageFromWebContents( | 173 const OfflinePageItem* OfflinePageUtils::GetOfflinePageFromWebContents( |
| 173 content::WebContents* web_contents) { | 174 content::WebContents* web_contents) { |
| 174 OfflinePageTabHelper* tab_helper = | 175 OfflinePageTabHelper* tab_helper = |
| 175 OfflinePageTabHelper::FromWebContents(web_contents); | 176 OfflinePageTabHelper::FromWebContents(web_contents); |
| 176 return tab_helper ? tab_helper->offline_page() : nullptr; | 177 return tab_helper ? tab_helper->offline_page() : nullptr; |
| 177 } | 178 } |
| 178 | 179 |
| 180 // static |
| 181 bool OfflinePageUtils::GetTabId(content::WebContents* web_contents, |
| 182 int* tab_id) { |
| 183 TabAndroid* tab_android = TabAndroid::FromWebContents(web_contents); |
| 184 if (!tab_android) |
| 185 return false; |
| 186 *tab_id = tab_android->GetAndroidId(); |
| 187 return true; |
| 188 } |
| 189 |
| 179 } // namespace offline_pages | 190 } // namespace offline_pages |
| OLD | NEW |