| 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 #include "chrome/browser/android/offline_pages/offline_page_utils.h" | 5 #include "chrome/browser/android/offline_pages/offline_page_utils.h" |
| 6 | 6 |
| 7 #include "base/strings/string_number_conversions.h" |
| 7 #include "base/strings/string_piece.h" | 8 #include "base/strings/string_piece.h" |
| 8 #include "base/strings/string_util.h" | 9 #include "base/strings/string_util.h" |
| 9 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h" | 10 #include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h" |
| 10 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" | 11 #include "chrome/browser/android/offline_pages/offline_page_model_factory.h" |
| 11 #include "components/offline_pages/offline_page_feature.h" | 12 #include "components/offline_pages/offline_page_feature.h" |
| 12 #include "components/offline_pages/offline_page_item.h" | 13 #include "components/offline_pages/offline_page_item.h" |
| 13 #include "components/offline_pages/offline_page_model.h" | 14 #include "components/offline_pages/offline_page_model.h" |
| 14 #include "content/public/browser/browser_context.h" | 15 #include "content/public/browser/browser_context.h" |
| 15 #include "url/gurl.h" | 16 #include "url/gurl.h" |
| 16 | 17 |
| (...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 96 | 97 |
| 97 // static | 98 // static |
| 98 int64_t OfflinePageUtils::GetBookmarkIdForOfflineURL( | 99 int64_t OfflinePageUtils::GetBookmarkIdForOfflineURL( |
| 99 content::BrowserContext* browser_context, | 100 content::BrowserContext* browser_context, |
| 100 const GURL& offline_url) { | 101 const GURL& offline_url) { |
| 101 const offline_pages::OfflinePageItem* offline_page = | 102 const offline_pages::OfflinePageItem* offline_page = |
| 102 GetOfflinePageForOfflineURL(browser_context, offline_url); | 103 GetOfflinePageForOfflineURL(browser_context, offline_url); |
| 103 if (!offline_page) | 104 if (!offline_page) |
| 104 return -1; | 105 return -1; |
| 105 | 106 |
| 106 return offline_page->bookmark_id; | 107 if (offline_page->client_id.name_space != offline_pages::BOOKMARK_NAMESPACE) { |
| 108 return -1; |
| 109 } |
| 110 |
| 111 int64_t result; |
| 112 if (base::StringToInt64(offline_page->client_id.id, &result)) { |
| 113 return result; |
| 114 } |
| 115 return -1; |
| 107 } | 116 } |
| 108 | 117 |
| 109 // static | 118 // static |
| 110 bool OfflinePageUtils::IsOfflinePage(content::BrowserContext* browser_context, | 119 bool OfflinePageUtils::IsOfflinePage(content::BrowserContext* browser_context, |
| 111 const GURL& offline_url) { | 120 const GURL& offline_url) { |
| 112 return GetOfflinePageForOfflineURL(browser_context, offline_url) != nullptr; | 121 return GetOfflinePageForOfflineURL(browser_context, offline_url) != nullptr; |
| 113 } | 122 } |
| 114 | 123 |
| 115 // static | 124 // static |
| 116 bool OfflinePageUtils::HasOfflinePageForOnlineURL( | 125 bool OfflinePageUtils::HasOfflinePageForOnlineURL( |
| (...skipping 12 matching lines...) Expand all Loading... |
| 129 if (!offline_pages::IsOfflinePagesEnabled()) | 138 if (!offline_pages::IsOfflinePagesEnabled()) |
| 130 return false; | 139 return false; |
| 131 | 140 |
| 132 offline_pages::OfflinePageModel* offline_page_model = | 141 offline_pages::OfflinePageModel* offline_page_model = |
| 133 offline_pages::OfflinePageModelFactory::GetForBrowserContext( | 142 offline_pages::OfflinePageModelFactory::GetForBrowserContext( |
| 134 browser_context); | 143 browser_context); |
| 135 return offline_page_model->HasOfflinePages(); | 144 return offline_page_model->HasOfflinePages(); |
| 136 } | 145 } |
| 137 | 146 |
| 138 } // namespace offline_pages | 147 } // namespace offline_pages |
| OLD | NEW |