| 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 | 11 |
| 12 class GURL; | 12 class GURL; |
| 13 | 13 |
| 14 namespace content { | 14 namespace content { |
| 15 class BrowserContext; | 15 class BrowserContext; |
| 16 class WebContents; | 16 class WebContents; |
| 17 } | 17 } |
| 18 | 18 |
| 19 namespace offline_pages { | 19 namespace offline_pages { |
| 20 struct OfflinePageItem; | 20 struct OfflinePageItem; |
| 21 | 21 |
| 22 class OfflinePageUtils { | 22 class OfflinePageUtils { |
| 23 public: | 23 public: |
| 24 // Returns true if |url| might point to an offline page. | 24 // Returns true if |url| might point to an offline page. |
| 25 static bool MightBeOfflineURL(const GURL& url); | 25 static bool MightBeOfflineURL(const GURL& url); |
| 26 | 26 |
| 27 // Returns via callback an offline page saved for |online_url|, if any. The |
| 28 // page is chosen based on creation date; a more recently created offline |
| 29 // page will be preferred over an older one. The offline page captured from |
| 30 // last visit in the tab will not be considered if its tab id does not match |
| 31 // the provided |tab_id|. |
| 32 static void SelectPageForOnlineURL( |
| 33 content::BrowserContext* browser_context, |
| 34 const GURL& online_url, |
| 35 int tab_id, |
| 36 const base::Callback<void(const OfflinePageItem*)>& callback); |
| 37 |
| 27 // Gets an online URL of an offline page with |offline_url| if one exists. | 38 // Gets an online URL of an offline page with |offline_url| if one exists. |
| 28 // Deprecated. Use |GetOnlineURLForOfflineURL|. | 39 // Deprecated. Use |GetOnlineURLForOfflineURL|. |
| 29 static GURL MaybeGetOnlineURLForOfflineURL( | 40 static GURL MaybeGetOnlineURLForOfflineURL( |
| 30 content::BrowserContext* browser_context, | 41 content::BrowserContext* browser_context, |
| 31 const GURL& offline_url); | 42 const GURL& offline_url); |
| 32 | 43 |
| 33 static void GetOnlineURLForOfflineURL( | 44 static void GetOnlineURLForOfflineURL( |
| 34 content::BrowserContext* browser_context, | 45 content::BrowserContext* browser_context, |
| 35 const GURL& offline_url, | 46 const GURL& offline_url, |
| 36 const base::Callback<void(const GURL&)>& callback); | 47 const base::Callback<void(const GURL&)>& callback); |
| (...skipping 20 matching lines...) Expand all Loading... |
| 57 | 68 |
| 58 // Gets an Android Tab ID from a tab containing |web_contents|. Returns false, | 69 // Gets an Android Tab ID from a tab containing |web_contents|. Returns false, |
| 59 // when tab is not available. Returns true otherwise and sets |tab_id| to the | 70 // when tab is not available. Returns true otherwise and sets |tab_id| to the |
| 60 // ID of the tab. | 71 // ID of the tab. |
| 61 static bool GetTabId(content::WebContents* web_contents, int* tab_id); | 72 static bool GetTabId(content::WebContents* web_contents, int* tab_id); |
| 62 }; | 73 }; |
| 63 | 74 |
| 64 } // namespace offline_pages | 75 } // namespace offline_pages |
| 65 | 76 |
| 66 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_UTILS_H_ | 77 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_UTILS_H_ |
| OLD | NEW |