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