| 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 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 102 | 102 |
| 103 // static | 103 // static |
| 104 const OfflinePageHeader* OfflinePageUtils::GetOfflineHeaderFromWebContents( | 104 const OfflinePageHeader* OfflinePageUtils::GetOfflineHeaderFromWebContents( |
| 105 content::WebContents* web_contents) { | 105 content::WebContents* web_contents) { |
| 106 OfflinePageTabHelper* tab_helper = | 106 OfflinePageTabHelper* tab_helper = |
| 107 OfflinePageTabHelper::FromWebContents(web_contents); | 107 OfflinePageTabHelper::FromWebContents(web_contents); |
| 108 return tab_helper ? &(tab_helper->offline_header()) : nullptr; | 108 return tab_helper ? &(tab_helper->offline_header()) : nullptr; |
| 109 } | 109 } |
| 110 | 110 |
| 111 // static | 111 // static |
| 112 bool OfflinePageUtils::IsShowingOfflinePreview( | |
| 113 content::WebContents* web_contents) { | |
| 114 OfflinePageTabHelper* tab_helper = | |
| 115 OfflinePageTabHelper::FromWebContents(web_contents); | |
| 116 return tab_helper && tab_helper->IsShowingOfflinePreview(); | |
| 117 } | |
| 118 | |
| 119 // static | |
| 120 bool OfflinePageUtils::GetTabId(content::WebContents* web_contents, | 112 bool OfflinePageUtils::GetTabId(content::WebContents* web_contents, |
| 121 int* tab_id) { | 113 int* tab_id) { |
| 122 TabAndroid* tab_android = TabAndroid::FromWebContents(web_contents); | 114 TabAndroid* tab_android = TabAndroid::FromWebContents(web_contents); |
| 123 if (!tab_android) | 115 if (!tab_android) |
| 124 return false; | 116 return false; |
| 125 *tab_id = tab_android->GetAndroidId(); | 117 *tab_id = tab_android->GetAndroidId(); |
| 126 return true; | 118 return true; |
| 127 } | 119 } |
| 128 | 120 |
| 129 // static | 121 // static |
| (...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 185 GURL::Replacements remove_params; | 177 GURL::Replacements remove_params; |
| 186 remove_params.ClearRef(); | 178 remove_params.ClearRef(); |
| 187 | 179 |
| 188 GURL lhs_stripped = lhs.ReplaceComponents(remove_params); | 180 GURL lhs_stripped = lhs.ReplaceComponents(remove_params); |
| 189 GURL rhs_stripped = lhs.ReplaceComponents(remove_params); | 181 GURL rhs_stripped = lhs.ReplaceComponents(remove_params); |
| 190 | 182 |
| 191 return lhs_stripped == rhs_stripped; | 183 return lhs_stripped == rhs_stripped; |
| 192 } | 184 } |
| 193 | 185 |
| 194 } // namespace offline_pages | 186 } // namespace offline_pages |
| OLD | NEW |