| 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/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/location.h" | 8 #include "base/location.h" |
| 9 #include "base/strings/string_number_conversions.h" | 9 #include "base/strings/string_number_conversions.h" |
| 10 #include "base/strings/string_piece.h" | 10 #include "base/strings/string_piece.h" |
| (...skipping 13 matching lines...) Expand all Loading... |
| 24 | 24 |
| 25 namespace offline_pages { | 25 namespace offline_pages { |
| 26 namespace { | 26 namespace { |
| 27 | 27 |
| 28 // Returns an offline page that is stored as the |offline_url|. | 28 // Returns an offline page that is stored as the |offline_url|. |
| 29 const OfflinePageItem* GetOfflinePageForOfflineURL( | 29 const OfflinePageItem* GetOfflinePageForOfflineURL( |
| 30 content::BrowserContext* browser_context, | 30 content::BrowserContext* browser_context, |
| 31 const GURL& offline_url) { | 31 const GURL& offline_url) { |
| 32 DCHECK(browser_context); | 32 DCHECK(browser_context); |
| 33 | 33 |
| 34 if (!IsOfflinePagesEnabled()) | |
| 35 return nullptr; | |
| 36 | |
| 37 // Note that we first check if the url likely points to an offline page | 34 // Note that we first check if the url likely points to an offline page |
| 38 // before calling GetPageByOfflineURL in order to avoid unnecessary lookup | 35 // before calling GetPageByOfflineURL in order to avoid unnecessary lookup |
| 39 // cost. | 36 // cost. |
| 40 if (!OfflinePageUtils::MightBeOfflineURL(offline_url)) | 37 if (!OfflinePageUtils::MightBeOfflineURL(offline_url)) |
| 41 return nullptr; | 38 return nullptr; |
| 42 | 39 |
| 43 OfflinePageModel* offline_page_model = | 40 OfflinePageModel* offline_page_model = |
| 44 OfflinePageModelFactory::GetForBrowserContext(browser_context); | 41 OfflinePageModelFactory::GetForBrowserContext(browser_context); |
| 45 if (!offline_page_model) | 42 if (!offline_page_model) |
| 46 return nullptr; | 43 return nullptr; |
| (...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 166 bool OfflinePageUtils::GetTabId(content::WebContents* web_contents, | 163 bool OfflinePageUtils::GetTabId(content::WebContents* web_contents, |
| 167 int* tab_id) { | 164 int* tab_id) { |
| 168 TabAndroid* tab_android = TabAndroid::FromWebContents(web_contents); | 165 TabAndroid* tab_android = TabAndroid::FromWebContents(web_contents); |
| 169 if (!tab_android) | 166 if (!tab_android) |
| 170 return false; | 167 return false; |
| 171 *tab_id = tab_android->GetAndroidId(); | 168 *tab_id = tab_android->GetAndroidId(); |
| 172 return true; | 169 return true; |
| 173 } | 170 } |
| 174 | 171 |
| 175 } // namespace offline_pages | 172 } // namespace offline_pages |
| OLD | NEW |