blob: b2ca72d566847831aa800e8e1d32f2938ffc7a61 [file] [log] [blame]
petewil7c8537f2017-06-16 23:03:151// Copyright 2017 The Chromium Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5#ifndef CHROME_BROWSER_OFFLINE_PAGES_OFFLINER_USER_DATA_H_
6#define CHROME_BROWSER_OFFLINE_PAGES_OFFLINER_USER_DATA_H_
7
8#include "chrome/browser/offline_pages/background_loader_offliner.h"
9#include "chrome/browser/offline_pages/resource_loading_observer.h"
petewil7c8537f2017-06-16 23:03:1510#include "content/public/browser/web_contents_user_data.h"
11
12namespace offline_pages {
13
14class OfflinerUserData : public content::WebContentsUserData<OfflinerUserData> {
15 public:
16 static void AddToWebContents(content::WebContents* webcontents,
17 BackgroundLoaderOffliner* offliner);
18
19 static BackgroundLoaderOffliner* OfflinerFromWebContents(
20 content::WebContents* webcontents);
21
22 static ResourceLoadingObserver* ResourceLoadingObserverFromWebContents(
23 content::WebContents* webcontents);
24
25 explicit OfflinerUserData(BackgroundLoaderOffliner* offliner) {
26 offliner_ = offliner;
27 }
28 BackgroundLoaderOffliner* offliner() { return offliner_; }
29
30 private:
31 // The offliner that the WebContents is attached to. The offliner owns the
32 // Delegate which owns the WebContents that this data is attached to.
33 // Therefore, its lifetime should exceed that of the WebContents, so this
34 // should always be non-null.
35 BackgroundLoaderOffliner* offliner_;
36};
37
38} // namespace offline_pages
39
40#endif // CHROME_BROWSER_OFFLINE_PAGES_OFFLINER_USER_DATA_H_