Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(4882)

Unified Diff: chrome/browser/android/offline_pages/offline_page_utils.cc

Issue 2362033002: Showing previews UI for Offline Previews (Closed)
Patch Set: megjablon comments rebase Created 4 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/browser/android/offline_pages/offline_page_utils.cc
diff --git a/chrome/browser/android/offline_pages/offline_page_utils.cc b/chrome/browser/android/offline_pages/offline_page_utils.cc
index d6cbffe2923dcdde80726881a4b9c3f839c09c1d..2768e1ed8c2bd422f6020240c07829f43a770286 100644
--- a/chrome/browser/android/offline_pages/offline_page_utils.cc
+++ b/chrome/browser/android/offline_pages/offline_page_utils.cc
@@ -7,20 +7,21 @@
#include "base/bind.h"
#include "base/location.h"
#include "base/strings/string_number_conversions.h"
#include "base/strings/string_piece.h"
#include "base/strings/string_util.h"
#include "base/threading/thread_task_runner_handle.h"
#include "chrome/browser/android/offline_pages/offline_page_mhtml_archiver.h"
#include "chrome/browser/android/offline_pages/offline_page_model_factory.h"
#include "chrome/browser/android/offline_pages/offline_page_tab_helper.h"
#include "chrome/browser/android/tab_android.h"
+#include "chrome/browser/previews/previews_infobar_tab_helper.h"
#include "components/offline_pages/client_namespace_constants.h"
#include "components/offline_pages/offline_page_feature.h"
#include "components/offline_pages/offline_page_item.h"
#include "components/offline_pages/offline_page_model.h"
#include "components/offline_pages/request_header/offline_page_header.h"
#include "content/public/browser/browser_context.h"
#include "content/public/browser/web_contents.h"
#include "url/gurl.h"
namespace offline_pages {
@@ -174,21 +175,30 @@ const OfflinePageItem* OfflinePageUtils::GetOfflinePageFromWebContents(
GURL web_contents_url =
web_contents->GetVisibleURL().ReplaceComponents(remove_params);
return offline_url == web_contents_url ? offline_page : nullptr;
}
// static
const OfflinePageHeader* OfflinePageUtils::GetOfflineHeaderFromWebContents(
content::WebContents* web_contents) {
OfflinePageTabHelper* tab_helper =
OfflinePageTabHelper::FromWebContents(web_contents);
- return tab_helper ? &(tab_helper->offline_header()) : nullptr;
+ return tab_helper ? tab_helper->offline_header() : nullptr;
+}
+
+// static
+bool OfflinePageUtils::IsShowingOfflinePreview(
+ content::WebContents* web_contents) {
+ PreviewsInfoBarTabHelper* previews_tab_helper =
+ PreviewsInfoBarTabHelper::FromWebContents(web_contents);
+ return previews_tab_helper &&
+ previews_tab_helper->is_showing_offline_preview();
}
// static
bool OfflinePageUtils::GetTabId(content::WebContents* web_contents,
int* tab_id) {
TabAndroid* tab_android = TabAndroid::FromWebContents(web_contents);
if (!tab_android)
return false;
*tab_id = tab_android->GetAndroidId();
return true;

Powered by Google App Engine
This is Rietveld 408576698