| OLD | NEW |
| (Empty) |
| 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 | |
| 3 // found in the LICENSE file. | |
| 4 | |
| 5 #include "components/reading_list/offline_url_utils.h" | |
| 6 | |
| 7 #include "base/md5.h" | |
| 8 #include "base/strings/stringprintf.h" | |
| 9 | |
| 10 namespace { | |
| 11 const char kOfflineDirectory[] = "Offline"; | |
| 12 const char kMainPageFileName[] = "page.html"; | |
| 13 } // namespace | |
| 14 | |
| 15 namespace reading_list { | |
| 16 | |
| 17 base::FilePath OfflineRootDirectoryPath(const base::FilePath& profile_path) { | |
| 18 return profile_path.Append(FILE_PATH_LITERAL(kOfflineDirectory)); | |
| 19 } | |
| 20 | |
| 21 std::string OfflineURLDirectoryID(const GURL& url) { | |
| 22 return base::MD5String(url.spec()); | |
| 23 } | |
| 24 | |
| 25 base::FilePath OfflinePagePath(const GURL& url) { | |
| 26 base::FilePath directory(OfflineURLDirectoryID(url)); | |
| 27 return directory.Append(FILE_PATH_LITERAL(kMainPageFileName)); | |
| 28 } | |
| 29 | |
| 30 base::FilePath OfflineURLDirectoryAbsolutePath( | |
| 31 const base::FilePath& profile_path, | |
| 32 const GURL& url) { | |
| 33 return OfflineRootDirectoryPath(profile_path) | |
| 34 .Append(OfflineURLDirectoryID(url)); | |
| 35 } | |
| 36 | |
| 37 base::FilePath OfflinePageAbsolutePath(const base::FilePath& profile_path, | |
| 38 const GURL& url) { | |
| 39 return OfflineRootDirectoryPath(profile_path).Append(OfflinePagePath(url)); | |
| 40 } | |
| 41 } | |
| OLD | NEW |