| 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 } | 17 } |
| 17 | 18 |
| 18 namespace offline_pages { | 19 namespace offline_pages { |
| 19 struct OfflinePageItem; | 20 struct OfflinePageItem; |
| 20 | 21 |
| 21 class OfflinePageUtils { | 22 class OfflinePageUtils { |
| 22 public: | 23 public: |
| 23 // Returns true if |url| might point to an offline page. | 24 // Returns true if |url| might point to an offline page. |
| 24 static bool MightBeOfflineURL(const GURL& url); | 25 static bool MightBeOfflineURL(const GURL& url); |
| 25 | 26 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 51 const GURL& offline_url); | 52 const GURL& offline_url); |
| 52 | 53 |
| 53 // Checks whether offline page for |online_url| exists. | 54 // Checks whether offline page for |online_url| exists. |
| 54 static bool HasOfflinePageForOnlineURL( | 55 static bool HasOfflinePageForOnlineURL( |
| 55 content::BrowserContext* browser_context, | 56 content::BrowserContext* browser_context, |
| 56 const GURL& online_url); | 57 const GURL& online_url); |
| 57 | 58 |
| 58 // Marks that the offline page related to the |offline_url| has been accessed. | 59 // Marks that the offline page related to the |offline_url| has been accessed. |
| 59 static void MarkPageAccessed(content::BrowserContext* browser_context, | 60 static void MarkPageAccessed(content::BrowserContext* browser_context, |
| 60 const GURL& offline_url); | 61 const GURL& offline_url); |
| 62 |
| 63 // Gets the offline page corresponding to the given web contents. The |
| 64 // returned pointer is owned by the web_contents and may be deleted by user |
| 65 // navigation, so it is unsafe to store a copy of the returned pointer. |
| 66 static const OfflinePageItem* GetCurrentOfflinePage( |
| 67 content::WebContents* web_contents); |
| 68 |
| 69 // Sets the offline page corresponding to the given web contents. If |
| 70 // |offline_page| contains |nullptr|, removes the page from the web contents. |
| 71 static void SetCurrentOfflinePage(content::WebContents* web_contents, |
| 72 const OfflinePageItem* offline_page); |
| 61 }; | 73 }; |
| 62 | 74 |
| 63 } // namespace offline_pages | 75 } // namespace offline_pages |
| 64 | 76 |
| 65 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_UTILS_H_ | 77 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_UTILS_H_ |
| OLD | NEW |