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