| 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/guid.h" | 8 #include "base/guid.h" |
| 9 #include "base/location.h" | 9 #include "base/location.h" |
| 10 #include "base/strings/string_number_conversions.h" | 10 #include "base/strings/string_number_conversions.h" |
| (...skipping 140 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 151 bool OfflinePageUtils::GetTabId(content::WebContents* web_contents, | 151 bool OfflinePageUtils::GetTabId(content::WebContents* web_contents, |
| 152 int* tab_id) { | 152 int* tab_id) { |
| 153 TabAndroid* tab_android = TabAndroid::FromWebContents(web_contents); | 153 TabAndroid* tab_android = TabAndroid::FromWebContents(web_contents); |
| 154 if (!tab_android) | 154 if (!tab_android) |
| 155 return false; | 155 return false; |
| 156 *tab_id = tab_android->GetAndroidId(); | 156 *tab_id = tab_android->GetAndroidId(); |
| 157 return true; | 157 return true; |
| 158 } | 158 } |
| 159 | 159 |
| 160 // static | 160 // static |
| 161 bool OfflinePageUtils::CurrentlyShownInCustomTab( |
| 162 content::WebContents* web_contents) { |
| 163 TabAndroid* tab_android = TabAndroid::FromWebContents(web_contents); |
| 164 DCHECK(tab_android); |
| 165 return tab_android && tab_android->IsCurrentlyACustomTab(); |
| 166 } |
| 167 |
| 168 // static |
| 161 void OfflinePageUtils::CheckExistenceOfPagesWithURL( | 169 void OfflinePageUtils::CheckExistenceOfPagesWithURL( |
| 162 content::BrowserContext* browser_context, | 170 content::BrowserContext* browser_context, |
| 163 const std::string name_space, | 171 const std::string name_space, |
| 164 const GURL& offline_page_url, | 172 const GURL& offline_page_url, |
| 165 const PagesExistCallback& callback) { | 173 const PagesExistCallback& callback) { |
| 166 OfflinePageModel* offline_page_model = | 174 OfflinePageModel* offline_page_model = |
| 167 OfflinePageModelFactory::GetForBrowserContext(browser_context); | 175 OfflinePageModelFactory::GetForBrowserContext(browser_context); |
| 168 DCHECK(offline_page_model); | 176 DCHECK(offline_page_model); |
| 169 auto continuation = []( | 177 auto continuation = []( |
| 170 const std::string& name_space, | 178 const std::string& name_space, |
| (...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 256 GURL OfflinePageUtils::GetOriginalURLFromWebContents( | 264 GURL OfflinePageUtils::GetOriginalURLFromWebContents( |
| 257 content::WebContents* web_contents) { | 265 content::WebContents* web_contents) { |
| 258 content::NavigationEntry* entry = | 266 content::NavigationEntry* entry = |
| 259 web_contents->GetController().GetLastCommittedEntry(); | 267 web_contents->GetController().GetLastCommittedEntry(); |
| 260 if (!entry || entry->GetRedirectChain().size() <= 1) | 268 if (!entry || entry->GetRedirectChain().size() <= 1) |
| 261 return GURL(); | 269 return GURL(); |
| 262 return entry->GetRedirectChain().front(); | 270 return entry->GetRedirectChain().front(); |
| 263 } | 271 } |
| 264 | 272 |
| 265 } // namespace offline_pages | 273 } // namespace offline_pages |
| OLD | NEW |