| 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 #ifndef CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_UTILS_H_ | 5 #ifndef CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_UTILS_H_ |
| 6 #define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_UTILS_H_ | 6 #define CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_UTILS_H_ |
| 7 | 7 |
| 8 #include <stdint.h> | 8 #include <stdint.h> |
| 9 | 9 |
| 10 #include "base/callback.h" | 10 #include "base/callback.h" |
| 11 #include "components/offline_pages/offline_page_model.h" |
| 11 | 12 |
| 12 class GURL; | 13 class GURL; |
| 13 | 14 |
| 14 namespace content { | 15 namespace content { |
| 15 class BrowserContext; | 16 class BrowserContext; |
| 16 class WebContents; | 17 class WebContents; |
| 17 } | 18 } |
| 18 | 19 |
| 19 namespace offline_pages { | 20 namespace offline_pages { |
| 20 struct OfflinePageHeader; | 21 struct OfflinePageHeader; |
| 21 struct OfflinePageItem; | 22 struct OfflinePageItem; |
| 22 | 23 |
| 23 class OfflinePageUtils { | 24 class OfflinePageUtils { |
| 24 public: | 25 public: |
| 25 // Returns via callback an offline page saved for |online_url|, if any. The | 26 // Returns via callback an offline page related to |url|, if any. The |
| 26 // page is chosen based on creation date; a more recently created offline | 27 // page is chosen based on creation date; a more recently created offline |
| 27 // page will be preferred over an older one. The offline page captured from | 28 // page will be preferred over an older one. The offline page captured from |
| 28 // last visit in the tab will not be considered if its tab id does not match | 29 // last visit in the tab will not be considered if its tab id does not match |
| 29 // the provided |tab_id|. | 30 // the provided |tab_id|. |
| 30 static void SelectPageForOnlineURL( | 31 static void SelectPageForURL( |
| 31 content::BrowserContext* browser_context, | 32 content::BrowserContext* browser_context, |
| 32 const GURL& online_url, | 33 const GURL& url, |
| 34 OfflinePageModel::URLSearchMode url_search_mode, |
| 33 int tab_id, | 35 int tab_id, |
| 34 const base::Callback<void(const OfflinePageItem*)>& callback); | 36 const base::Callback<void(const OfflinePageItem*)>& callback); |
| 35 | 37 |
| 36 // Gets the offline page corresponding to the given web contents. The | 38 // Gets the offline page corresponding to the given web contents. The |
| 37 // returned pointer is owned by the web_contents and may be deleted by user | 39 // returned pointer is owned by the web_contents and may be deleted by user |
| 38 // navigation, so it is unsafe to store a copy of the returned pointer. | 40 // navigation, so it is unsafe to store a copy of the returned pointer. |
| 39 static const OfflinePageItem* GetOfflinePageFromWebContents( | 41 static const OfflinePageItem* GetOfflinePageFromWebContents( |
| 40 content::WebContents* web_contents); | 42 content::WebContents* web_contents); |
| 41 | 43 |
| 42 // Gets the offline header provided when loading the offline page for the | 44 // Gets the offline header provided when loading the offline page for the |
| (...skipping 20 matching lines...) Expand all Loading... |
| 63 const std::string name_space, | 65 const std::string name_space, |
| 64 const GURL& offline_page_url, | 66 const GURL& offline_page_url, |
| 65 const base::Callback<void(bool)>& callback); | 67 const base::Callback<void(bool)>& callback); |
| 66 | 68 |
| 67 static bool EqualsIgnoringFragment(const GURL& lhs, const GURL& rhs); | 69 static bool EqualsIgnoringFragment(const GURL& lhs, const GURL& rhs); |
| 68 }; | 70 }; |
| 69 | 71 |
| 70 } // namespace offline_pages | 72 } // namespace offline_pages |
| 71 | 73 |
| 72 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_UTILS_H_ | 74 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_UTILS_H_ |
| OLD | NEW |