| 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 25d49cb9ea128b373f25b2b7136fabddd158a178..9145296dbde4ed87840c6e0ae68356490597e34f 100644
|
| --- a/chrome/browser/android/offline_pages/offline_page_utils.cc
|
| +++ b/chrome/browser/android/offline_pages/offline_page_utils.cc
|
| @@ -16,11 +16,14 @@
|
| #include "components/offline_pages/offline_page_item.h"
|
| #include "components/offline_pages/offline_page_model.h"
|
| #include "content/public/browser/browser_context.h"
|
| +#include "content/public/browser/web_contents.h"
|
| #include "url/gurl.h"
|
|
|
| namespace offline_pages {
|
| namespace {
|
|
|
| +const char kWebContentsUserDataKey[] = "OfflinePageForTab";
|
| +
|
| // Returns an offline page originated from the |online_url|.
|
| const OfflinePageItem* MaybeGetBestOfflinePageForOnlineURL(
|
| content::BrowserContext* browser_context,
|
| @@ -179,4 +182,23 @@ void OfflinePageUtils::MarkPageAccessed(
|
| offline_page_model->MarkPageAccessed(offline_page->offline_id);
|
| }
|
|
|
| +const OfflinePageItem* OfflinePageUtils::GetCurrentOfflinePage(
|
| + content::WebContents* web_contents) {
|
| + return static_cast<const OfflinePageItem*>(
|
| + web_contents->GetUserData(kWebContentsUserDataKey));
|
| +}
|
| +
|
| +void OfflinePageUtils::SetCurrentOfflinePage(
|
| + content::WebContents* web_contents,
|
| + const OfflinePageItem* offline_page) {
|
| + if (!offline_page) {
|
| + web_contents->RemoveUserData(kWebContentsUserDataKey);
|
| + return;
|
| + }
|
| +
|
| + // |SetUserData| takes ownership of the data object, so we need to make a copy
|
| + // here.
|
| + web_contents->SetUserData(kWebContentsUserDataKey,
|
| + new OfflinePageItem(*offline_page));
|
| +}
|
| } // namespace offline_pages
|
|
|