| OLD | NEW |
| 1 // Copyright 2016 The Chromium Authors. All rights reserved. | 1 // Copyright 2016 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 IOS_CHROME_BROWSER_READING_LIST_OFFLINE_URL_UTILS_H_ | 5 #ifndef IOS_CHROME_BROWSER_READING_LIST_OFFLINE_URL_UTILS_H_ |
| 6 #define IOS_CHROME_BROWSER_READING_LIST_OFFLINE_URL_UTILS_H_ | 6 #define IOS_CHROME_BROWSER_READING_LIST_OFFLINE_URL_UTILS_H_ |
| 7 | 7 |
| 8 #include <string> | 8 #include <string> |
| 9 | 9 |
| 10 #include "base/files/file_path.h" | 10 #include "base/files/file_path.h" |
| 11 #include "base/strings/string16.h" | 11 #include "base/strings/string16.h" |
| 12 #include "url/gurl.h" | 12 #include "url/gurl.h" |
| 13 | 13 |
| 14 class ReadingListModel; |
| 15 |
| 14 namespace reading_list { | 16 namespace reading_list { |
| 15 | 17 |
| 16 // The distilled URL chrome://offline/... that will load the file at |path|. | 18 // The distilled URL chrome://offline/... that will load the file at |path|. |
| 17 // |entry_url| is the URL of the ReadingListEntry. | 19 // |entry_url| is the URL of the ReadingListEntry. |
| 18 // |virtual_url| is the URL to display in the omnibox. This can be different | 20 // |virtual_url| is the URL to display in the omnibox. This can be different |
| 19 // from |entry_url| is the distillation was done after a redirection. | 21 // from |entry_url| if the distillation was done after a redirection. |
| 20 // |entry_url| and |virtual_url| are optionnal. | 22 // |distilled_path|, |entry_url| and |virtual_url| are required and must not be |
| 23 // empty or invalid. |
| 21 GURL OfflineURLForPath(const base::FilePath& distilled_path, | 24 GURL OfflineURLForPath(const base::FilePath& distilled_path, |
| 22 const GURL& entry_url, | 25 const GURL& entry_url, |
| 23 const GURL& virtual_url); | 26 const GURL& virtual_url); |
| 24 | 27 |
| 25 // If |offline_url| has a "entryURL" query params that is a URL, returns it. | 28 // If |offline_url| has a "entryURL" query params that is a URL, returns it. |
| 26 // If not, return |offline_url| | 29 // If not, return GURL::EmptyURL(). |
| 27 GURL EntryURLForOfflineURL(const GURL& offline_url); | 30 GURL EntryURLForOfflineURL(const GURL& offline_url); |
| 28 | 31 |
| 29 // If |offline_url| has a "virtualURL" query params that is a URL, returns it. | 32 // If |offline_url| has a "virtualURL" query params that is a URL, returns it. |
| 30 // If not, return |EntryURLForOfflineURL(|offline_url|)| | 33 // If not, return GURL::EmptyURL(). |
| 31 GURL VirtualURLForOfflineURL(const GURL& offline_url); | 34 GURL VirtualURLForOfflineURL(const GURL& offline_url); |
| 32 | 35 |
| 33 // The file URL pointing to the local file to load to display |distilled_url|. | 36 // The file URL pointing to the local file to load to display |distilled_url|. |
| 34 // If |resources_root_url| is not nullptr, it is set to a file URL to the | 37 // If |resources_root_url| is not nullptr, it is set to a file URL to the |
| 35 // directory conatining all the resources needed by |distilled_url|. | 38 // directory conatining all the resources needed by |distilled_url|. |
| 36 // |offline_path| is the root path to the directory containing offline files. | 39 // |offline_path| is the root path to the directory containing offline files. |
| 37 GURL FileURLForDistilledURL(const GURL& distilled_url, | 40 GURL FileURLForDistilledURL(const GURL& distilled_url, |
| 38 const base::FilePath& offline_path, | 41 const base::FilePath& offline_path, |
| 39 GURL* resources_root_url); | 42 GURL* resources_root_url); |
| 40 | 43 |
| 41 // Returns whether the URL points to a chrome offline URL. | 44 // Returns whether the URL points to a chrome offline URL. |
| 42 bool IsOfflineURL(const GURL& url); | 45 bool IsOfflineURL(const GURL& url); |
| 43 | 46 |
| 47 // Returns whether the URL points to a valid chrome offline URL that can be |
| 48 // displayed by a |OfflinePageNativeContent|. |
| 49 bool IsOfflineURLValid(const GURL& url, ReadingListModel* model); |
| 50 |
| 44 } // namespace reading_list | 51 } // namespace reading_list |
| 45 | 52 |
| 46 #endif // IOS_CHROME_BROWSER_READING_LIST_OFFLINE_URL_UTILS_H_ | 53 #endif // IOS_CHROME_BROWSER_READING_LIST_OFFLINE_URL_UTILS_H_ |
| OLD | NEW |