summaryrefslogtreecommitdiffstats
path: root/components/history/content/browser/history_context_helper.cc
blob: dc14c6741155fc27146cf02fcfee23d1218d8ed8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Copyright 2015 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

#include "components/history/content/browser/history_context_helper.h"

#include "content/public/browser/web_contents.h"
#include "content/public/browser/web_contents_user_data.h"

namespace {

// WebContentsContext is used to bind an history::Context to a
// content::WebContents.
class WebContentsContext
    : public history::Context,
      public content::WebContentsUserData<WebContentsContext> {
 private:
  friend class content::WebContentsUserData<WebContentsContext>;
  explicit WebContentsContext(content::WebContents* web_contents) {}
};

}  // namespace

namespace history {

ContextID ContextIDForWebContents(content::WebContents* web_contents) {
  ContextID context_id = WebContentsContext::FromWebContents(web_contents);
  if (!context_id) {
    WebContentsContext::CreateForWebContents(web_contents);
    context_id = WebContentsContext::FromWebContents(web_contents);
  }
  return context_id;
}

}  // namespace history

DEFINE_WEB_CONTENTS_USER_DATA_KEY(WebContentsContext);