Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(74)

Side by Side Diff: chrome/browser/android/offline_pages/offline_page_utils.h

Issue 2284933002: Remove OfflineURL from offline page (Closed)
Patch Set: Add comment per feedback Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 OfflinePageHeader; 20 struct OfflinePageHeader;
21 struct OfflinePageItem; 21 struct OfflinePageItem;
22 22
23 class OfflinePageUtils { 23 class OfflinePageUtils {
24 public: 24 public:
25 // Returns true if |url| might point to an offline page.
26 static bool MightBeOfflineURL(const GURL& url);
27
28 // Returns via callback an offline page saved for |online_url|, if any. The 25 // Returns via callback an offline page saved for |online_url|, if any. The
29 // page is chosen based on creation date; a more recently created offline 26 // page is chosen based on creation date; a more recently created offline
30 // page will be preferred over an older one. The offline page captured from 27 // page will be preferred over an older one. The offline page captured from
31 // last visit in the tab will not be considered if its tab id does not match 28 // last visit in the tab will not be considered if its tab id does not match
32 // the provided |tab_id|. 29 // the provided |tab_id|.
33 static void SelectPageForOnlineURL( 30 static void SelectPageForOnlineURL(
34 content::BrowserContext* browser_context, 31 content::BrowserContext* browser_context,
35 const GURL& online_url, 32 const GURL& online_url,
36 int tab_id, 33 int tab_id,
37 const base::Callback<void(const OfflinePageItem*)>& callback); 34 const base::Callback<void(const OfflinePageItem*)>& callback);
38 35
39 // Gets an online URL of an offline page with |offline_url| if one exists.
40 // Deprecated. Use |GetOnlineURLForOfflineURL|.
41 static GURL MaybeGetOnlineURLForOfflineURL(
42 content::BrowserContext* browser_context,
43 const GURL& offline_url);
44
45 static void GetOnlineURLForOfflineURL(
46 content::BrowserContext* browser_context,
47 const GURL& offline_url,
48 const base::Callback<void(const GURL&)>& callback);
49
50 // Checks whether |offline_url| points to an offline page.
51 // Deprecated. Use something else.
52 static bool IsOfflinePage(content::BrowserContext* browser_context,
53 const GURL& offline_url);
54
55 // Marks that the offline page related to the |offline_url| has been accessed.
56 static void MarkPageAccessed(content::BrowserContext* browser_context,
57 const GURL& offline_url);
58
59 // Gets the offline page corresponding to the given web contents. The 36 // Gets the offline page corresponding to the given web contents. The
60 // returned pointer is owned by the web_contents and may be deleted by user 37 // returned pointer is owned by the web_contents and may be deleted by user
61 // navigation, so it is unsafe to store a copy of the returned pointer. 38 // navigation, so it is unsafe to store a copy of the returned pointer.
62 static const OfflinePageItem* GetOfflinePageFromWebContents( 39 static const OfflinePageItem* GetOfflinePageFromWebContents(
63 content::WebContents* web_contents); 40 content::WebContents* web_contents);
64 41
65 // Gets the offline header provided when loading the offline page for the 42 // Gets the offline header provided when loading the offline page for the
66 // given web contents. 43 // given web contents.
67 static const OfflinePageHeader* GetOfflineHeaderFromWebContents( 44 static const OfflinePageHeader* GetOfflineHeaderFromWebContents(
68 content::WebContents* web_contents); 45 content::WebContents* web_contents);
69 46
70 // Gets an Android Tab ID from a tab containing |web_contents|. Returns false, 47 // Gets an Android Tab ID from a tab containing |web_contents|. Returns false,
71 // when tab is not available. Returns true otherwise and sets |tab_id| to the 48 // when tab is not available. Returns true otherwise and sets |tab_id| to the
72 // ID of the tab. 49 // ID of the tab.
73 static bool GetTabId(content::WebContents* web_contents, int* tab_id); 50 static bool GetTabId(content::WebContents* web_contents, int* tab_id);
74 }; 51 };
75 52
76 } // namespace offline_pages 53 } // namespace offline_pages
77 54
78 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_UTILS_H_ 55 #endif // CHROME_BROWSER_ANDROID_OFFLINE_PAGES_OFFLINE_PAGE_UTILS_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698